This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
What is the recommended approach for managing MongoClient instances in an application?
Create a new MongoClient for each database operation
Create one MongoClient instance and reuse it throughout the application's lifetime
Create one MongoClient per database you access
A developer stores the database connection string directly in their Python source code and commits it to a Git repository. What security risk does this action creates?
No risk, since the code is in a private repository.
The credentials are exposed in version control history and can't be fully removed.
The connection string expires after 24 hours, so the risk is temporary.
Which MongoDB driver object represents a database in all three languages (Python, .NET, JavaScript)?
MongoClient
Database (Python), IMongoDatabase (.NET), Db (JavaScript)
Collection (Python), IMongoCollection (.NET), Collection (JavaScript)
A team's application uses insertMany() to add 100 products but the operation fails on the 50th document due to a validation error. How many documents are inserted?
All 100 documents are inserted because insertMany is atomic.
49 documents are inserted; the remaining 51 aren't.
Zero documents are inserted; the entire batch is rolled back.
A Python developer uses products.find({'price': {'$gt': 50}}) and gets back a cursor object instead of a list. Why?
The query failed and returned an error object.
The find() method returns a cursor that lazily loads documents as you iterate over them.
The query matched no documents, so an empty cursor is returned.
You must answer all questions before checking your work.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?