Howto append new value pair to existing json object in lawnchair
I was looking documentation at Lawnchair website and I am trying to figure out how do I insert new value pair to existing data.
Following sample in Lawnchair website.
var peo开发者_JAVA百科ple = new Lawnchair('people');
var me = {name:'brian'};
people.save(me);
Now if I want to add "brian" age.
I kind of expected having something like people.append("{key:mykey, age:30}")
but looks like there is no such a method?
Is there any any other way to do this?
I am not much familiar with LawnChair, but to the extent I can understand it, I would suggest something like the following:
people.find('r.name == "brian"', function(r){
//remove 'r' (from the main storehouse) here somehow, I dont know how.
r.key = yourkey
r.age=30
people.save(r)
});
- Retrieve and save the entry
- Remove the entry
- add
age
field to the saved object - save it back! :-)
Do tell me if that helps. :-)
精彩评论