lowdb
lowdb copied to clipboard
Can you use more than one instance of lowdb?
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
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.