Where is NEDB file stored?

房东的猫 提交于 2021-02-07 09:44:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!