-
Notifications
You must be signed in to change notification settings - Fork 10
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
DOCSP-43063 Time Series Data #55
DOCSP-43063 Time Series Data #55
Conversation
✅ Deploy Preview for docs-c ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Some nits and one open question! Looks good otherwise, but would appreciate @kevinAlbs feedback on one point.
|
||
- The database in which to create the collection | ||
- The name of the new collection to create | ||
- A ``timeseries`` object that specifies the ``timeField`` option |
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'm not sure if "object" is the correct terminology here.
@kevinAlbs might be able to clarify.
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.
That particular parameter is a bson_t
, so I would suggest altering as such:
- A ``timeseries`` object that specifies the ``timeField`` option | |
- A BSON document that specifies the ``timeField`` option |
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.
LGTM!
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
int main (int argc, char *argv[]) |
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.
int main (int argc, char *argv[]) | |
int main (void) |
Suggest passing through no arguments as to avoid warnings (arguments aren't used in the program).
"location", "{", "city", BCON_UTF8 ("New York"), "}", | ||
"timestamp", BCON_DATE_TIME (1633046400000)); | ||
|
||
mongoc_collection_insert_one (collection, insert_doc, NULL, NULL, &error)) |
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.
mongoc_collection_insert_one (collection, insert_doc, NULL, NULL, &error)) | |
mongoc_collection_insert_one (collection, insert_doc, NULL, NULL, &error); |
"}"); | ||
|
||
// Create the time series collection | ||
mongoc_database_create_collection (database, "october2024", opts, &error); |
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.
mongoc_database_create_collection (database, "october2024", opts, &error); | |
mongoc_collection_t *collection = mongoc_database_create_collection (database, "october2024", opts, &error); |
Suggest saving the result of the function call in a variable. collection
is used in mongoc_collection_insert_one
below.
const bson_t *insert_doc; | ||
insert_doc = BCON_NEW ( |
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.
const bson_t *insert_doc; | |
insert_doc = BCON_NEW ( | |
const bson_t *insert_doc = BCON_NEW ( |
int main (int argc, char *argv[]) | ||
{ | ||
// start-create-time-series | ||
bson_error_t error; |
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.
Suggest moving error
closer to mongoc_database_create_collection
where it is being used.
mongoc_collection_insert_one (collection, insert_doc, NULL, NULL, &error)) | ||
// end-insert-document | ||
|
||
bson_destroy (opts); |
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.
bson_destroy (opts); |
|
||
// Create the time series collection | ||
mongoc_database_create_collection (database, "october2024", opts, &error); | ||
// end-create-time-series |
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.
// end-create-time-series | |
bson_destroy (opts); | |
// end-create-time-series |
bson_destroy (opts); | ||
mongoc_cursor_destroy (cursor); | ||
mongoc_database_destroy (database); | ||
mongoc_client_destroy (client); |
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.
mongoc_client_destroy (client); | |
mongoc_client_destroy (client); | |
mongoc_collection_destroy (collection); |
// end-insert-document | ||
|
||
bson_destroy (opts); | ||
mongoc_cursor_destroy (cursor); |
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.
mongoc_cursor_destroy (cursor); |
if (mongoc_cursor_error (cursor, &error)) | ||
{ | ||
fprintf (stderr, "Cursor error: %s\n", error.message); | ||
} |
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.
} | |
} | |
mongoc_cursor_destroy (cursor); |
"location", "{", "city", BCON_UTF8 ("New York"), "}", | ||
"timestamp", BCON_DATE_TIME (1633046400000)); | ||
|
||
if (!mongoc_collection_insert_one (collection, insert_doc, NULL, NULL, &error) { |
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.
if (!mongoc_collection_insert_one (collection, insert_doc, NULL, NULL, &error) { | |
if (!mongoc_collection_insert_one (collection, insert_doc, NULL, NULL, &error)) { |
"timestamp", BCON_DATE_TIME (1633046400000)); | ||
|
||
if (!mongoc_collection_insert_one (collection, insert_doc, NULL, NULL, &error) { | ||
fprintf("Error inserting document: %s\n", error.message); |
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.
fprintf("Error inserting document: %s\n", error.message); | |
fprintf(stderr, "Error inserting document: %s\n", error.message); |
// end-create-time-series | ||
bson_destroy (opts); |
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.
// end-create-time-series | |
bson_destroy (opts); | |
bson_destroy (opts); | |
// end-create-time-series |
Suggest swapping these two lines so the user can see in documentation that they have to destroy the opts
variable.
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.
LGTM
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-43063
Staging - https://deploy-preview-55--docs-c.netlify.app/databases-collections/time-series/
Self-Review Checklist