0
我想寫一個mongo查詢來更新一個集合。
在SQL它會是這個樣子:
UPDATE myCollection SET count=(count-1)
WHERE otherCollectionId=otherCollection._id
AND otherCollectionUserId='HFDDEE78DFDSER34'
AND count > 0
我已經嘗試了一些事情,但是這個人是絕對行不通的。我發現了錯誤:
MongoError: Invalid modifier specified $gt
我蒙戈查詢至今:
myCollection.update({otherCollectionId: otherCollection._id,
otherCollectionUserId: Meteor.userId()
},
{$gt: {count: 0},
$inc: {count: -1}
});
任何想法?
這樣做的技巧,謝謝:) – user1532669 2014-10-01 00:55:49