nerdexam
MongoDB

C100DBA · Question #116

Which of the documents below will be retrieved by the following query? Assume the documents are stored in a collection called "sample". Check all that apply. db.sample.find( { "$or" : [ { "a" : {…

The document choices in your question appear to be corrupted or truncated - all options (A–J) show incomplete content like {''_ or {". Without the actual document contents, it's impossible to identify which are correct. However, here's a clear explanation of the query logic so…

MongoDB Fundamentals

Question

Which of the documents below will be retrieved by the following query? Assume the documents are stored in a collection called "sample". Check all that apply. db.sample.find( { "$or" : [ { "a" : { "$in" : [ 3, 10] > }, { "b" : { "$lt" : 2 > > ] > )

Options

  • A{''_
  • B{''_
  • C{".
  • D{ ''\
  • E{ \
  • F{".
  • G{".
  • H{".
  • I{".
  • J{".

Explanation

The document choices in your question appear to be corrupted or truncated - all options (A–J) show incomplete content like {''_ or {". Without the actual document contents, it's impossible to identify which are correct.

However, here's a clear explanation of the query logic so you can apply it yourself:

The Query:

db.sample.find({
  "$or": [
    { "a": { "$in": [3, 10] } },
    { "b": { "$lt": 2 } }
  ]
})

What it retrieves: Any document matching at least one of these conditions:

  • Field a equals 3 or 10 (via $in)
  • Field b is less than 2 (via $lt)

How to evaluate each document:

  1. Check if a is in the set {3, 10} → match
  2. OR check if b < 2 → match
  3. If either is true, the document is retrieved
  4. A document with neither condition met is excluded

Memory tip: Think of $or as a bouncer who lets you in if you meet any one of the rules. $in is a VIP list, and $lt is an age check - pass either and you're in.

If you can share the actual document contents for choices A–J, I can tell you exactly which ones match.

Topics

#$or operator#$in operator#query operators#logical operators

Community Discussion

No community discussion yet for this question.

Full C100DBA Practice