Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

87
Vistas
concat not beeing recognized by mongodb

I have this field on my collection:

uniqueId: 123
inTarefa: true
exclude: "ab,cd,"
orderId: 987

and I'm trying to update all values using a "FindOneAndUpdate" like this:

collection.findOneAndUpdate({
'uniqueId': 123
},
{{
  "$set":{
  "inTarefa":false,
  "orderId":0,
  "exclude":{"$concat":["$exclude","servico"]}
}}})

inTarefa and orderId is successfully changed but the "exclude" is changed to an object like this:

exclude:{$concat:[0: "$exclude", 1: "servico"]}

Yeah, this is exactly what it's supposed to do IF the keyword "$concat" was not a command to mongodb. What I'm doing wrong?

Mongodb version: 4.3.1

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

$concat is an aggregation operator, you should use the pipelined form of update. Try this:

collection.findOneAndUpdate({
'uniqueId': 123
},
[
  {"$set":{
    "inTarefa":false,
    "orderId":0,
    "exclude":{"$concat":["$exclude","servico"]}
  }}
])
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda