Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

64
Vistas
How to filter based on a property of an inner object in mongoose?
    const collection = [
      {
        inner_obj: {
          prop: "A"
        }
      }
    ]

    collection.find(
      //code to find outer records based on the `prop` property of column `inner_obj`
    )

how to find outer records based on the prop property of column inner_obj.

7 months ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can use Array.filter to filter out the items in the array which don't match the condition:

const desiredProp = "A"

const collection = [{
  inner_obj: {
    prop: "A"
  }
},
{
  inner_obj: {
    prop: "B"
  }
}]

const filtered = collection.filter(e => e.inner_obj.prop == desiredProp)

console.log(filtered)

7 months ago · Juan Pablo Isaza Denunciar

0

You can try this

collection.find({"inner_obj.prop": "A"})
7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Planes Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.