Mongo create document call creating 2 different documents with a legacy schema version and another with new schema

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.

Really?

It looks like there is 1 day difference between the 2 documents you shared. The one with the old schema is 2023-11-07 and the one with the new schema is 2023-11-08. It is far from being created at the same time. Since both schema call new Date(), I would surprised that there is a bug in new Date() that could generate 2 dates with 1 day difference if called at the same time.

And what about __v:0 is both case? I suspect you are using some kind of abstraction layer and I suspect that something is missing and the new schema is not registered correctly.

And why, why, why would you change a perfectly valid Date field into a ISO string? Do you really what to make your queries slower? Do you really want to make your data take more space? Date values stored as Date data type are smaller and faster than their ISO string variant.