node.js - mongoose/nodejs: add item to collection only if it's not already in it -
hi trying add item array database i'd check if collection doesnt contain item.
so far, i've used:
var countryarray = ['france', 'united kingdom', 'germany', 'remote']; (var = 0; < countryarray.length; i++){ country.update({ type: countryarray[i] }, {$set: { type: countryarray[i] }}, {upsert: true}, function(err){}); }; however doesnt work...
does has better way it?
cheers
Comments
Post a Comment