Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

85
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!