MongoDB TutorialLesson 26Free preview
MongoDB Node.js Driver
This lesson is part of MongoDB · All levels
Summary
This lesson shows how to connect Node.js applications to MongoDB using its official driver. You call new MongoClient(uri), then await client.connect() before using client.db("name") and the desired collection. Since the database operation runs async, the Node.js code generally uses async/await to be neat and easy to read.
Key points
- Install the driver with npm install mongodb and then import MongoClient
- Connect to new
- Client.db() and db.collection() select the target of the operation
- CRUD operation is running so it is called as
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.