Agregar campo a todos los documentos
Agregar un nuevo campo a todos los documentos en una colección
En MongoDB
Agregar un String
db.vehiculos.update({},{$set:{"activo":"si"}},{upsert:false,multi:true})
Agregar campos fechas
db.notificaciones.update({},{$set:{"fechacrea":new Date()}},{upsert:false,multi:true})
Agregar un Integer
usar NumberInt
db.persona.update({},{$set:{"edad": NumberInt(0)}},{upsert:false,multi:true})
Agregar un Double
db.persona.update({},{$set:{"salario": 0}},{upsert:false,multi:true})
Agregar un documento embebido
db.pronvincia.update({},{$set:{"country.idcountry":"PA"}},{upsert:false,multi:true})
Agregar una lista de embebidos
db.actividad.update({},{$set:{ "actionHistory" : [{ "fecha" : ISODate("2023-03-13T02:15:44.973Z"), "iduser" : NumberLong(1),"evento" : "crear","clase" : "ProyectoFaces", "metodo" : "save" }] }},{upsert:false,multi:true})
Last updated
Was this helpful?