خرید بک لینک

Vote count: 0

Why is there a difference between using lowdb directly:

// app.js
const low = require('lowdb');
const storage = require('lowdb/file-async'); 
const db = low('db.json', { storage });

and wrap it as module

// lib/db.js
const low = require('lowdb');
const storage = require('lowdb/file-async'); 
const db = low('db.json', { storage });
module.exports = db;

// app.js
var db = require('lib/db');

In second case, following code in app.js:

db1('posts')
.push({})
.then(post => res.send(post));

Produces error "then is not a function". But using lowjs directly works just fine.

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 18 ارديبهشت 1395 ساعت: 3:16

صفحه بندی