Date Tags for Easier Querying of Date Fields
I propose adding a feature called "Date Tags" to MongoDB Compass, which would allow users to query date fields more easily. Date Tags would serve as shorthand for commonly used date queries, enhancing user efficiency and readability.
Example Use-Case:
Consider the task of finding all documents where the createdAt field was set to "yesterday". Normally, the query would look something like:
{
"createdAt": {
"$gte": ISODate("2023-10-17T00:00:00"),
"$lt": ISODate("2023-10-18T00:00:00")
}
}
With Date Tags, this could be simplified to:
{
"createdAt": #yesterday
}
Proposed Date Tags:
#today
#yesterday
#lastNDays
#lastNHours
#lastNMinutes
#others
Each tag would automatically be translated to the corresponding MongoDB date query format.
This feature is inspired by a similar implementation in Studio3T, and I believe it would be a valuable addition to MongoDB Compass as well.