import { join } from 'path';
import { Low, JSONFile } from 'lowdb';
import { hlinkHomeDir } from '@hlink/core';
import lodash from 'lodash';
import lodashId from 'lodash-id';
lodash.mixin(lodashId);
let baseDir = hlinkHomeDir;
class LowWithLodash extends Low {
    constructor() {
        super(...arguments);
        this.chain = lodash.chain(this).get('data');
    }
}
lodash.id = 'name';
// Use JSON file for storage
const file = join(baseDir, 'db.json');
const adapter = new JSONFile(file);
const db = new LowWithLodash(adapter);
await db.read();
db.data || (db.data = { configs: [], tasks: [] });
export default db;
