0
0
MongoDBquery~10 mins

String and number types in MongoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to insert a document with a string field named 'name'.

MongoDB
db.users.insertOne({ name: [1] })
Drag options to blanks, or click blank then click option'
A"Alice"
B123
Ctrue
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number without quotes for a string field.
Using boolean or null instead of a string.
2fill in blank
medium

Complete the code to find documents where the 'age' field is a number equal to 30.

MongoDB
db.users.find({ age: [1] })
Drag options to blanks, or click blank then click option'
A30
Btrue
Cnull
D"30"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string "30" instead of number 30.
Using boolean or null values.
3fill in blank
hard

Fix the error in the query to find users with a string 'status' equal to 'active'.

MongoDB
db.users.find({ status: [1] })
Drag options to blanks, or click blank then click option'
Atrue
Bnull
C"active"
Dactive
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving out quotes around string values.
Using boolean or null instead of string.
4fill in blank
hard

Fill both blanks to create a document with a string 'title' and a number 'pages'.

MongoDB
db.books.insertOne({ title: [1], pages: [2] })
Drag options to blanks, or click blank then click option'
A"MongoDB Guide"
Btrue
C250
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the string value for title.
Quoting the number value for pages.
5fill in blank
hard

Fill all three blanks to find documents where 'author' is a string, 'year' is a number greater than 2000, and 'available' is a boolean true.

MongoDB
db.books.find({ author: [1], year: { $gt: [2] }, available: [3] })
Drag options to blanks, or click blank then click option'
A"John Doe"
B2000
Ctrue
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the string author.
Quoting the number year.
Using false instead of true for available.