Open rxjs-space opened 7 years ago
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'}
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.
path: '/details/parts/2'
2
The doc in db:
the json-patch to apply:
the query generated:
with above query, the doc after change:
but the doc expected is actually: