Unit 4 - Practice Quiz

INT222 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 MongoDB is a type of NoSQL database. What category does it fall into?

Introduction to MongoDB Easy
A. Graph database
B. Document-oriented
C. Column-family store
D. Key-value store

2 In relational database terms, what is a MongoDB collection most similar to?

MongoDB Terminology - database, collection, document and files Easy
A. A table
B. A column
C. A database
D. A row

3 What is a single entry in a MongoDB collection called?

MongoDB Terminology - database, collection, document and files Easy
A. A row
B. A cell
C. A record
D. A document

4 What is the name of the interactive command-line interface for MongoDB?

MongoDB database installation and shell installation Easy
A. mdb-shell
B. psql
C. sqlplus
D. mongosh

5 Which command is used in the MongoDB shell to switch to a new or existing database?

MongoDB shell commands - create database, create documents, create collections Easy
A. use databasename
B. switch databasename
C. connect databasename
D. create database databasename

6 Which method is used to add a single document to a collection?

data manipulation - insert, update, delete, find Easy
A. db.collection.add()
B. db.collection.insertOne()
C. db.collection.create()
D. db.collection.putOne()

7 How do you find all documents in a collection named users?

data manipulation - insert, update, delete, find Easy
A. db.users.select(*)
B. db.users.find({})
C. db.users.fetchAll({})
D. db.users.getAll()

8 What is Mongoose?

Introduction to Mongoose Easy
A. A front-end JavaScript framework
B. A query language for SQL databases
C. A standalone database server
D. An Object Data Modeling (ODM) library for MongoDB and Node.js

9 In Mongoose, what is the primary purpose of a Schema?

Schema definition Easy
A. To create a new database
B. To execute raw database commands
C. To define the structure and properties of documents within a collection
D. To connect to the MongoDB database

10 Once you have a Mongoose schema, what do you need to create to interact with the corresponding MongoDB collection?

Models Easy
A. A View
B. A Model
C. A Service
D. A Controller

11 What does the 'U' in CRUD stand for?

CRUD operations Easy
A. Undo
B. Update
C. Upload
D. Unify

12 MongoDB documents are stored in a format that is a binary representation of JSON. What is this format called?

Getting familiar with MongoDB documents and collections Easy
A. XML
B. YML
C. DocDB
D. BSON

13 Which command correctly drops a collection named products?

MongoDB shell commands - drop collection, drop database Easy
A. db.drop(products)
B. drop collection products
C. db.products.drop()
D. db.deleteCollection('products')

14 To delete the entire database you are currently using, which command should be run?

MongoDB shell commands - drop collection, drop database Easy
A. db.drop()
B. deleteAllData()
C. db.admin.drop()
D. db.dropDatabase()

15 To modify the first document that matches a filter, which command would you use?

data manipulation - insert, update, delete, find Easy
A. db.collection.save()
B. db.collection.update()
C. db.collection.modifyOne()
D. db.collection.updateOne()

16 To remove the first document where the status field is "archived", which command is correct?

data manipulation - insert, update, delete, find Easy
A. db.collection.deleteOne({ status: "archived" })
B. db.collection.remove({ status: "archived" })
C. db.collection.drop({ status: "archived" })
D. db.collection.eraseOne({ status: "archived" })

17 Which Mongoose function is used to compile a schema into a Model?

Models Easy
A. mongoose.compile()
B. mongoose.createModel()
C. mongoose.model()
D. mongoose.schema()

18 When implementing pagination, which method is used to specify the maximum number of documents a query should return?

Perform pagination Easy
A. .limit()
B. .max()
C. .size()
D. .count()

19 To get the documents for the third page of a list, where each page has 10 items, you would use .skip(20). What is the purpose of .skip()?

Perform pagination Easy
A. To limit the number of results
B. To ignore a specified number of documents from the beginning of the result set
C. To jump to a specific document ID
D. To skip over documents with errors

20 What is a key advantage of MongoDB's flexible schema?

Introduction to MongoDB Easy
A. It requires all documents to have the exact same fields.
B. It does not allow the data structure to change over time.
C. It allows documents in the same collection to have different fields and structures.
D. It enforces a strict, predefined table structure like SQL.

21 In the MongoDB shell, you execute the command use myNewAppDB. At this exact moment, what is the status of the myNewAppDB database on the server?

