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

Return counts for collection update and remove commands #1046

Closed
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
3 participants
@jacott
Contributor

jacott commented May 15, 2013

In order to support optimistic locking the counts from the MongoDB
update and remove commands need to be returned to the application code
so that the update/remove can be verified they took place and action
taken if they did not (like throwing a 409 Error).

For consistency make LocalCollection return counts also.

Return counts for collection update and remove commands
In order to support optimistic locking the counts from the MongoDB
update and remove commands need to be returned to the application code
so that the update/remove can be verified they took place and action
taken if they did not (like throwing a 409 Error).

For consistency make LocalCollection return counts also.
@jacott

This comment has been minimized.

Contributor

jacott commented May 15, 2013

With this change you can write code on the server like:

function editDoc(id, version, changes) {
  var count = col.update({_id: id, _version: version}, {$set: changes, $inc: {_version: 1}});

  if (count === 0)
    throw new Meteor.Error(409, 'Edit conflict')
}
@mitar

This comment has been minimized.

Collaborator

mitar commented Jul 3, 2013

+1

@estark37

This comment has been minimized.

Contributor

estark37 commented Sep 25, 2013

Thanks @jacott! This is merged into mongo-upsert which will hopefully be merged into devel soon-ish.

@estark37 estark37 closed this Sep 25, 2013

@jacott

This comment has been minimized.

Contributor

jacott commented Sep 25, 2013

Cool! Thanks Emily :)

On 26 September 2013 10:49, Emily Stark notifications@github.com wrote:

Thanks @jacott https://github.com/jacott! This is merged into
mongo-upsert which will hopefully be merged into devel soon-ish.


Reply to this email directly or view it on GitHubhttps://github.com//pull/1046#issuecomment-25131177
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment