I have data like this
Mywants:[
{"title":"lap","rate":$20}
{"title":"lap","rate":$20}
{"title":"lap","rate":$20}
]
If I save new data into array(mywant) I should save with new unique id so how to save like that using javascript. So it should be look like:
Mywants:[
{"title":"lap","rate":$20,_id:objectId("512640f3243c837c0e0004401}
{"title":"lap","rate":$20,_id:objectId("512640f3243c837254000001}
{"title":"lap","rate":$20,_id:objectId("512640f3243c8372540257001}}
]
To insert I am using command like
collection.update({"userid":1248787885},{$push:{"Mywant":{"title":"car","rate":$100}}});