flosse / json-file-store

A simple JSON store for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

both save and delete will not check existence of the record

windmaomao opened this issue · comments

so i need to wrap it with get() first. It'll be great if the library can take care for me, so that i can do

    db.delete(id, function(err) {
        console.log(err);
        if (err) {
            next(err);
        } else {
            res.json({status: "success"});
        }
    });

instead of

    db.get(id, function(err, item) {
        if (err) {
            next(err);
        } else {
            db.save(id, item, function(err) {
                if (err) {
                    next(err);
                } else {
                    item = db.getSync(id);
                    res.json(_attach_id(item, id));
                }
            });
        }
    });

does this commit change anything?

please reopen if it's not the case