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

142
Views
Obtener un documento con exactamente las mismas claves

Si tengo un formato de documento en mi colección de comunicaciones:

 { "recipients": { "key1": "value1", "key2": "value2", "key3": "value3", } }

Quiero obtener todos los documentos que tengan exactamente las mismas claves. En otras palabras, en el ejemplo anterior, si consulto "key1", "key2", "key3", obtengo el documento anterior. Si por el contrario dispongo del siguiente documento:

 { "recipients": { "key1": "value1", "key2": "value2", "key3": "value3", "key4": "value4", } }

Consultar "key1", "key2", "key3" no debería devolver nada.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Existe una solución rápida con $:

 db.collection.find({ "recipients.key1":{ $exists:true }, "recipients.key2":{ $exists:true }, "recipients.key3":{ $exists:true }, "recipients.key4":{ $exists:false } })

Pero esto requiere conocer todas las demás claves posibles y puede ser bastante doloroso de escribir.

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!