-
Notifications
You must be signed in to change notification settings - Fork 95
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
Incorrect behavior in a shard cluster #361
Comments
@sarkistlt would this break any functionality that you're aware of? |
@marshallswain currently I'm manually patching return this.Model.findOneAndDelete(query, params.mongoose).lean(this.lean)
.exec().then(result => {
if (result === null) {
throw new errors.NotFound(`No record found for id '${id}'`, query);
}
return result;
}).then(select(params, this.id)).catch(errorHandler); has to be replaced with 2 calls instead of one, to maintain current behavior in after return this.Model.findById(id)
.then((result) => {
if (result === null) {
throw new errors.NotFound(`No record found for id '${id}'`, query);
}
return this.Model.deleteOne(query, params.mongoose).lean(this.lean)
.exec()
.then(() => result)
.then(select(params, this.id));
})
.catch(errorHandler); But it's still better than providing shard key to remove object. |
This makes complete sense to me. I completely agree about not having to pass a shard key. The only thing that could make that API worse is having to pass your social security number. ;) It seems reasonable to me to have |
@marshallswain thanks! Sure will do it later today as soon as I'll get to my laptop. |
@sarkistlt should this be closed now that #364 is merged? |
@marshallswain yes, thank you! |
Currently
.remove
method always usesfindAndModify
. It should usedeleteOne
ifctx.id
is present.Main problem right now it's not possible to remove document by
_id
without passing shard key, because.remove
usesfindAndModify
, if it would usedeleteOne
you'll be able to remove document just by_id
, without passing extra query with sharding key.This is my current workaround, in before remove hook:
The text was updated successfully, but these errors were encountered: