javascript - Meteor.js update only one parameter instead of whole collection -
i'm trying mark message readed using code below :
template.fullmessage.onrendered(function () { var id = flowrouter.getparam('id'); messages.update(id, {$set: {readed: true} }); });
collection :
"_id": "ymxyn9nodpezqfp83", "whatabout": "adsfadsfasdf", "message": "sdfadsfadfadsfasdfasdf", "recipientid": "9ewif8jtnp77pmijw", "author": "9ewif8jtnp77pmijw", "createdat": "2016-05-09t08:37:52.282z", "owner": "seofilms", "readed": false }
i expected column "readed":"false" replaced "readed":true,
but instead of it, in here changing, including owner. instance if open message user test, change owner of message.
why happens ?
is possible prevent sending whole object , change id?
thank ideas.
try this:
messages.update({_id: id}, {$set: {readed: true} });
it should work id
, you're doing. there other code that's writing same collection? try run in console , check if it's still updating properties.
Comments
Post a Comment