Skip to content

electron no read data #599

@Hiram-Wong

Description

@Hiram-Wong
import _ from 'lodash';
import { Low } from 'lowdb';
import { JSONFileSync } from 'lowdb/node';
const STORE_PATH = join(app.getPath('userData'), 'database.json');
let defaultData = {
    tbl_setting: []
};
class LowWithLodash extends Low {
  chain = _.chain(this).get('data');
};
const adapter = new JSONFile(STORE_PATH);
const db = new LowWithLodash(adapter, defaultData);
console.log(db.chain.get('tbl_setting').castArray().value())

join(app.getPath('userData'), 'database.json') is have data,butJSONFileSyncread is undefine, uesfs.readFileSync(STORE_PATH, 'utf8') || {};can read it but not write,how to fix it

env: electron22 lowdb7.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions