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
feat: Support dot notation on array fields #9115
base: alpha
Are you sure you want to change the base?
Conversation
Thanks for opening this pull request! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## alpha #9115 +/- ##
=======================================
Coverage 94.13% 94.14%
=======================================
Files 186 186
Lines 14687 14727 +40
=======================================
+ Hits 13826 13864 +38
- Misses 861 863 +2 ☔ View full report in Codecov by Sentry. |
obj.set('items', [ { value: 'a', count: 5 }, { value: 'b', count: 1 } ]); | ||
await obj.save(); | ||
|
||
obj.increment('items.0.count', 15); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this notation MongoDB specific? If so, this may not be clear for developers who use Postgres. Should this notation be documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got dot notation working on PG years ago. Adding Array support might be possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a requirement for this PR to add support for PG, I was just referring to the syntax itself, whether that is commonly known or should be documented.
@mtrezza This is an extremely complicated feature. I tried running this with the SDK internal fix against the server test suite and got Array dot notation working but it somehow broke the server. I’ll let you know when this is ready for review. |
Pull Request
Issue
Currently all dot notations are treated as operations on Object type field. This results in a
error: Cannot read property '0' of undefined
when used on Array type fields.Closes: #6687
Approach
Check types for Array vs Fields based on dot notation format.
https://www.mongodb.com/docs/manual/core/document/#dot-notation
Tasks