Adding a new record into a collection

Inside of Atom, what I'd like you to do is take the code all the way from db.collection down to the bottom of our callback, and comment it out. Then, we're going to go ahead and add something following it. Right previous db.close(), you're going to type Insert new doc into the Users collection. This doc is going to have a few properties. I want you to give it a name property; set that equal to your name. Then, we're going to give it an age property, and last but not least we can give it a location string. I want you to insert that doc using insertOne. You're going to need to pass in the new collection name into the collection method. Then, further down, you're going to add some error-handling code, and ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.