Meteor Mongo Document update difference beween calling update(id) vs update({_id: id))

- QUESTION - 

Can anyone explain what is the difference between calling
update(id) (without object) vs update({_id: id)) (with object)
Eg:
var id = "TByq2TNcyPrpcu9nu";

Tasks.update(id, {$set: {name: "hello"}});
and
Tasks.update({_id: id}, {$set: {name: "hello"}});
Both the case seems to work properly though. Which is the correct approach and the reason?

- ANSWER  1 -

Both are correct : while the first has been imagined to be a shortcut, the second is the logical way for those who are not aware of it

- ANSWER 2 -

There is no difference. The first way is just sugar for the second way.

0 comments:

Post a Comment

Powered by Blogger.