javascript - How can I use $each and $position while using $push with a variable field name? -
this code working me:
var currentuser = meteor.userid() var json = {} json[currentuser] = {score: -1, created: new date()} words.update({_id: word._id}, { $push: json } )
but put new array items @ 0 position.
how can modify code use $each , $position?
i don't know meteor, in plain javascript need mention field name after $push, , push variable @ first place below query.
words.update({_id: word._id}, { $push: {field_name: { $each: [ json ], $position: 0 }} } )
Comments
Post a Comment