What is the difference between deleteOne() and deleteMany() in MongoDB?
deleteOne()
deleteMany()
deleteOne() deletes the first matching document, while deleteMany() deletes all matching documents.
There is no difference; both commands perform the same action.
deleteOne() deletes documents permanently, while deleteMany() moves them to the trash.
deleteOne() deletes all documents, while deleteMany() deletes only the specified number of documents.
What is the function of the $project stage in the aggregation pipeline?
$project
To reshape and transform the structure of output documents.
To filter documents based on matching criteria.
To group documents based on shared values.
To sort documents in ascending or descending order.
What is the role of the MongoClient object in a MongoDB Node.js application?
MongoClient
To establish a connection to the MongoDB server
To create and manage user accounts
To define the database schema
To execute queries against the database
What is the role of a MongoDB cursor in the context of database interactions?
To create and manage indexes on a collection
To store the results of a query, allowing for iteration over the returned documents
To handle authentication and authorization for database access
To define the structure of a document
What is the primary advantage of MongoDB's flexible schema design?
Faster query performance
Reduced storage space requirements
Simplified data modeling and agility
Improved data integrity
Which is NOT a valid index type in MongoDB?
Hashed Index
Spatial Index
Full Text Index
Array Index
How do you verify that the MongoDB server has started successfully?
All of the above
Check the log file for messages indicating successful startup
Use the systemctl status mongod command to view the service's status
Try to connect to the MongoDB server using the mongo shell
What is the purpose of replica sets in MongoDB?
High Availability and Data Redundancy
Load Balancing
Data Sharding
Query Optimization
In a MongoDB cluster, which component acts as a query router and distributes requests to the appropriate shards?
Primary Node
Replica Set
Mongos
Config Server
How do you switch to a specific database, for example, a database named 'myDatabase', in the MongoDB shell?
switch to myDatabase
change to myDatabase
connect myDatabase
use myDatabase