1

Suppose I have this document in mongodb collection:

{
  "_id": {
    "playerId": "113069",
    "tournamentId": "197831"
  },
  "__v": 0,
  "playerName": "David WArner",
  "pointsTotal": 426
}

I update it using this update query(using mongoose):

await PointsTotal.findOneAndUpdate(
      {
        _id: {
          playerId: player._id,
          tournamentId: tournamentId,
        }
      },
      {
        $set: {
          playerName: playerName,
          pointsTotal: totalPoints
        },
      },
      {
        upsert: true,
      }
    );
  }

But, if the playerName and totalPoints is same as before updating, will it perform update operation to overwrite these fields and I am able to listen this update in change stream or not?

1 Answer 1

1

No, if there is no change to the document MongoDB will not perform a write, there will be no operation in the oplog, and nothing will appear in the change stream.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.