-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
How to increment array nested object field? #6687
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
Comments
To clarify my previous comment: what you want to do is not documented and not supported in Parse Server, but I think you're onto something. It makes sense to support it since it is supported by MongoDB. I had a look into why this doesn't work and I found several roadblocks: 1) Parse JS SDK:The SDK assumes that a nested key path does not require to traverse over an array element. It fails to traverse the path, because This causes the error: 2) Parse JS SDK:For nested keys the SDK validates the existence of said key, otherwise it does not set the increment operator on that key. Effectively, this does not allow to increment a nested key for an object that has been instantiated with This causes the 3) Parse Server:SchemaController expects the parse-server/src/Controllers/SchemaController.js Lines 1132 to 1136 in 6b0efae
This fails the schema validation because the field in the example above is of type This causes the error: Conclusion:
|
I really thank you for the explanation. I think I will use mongodb collection.updateOne() with $inc operator directly to increment the field until the feature is considered to be implemented. |
Do you want to reopen this issue to keep track of it? Sent with GitHawk |
Ok! I'll reopen it |
hye, is this issue open .? |
Is this issue still open? |
Yes. It is open for a PR. Would you be willed to tackle this one? |
Fixes parse-community/parse-server#6687 by modifying the estimateAttribute function logic in src/ObjectStateMutations.js.
Fixes parse-community/parse-server#6687 by modifying the estimateAttribute function logic in src/ObjectStateMutations.js.
This comment has been minimized.
This comment has been minimized.
🎉 This change has been released in version 7.2.0-beta.1 |
🎉 This change has been released in version 7.2.0 |
Hi! Let's assume I have the following data:
Please, I want to know how can I use obj.increment() to increment the count field of the first element in items?
I have tried obj.increment('items.0.count') but it doesn't work. I got the following error: Cannot read property '0' of undefined
The text was updated successfully, but these errors were encountered: