Timestramps in nested objects

I have collection like this,

whenever I try to update the notes with _id createdAt and updatedAt is also getting updated.
I use the below query to do that operation,

db.mycollection.findOneAndUpdate({“_id”:“”, “NOTES._id”: NOTES[i]._id }, { $set: {“srType.$.NOTES”:obj} }, {new: true })

I would be very surprised if that would be the case. Your sample document DOES NOT have a field named SR_NOTES. So you either redacted the query or the sample document. In this case, we really cannot help you because we have no way to know what part of the information you share is correct and which one is wrongly redacted.

Please read Formatting code and log snippets in posts so that you documents and code can be used without further editing.

I have updated the code

Thanks but it is still unusable without editing because it is still not formatted according to the link I provided.

"ST_PARTY_SITE_ID": 739731,
    "ACTION": "submit",
    "NOTES": [
            "TYPE": "INVOICE",
            "DESCRIPTION": "test 55454",
            "_id": "65143e3101b2a56e7e45022f",
db.mycollection.findOneAndUpdate({“_id”:“”, “NOTES._id”: NOTES[i]._id }, { $set: {“srType.$.NOTES”:obj} }, {new: true })

when I try to update the main collection, embedded documents behaves like it is getting inserted createdAt is always be same as updatedAt. but for me, createdAt should not get chnaged when we update the embedded document

When you write

what you actually asking is to replace the given array element with the object obj. So what ever fields and values the object obj has will end up stored in the document. You may use the dot notation to set the individuals fields you what. If $mergeObjects can be used in this context (something worth testing) then it would be less cumbersome than the dot notation.