MongoDB shell commands - create database Medium
A. The command will fail if the database does not already exist.
B. A database object is created in the shell's memory, but the database is not physically created on disk until the first document is inserted into a collection within it.
C. The database is immediately created on the server's file system, but it is empty.
D. The database and a default 'test' collection are created on the server's file system.

22 You want to update a user's profile. The user document is { "_id": 1, "username": "alex", "status": "active", "profile": { "theme": "dark" } }. Which command will change the status to "inactive" and add a lastLogin field without removing the existing profile object?

Data manipulation - update Medium
A. db.users.updateOne({ "_id": 1 }, { $update: { "status": "inactive", "lastLogin": new Date() } })
B. db.users.replaceOne({ "_id": 1 }, { $set: { "status": "inactive", "lastLogin": new Date() } })
C. db.users.updateOne({ "_id": 1 }, { "status": "inactive", "lastLogin": new Date() })
D. db.users.updateOne({ "_id": 1 }, { $set: { "status": "inactive", "lastLogin": new Date() } })

23 A collection products contains documents with name, price, and category fields. How would you query for all products in the 'electronics' category that cost more than $500, showing only their name and price?

Data manipulation - find Medium
A. db.products.find({ category: 'electronics' AND price: { $gt: 500 } }, { project: { name: 1, price: 1 } })
B. db.products.find({ category: 'electronics', price: > 500 }, { fields: ['name', 'price'] })
C. db.products.find({ category: 'electronics', price: { $gt: 500 } }, { name: 1, price: 1, _id: 0 })
D. db.products.find({ gt: 500 }}], $show: { name: 1, price: 1 } })

24 You are defining a Mongoose schema for a blog post which should have a title that is required and unique. Which schema definition is correct?

Schema definition Medium
A. const postSchema = new Schema({ title: { type: String, properties: ['required', 'unique'] } });
B. const postSchema = new Schema({ title: String, required: true, unique: true });
C. const postSchema = new Schema({ title: { type: String, required: true, unique: 'true' } });
D. const postSchema = new Schema({ title: { type: String, required: true, unique: true } });

25 In Mongoose, you execute await Product.findByIdAndUpdate('someId', { $inc: { stock: -1 } }, { new: true });. What is the primary purpose of the { new: true } option?

CRUD operations Medium
A. It creates a new document if one with the given ID is not found.
B. It validates the update operation against the schema before executing.
C. It forces the creation of a new document, ignoring the provided ID.
D. It returns the document as it was after the update has been applied.

26 You need to implement pagination in a Mongoose query to display the 5th page of results, with each page containing 20 items. Which combination of .skip() and .limit() methods should be used?

Perform pagination Medium
A. .limit(5).skip(20)
B. .skip(5).limit(20)
C. .limit(20).skip(80)
D. .skip(100).limit(20)

27 A collection articles has documents that may or may not have a tags array. You want to add the tag 'featured' to an article with _id: 123, but only if 'featured' is not already in the tags array. Which update operation is most appropriate?

