In a shell, I can do use new Date() as shown below:
db.myCollection.insertOne({
...
"Last Modified Date": new Date()
});
How do I do it in MongoDB Compass? new Date() is not valid. <! Insert not permitted while document contains errors.>
{
"_id": {
"$oid": "xxxx"
},
...
"Last Modified Date": new Date()
}
I could manually enter the current systems date but I want it to grab that automatically when a document is inserted.
Thanks!
Tried below but no luck
- "Last Modified Date": new Date().toISOString(),
- "Last Modified Date": new Date().toISOString().split('T')[0] + ' ' + new Date().toISOString().split('T')[1].split('.')[0] + 'Z',
- "Last Modified Date": { "$currentDate": { "$type": "date" } },