NEDB坚持电子应用程序 [英] NEDB persistance in Electron app

查看:143
本文介绍了NEDB坚持电子应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从电子应用程序连接到nedb。 CRUD操作很有效。但我没有看到db文件(D:/my.db,检查隐藏文件)。文件存在于某处,因为它甚至在机器重启后仍保留数据。我怀疑电子威胁我的路径是相对的,但我可以在任何地方找到它。

I am trying to connect to nedb from electron app. CRUD operations work great. BUT I don't see db file (D:/my.db, checked for hidden files). 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
});


推荐答案

doc


如果指定文件名,数据库将持久化,并根据浏览器自动选择可用的最佳存储方法(IndexedDB,WebSQL或localStorage)。

If you specify a filename, the database will be persistent, and automatically select the best storage method available (IndexedDB, WebSQL or localStorage) depending on the browser.

这篇关于NEDB坚持电子应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