Les99 Mongo Practice Questions
Les99 Mongo Practice Questions
Choose from thee following operators. Which one cane be used to control the number of items from an array that a query will return
A SelemMatch
B $slice
C$
4 MongoDB does not support partial retrieval of items from an array
Q 2 - A collection and a document in MongoDB is equivalent to which of the SQL concepts respectively?
A - Table and Row
B - Table and Column
C - Column and Row
824457596.docx by rt -- 6 December 2024 1 of 5
D - Database and Table
Q 6 - Consider a collection posts which has fields: _id, post_text, post_author, post_timestamp, post_tags etc. Which of the following query
retrieves ONLY the key named post_text from the first document retrieved?
A - db.posts.find({},{_id:0, post_text:1})
B - db.posts.findOne({post_text:1})
C - db.posts.finOne({},{post_text:1})
D - db.posts.finOne({},{_id:0, post_text:1})
Q 8 - In a collection that contains 100 post documents, what does the following command do?
db.posts.find().skip(5).limit(5)
A - Skip and limit nullify each other. Hence returning the first five documents.
B - Skips the first five documents and returns the sixth document five times
C - Skips the first five documents and returns the next five
D - Limits the first five documents and then return them in reverse order
Q 9 - Which of the following MongoDB query is equivalent to the following SQL query:
UPDATE users SET status = "C" WHERE age > 25
A
db.users.update(
{ age: { $gt: 25 } },
{ status: "C" })
B
db.users.update(
{ age: { $gt: 25 } },
{ $set: { status: "C" } })
C
824457596.docx by rt -- 6 December 2024 2 of 5
db.users.update(
{ age: { $gt: 25 } },
{ $set: { status: "C" } },
{ multi: true })
D
db.users.update(
{ age: { $gt: 25 } },
{ status: "C" },
{ multi: true })
Q 17 - Which of the following commands finds all the documents in the posts collection with post timestamp field as null?
A - db.posts.find( { post_timestamp : { $type: 10 } } )
B - db.posts.find( { post_timestamp: { $type: null } } )
C - db.posts.find( { post_timestamp: { $fieldtype: 10 } } )
D - db.posts.find( { post_timestamp: { $fieldtype: null } } )
Q 19 - Which of the following command can be used in mongo shell to show all the databases in your MongoDB instance?
A - show dbs
B - show databases
824457596.docx by rt -- 6 December 2024 3 of 5
C - show dbs -all
D - ls dbs
Q 25 - In our posts collection, which command can be used to find all the posts whose author names begin lie between �A� and �C� in
dictionary order?
A - db.posts.find( { post_author : { $gte : "A" , $lte : "C" } } );
B - db.posts.find( { post_author : { $gte : "C" , $lte : "A" } } );
C - db.posts.find( { post_author : { $gt : "A" , $lt : "C" } } );
D - This type of search is not supported by MongoDB. $lt and $gt operators are applicable only for numeric values.