flosse / json-file-store

A simple JSON store for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

id not stored with the item ?

windmaomao opened this issue · comments

thanks for this wonderful module, I have a quick question, I noticed that when I add a new record, the id is not stored inside the record like what I expected, ex.

{
"b5468c93-7799-43ce-97a5-9d8c9bd5547a": {
"title": "ABC"
},
// expected
"a34c41fb-124d-40c0-8383-858d344c48a9": {
"id": "a34c41fb-124d-40c0-8383-858d344c48a9",
"title": "ABC"
}
}

but i guess i can handle that after i call getSync(id) :)

If i use node extend, i can write the following line before returning the record i need, just because I want id to be the first row :)

    var id = db.saveSync(item);
    item = extend({id: id}, db.getSync(id));

I noticed that when I add a new record, the id is not stored inside the record

yes, that's not a bug, its a feature :)

but i guess i can handle that after i call getSync(id) :)

correct.
You could also extend/wrap the Store class if you like

wow, that's just so awesome !! thank you, i'll try it out.

On Wed, Dec 31, 2014 at 10:58 AM, flosse notifications@github.com wrote:

@windmaomao https://github.com/windmaomao I just added an option for
you, vide: https://github.com/flosse/json-file-store#id-storage

Reply to this email directly or view it on GitHub
#4 (comment)
.