Loading

Quipoin Menu

Learn • Practice • Grow

mongodb / Connecting Node.js to MongoDB
mcq
Direction: Choose the correct option

Q1.

Which official MongoDB driver is used to connect Node.js to MongoDB?
A. mongojs
B. mongo-client
C. mongoose
D. mongodb
Direction: Choose the correct option

Q2.

How do you establish a connection to MongoDB using the official Node.js driver?
A. `MongoClient.connect()` with a connection string
B. `mongodb.connect()`
C. `mongoose.connect()`
D. `new Mongo().connect()`
Direction: Choose the correct option

Q3.

What is the typical connection string format for a local MongoDB instance?
A. `mongo://localhost:27017`
B. Both A and C
C. `mongodb://localhost:27017`
D. `mongodb://127.0.0.1:27017/db`
Direction: Choose the correct option

Q4.

What does `MongoClient.connect()` return or accept as a callback?
A. The collection object
B. The database object directly
C. A promise (if using async/await) or a callback with error and client object
D. A boolean
Direction: Choose the correct option

Q5.

After connecting with `MongoClient`, how do you access a specific database?
A. client.getDatabase('databaseName')
B. client.database('databaseName')
C. client.db('databaseName')
D. client.use('databaseName')