-
Notifications
You must be signed in to change notification settings - Fork 1
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
array operator #96
Comments
Although I understand the need, but there are work arounds like you can select the array update it using native JSON operators and then use the update method to update the document. |
Does I know that we can grab the document and perform the action ourselves, but it's not safe as compared to offloading to the database to do the work. Consider the following scenario where Request 1 grab the document, make the changes manually to the document, and update it to the database and at the same time Request 2 also grab the document before the changes are made and make changes to the document array. // req1
.findById('12345');
// req2
.findById('12345');
// req1
.updateById('12345', { comments: [<whatever values before>, 'abcde'] });
// req2
.updateById('12345', { comments: [<whatever values before>, 'defgc'] });
// end state would be
comments: [<whatever values before>, 'defgc'] I understand this might not be the best example since there are also other scenarios where this would occur and developer have to manage themselves via // req1
.updateById('12345', { comments: { $push: ['abcde'] } });
// req2
.updateById('12345', { comments: { $push: ['defgc'] } });
// end state would be
comments: [<whatever values before>, 'abcde', 'defgc'] As such, this is safe for the developer, and know that there won't be conflict. Without it, there is a lot more work that needs to be done on the developer side to ensure the safety of document conflict. Ease of array/object manipulation should be something that is provided by the driver that also ensures the safety of the document (as much as possible) |
I think these are the ones I'm looking for (if I understand those correctly) https://docs.couchbase.com/nodejs-sdk/current/howtos/subdocument-operations.html#array-append-and-prepend |
I understand, however we dont support sub-document operations yet. We will have to get there first and then apparently think of this. Thats why its listed as no-op atleast for now. |
Alright, it is quite an important feature to have. So long that this feature is planned to be added, I think it's fine to be lacking for now. Thanks |
Hi,
Something that I've missed out again but is there an existing feature to perform array operation such as
$push, $pull, $each, $pop, etc
as described in hereI don't think I've seen it mentioned anywhere in the documentation, and it has quite a common use case to manipulate an array within a document.
Thanks
The text was updated successfully, but these errors were encountered: