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

772
Views
¿Cómo obtengo solo los documentos que no tienen 'falso' en una matriz de valores booleanos?

Supongamos que tengo estos documentos:

 [ { _id: 132143124, orders: [true, false, false], }, { _id: 3123, orders: [true, true, true], }, ];

¿Cómo obtengo solo los documentos que no tienen 'falso' en su matriz de pedidos? Necesito una solución de etapa agregada. (Solución agregada de MongoDB)

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

0

Puede usar $not o $ne (ya que el lenguaje de consulta de Mongo aplana las matrices) para esto, así:

 db.collection.find({ orders: {$ne: false} })

Parque infantil Mongo

la misma sintaxis funcionará en la canalización de agregación: Mongo Playground Aggregation

about 4 years ago · Juan Pablo Isaza Report

0

Podría usar la función de filtro para matrices:

 const results = [ { _id: 1, orders: [true, false, false], }, { _id: 2, orders: [true, true, true], } ] const filtered_results = results.map(({orders, ...data}) => { return { orders: orders.filter((order)=>order === true), ...data } }) console.log(filtered_results)

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!