sql >> Base de Datos >  >> NoSQL >> MongoDB

¿Cómo (DÓNDE) columna =columna en Mongo?

Desea verificar la documentación para la actualización.
http://www.mongodb. org/display/DOCS/Actualización

Su código podría tener este aspecto:
db.tbl.update( { c:{$ne:0}}, { $set: { a : b } } );

Si necesita repasar consultas avanzadas (por ejemplo, usando $ne ), luego marque aquí:
http://www.mongodb.org /display/DOCS/Avanzado+Consultas

EDITAR:
Aparentemente no puede actualizar con datos del mismo documento.
MongoDB:Actualización de documentos utilizando datos del mismo documento

EDIT 2 (solución con map reduce) :

var c = new Mongo();
var db = c.getDB('db')
var s = db.getCollection('s')
s.drop();
s.save({z:1,q:5});
s.save({z:11,q:55});

db.runCommand({
mapreduce:'s',
map:function(){
  var i = this._id; //we will emit with a unique key. _id in this case
  this._id=undefined; //strange things happen with merge if you leave the id in
  //update your document with access to all fields!
  this.z=this.q;

  emit(i,this);
}, 
query:{z:1},    //apply to only certain documents
out:{merge:'s'} //results get merged (overwrite themselves in collection)
});

//now take a look
s.find();