My tech stack is Nest JS with mongo DB atlas.
When I create a document, I want a field ‘dateAdded’ parameter to be set with the value of current time by default. And for that I am not passing in the time parameter but defined it to be a default value with ‘new Date()’ in schema.
In Atlas this operation is always creating a constant time string to be created. Irrespective of when the document is created.
How to solve this ?
This is the schema for my conversations collections
I tried it in my environment and it worked perfectly using the schema you provided. Could you please specify the version of MongoDB you’re using and share some sample documents that have been created? Additionally, could you confirm whether it worked in a local MongoDB deployment or not?
May I ask about the choice of using a string data type for dateAdded instead of a date? Is there a specific reason behind this?