update record push unique value in array Node.js + MongoDB

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) {