node.js – How would I update variables in node js using promises?

Currently I am making a database using json taking inspiration from quick.db. However have run into the problem that I cannot auto update variables that i use the db.get function with.


const DB = require("./DB.js");

const db = new DB();

(async function() {
    await db.set("kuno", 0);
    var kuno = await db.get("kuno");
    await db.add("kuno", 1);

The thing about that code is it does work, and add one to the db key “kuno” however still returns 0, is there any way I can update the kuno variable whenever the key is modified in the DB? Not sure if promises are even required for this but I intend on making this rely on actual SQL later.

Source link