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

438
Views
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
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!