Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有用户记录,每个用户都有一个朋友列表。
如何仅推送用户记录中朋友数组中的唯一值?
accounts.update({user:nickNameField}, {$push:{"friends":friendsName}}, { upsert:true }, function (e, res) { ...
还是我需要手动检查该值是否在朋友数组中?
啊,可以用 $addToSet 来完成
AM.accounts.update({user:nickNameField}, {$addToSet:{friends:friendsName}}, function (e, res) {