For context, my document’s latest schema looks like this:
@Prop({
type: String,
required: true,
default: new Date().toISOString(),
})
dateAdded: string;
the legacy schema was:
@Prop({
type: Date,
default: new Date(),
})
dateAdded: Date;
Now when I try to create the document in a single call, with a single payload for document body (which I checked with debuggers, for the presence of any async call being made or multiple calls being made. Which is not). I see that it is creating 2 different documents like
{
"_id": {
"$oid": "654bfb0fd1c75afd0193f1d6"
},
"dateAdded": {
"$date": "2023-11-07T21:31:30.373Z"
},
"__v": 0
},
{
"_id": {
"$oid": "654bfb1246e0213aa264584a"
},
"dateAdded": "2023-11-08T21:17:13.093Z",
"__v": 0
},
The point to be noted is though they are created at the same time(verified by testing), their dateAdded field is different.