javascript - Updating array in MongoDb using Node is not working -


i've have done due diligence, , can't figure out doing wrong. appreciated.

i have collection in mongo (trips) following:

{     "_id": objectid("56f5ee3dab124b181256ddf1"),     "waypoints": [{         "address": "",         "sequencenumber": 0     }] } 

to update waypoint.address, have done following:

var tripid = new mongodb.objectid(waypoint.tripid);     var db = resources.getdbconn();     db.collection('trips').update(         { _id: tripid,           'waypoints.sequencenumber': waypoint.sequencenumber         },         {$set:              { 'waypoints.$.address': waypoint.address}         }); 

however, not working. missing, or not understanding something?

update:

i figured out. 'waypoint.sequencenumber' being stored integer, however, querying string. ugh. shame on me.

i think issue _id field being objectid(1), , not literal integer 1.


Comments