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

443
Views
Mongoose: la cadena de coincidencia poblada en la matriz no funciona

Intento buscar objetos con Mongoose (v4.6.2) usando populate. Aquí están mis modelos (en dos archivos diferentes):

 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 });

Luego tengo una matriz: ["pizza", "GOT"]. Así que quiero encontrar todas las experiencias que tengan al menos un interés de la matriz. Así que hago esto:

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

Entonces, no sé por qué, el resultado contiene experiencias que no tienen ningún interés, especialmente las del array :(

¿Ves de dónde puede venir el problema?

Gracias que tengas un buen día :)

over 4 years ago · Santiago Trujillo
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!