2012-04-28 13 views
5

Estoy aprendiendo node.js y mongodb. Estoy usando el módulo mongoskin en mi aplicación, pero parece que no puedo obtener la funcionalidad "upsert" para funcionar.Upsert con Mongoskin (node.js y mongodb)

He leído la (bastante opaca) guía mongoskin en github. Esto es lo que he intentado hasta ahora:

// 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); 

¿Cómo puedo crear la funcionalidad "actualizar o insertar si no existe"?

Respuesta

Cuestiones relacionadas