121. Which command validates collection documents?
- a) db.collection.validate()
- b) db.checkDocuments()
- c) mongod --validate
- d) db.validateAll()
validate() checks data structure integrity and returns storage statistics.
Test your knowledge of Database - [MongoDB] section with these interactive multiple-choice questions.
121. Which command validates collection documents?
validate() checks data structure integrity and returns storage statistics.
122. What is the purpose of the $dayOfMonth operator?
{ $dayOfMonth: "$date" } extracts the day portion from a date.
123. Which method creates a MongoDB Atlas Data Lake?
124. What does the $cond operator do?
{ $cond: { if: condition, then: value1, else: value2 } } works like a ternary operator.
125. Which operator performs set union?
{ $setUnion: [array1, array2] } returns unique elements from both arrays.
126. What is the purpose of the $last operator in $group?
{ $last: "$field" } in $group stage returns the last encountered value.
127. Which command enables MongoDB's free monitoring?
db.serverStatus().
128. What does the $rtrim operator do?
{ $rtrim: { input: " text " } } returns " text".
129. Which method returns MongoDB's host info?
hostInfo() shows OS, CPU, and memory details of the host machine.
130. What is the purpose of the $dateToParts operator?
{ $dateToParts: { date: "$timestamp" } } returns { year, month, day, etc. }.
131. Which operator checks if arrays are subsets?
{ $setIsSubset: [smallArray, largeArray] } returns true if all elements exist.
132. What does the $avg operator do in $group?
{ $avg: "$field" } computes the average of numeric values across documents.
133. Which command lists all MongoDB features?
134. What is the purpose of the $objectToArray operator?
{ $objectToArray: { field1: "value1" } } returns [ { k: "field1", v: "value1" } ].
135. Which operator checks if arrays share elements?
{ $gt: [ { $size: { $setIntersection: [array1, array2] } }, 0 ] } checks for common elements.
136. What does the $stdDevPop operator return?
{ $stdDevPop: "$values" } calculates the population standard deviation.
137. Which method returns MongoDB's network stats?
serverStatus() output.
138. What is the purpose of the $arrayToObject operator?
$objectToArray, turns [ { k: "field", v: "value" } ] into { field: "value" }.
139. Which operator checks if arrays are disjoint?
{ $setDisjoint: [array1, array2] } returns true if arrays share no elements.
140. What does the $trim operator do?
{ $trim: { input: " text " } } returns "text".