Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projection not working properly for deep nested objects #287

Closed
nkemtasoft opened this issue Dec 15, 2022 · 1 comment
Closed

Projection not working properly for deep nested objects #287

nkemtasoft opened this issue Dec 15, 2022 · 1 comment
Labels

Comments

@nkemtasoft
Copy link

First, thanks for building this amazing library. It's been of an invaluable help to me.

So, there's this issue I've encountered while working with mingo. When I apply this projection rules

{ 'comments.title': 0, 'comments.comments.comments': 0, numbers: 0 }

on this object

{
  "_id": "639b4a1dc9414e958b1484ba",
  "title": "mingo is cool",
  "numbers": [],
  "owners": [],
  "comments": [
    {
      "title": "a",
      "body": "body",
      "comments": []
    },
    {
      "title": "b",
      "body": "body",
      "comments": [
        {
          "title": "c",
          "comments": []
        }
      ]
    }
  ],
  "text": "kandinsky"
}

I get this result

{
  "_id": "639b4a1dc9414e958b1484ba",
  "title": "mingo is cool",
  "owners": [],
  "comments": [
    {
      "body": "body",
      "comments": []
    },
    {
      "body": "body",
      "comments": [
        {
          "title": "c",
          "comments": []    // <-- this shouldn't be included
        }
      ]
    }
  ],
  "def": "kandinsky"
}

The issue is that this rule 'comments.comments.comments': 0 should not include the last level "comments": [] (where the title is "c") but it does.

@nkemtasoft nkemtasoft changed the title Projection not working for deep nested objects Projection not working properly for deep nested objects Dec 15, 2022
@kofrasa kofrasa added the bug label Dec 16, 2022
@kofrasa
Copy link
Owner

kofrasa commented Dec 17, 2022

Thanks for reporting this bug @nkemtasoft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants