Show List

Quiz - MongoDB - 3

59%

Public Average Score
Select the right answer for below questions:

What is the difference between a single-field index and a compound index in MongoDB?
A single-field index indexes multiple fields, while a compound index indexes a single field
A single-field index indexes a single field, while a compound index indexes multiple fields
There is no difference between a single-field index and a compound index in MongoDB
A single-field index indexes a single field, while a compound index indexes multiple fields

What is the syntax for creating a single-field index in MongoDB?
db.collection.createSingleIndex({"field": 1})
db.collection.createIndex({"field": 1})
db.collection.createSingleFieldIndex({"field": 1})
db.collection.createIndex({"field": 1})

What is the syntax for creating a compound index in MongoDB?
db.collection.createCompoundIndex({"field1": 1, "field2": -1})
db.collection.createIndex({"field1": 1, "field2": -1})
db.collection.createMultiFieldIndex({"field1": 1, "field2": -1})
db.collection.createIndex({"field1": 1, "field2": -1})

What is the difference between a TTL index and a regular index in MongoDB?
A TTL index automatically expires documents, while a regular index does not
A regular index automatically expires documents, while a TTL index does not
There is no difference between a TTL index and a regular index in MongoDB
A TTL index automatically expires documents, while a regular index does not

What is the aggregation pipeline in MongoDB?
A way to index data in MongoDB
A set of stages that can be used to process data in MongoDB
A way to store data in MongoDB
A set of stages that can be used to process data in MongoDB

What is the syntax for using the aggregation pipeline in MongoDB?
db.collection.aggregate([{ $match: { field: value } }, { $group: { _id: "$field", count: { $sum: 1 } } }])
db.collection.find([{ $match: { field: value } }, { $group: { _id: "$field", count: { $sum: 1 } } }])
db.collection.update([{ $match: { field: value } }, { $group: { _id: "$field", count: { $sum: 1 } } }])
db.collection.aggregate([{ $match: { field: value } }, { $group: { _id: "$field", count: { $sum: 1 } } }])

What is the $project operator in the aggregation pipeline?
A way to filter data in the aggregation pipeline
A way to project fields in the aggregation pipeline
A way to sort data in the aggregation pipeline
A way to project fields in the aggregation pipeline

What is the syntax for using the $project operator in the aggregation pipeline?
{ $sort: { field1: 1, field2: 1 } }
{ $project: { field1: 1, field2: 1 } }
{ $filter: { field1: 1, field2: 1 } }
{ $project: { field1: 1, field2: 1 } }

What is the difference between the $in and $nin operators in MongoDB?
$in matches values that are in an array, while $nin matches values that are not in an array
$nin matches values that are in an array, while $in matches values that are not in an array
$in and $nin are the same operator in MongoDB
$in matches values that are in an array, while $nin matches values that are not in an array

What is the syntax for using the $in operator in MongoDB?
db.collection.find({ field: { $nin: [value1, value2] } })
db.collection.find({ field: { $in: [value1, value2] } })
db.collection.find({ field: { $all: [value1, value2] } })
db.collection.find({ field: { $in: [value1, value2] } })

Submit
Retry
{"qz1-745268":"A single-field index indexes a single field, while a compound index indexes multiple fields","qz1-745269":"db.collection.createIndex({\"field\": 1})","qz1-745270":"db.collection.createIndex({\"field1\": 1, \"field2\": -1})","qz1-745271":"A TTL index automatically expires documents, while a regular index does not","qz1-745272":"A set of stages that can be used to process data in MongoDB","qz1-745273":"db.collection.aggregate([{ $match: { field: value } }, { $group: { _id: \"$field\", count: { $sum: 1 } } }])","qz1-745274":"A way to project fields in the aggregation pipeline","qz1-745275":"{ $project: { field1: 1, field2: 1 } }","qz1-745276":"$in matches values that are in an array, while $nin matches values that are not in an array","qz1-745277":"db.collection.find({ field: { $in: [value1, value2] } })"}

    Leave a Comment


  • captcha text