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);
});
我在计算机中找不到“testdb.db”,但控制台日志显示数据存在! 有什么建议吗?
最佳答案
给出数据库需要存储的绝对文件位置,如下所示
var db = new DataStore({filename:path.join(__dirname, '/nedb.db'), autoload:true});
否则数据将存储在您执行它的位置
关于node.js - NEDB 文件存储在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43133299/