Data manipulation - update Medium
A. db.articles.updateOne({ _id: 123 }, { $addToSet: { tags: 'featured' } })
B. db.articles.updateOne({ _id: 123 }, { $set: { tags: ['featured'] } })
C. db.articles.updateOne({ _id: 123 }, { $push: { tags: 'featured' } })
D. db.articles.updateOne({ _id: 123, 'tags.featured': { push: { tags: 'featured' } })

28 When you define a Mongoose model like const User = mongoose.model('User', userSchema);, what is the conventional name of the MongoDB collection that Mongoose will interact with by default?

Models Medium
A. 'user'
B. 'user_collection'
C. 'User'
D. 'users'

29 You are using db.products.insertMany([...], { ordered: false }) to insert 100 documents. A validation error occurs on the 50th document. What will be the outcome of the operation?

Data manipulation - insert Medium
A. The server attempts to insert all 100 documents, skipping the 50th one, and reports errors for any that fail.
B. Only the 50th document fails; the other 99 are guaranteed to be inserted successfully.
C. The first 49 documents are inserted, and the operation stops.
D. The entire operation fails, and no documents are inserted.

30 What is a key difference between Model.findById('someId') and Model.findOne({ _id: 'someId' }) in Mongoose?

CRUD operations Medium
A. findById can only query by _id, while findOne can use any field.
B. There is no functional difference; findById is just a shorthand.
C. findById is faster because it bypasses schema validation.
D. findById returns a full document while findOne returns only the _id.

31 In the context of MongoDB, how does a document relate to a collection?

MongoDB Terminology - database, collection, document and files Medium
A. A document is a metadata file that describes the indexes of a collection.
B. A document is a single record within a collection, analogous to a row in a relational table.
C. A document is a schema that defines the structure of a collection.
D. A document is a container for multiple collections, similar to a database.

32 Your logs collection has 1000 documents where the level field is 'DEBUG'. If you run the command db.logs.deleteOne({ level: 'DEBUG' }), what will be the result?

Data manipulation - delete Medium
A. Exactly one document matching the filter will be deleted, typically the first one found by the database.
B. All 1000 'DEBUG' log documents will be deleted.
C. The command will fail because it matched more than one document.
D. A random 'DEBUG' log document will be deleted.

33 How would you define a field in a Mongoose schema that must be a string from a predefined list of values, such as 'pending', 'processing', or 'complete'?

Schema definition Medium
A. status: { type: String, enum: ['pending', 'processing', 'complete'] }
B. status: { type: 'enum', values: ['pending', 'processing', 'complete'] }
C. status: String(['pending', 'processing', 'complete'])
D. status: { type: String, oneOf: ['pending', 'processing', 'complete'] }

34 You attempt to update a document that does not exist using db.metrics.updateOne({ date: '2023-10-26' }, { $inc: { visits: 1 } }). The document is not found and nothing happens. How can you modify this command to create the document with visits: 1 if it doesn't exist?

Data manipulation - update Medium
A. Add the { upsert: true } option.
B. Add the { create: true } option.
C. Add the { new: true } option.
D. Use the updateAndInsertOne() command instead.

35 What is the primary advantage of using Mongoose, an Object Data Modeling (ODM) library, over the native MongoDB driver in a Node.js application?

Introduction to Mongoose Medium
A. Mongoose provides a direct performance increase, making all database queries faster.
B. Mongoose translates MongoDB queries into SQL, allowing developers to use familiar syntax.
C. Mongoose is the only way to connect a Node.js application to a MongoDB database.
D. Mongoose provides schema definition and validation, type casting, and business logic hooks, which are not present in the native driver.

36 You have two collections: users and users_temp. What is the result of running db.getCollection('users_temp').drop() in the MongoDB shell?

MongoDB shell commands - drop collection Medium
A. It renames the users_temp collection to users_temp_dropped.
B. It empties the users_temp collection but keeps the collection and its indexes.
C. It drops the users_temp collection and all of its indexes permanently.
D. It drops both the users and users_temp collections.

37 In a Mongoose model named Comment, how would you efficiently count the total number of comments where the isApproved field is true?

CRUD operations Medium
A. await Comment.count({ isApproved: true })
B. await Comment.aggregate([{ count: 'total' }])
C. await Comment.countDocuments({ isApproved: true })
D. await Comment.find({ isApproved: true }).length

38 When building a paginated API endpoint, what is the most robust way to handle both the paginated results and the total number of documents matching the query?

Perform pagination Medium
A. First, run a find() query with .skip() and .limit(). Then, in the application, use the length of the returned array as the total.
B. Use an aggregation pipeline with $facet to get both the count and the paginated data in a single database call.
C. Run two separate queries: one find() with .skip() and .limit() for the data, and another countDocuments() with the same filter for the total count.
D. Run a single find() query without pagination, get the total count from the result's length, then slice the array in the application code.

39 Which of the following statements is true regarding schemas in MongoDB collections?

Getting familiar with MongoDB documents and collections Medium
A. A schema must be defined for a collection before any documents can be inserted.
B. MongoDB uses a global schema that applies to all collections within a database.
C. MongoDB collections are schema-less, meaning documents in the same collection do not need to have the same set of fields or structure.
D. Every document in a collection must strictly adhere to the same schema, enforced by the database.

40 You have a collection of events with an eventDate field stored as an ISODate. Which query finds all events that occurred on or after the beginning of 2023 and before the beginning of 2024?

Data manipulation - find Medium
A. db.events.find({ eventDate: '2023' })
B. db.events.find({ 'eventDate.year': 2023 })
C. db.events.find({ eventDate: { $between: [ISODate('2023-01-01'), ISODate('2023-12-31')] } })
D. db.events.find({ eventDate: { lt: ISODate('2024-01-01') } })

41 Consider a users collection with a document for Alice: { "_id": 1, "name": "Alice", "profile": { "tags": ["A", "B"], "score": 10 } }. What is the final state of Alice's document after executing the following command?

javascript
db.users.updateMany(
{ 'profile.tags': 'B' },
{
$inc: { 'profile.score': 5 },
$addToSet: { 'profile.tags': 'D' }
}
)

data manipulation - update Hard
A. The operation fails because addToSet cannot be used together.
B. { "_id": 1, "name": "Alice", "profile": { "tags": ["A", "B"], "score": 15 } }
C. { "_id": 1, "name": "Alice", "profile": { "tags": ["A", "B", "D"], "score": 15 } }
D. { "_id": 1, "name": "Alice", "profile": { "tags": ["A", "B", "D"], "score": 10 } }

42 Given a products collection where a document has a variants array like:
{ name: 'Shirt', variants: [ { color: 'red', stock: 10 }, { color: 'blue', stock: 5 }, { color: 'red', stock: 0 } ] }

What is the precise output of the following query?

javascript
db.products.find(
{ variants: { gt: 0 } } } },
{ 'name': 1, 'variants.$': 1, '_id': 0 }
)

