Uczę się node.js i mongodb. Używam modułu mongoskin w mojej aplikacji, ale nie mogę sprawić, że funkcjonalność "upsert" zadziała.Upsert with Mongoskin (node.js i mongodb)
Przeczytałem (raczej nieprzejrzysty) przewodnik mongoszkin na githubie. Oto, co próbowałem do tej pory:
// this works. there's an insert then an update. The final "x" is "XX".
db.collection("stuff").insert({a:"A"}, {x:"X"});
db.collection("stuff").update({a:"A"}, {x:"XX"});
// this does NOT work. I thought it would do an upsert, but nothing.
db.collection("stuff").update({b:"B"}, {y:"YY"}, true);
Jak mogę utworzyć funkcję "zaktualizuj lub wstaw, jeśli nie istnieje"?