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

98
Views
Parámetros de MongoDB para filtrar a través de la matriz

Tengo un problema a través de una matriz con parámetros mongoDB... asumiendo que tengo estas dos matrices

 const diversityArray = ['video', 'gps']
 const entries = [ { name: 'First entry', slug: 'first', diversity: 'image, video' }, { name: 'Second entry', slug: 'second', diversity: 'image, gps' }, { name: 'Third entry', slug: 'third', diversity: 'iframe' }];

¿Cómo podría hacer esto pero con parámetros mongoDB? Quiero filtrar todos los elementos de la matriz que contiene uno o más de los elementos de diversityArray.

 const filtered = entries.filter(item => diversityArray.some(data => item.diversity.includes(data)));

Necesito hacer esto porque tengo una matriz más grande y más compleja proveniente de Builder.io Headless CMS y quiero hacer el filtro en la consulta.

Tengo este código ahora mismo:

 const sets = await builder.getAll('open-dataset', { options: { noTargeting: true }, limit: 100, query: { data: { date: { $gt: newMinYear, $lt: newMaxYear }, title: { $regex: search, $options: 'i' }, diversity: ...what I want to do } } });

¡Gracias!

about 4 years ago · Juan Pablo Isaza
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!