Q:

Consider that the posts collection contains an array called ratings which contains ratings given to the post by various users in the following format:

0

Consider that the posts collection contains an array called ratings which contains ratings given to the post by various users in the following format:

{
         _id: 1,
         post_text: "This is my first post",
         ratings: [5, 4, 2, 5],
         //other elements of document 			
}

Which of the following query will return all the documents where the rating array contains elements that in some combination satisfy the query conditions?


  1. db.inventory.find( { ratings: { $elemMatch: { $gt: 3, $lt: 6 } } } )
  2. db.inventory.find( { ratings: { ratings: { $gt: 5, $lt: 9 } } } )
  3. db.inventory.find( { ratings: { ratings.$: { $gt: 5, $lt: 9 } } } )
  4. db.inventory.find( { ratings: { $elemMatch: { $gte: 3, $lte: 6 } } } )

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Correct Answer:

B.db.inventory.find( { ratings: { ratings: { $gt: 5, $lt: 9 } } } )

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now