Clarify Usage of MongoDB's $currentDate operator (#4630)

* Fix gtx-trans close sidepanel

* reset the package-lock.json file

* Fix: mongoDB date type
pull/4631/head
Abdelrhman Kamal 1 year ago committed by GitHub
parent cc258b7612
commit 7f6a42a0c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/data/roadmaps/mongodb/content/101-datatypes/110-date.md

@ -20,13 +20,18 @@ When inserting a document with a Date field, you can store the date value as fol
db.events.insertOne({ title: 'Sample Event', eventDate: new Date() });
```
You can also specifically store the current date and time using MongoDB's `$currentDate` operator:
You can also store the current date and time using MongoDB's `$currentDate` operator when updating a document:
```javascript
db.events.insertOne({
db.events.updateOne(
{ _id: ObjectId('your_document_id') },
{
$set: {
title: 'Sample Event',
eventDate: { $currentDate: { $type: 'date' } },
});
eventDate: { $currentDate: { $type: 'date' } }
}
}
);
```
## Querying Dates

Loading…
Cancel
Save