I work in Pymongo and would like to create 2 types of time fields for the document: time_creation and time_update .
time_creation : it is only created for the first time. If I update the database, it does not change (it must be constant).
time_update : it should be updated every time I update the database.
To time_update I am using:
'$currentDate':{'time_update': { '$type': 'date' }}
and it works great. I need an identical structure for time_creation , i.e. I would like to use '$ currentDate' and I don't want to use datetime ! I know the structure:
'$setOnInsert':{'time_creation': datetime.utcnow()}
works great. But I do not want to use it. I would like to know if there is a way to do this using '$ currentDate' and '$ type': 'date'
source
share