101. Which command imports BSON data into MongoDB?
- a) mongorestore
- b) mongoimport
- c) loadbson
- d) db.import()
mongorestore imports binary BSON files created by mongodump.
Test your knowledge of Database - [MongoDB] section with these interactive multiple-choice questions.
101. Which command imports BSON data into MongoDB?
mongorestore imports binary BSON files created by mongodump.
102. What is the purpose of the $hour operator?
{ $hour: "$timestamp" } returns the hour portion of a date.
103. Which method creates a MongoDB Atlas cluster?
104. What does the $literal operator do?
$literal treats values as literals rather than field paths (e.g., "$field" vs { $literal: "$field" }).
105. Which operator performs set intersection?
{ $setIntersection: [array1, array2] } returns common elements.
106. What is the purpose of the $indexOfArray operator?
{ $indexOfArray: [array, value] } returns the index of the first match (-1 if not found).
107. Which command enables MongoDB profiling?
108. What does the $reverseArray operator do?
{ $reverseArray: array } returns a new array with elements in reverse order.
109. Which method creates a MongoDB client session?
110. What is the purpose of the $dateDiff operator?
{ $dateDiff: { startDate: date1, endDate: date2, unit: "day" } } computes intervals.
111. Which operator implements set difference?
{ $setDifference: [array1, array2] } returns elements in array1 not in array2.
112. What does the $first operator return in $group?
{ $group: { _id: "$field", firstVal: { $first: "$target" } } }.
113. Which command lists MongoDB's available commands?
listCommands() displays all supported commands with their requirements.
114. What is the purpose of the $zip operator?
{ $zip: { inputs: [array1, array2] } } produces [ [elem1,elem2], ... ].
115. Which operator checks if a value is in an array?
{ field: { $in: [value1, value2] } } matches documents where field equals any array value.
116. What does the $min operator do in $group?
{ $min: "$field" } in $group finds the minimum value across documents.
117. Which method returns MongoDB's build info?
buildInfo() shows version, git hash, and compilation flags.
118. What is the purpose of the $reduce operator?
{ $reduce: { input: array, initialValue: 0, in: "$$value + $$this" } } works like JavaScript's reduce().
119. Which operator implements set equality?
{ $setEquals: [array1, array2] } returns true if arrays have same elements (order irrelevant).
120. What does the $ltrim operator do?
{ $ltrim: { input: " text " } } returns "text ".