Closed ghost closed 13 years ago
Vic: did you check your err
value? Maybe there was a server error. It's good practice to always check this for errors.
Your best bet for mongo documentation is mongo's website! http://www.mongodb.org/display/DOCS/Manual
OK, now I can update, but not w/ _id. How do I update w/ _id? findAndModify({ query:{roomName:'Bla'} ,update:{ stationName:'ha ha' } },function(err,res) { console.log(err); console.log(res); });
On the first way, it give null for err. I think the second way is good, I just need to figure out why it does not like _id. hint?
OK, I got a clue, findById also does not work, so it might not find a string, might need objectId. I think I can figure it out now!
I am trying to update a record by the primary key. (I got insert and find working great, thank you!)
There are no examples or tests of update, save or findAndModify.
My code is, the id exists tabCol.update({_id:'123121231'} ,{ stationName:'ha ha' } ,false,false ,function(err,res) { console.log(res); });
It does not update when I look at mongo and it prints out undefined. There should be an example of how to update by primary key.
2nd question is more mongo: When to use update vs findAndModify vs save, ex when 'updating' by pk.
tia, Vic