MongoDB Questions and Answers – Pipeline Operators – 1

«
»

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Pipeline Operators – 1”.

1. $dayOfMonth returns the day of the month for a date as a number between ________________
a) 1 and 31
b) 1 and 30
c) 1 and 28
d) None of the mentioned
View Answer

Answer: a
Explanation: The $dayOfMonth expression has the following syntax: { $dayOfMonth: }.

advertisement

2. Point out the wrong statement.
a) $second returns the seconds for a date as a number between 0 and 60 (leap seconds)
b) $minute returns the minute for a date as a number between 0 and 59
c) $millis returns the milliseconds of a date as a number between 0 and 1000
d) All of the mentioned
View Answer

Answer: c
Explanation: $millisecond returns the milliseconds of a date as a number between 0 and 999.

3. __________ returns the day of the year for a date as a number between 1 and 366.
a) $dayofWeekend
b) $dayOfWeek
c) $dayOfYear
d) None of the mentioned
View Answer

Answer: c
Explanation: The $dayOfYear expression has the following syntax:{ $dayOfYear: }.

advertisement
advertisement

4. Which of the following returns year for particular date?
a) $year
b) $yearday
c) $syearofmonth
d) None of the mentioned
View Answer

Answer: a
Explanation: $year returns the year for a date as a number (e.g. 2014).

5. Point out the wrong statement.
a) $weekDay returns the week number for a date as a number between 0 and 53 (leap year)
b) $cond accepts either two expressions in an ordered list or three named parameters
c) $toLower only has a well-defined behavior for strings of ASCII characters
d) None of the mentioned
View Answer

Answer: b
Explanation: $cond is a ternary operator that evaluates one expression, and depending on the result, returns the value of one of the other two expressions.

advertisement

6. Which of the following returns the hour for a date as a number between 0 and 23?
a) $minute
b) $hour
c) $seconds
d) All of the mentioned
View Answer

Answer: b
Explanation: The argument in hour statement can be any expression as long as it resolves to a date.

7. __________ returns the date as a formatted string.
a) $toString
b) $dateToString
c) $letString
d) None of the mentioned
View Answer

Answer: b
Explanation: $dateToString converts a date object to a string according to a user-specified format.

advertisement

8. _______ result encompasses instances of undefined values or missing fields.
a) Number
b) String
c) Null
d) None of the mentioned
View Answer

Answer: c
Explanation: Null value does not imply zero.

9. ___________ returns either the non-null result of the first expression.
a) $Null
b) $ifNull
c) $ElseNull
d) None of the mentioned
View Answer

Answer: b
Explanation:$ifNull returns the result of the second expression if the first expression results in a null result.

advertisement

10. __________ take as input a single expression, evaluating the expression once for each input document, and maintain their state for the group of documents.
a) Computer
b) Monitors
c) Accumulators
d) Performoner
View Answer

Answer: c
Explanation: Accumulators are available only for the $group stage.

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Reference Books in MongoDB.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter