-
Notifications
You must be signed in to change notification settings - Fork 239
Add create.js #1
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
Conversation
* The Mongo Client you will use to interact with your database | ||
* See bit.ly/Node_MongoClient for more details | ||
*/ | ||
const client = new MongoClient(uri); |
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.
Depending on what version of the node driver is being used here, this line has the potential to log one or both of the following notices:
(node:11642) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:11642) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.connect.
This is encouraging the user to opt-in to new features that will become the default in later version of the driver. To see a version with no warnings at all, you would need the constructor to look like:
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });
These flags will eventually go away as we release new versions of the driver, so I'm not sure if you want to include them in the blog post, as it can lead to stale info persisting on the internet.
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 had those params in initially and @mbroadst suggested I remove them in order to future-proof the post. The initial post in the series (not yet published) addresses how to get rid of the errors.
create.js
Outdated
} | ||
} | ||
|
||
main().catch(console.err); |
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 think this should be console.error
.
create.js
Outdated
]); | ||
|
||
} catch (e) { | ||
console.error(e); |
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.
Minor point: this catch
block will log any error that occurs in the above try
block, but it will also stop the error from propagating. Since you already have a .catch
on the main
function invocation at line 66, this might not be necessary.
That said, if you think this is clearer for readers on how to catch the errors, then it is fine.
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
No description provided.