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

275
Views
Query for a user and then a specific object in an array with one mongoose query

enter image description here

I have a user object as shown above. I am trying to write a mongoose query that finds the user via the req.user.id and then queries their wishList array for a specific item with the id that matches the req.params.id

Here is my query:

let userWishListItem = await User.find({_id: req.user.id, 'wishList': {_id: req.params.id}})

userWishListItem just gives back the user currently. how can I get back the specific wishList object in their wishList array. Any advice would be great.

about 4 years ago · Juan Pablo Isaza
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!