Complete the code to import the MongoClient class from the mongodb package.
const { [1] } = require('mongodb');The MongoClient class is imported from the 'mongodb' package to create a client for connecting to MongoDB.
Complete the code to create a new MongoClient instance with the connection URI.
const client = new MongoClient([1]);The connection URI for MongoDB uses the 'mongodb://' protocol and the default port 27017.
Fix the error in the async function to connect the client.
async function connectDB() {
await client.[1]();
}The MongoClient instance has a method named 'connect' to establish the connection.
Fill both blanks to get a database named 'testdb' from the client.
const db = client.[1]([2]);
The method to get a database is 'db' and the database name is passed as a string.
Fill all three blanks to get a collection named 'users' from the database and insert a document.
const collection = db.[1]([2]); await collection.[3]({ name: 'Alice', age: 25 });
Use 'collection' method to get the collection, pass the collection name as a string, and use 'insertOne' to insert a single document.