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

128
Views
Buscar/agregar de otra colección en función de su _id en mongodb
PetTable { _id: ObjectId, bdTable: string, status: ObjectId(ref=Status) } Status { _id : ObjectId, statusCode : number, --> exple: (1, 2, ...7) petId : ObjectId(ref=PetTable), }

quiero encontrar todos los objetos de PetTable con bdTable = "zzzz" y estado =5;

No tengo idea de cómo hacerlo?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Ejecute una operación agregada con la etapa de canalización $lookup de la siguiente manera:

 db.PetTable.aggregate([ { $match: { bdTable: 'zzzz' } }, { $lookup: { from: 'Status', let: { status_id: '$status' }, pipeline: [ { $match: { $expr: { $and: [ { $eq: [ 5, '$statusCode' ] }, { $eq: [ '$_id', '$$status_id' ] } ] } } } ], as: 'status' } }, { $match: { $expr: { $gt: [ { $size: '$status' }, 0] } } }, ]);

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!