data manipulation - find Hard
A. The query returns an empty result because not all 'red' variants have stock greater than 0.
B. { "name": "Shirt", "variants": [ { "color": "red", "stock": 10 }, { "color": "red", "stock": 0 } ] }
C. { "name": "Shirt", "variants": [ { "color": "red", "stock": 10 }, { "color": "blue", "stock": 5 }, { "color": "red", "stock": 0 } ] }
D. { "name": "Shirt", "variants": [ { "color": "red", "stock": 10 } ] }

43 You execute an insertMany operation on an empty collection with the ordered: false option, where one of the documents violates the unique _id constraint. What is the outcome?

javascript
db.items.insertMany([
{ _id: 1, val: 'A' },
{ _id: 2, val: 'B' },
{ _id: 1, val: 'C' }
], { ordered: false });

data manipulation - insert Hard
A. The operation fails completely before inserting any documents, and the collection remains empty.
B. The operation is aborted when the duplicate key is found. Only the document { _id: 1, val: 'A' } is inserted.
C. The operation continues after the error. The documents { _id: 1, val: 'A' } and { _id: 2, val: 'B' } are inserted. A write error is reported for the third document.
D. The behavior is undefined and depends on the storage engine.

44 Analyze the following Mongoose schema and subsequent code. After user.save() is successfully executed, what will be the values of user.level, user.xp, and the virtual property user.rank?

javascript
const userSchema = new mongoose.Schema({
name: String,
level: { type: Number, default: 1 },
xp: { type: Number, default: 0 }
});

userSchema.virtual('rank').get(function() {
if (this.level >= 10) return 'Veteran';
return 'Rookie';
});

userSchema.pre('save', function(next) {
if (this.isModified('xp') && this.xp >= this.level 100) {
this.level += 1;
this.xp = this.xp - (this.level - 1)
100;
}
next();
});

const User = mongoose.model('User', userSchema);
const user = new User({ name: 'Zelda', level: 5, xp: 550 });
await user.save();

Schema definition Hard
A. level: 6, xp: 50, rank: 'Rookie'
B. level: 6, xp: 550, rank: 'Rookie'
C. level: 6, xp: 0, rank: 'Veteran'
D. level: 5, xp: 550, rank: 'Rookie'

45 Consider an empty items collection and the following Mongoose operation. What is the most accurate description of the outcome?

javascript
const itemSchema = new mongoose.Schema({ name: { type: String, required: true }, stock: Number });
const Item = mongoose.model('Item', itemSchema);

const result = await Item.findOneAndUpdate(
{ name: 'Gadget' },
{ $inc: { stock: 1 } },
{ new: false, upsert: true, runValidators: true }
);

CRUD operations Hard
A. The result variable will be { _id: ..., name: 'Gadget', stock: 1 }, and a new document will be inserted.
B. The operation will throw a ValidationError because stock is not defined in the schema with a default value.
C. The result variable will be null, and a document { name: 'Gadget' } will be inserted, with stock remaining unset.
D. The result variable will be null, and a new document { name: 'Gadget', stock: 1 } will be inserted into the database.

