Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Not supporting nested objects #10

Open
rxjs-space opened this issue Jun 11, 2017 · 1 comment
Open

Not supporting nested objects #10

rxjs-space opened this issue Jun 11, 2017 · 1 comment

Comments

@rxjs-space
Copy link

The doc in db:

{"details": {
    "parts": [
          {"id": "p001", "name": "abc"}
        ]
  }
}

the json-patch to apply:

[ { op: 'add',
    path: '/details/parts/2',
    value: { id: 'p002', name: 'xyz' } }]

the query generated:

{ '$push': { 'details.parts.2': { id: 'p002', name: 'xyz' } } }

with above query, the doc after change:

details.parts[1] === [{id: 'p002', name: 'xyz'}]

but the doc expected is actually:

details.parts[1] = {id: 'p002', name: 'xyz'}
@marcj
Copy link

marcj commented May 16, 2018

I guess the missing check here is that when the last part of path: '/details/parts/2' which is here 2 is a numeric value, then only it should use $push, else $set.

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

No branches or pull requests

3 participants