[英]NEDB persistance in Electron app
I am trying to connect to nedb from electron app. 我想从电子应用程序连接到nedb。 CRUD operations work great. CRUD操作很有效。 BUT I don't see db file (D:/my.db, checked for hidden files). 但我没有看到db文件(D:/my.db,检查隐藏文件)。 File exists somewhere, because it keeps data even after machine reboot. 文件存在于某处,因为它甚至在机器重启后仍保留数据。 I suspect that electron threats my path as relative, but I can find it anywhere. 我怀疑电子威胁我的路径是相对的,但我可以在任何地方找到它。
var Datastore = require('nedb'), db = new Datastore({filename : 'D:/my.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) { // Callback is optional
// newDoc is the newly inserted document, including its _id
// newDoc has no key called notToBeSaved since its value was undefined
});
I found a way to work around this. 我找到了解决这个问题的方法。 When creating the datastore in the main.js and making it global, nedb won't use the indexedDB but a local file as specified. 在main.js中创建数据存储区并使其成为全局数据存储区时,nedb将不使用indexedDB,而是使用指定的本地文件。
Then in the renderer process get the datastore via Electron.Remote 然后在渲染器进程中通过Electron.Remote获取数据存储区
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.