Skip to content

How to increment a nested object field ? #7202

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

Closed
4 of 6 tasks
sadortun opened this issue Feb 17, 2021 · 1 comment
Closed
4 of 6 tasks

How to increment a nested object field ? #7202

sadortun opened this issue Feb 17, 2021 · 1 comment

Comments

@sadortun
Copy link
Contributor

sadortun commented Feb 17, 2021

New Issue Checklist

Issue Description

This is a simpler case version of issue #6687. I'm not sure if i'm doing anything wrong, but i think this should work

I'm trying to increment a value of a newly created object.

Ex:

db.test.findOneAndUpdate(
    {"_id":"20mMYzLTjx"} ,
    {$inc:{ "a.b.c.d" : 1 }}
)

Steps to reproduce

const obj= await Parse.Object
    .extend('test')
    .createWithoutData('20mMYzLTjx').fetch()

// obj.get('a') === {}   (my schema defaults a to {}

obj.increment('a.b.c.d' , 1 )
await obj.save()

Actual Outcome

TypeError: Cannot read property 'd' of undefined at Object.estimateAttributes (.....parse-server\node_modules\parse\lib\node\ObjectStateMutations.js:234:28)

Expected Outcome

Path a.b.c.d get created and persisted

Failing Test Case / Pull Request

  • 🤩 I submitted a PR with a fix and a test case.
  • 🧐 I submitted a PR with a failing test case.

Environment

Server

  • Parse Server version: v4.5.0 / 3d76643286d41b954b6c8e2d6614657c891a31e7
  • Operating system: Win 10
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): Mongo
  • Database version: 4.4.4
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): remote/self hosted

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): Js
  • SDK version: 2.17.0

Logs

@sadortun
Copy link
Contributor Author

moved -> parse-community/Parse-SDK-JS#1299

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

1 participant