nerdexam
MongoDB

C100DBA · Question #131

Consider the following document: > db.c.find() { "_id" : 12, b : [ 3, 5, 7, 2, 1, -4, 3, 12 ] } Which of the following queries on the "c" collection will return only the first five elements of the arr

Sign in or unlock C100DBA to reveal the answer and full explanation for question #131. The question stem and answer options stay visible for context.

MongoDB Fundamentals

Question

Consider the following document:

db.c.find() { "_id" : 12, b : [ 3, 5, 7, 2, 1, -4, 3, 12 ] } Which of the following queries on the "c" collection will return only the first five elements of the array in the "b" field? E.g., Document you want returned by your query:

{ "_id" : 12, "b" : [ 3, 5, 7, 2, 1 ] >

Options

  • Adb.c.find( { > , { b : { $slice : [ 0 , 5 ] } } )
  • Bdb.c.find( { b : [ 0 , 5 ] > )
  • Cdb.c.find( { > , { b : { $substr[ 0 , 5 ] > > )
  • Ddb.c.find( { > , { b : [ 0, 1, 2, 3, 4, 5 ] > )
  • Edb.c.find( { > , { b : [ 0 , 5 ] > )

Unlock C100DBA to see the answer

You've previewed enough free C100DBA questions. Unlock C100DBA for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#$slice#array projection#query operators#field projection
Full C100DBA Practice