I have user records and each user has a list of friends.
How can I push only unique values in the friends array in the user record?
accounts.update({user:nickNameField}, {$push:{"friends":friendsName}}, { upsert:true },
function (e, res) {
...
Or do I need to manually check if the value is in the friends array?
Ah, it can be done with $addToSet
AM.accounts.update({user:nickNameField}, {$addToSet:{friends:friendsName}},
function (e, res) {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With