问题
var Datastore = require('nedb')
, db = new Datastore({ filename: 'testdb.db', autoload: true });\
var doc = { hello: 'world'
, n: 5
, today: new Date()
, nedbIsAwesome: true
, notthere: null
, notToBeSaved: undefined // Will not be saved
, fruits: [ 'apple', 'orange', 'pear' ]
, infos: { name: 'nedb' }
};
db.insert(doc, function (err, newDoc) {
console.log(newDoc);
});
I can't find "testdb.db" anywhere in my computer, but the console log show the data exist! Any suggestion?
回答1:
Give absolute file location of where the db needs to be stored like below
var db = new DataStore({filename:path.join(__dirname, '/nedb.db'), autoload:true});
Otherwise data will get stored in the location from where you are executing it
回答2:
Finally i know, im using webpack dev server, the file actually there, but only in memory, not written to my harddisk.
来源:https://stackoverflow.com/questions/43133299/where-is-nedb-file-stored