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

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -