Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upHow to increment array nested object field? #6687
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 .? |


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