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

Support $project exclusion of nested fields. #121

Closed
Gaff opened this issue Mar 9, 2020 · 3 comments
Closed

Support $project exclusion of nested fields. #121

Gaff opened this issue Mar 9, 2020 · 3 comments

Comments

@Gaff
Copy link
Contributor

Gaff commented Mar 9, 2020

If I have a document like so:

{
  "foo":  { "bar" :1, "bas": 1}
}

and I do: $project("foo.bas":0)

I should get back:

{
   "foo": {"bar":1}
}

This isn't working because Projection.projectDoucment() in the if(onlyExclusions(...)){...} clause takes a simplistic view on how to remove fields.

There's plenty of code in the same class for handling nested fields - maybe it can be changed to work with exclusions as well as inclusions?

@bwaldvogel
Copy link
Owner

I’ve reworked the $project staging handling to support exclusion/inclusion of nested fields.
Could you give 209a4b1 a try?

@bwaldvogel
Copy link
Owner

The change is part of v1.26.0.

@Gaff
Copy link
Contributor Author

Gaff commented Apr 28, 2020

HI thanks - finally got back on this. I see it works for aggregations, but not for a vanilla project. I'll raise a separate ticket.

(Also since I'm here, is it worth testing this on arrays:

{
  "foo": [{"a":1}, {"b:1}]
}

and I do: $project("foo.b":0)

I should get back:

{
   "foo": [{"a":1}]
}

)

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

No branches or pull requests

2 participants