我正在尝试从电子应用程序连接到nedb。CRUD操作非常有效。但是我没有看到db文件(D:/my.db,检查了隐藏文件)。文件存在于某个地方,因为它保存数据,即使在机器重新启动之后。我怀疑电子威胁我的路径作为相对,但我可以找到它在任何地方。
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
});发布于 2016-05-18 22:44:25
文档说
如果指定文件名,数据库将是持久的,并根据浏览器自动选择可用的最佳存储方法(IndexedDB、WebSQL或localStorage)。
发布于 2017-01-27 17:35:10
我找到了解决这个问题的方法。当在main.js中创建数据存储并使其成为全局时,nedb将不使用indexedDB,而是使用指定的本地文件。
然后在呈现器过程中通过Electron.Remote获取数据存储
https://stackoverflow.com/questions/37310666
复制相似问题