Closed hoonion90 closed 3 years ago
how to increase db.json visitors + 1 ?
index.js
import { join, dirname } from 'path' import { fileURLToPath } from 'url' import { LowSync, JSONFileSync } from "lowdb"; import _ from 'lodash' const __dirname = dirname(fileURLToPath(import.meta.url)); const file = join(__dirname, 'db.json') const adapter = new JSONFileSync(file) const db = new LowSync(adapter) db.read(); db.chain = _.chain(db.data); //db.chain.update('visitors', n => n + 1);
db.json
{ "visitors": 8000 }
db.chain.update('visitors', n => n + 1).value() value() is required to execute chain
db.chain.update('visitors', n => n + 1).value()
how to increase db.json visitors + 1 ?
index.js
db.json