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

314
Views
Cómo convertir la estructura del objeto del documento mongo db

Tengo un documento con la siguiente estructura:

 id: 6229d3fd40bac327243e4ww2 userID: "594e710c-c632-3ae-929a-f13e294ee6ef" appID: "622994e2b98225609b89affd" notifications:Object 6229d3e040bac3272qwe4441: 1 622ew3e041bac3272qwe4441: 1

Quiero actualizar esta estructura a esto:

 id: 6229d3fd40bac327243e4ww2 userID: "594e710c-c632-43ae-929a-f13e294ee6ef" appID: "622994e2b98225609b89affd" notifications:Object 6229d3e040bac3272qwe4441: {a:1, b:false} 622ew3e040bac3272qwe4441: {a:1, b:false}

Tengo problemas para iterar los campos de objetos de notification , ya que es una cadena hexadecimal aleatoria. Intenté usar las siguientes soluciones, pero no pude obtener el resultado esperadoCanalización de agregación de MongoDB: uso de For loop

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

db.collection.update({}, [ { $set: { notifications: { $arrayToObject: { $map: { input: { $objectToArray: "$notifications" }, as: "n", in: { k: "$$nk", v: { a: "$$nv", b: false } } } } } } } ], { multi: true })

parque infantil mongo

over 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!