-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOCS-1639: Recommend BSON date #2582
DOCS-1639: Recommend BSON date #2582
Conversation
9061e53
to
46d50cf
Compare
Overall readability score: 55.6 (🟢 +0)
View detailed metrics🟢 - Shows an increase in readability
Averages:
View metric targets
|
Hi @dmhilly - quick clarification to recommend using the BSON date data type in MQL queries, with an example based on Jack's code as linked in the DOCS ticket. LMK if you'd like to see any changes -- thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thanks Andrew! Left a couple suggestions
@@ -202,6 +202,31 @@ See the [MongoDB Atlas Documentation](https://www.mongodb.com/docs/atlas/data-fe | |||
|
|||
For information on connecting to your Atlas instance from other MQL clients, see the MongoDB Atlas [Connect to your Cluster Tutorial](https://www.mongodb.com/docs/atlas/tutorial/connect-to-your-cluster/). | |||
|
|||
#### Query by date | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can link to BSON spec itself if too many MDB docs links already, up to you.
I think using the MongoDB documentation is okay! It has more info than the BSON spec
docs/data/query.md
Outdated
|
||
When using MQL to query your data by date or time range, you can optimize query performance by avoiding the MongoDB `$toDate` expression, using the [BSON `date` type](https://www.mongodb.com/docs/manual/reference/bson-types/#date) instead. | ||
|
||
For example, you could use the following to query a dataset over a date range, specifying a target start timestamp in BSON date format, and using the `Date()` constructor to use the current time as the end timestamp: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, you could use the following to query a dataset over a date range, specifying a target start timestamp in BSON date format, and using the `Date()` constructor to use the current time as the end timestamp: | |
For example, you could use the following to query a dataset over a date range, specifying a target start timestamp in BSON date format, and using the JavaScript `Date()` constructor to use the current time as the end timestamp: |
Thoughts? Just to make it clear that this is specific to JavaScript/the shell, since to construct a date type in another language they will need to use the language-specific constructs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right on, this is indeed continuing the mongoh
example, so JS it is. Clarified this a bit, thank you!
docs/data/query.md
Outdated
use sensorData | ||
|
||
// Set desired start and end times: | ||
const startTime = 'Mon Feb 10 2024 14:45:07 GMT-0500 (Eastern Standard Time)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I just noticed that this is a string type, not a date. That might confuse users. I don't really know JS but maybe we want something like:
const startTime = new Date('Mon Feb 10 2024 14:45:07 GMT-0500 (Eastern Standard Time)')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right I think, and we can simplify it a bit too if we're using Date()
then. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look great - LGTM! 🎉
You can view a rendered version of the docs from this PR at https://docs-test.viam.dev/2582 |
Recommend that MQL query users use the built-in BSON date type instead of converting from string.
Date()
constructorDate()
constructor without argument to use current timestamp.Question: