141. Which command converts a replica set to a sharded cluster?
- a) sh.addShard()
- b) mongos --convert
- c) No single command (multi-step process)
- d) db.convertToSharded()
sh.addShard().
Test your knowledge of Database - [MongoDB] section with these interactive multiple-choice questions.
141. Which command converts a replica set to a sharded cluster?
sh.addShard().
142. What is the purpose of the $dayOfYear operator?
{ $dayOfYear: "$date" } gives the numeric day within a year (Julian day).
143. Which method configures MongoDB Atlas Triggers?
144. What does the $ifNull operator do?
{ $ifNull: [ "$field", "default" ] } provides fallback values.
145. Which operator performs element-wise array comparison?
{ $cmp: [array1, array2] } returns 0 if equal, -1/1 if less/greater.
146. What is the purpose of the $addFields stage?
$project but preserves existing fields by default.
147. Which command lists MongoDB's storage engines?
serverStatus() (WiredTiger/inMemory/etc).
148. What does the $substrBytes operator do?
{ $substrBytes: ["string", startByte, length] } handles multi-byte characters safely.
149. Which method returns MongoDB's sharding status?
sh.status() displays shard distribution, chunks, and balances.
150. What is the purpose of the $dateFromParts operator?
{ $dateFromParts: { year: 2023, month: 6, day: 15 } } builds a Date.
151. Which operator checks array position conditions?
$slice and $arrayElemAt for positional checks.
152. What does the $stdDevSamp operator return?
{ $stdDevSamp: "$values" } calculates standard deviation for a sample (n-1 denominator).
153. Which command lists all shards in a cluster?
154. What is the purpose of the $split operator?
{ $split: ["a,b,c", ","] } returns ["a","b","c"].
155. Which operator checks if all array elements are true?
{ $allElementsTrue: [true, false] } returns false.
156. What does the $sum operator do in $group?
{ $sum: "$field" } adds all numeric values across documents.
157. Which method returns MongoDB's connection pool stats?
serverStatus() output.
158. What is the purpose of the $concat operator?
{ $concat: ["a","b"] } returns "ab".
159. Which operator checks if any array element is true?
{ $anyElementTrue: [false, true] } returns true.
160. What does the $strLenBytes operator return?
{ $strLenBytes: "MongoDB" } returns 7 (1 byte per ASCII char).