46 When implementing cursor-based pagination on a posts collection sorted by createdAt: -1, you notice multiple posts can have the exact same createdAt timestamp. A common solution is to add _id: -1 as a secondary sort field. How must the query filter be structured to correctly fetch the next page, given the last post seen had lastCreatedAt and lastId?

Perform pagination Hard
A. { createdAt: { lt: lastId } }
B. { lt: lastCreatedAt } }, { createdAt: lastCreatedAt, _id: { $lt: lastId } } ] }
C. { createdAt: { lt: lastId } }
D. { createdAt: { $lt: lastCreatedAt } }

47 What is a key characteristic of a Capped Collection in MongoDB that differentiates it from a standard collection, and what is its primary use case?

MongoDB Terminology - database, collection, document and files Hard
A. They support transactions and are used for financial data.
B. They enforce a strict schema on all documents inserted, used for data validation at the database level.
C. They automatically shard data across multiple servers for horizontal scaling.
D. They are fixed-size collections that maintain insertion order and overwrite the oldest entries when full, ideal for logging or caching.

48 You have a Mongoose model with a static method and an instance method. Given const alice = await User.findOne({ name: 'Alice' });, which statement correctly describes the valid and invalid use of these methods?

javascript
// Static Method
userSchema.statics.findByName = function(name) {
return this.findOne({ name });
};

// Instance Method
userSchema.methods.hasName = function(name) {
return this.name === name;
};

Models Hard
A. Only User.findByName('Alice') is a valid call; alice.hasName('Alice') is invalid.
B. Both User.findByName('Alice') and alice.hasName('Alice') are valid calls.
C. Both User.hasName('Alice') and alice.findByName('Alice') are valid calls.
D. Only alice.hasName('Alice') is a valid call; User.findByName('Alice') is invalid.

49 By default, Mongoose does not run schema validators on updateOne and updateMany operations. An update operation is performed on a document that would violate a schema validator if it were run. What is the outcome?

javascript
const postSchema = new mongoose.Schema({
tags: [{ type: String, maxlength: 8 }]
});
const Post = mongoose.model('Post', postSchema);
const doc = await Post.create({ tags: ['news'] });

await Post.updateOne(
{ _id: doc._id },
{ $push: { tags: 'announcements' } } // 'announcements' is > 8 chars
);

CRUD operations Hard
A. The update partially succeeds, adding the tag but marking the document as invalid.
B. The update fails with a ValidationError because Mongoose automatically enables validation for all update operations.
C. The update succeeds, and the tags array becomes ['news', 'announcements'] because validators are not run by default.
D. The update succeeds, but the invalid tag 'announcements' is silently ignored and not added to the array.

50 To optimize the query db.users.find({ status: "active" }).sort({ lastLogin: -1 }) for a large collection, which compound index provides the best performance according to the Equality-Sort-Range (ESR) rule?

data manipulation - find Hard
A. { "status": 1, "lastLogin": -1 }
B. A text index on both status and lastLogin.
C. Two separate single-field indexes: one on status and one on lastLogin.
D. { "lastLogin": -1, "status": 1 }

51 You execute use newDB in the mongo shell, followed by db.createCollection("myColl"). Immediately after, you execute db.dropDatabase(). At what point are the physical database files for newDB actually created on disk, and what is the final result?

MongoDB shell commands - create database, create documents, create collections, drop collection, drop database Hard
A. Files are created on use newDB. The dropDatabase() call then removes them.
B. Files are created on use newDB. The dropDatabase() call fails because the database is empty.
C. Files are not created until the first document is inserted. The dropDatabase() call does nothing.
D. Files are created on db.createCollection("myColl"). The dropDatabase() call then removes them.

52 In a MongoDB replica set, what level of atomicity is guaranteed for the following single updateOne operation?

javascript
db.accounts.updateOne(
{ _id: 123 },
{
$inc: { balance: -100 },
$push: { history: { type: 'debit', amount: 100 } }
}
)

CRUD operations Hard
A. Field-level atomicity. push is atomic, but not together.
B. Transaction-level atomicity. It requires an explicit transaction to be atomic.
C. Document-level atomicity. Both modifications (push) are applied to the single document as a single, indivisible operation.
D. None. The push operations are independent and may succeed or fail separately.

