1.electron應(yīng)用操作數(shù)據(jù)的幾種方法:
1、遠程api接口 (多個客戶端公用一套數(shù)據(jù))
2、連接遠程數(shù)據(jù)庫 (局域網(wǎng)內(nèi)使用 多個客戶端公用一套數(shù)據(jù) ) (不建議使用)
3丧枪、連接本地數(shù)據(jù)庫 (nedb sqlite) 應(yīng)用本地保存數(shù)據(jù)(localstore 5M) 用戶設(shè)置信息 qq聊天記錄
2.electron-vue讀寫本地數(shù)據(jù)庫文件
https://simulatedgreg.gitbooks.io/electron-vue/content/cn/savingreading-local-files.html
3.electron app模塊詳細:
https://www.w3cschool.cn/electronmanual/electronmanual-electronapp.html
4.Nedb 數(shù)據(jù)庫文檔:
https://github.com/louischatriot/nedb
nedb數(shù)據(jù)庫和mongodb數(shù)據(jù)庫的操作方法幾乎一模一樣桑谍。
如果對mongodb數(shù)據(jù)庫不熟悉 請看以下教程:
https://www.itying.com/goods-783.html
koa教程封裝一個mongodb數(shù)據(jù)庫
5.electron-vue中使用Nedb 數(shù)據(jù)庫
(1)安裝nedb數(shù)據(jù)庫
cnpm install nedb --save
(2)新建一個src/renderer/datastore.js
import Datastore from 'nedb'
import path from 'path'
import { remote } from 'electron'
export default new Datastore({
autoload: true,
filename: path.join(remote.app.getPath('userData'), '/data.db')
})
(3)src/renderer/main.js
import db from './datastore.js'
/* 其它代碼 */
Vue.prototype.$db = db
(4)在vue的組件里面實現(xiàn)數(shù)據(jù)的增加 修改 刪除 顯示
this.$db.insert({},function(){
})
this.$db.find({},function(){
//獲取查詢的數(shù)據(jù)
})
this.$db.update({條件},{$set:{更改的數(shù)據(jù)}},function(){
})
this.$db.remove({條件},{},function(){
})