LOGBOOK

HELP

Quiz Entry - updated: 2026.06.20

How do you access a database and collection in MongoDB?

Call client.db(name) to get a database handle, then db.collection(name) to get a collection handle.

const db = client.db('people');
const birthdaysCollection = db.collection('birthdays');
const jobsCollection = db.collection('jobs');

Lazy creation: If the database or collection doesn't exist, it will be created automatically on first write operation.

From Quiz: WEBT / Database Connections | Updated: Jun 20, 2026