LiSA.sync
sync framework for node
LiSA.sync 默认的采用 fileAdapter
使用不同的adapter时请参考示例
phil(哲学)
use
use with lisa.sync.fileadapter
npm i --save lisa.sync
var LiSASync = require('lisa.sync')
var LiSA = LiSASync(__dirname + '/test/LiSA.json',{internal : 2000})
console.log(LiSA.getSync())
LiSA.set({ name : "LiSA1" , gender : "girl"})
console.log(LiSA.getSync())
var index =0
LiSA.sync(()=>{
return {
name : "LiSA2"
}
})
console.log(LiSA.getSync())
//you can call sync
LiSA.sync(data=>{
data.oneNode = { name : "testNode"}
})
LiSA.get().then(d=>{
console.log(d)
})
//stop sync
LiSA.stop()
how to diy your adapter
exports.getId = (D)=>{}
exports.syncReader = (D) =>{}
exports.reader = (D)=>{}
exports.writer = (D,data)=>{}
use your adapter
var LiSASync = require('lisa.sync')
var yourAdapter = require('yourAdapterPath')
var LiSA = LiSASync(__dirname + '/test/LiSA.json',{internal : 2000} , yourAdapter)
just have a peek on lisa.sync.fileadapter
aok adapter aok
csv adapter csv