when i use db.saveDatabase(), it will happen TrpeError.
TypeError: this.fs.writeFile is not a function at LokiFsAdapter.saveDatabase (lokijs.js:2368) at Loki.saveDatabaseInternal (lokijs.js:2666) at Loki.saveDatabase (lokijs.js:2711) at _callee2$ (db.js:30) at tryCatch (runtime.js:45) at Generator.invoke [as _invoke] (runtime.js:271) at Generator.prototype.<computed> [as next] (runtime.js:97) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25)
also when i use db.loadDatabase()
TypeError: this.fs.stat is not a function at LokiFsAdapter.loadDatabase (lokijs.js:2340) at Loki.loadDatabaseInternal (lokijs.js:2532) at lokijs.js:2615 at Loki.throttledSaveDrain (lokijs.js:2511) at Loki.loadDatabase (lokijs.js:2610) at _callee2$ (db.js:21) at tryCatch (runtime.js:45) at Generator.invoke [as _invoke] (runtime.js:271) at Generator.prototype.<computed> [as next] (runtime.js:97) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25) at asyncToGenerator.js:32 at new Promise (<anonymous>) at asyncToGenerator.js:21 at _saveData (p__Create__models__seedphrase.js.async.js:255) at saveData (db.js:19) at _callee$ (seedphrase.js:3) at tryCatch (runtime.js:45) at Generator.invoke [as _invoke] (runtime.js:271) at Generator.prototype.<computed> [as next] (runtime.js:97) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25) at asyncToGenerator.js:32 at new Promise (<anonymous>) at asyncToGenerator.js:21 at _getSeedPhrase (p__Create__models__seedphrase.js.async.js:312) at getSeedPhrase (seedphrase.js:2) at runCallEffect (proc.js:524) at runEffect (proc.js:446) at next (proc.js:326) at proc (proc.js:281) at resolveIterator (proc.js:467) at runEffect (proc.js:443) at next (proc.js:326) at currCb (proc.js:399) at proc.js:510 at exec (scheduler.js:25) at flush (scheduler.js:66) at asap (scheduler.js:39) at Array.<anonymous> (channel.js:197) at Object.emit (channel.js:38) at middleware.js:73 at createPromiseMiddleware.js:26 at new Promise (<anonymous>) at new F (_export.js:36) at createPromiseMiddleware.js:25 at middleware.js:13 at SeedPhrase.componentDidMount (SeedPhrase.js:24) at commitLifeCycles (react-dom.development.js:20049) at commitLayoutEffects (react-dom.development.js:22813)
I use it like this:
`
const loki = require('lokijs')
const db = new loki('loki.json')
export async function saveData(collection, name, value) {
try{
db.loadDatabase();
let colt = await getCollection(collection);
let data = colt.find({"name": name})
if(data.length == 0) {
let test = colt.insert({name: name, value: value})
let test2 = colt.find({"name": name})
db.saveDatabase()
}
}catch(e) {
console.log(e)
}
}`
I use it in Electron renderer process, is realy weird, I don`t know how to resolve it, can you help me?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
when i use db.saveDatabase(), it will happen TrpeError.
TypeError: this.fs.writeFile is not a function at LokiFsAdapter.saveDatabase (lokijs.js:2368) at Loki.saveDatabaseInternal (lokijs.js:2666) at Loki.saveDatabase (lokijs.js:2711) at _callee2$ (db.js:30) at tryCatch (runtime.js:45) at Generator.invoke [as _invoke] (runtime.js:271) at Generator.prototype.<computed> [as next] (runtime.js:97) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25)
also when i use db.loadDatabase()
TypeError: this.fs.stat is not a function at LokiFsAdapter.loadDatabase (lokijs.js:2340) at Loki.loadDatabaseInternal (lokijs.js:2532) at lokijs.js:2615 at Loki.throttledSaveDrain (lokijs.js:2511) at Loki.loadDatabase (lokijs.js:2610) at _callee2$ (db.js:21) at tryCatch (runtime.js:45) at Generator.invoke [as _invoke] (runtime.js:271) at Generator.prototype.<computed> [as next] (runtime.js:97) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25) at asyncToGenerator.js:32 at new Promise (<anonymous>) at asyncToGenerator.js:21 at _saveData (p__Create__models__seedphrase.js.async.js:255) at saveData (db.js:19) at _callee$ (seedphrase.js:3) at tryCatch (runtime.js:45) at Generator.invoke [as _invoke] (runtime.js:271) at Generator.prototype.<computed> [as next] (runtime.js:97) at asyncGeneratorStep (asyncToGenerator.js:3) at _next (asyncToGenerator.js:25) at asyncToGenerator.js:32 at new Promise (<anonymous>) at asyncToGenerator.js:21 at _getSeedPhrase (p__Create__models__seedphrase.js.async.js:312) at getSeedPhrase (seedphrase.js:2) at runCallEffect (proc.js:524) at runEffect (proc.js:446) at next (proc.js:326) at proc (proc.js:281) at resolveIterator (proc.js:467) at runEffect (proc.js:443) at next (proc.js:326) at currCb (proc.js:399) at proc.js:510 at exec (scheduler.js:25) at flush (scheduler.js:66) at asap (scheduler.js:39) at Array.<anonymous> (channel.js:197) at Object.emit (channel.js:38) at middleware.js:73 at createPromiseMiddleware.js:26 at new Promise (<anonymous>) at new F (_export.js:36) at createPromiseMiddleware.js:25 at middleware.js:13 at SeedPhrase.componentDidMount (SeedPhrase.js:24) at commitLifeCycles (react-dom.development.js:20049) at commitLayoutEffects (react-dom.development.js:22813)
I use it like this: ` const loki = require('lokijs') const db = new loki('loki.json')
export async function saveData(collection, name, value) { try{ db.loadDatabase(); let colt = await getCollection(collection); let data = colt.find({"name": name}) if(data.length == 0) { let test = colt.insert({name: name, value: value}) let test2 = colt.find({"name": name}) db.saveDatabase() } }catch(e) { console.log(e) } }`
I use it in Electron renderer process, is realy weird, I don`t know how to resolve it, can you help me?