How to update document in mongodb NodeJS?


This Content is from Stack Overflow. Question asked by Big Loot

I am using this command to update the document.

order = await db.collection("orders").findOneAndUpdate({ order_id: req.body.ORDERID }, {$set: { payment_status: "Paid", paymentInfo: JSON.stringify(myrequest) }})


But the document is not updated instead return this in console

lastErrorObject: { n: 0, updatedExisting: false },
  value: null,
  ok: 1,
  '$clusterTime': {
    clusterTime: new Timestamp({ t: 1663565745, i: 13 }),
    signature: {
      hash: new Binary(Buffer.from("5165sd1vdsvds651vds5vvs5dvdsvdskvjdsv, "hex"), 0),
      keyId: new Long("1451151132154123165")


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?