53 A developer defines a Mongoose schema where a field is type Number but provides a string value when creating a new document instance. What is Mongoose's behavior during the save() operation?

javascript
const itemSchema = new mongoose.Schema({ price: Number });
const Item = mongoose.model('Item', itemSchema);
const newItem = new Item({ price: '19.99' });
await newItem.save();

Introduction to Mongoose Hard
A. It saves the document, but the price field is stored as the string '19.99' in the database.
B. It successfully saves the document by automatically casting the string '19.99' to the number 19.99.
C. It saves the document, but the price field is set to null due to the failed cast.
D. It throws a CastError because the type of '19.99' is a string, not a number.

54 Which Mongoose query correctly performs a nested population, retrieving an Order document while also populating the user's name and, for each item in the items array, the product's name and price?

javascript
// Schemas:
// Order -> { user: { ref: 'User' }, items: [{ productId: { ref: 'Product' } }] }
// User -> { name: String }
// Product -> { name: String, price: Number }

Schema definition Hard
A. Order.findById(id).populate('user.name').populate('items.productId.name items.productId.price')
B. Order.findById(id).populate('user', 'name').populate('items.productId', 'name price')
C. This requires two separate queries; it cannot be done with a single populate chain.
D. Order.findById(id).populate({ path: 'items', populate: { path: 'productId', select: 'name price' } }).populate('user', 'name')

55 In a 3-node replica set (Primary, Secondary, Secondary), a write operation is issued with a write concern of w: "majority". At that moment, one of the secondary nodes is down. What is the expected outcome of the write operation?

MongoDB database installation and shell installation Hard
A. The write will succeed after being acknowledged by the Primary and the single remaining Secondary.
B. The write will fail immediately, returning an error to the client that a majority is not available.
C. The write will hang indefinitely until the downed secondary comes back online.
D. The write will succeed after being acknowledged by the Primary only, as majority is ignored when nodes are down.

56 A developer uses the mongoose-autopopulate plugin on a createdBy field in a Post schema. What is the most significant and common performance pitfall of this approach when applied universally?

Models Hard
A. It adds an extra database query to fetch the User document every time a Post is queried, even when the createdBy data is not needed for that specific operation.
B. It breaks queries that try to sort by the createdBy field.
C. It causes the Mongoose schema validation to be bypassed for the createdBy field.
D. It makes it impossible to use the .lean() method to get plain JavaScript objects.

57 In a large, sharded MongoDB cluster, what is the primary and most severe performance consequence of executing a deleteMany command where the query filter does not include the shard key?

data manipulation - delete Hard
A. The operation will fail with an error because the shard key is required for all delete operations.
B. The operation will only run on the primary shard, leading to incomplete data deletion.
C. MongoDB will perform a full collection scan on a single shard to find the shard key, then target the correct shard.
D. The mongos query router will broadcast the delete command to every shard in the cluster (a scatter-gather operation), potentially causing a cluster-wide performance degradation.

58 A MongoDB document is limited to 16 megabytes in size. An application needs to store user-uploaded files that are often larger than this limit (e.g., 100MB videos). What is the canonical MongoDB solution for handling this requirement?

Getting familiar with MongoDB documents and collections Hard
A. Store the file's binary data in a BSON BinData field and enable collection-level compression.
B. Manually split the file into an array of 15MB chunks within a single document.
C. Store the files on a traditional file system and only store the file path string in the MongoDB document.
D. Use GridFS, a specification for storing and retrieving large files by chunking them into separate documents within special collections (fs.files and fs.chunks).

59 In a MongoDB replica set, a client can specify a Read Concern to control the consistency of data it reads. Which Read Concern level ensures that a query reads data from a snapshot of the data that has been acknowledged by a majority of the replica set members, thus preventing reads of rolled-back data?

Introduction to MongoDB Hard
A. available
B. local
C. snapshot
D. majority

60 What is a key difference between db.collection.deleteMany({}) and db.collection.drop() in MongoDB?

MongoDB shell commands - drop collection, drop database Hard
A. There is no functional difference; drop() is just an alias for deleteMany({}).
B. drop() removes the collection and all its indexes, while deleteMany({}) only removes the documents, leaving the empty collection and its indexes intact.
C. deleteMany({}) can be rolled back in a transaction, but drop() cannot.
D. deleteMany({}) is faster because it does not have to remove indexes.