Can't write to db correctly
I am running rocksdb-node 1.7.2 with rocks 5.8 on MacOs. Below is my code:
db = rocksdb.open(
{create_if_missing: true},
path.join(dbPath, `users-${nodeEnv}.rocksdb`)
);
db.put('node', 'rocks');
after running above code and I use admin console to inspect the rocks file as below:
$ rocksdb_ldb --db=users-test.rocksdb/ scan
rock : rocks
I wonder why the key is not what I put which isnode.
That's very strange, works fine for me with 1.7.2, rocksdb 5.8.8 on MacOs:
$ cat ./simple.js
const rocksdb = require('./build/Release/rocksdb.node')
db = rocksdb.open(
{create_if_missing: true},
'/tmp/users-test.rocksdb');
db.put('node', 'rocks');
12:42 $ node ./simple.js
12:42 $ rocksdb_ldb --db=/tmp/users-test.rocksdb scan
node : rocks
If you do a db.get('node') after the put what does it return?
I get null output, below is my full code. I also tried to upgrade rocksdb to 5.8.8 and rebuild the project still get the same error.
$ cat lib/demo.js
const rocksdb = require('rocksdb-node');
db = rocksdb.open(
{create_if_missing: true},
'/tmp/users-test.rocksdb');
db.put('node', 'rocks');
console.log(db.get('node'));
$ node lib/demo.js
null
My env:
$ node --version
v7.9.0
$ npm --version
5.5.1
$ uname -a
Darwin 192-168-1-4.tpgi.com.au 17.2.0 Darwin Kernel Version 17.2.0: Fri Sep 29 18:27:05 PDT 2017; root:xnu-4570.20.62~3/RELEASE_X86_64 x86_64
Below is the dependency in package.json:
"rocksdb-node": "^1.7.2"
I make a reproducible demo: https://github.com/zhaoyi0113/rocksdb-demo.git
Could you try to build this repo and run node demo.js?
Demo works for me locally with both node 6 & node 8.
$ node demo.js
rocks
08:38 $ rocksdb_ldb --db=users-test.rocksdb scan
node : rocks
Not sure how to debug this further. Over the upcoming holidays I'll see if I can try a few other os'es, and I've also been meaning to add Travis CI for some time now, maybe that will show something up.
Thanks for checking it. Some of my co-workers checked these issue and we found this may relate to Mac OS version. It works fine on Mac OS 10.9.5 but doesn't work on 10.13.1. What is your mac version?
I Checked the demo on CentOS 7.2.1511, node v8.11.4, RocksDB v5.17.2, it does't work. I get null value without any error.