Closed louisameline closed 4 years ago
Yeah. need to do this.
we could use isEqual
of lodash-es
which supports treeshaking and is side-effect free.
If it's ok for you then, I'll make the PR today. It's like 2 lines of code, shouldn't be long :)
fix included in latest version and also upgraded ava to latest version!
Currently, there is this code:
I don't know what use case you had in mind when you wrote
I'm not sure why the fact that an object with the same
id
exists in the array would dismiss the add of the item if other properties are different?But besides this strange
id
thing, this code doesn't work well for arrays of objects. Let's say my array currently is like this:[{ message: 'hello', author: 'Tom' }, { message: 'world', author: 'John' }]
The next time you make an ArrayUnion with
{ message: 'hello', author: 'Tom' }
to the array, the item will be added a second time locally (the array will then have 3 items), while Firestore will recognize that the object is already there and will not add it (the array will stay with its 2 items).The solution is, instead of
to write this:
Same goes for ArrayRemove