I am learning node.js and mongodb. I use the mongoskin module in my application, but I can not get upsert to work.
I read the (rather opaque) mongoskin github guide. Here is what I have tried so far:
// this works. there 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);
How can I create the update or paste if none exists functionality?
source
share