Skip to content

Conversation

ljhaywar
Copy link
Contributor

@ljhaywar ljhaywar commented Oct 9, 2019

No description provided.

* The Mongo Client you will use to interact with your database
* See bit.ly/Node_MongoClient for more details
*/
const client = new MongoClient(uri);

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.

Copy link
Contributor Author

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);

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);

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.

Copy link

@daprahamian daprahamian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

@ljhaywar ljhaywar merged commit 5e452a4 into master Oct 17, 2019
@ljhaywar ljhaywar deleted the create branch October 17, 2019 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants