Update $currentDate

Hello, I’m actually on the Update videos and as I was experimenting I’m on $currentDate, while reading the doc I’m seeing I can use a boolean for the date, When I set it to true it insert the current date, and when I set it to false it also insert the current date, so what’s the difference ?

Documentation currentDate

Hi @Yoni_40785,

I’ve just tested it out and I can see what you mean. false has the same effect as true, i.e. they are both represented as ISODate().

The “field: true” syntax just seems quite unnecessary. One would expect a simple syntax like one of the following:

  • { $currentDate: { field: "date" or "timestamp" } }
    Or
  • { $currentDate: { field: { $type: "date" or "timestamp" } } }

I guess the “field: true” syntax is there as a syntactic sugar for $type: "date" but I can see how it can confuse.

1 Like