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

122
Views
Cómo seleccionar solo productos con identificadores de la matriz de identificadores. MongoDB

Obtengo todos los productos y relleno la categoría con mongoDB. También tengo una matriz con identificadores de categoría y quiero obtener solo productos que tengan esos identificadores en el objeto de categoría. ¿Cómo seleccionar solo estos productos?

 arr of ids [ '615e94cab42d2274f0481232' ] arr of products [ { _id: new ObjectId("615e945cb42d2274f0481211"), image: '', category: { _id: new ObjectId("615da90b689b8ef91fa90afd"), name: 'Разное' }, name: '435пукп', type: 'В упаковке', piecesPerPackage: 2, pricePerPiece: 1, pricePerPackage: 2, weight: 12, description: 'вапвап' }, { _id: new ObjectId("615eaa08f68e788c63817641"), image: '', category: { _id: new ObjectId("615e94cab42d2274f0481232"), name: '2' }, name: '2', type: 'В упаковке', piecesPerPackage: 2, pricePerPiece: 2, pricePerPackage: 2, weight: 2, description: '2' } ]

 async sortCatalog(arr) { const products = await CatalogModel.find().lean() .populate("category", "name").select('-__v'); console.log("arr of ids", arr) console.log("arr of products", products) }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Usa category._id para encontrarlo.

 await CatalogModel.find({'category._id':new ObjectId("615e94cab42d2274f0481232")})
about 4 years ago · Juan Pablo Isaza 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!