简体   繁体   English

如何将 Nedb 与 electron 集成

[英]How to integrate Nedb with electron

I'm making an app in electron and i want to use Nedb as its database.我正在 electron 中制作一个应用程序,我想使用Nedb作为其数据库。

I've tried for a couple of days to get this to work all in vain unfortunately.不幸的是,我已经尝试了几天让这个工作徒劳无功。

I'm using electron with VueJs我正在使用 electron 和VueJs

any help is greatly appreciated.任何帮助是极大的赞赏。

Here is an example:这是一个例子:

https://medium.com/@shivekkhurana/persist-data-in-electron-apps-using-nedb-5fa35500149a https://medium.com/@shivekkhurana/persist-data-in-electron-apps-using-nedb-5fa35500149a

Here is a code sample:这是一个代码示例:

// create a file named main/src/db.js
const {app} = require('electron');
const Datastore = require('nedb-promises');
const dbFactory = (fileName) => Datastore.create({
 filename: `${process.env.NODE_ENV === 'dev' ? '.' : 
 app.getAppPath('userData')}/data/${fileName}`, 
 timestampData: true,
 autoload: true
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM