Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

440
Vistas
Mongoose - populate match String in array doesn't work

I try to search objects with Mongoose (v4.6.2) using populate. Here are my models (in two different files) :

const experienceSchema = new mongoose.Schema({
  title: { type: String, maxlength: 50 },
  creator: { type: Schema.ObjectId, ref: 'User' },
  creatorName: String,
  city: { type: String, maxlength: 64 },
  interests: [{ type: Schema.ObjectId, ref: 'Interest' }],
}, { timestamps: true });

const interestSchema = new Schema({
  Name: { type: String, default: '' },
  illustration: { type: String, default: '' },
}, { timestamps: true });

Then I have an array : ["pizza", "GOT"]. So I want to fin all experiences which have at least one interest of the array. So i do this :

experienceModel.find()
.populate({
     path: 'interests',
     match: { Name: { $in: array }}
})
.exec(function(err, exps) {...}

Then, I don't know why, the result contains experiences which have no interests, especially those of the array :(

Do you see where the problem could comes from ?

Thank you, have a nice day :)

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda