lowdb.js 443 B

12345678910111213141516171819202122
  1. module.exports = function (app) {
  2. /*
  3. @param lowDB = function() => require('lowdb') in model
  4. @param FileSync = function() => require('lowdb/adapters/FileSync') in model
  5. @param modelName = string
  6. */
  7. this.lowConn = function (lowDB, FileSync, modelName) {
  8. const path = require('path');
  9. const dbl = lowDB(new FileSync(path.join(__dirname, 'database/') + modelName + '.json'));
  10. return dbl;
  11. }
  12. return this;
  13. }