lowdb icon indicating copy to clipboard operation
lowdb copied to clipboard

Can you use more than one instance of lowdb?

Open oceansync opened this issue 8 years ago • 1 comments

Can you have 2 lowdb databases? I tried doing it using a different json file in the file sync part but it returned an error can't find module lowdb/adapters/FileSync Thanks

oceansync avatar Aug 10 '18 18:08 oceansync

Hi @Deniernal354,

Yes, it's possible. Simply create 2 adapters/db instance, here's an example below:

const path = require('path')
const low = require('lowdb')
const FileSync = require('lowdb/adapters/FileSync')

const db1 = low(new FileSync(path.join(__dirname, 'db1.json')
const db2 = low(new FileSync(path.join(__dirname, 'db2.json')

can't find module lowdb/adapters/FileSync seems like a module resolution error. Does node_modules/lowdb/adapters/FileSync.js exists in your project?

If not, you may want to reinstall dependencies. Ensure also that you're using lowdb v1.0.0.

typicode avatar Aug 12 '18 01:08 typicode