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

132
Views
if mongoose population match condition failed then i don't need parent record how can i handle

In groupMember Model i try to populate group details and i apply match condition but if match condition failed then records also comes in result i dont wan't those records.

suppose group have eStatus D then IgroupId becomes null but record come.
outputs given below

const groups = await GroupMembers.find({ iUserId: ObjectId(id) })
  .populate({
    path: 'iGroupId',
    select: '-__v',
    match: { eStatus: { $in: ['Y', 'N'] } }
  })

Output

[
{
    "_id": "6298ad4ae7d755f6f3b46dda",
    "iUserId": "629465fe89062bd576a5954a",
    "iGroupId": {
        "_id": "6298aca5e7d755f6f3b46dca",
        "sGroupName": "Maldives from jay1",
        "eGroupType": "Trip",
        "sGroupAvatar": "v1654173001/userAvtars/wtkgrqqfjjspjswfbme4.jpg",
        "dCreatedAt": "2022-06-02T12:27:17.560Z",
        "dUpdatedAt": "2022-06-02T12:30:01.682Z",
        "eStatus": "Y"
    },
    "eUserStatus": "Y",
    "dCreatedAt": "2022-06-02T12:30:02.119Z",
    "dUpdatedAt": "2022-06-02T12:30:02.119Z",
    "__v": 0
},
{
    "_id": "6299caeb3706f2e0d7972d68",
    "iUserId": "629465fe89062bd576a5954a",
    "iGroupId": null,
    "eUserStatus": "Y",
    "dCreatedAt": "2022-06-03T08:48:43.126Z",
    "dUpdatedAt": "2022-06-03T08:48:43.126Z",
    "__v": 0
}

]

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!