Skip to content
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

An update should return the number of updated docs and not true - especially 0 in case when no doc is updated #100

Open
a4xrbj1 opened this issue Feb 2, 2019 · 1 comment

Comments

@a4xrbj1
Copy link

a4xrbj1 commented Feb 2, 2019

The current behavior to return true on a dbCollection.updateis making some important tests of ours fail. To give an example:

const numUpdates = MpIndex.update({ _id: mpIndexDoc }, { $addToSet: { cardsIdArray: cardId } }, { tx: true, instant: true }); if (numUpdates === 0) { throw new Error(Something is wrong - No doc was being updated - mpIndex _id: ${mpIndexDoc} / ${cardId}); }

Now we're receiving true instead of a number. It's important for us to identify where our functions are trying to update a doc with a value that already exists as that is a logical error.

@JackAdams
Copy link
Owner

Yes, good point. If you've got someone who can put a PR together, I'll happily merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants