I'm developing Vue-Electron with NeDB.
On using NeDB, I've encountered problem that NeDB don't save local file though I set option filename
and autoload: true
.
I tried output log of db object when load NeDB, it correct path set.
Datastore {inMemoryOnly: false,
autoload: true,
timestampData: false,
filename: "./db/nedb.db",
compareStrings: undefined, …}
autoload: (...)compareStrings: (...)
executor: Executorfilename: "./db/nedb.db"
inMemoryOnly: falseindexes: Objectpersistence: PersistencetimestampData: ...
I saw other posts. but I couldn't figure out how to do Then in the renderer process get the datastore via Electron.Remote
NEDB persistance in Electron app
I thought may it happen because NeDB needs file exist before run script. So I tried touch nedb.db
but that didn't work.
Moreover, other odd thing: I have another Vue Application that is using NeDB, and the data showed. But I don't set a db path in that application. Inserted data by this application doesn't exist in the other application's db file.
Below is my code. If Someone could help me. Thanks.
const remote = require('electron').remote;
const app = remote.app;
const path = require('path');
var db = new nedb({
//filename: path.join(app.getPath('userData'), 'library.db'),
filename: './db/nedb.db',
autoload: true
});
let doc = {
dev: true,
message: 'test'
}
db.insert(doc);
db.find({}, function (err, docs) {
console.log(docs)
console.log(err)
})