Skip to content

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

@a4xrbj1

Description

@a4xrbj1

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions