PLAY READ BLOG

Assess your experience with MongoDB

I estimate it would take you 40 steps in 10 minutes to Assess your experience with MongoDB.
Assume you're querying a "grades" collection and you just want to look at the first 3 documents in the collection. Which of these methods would you use?
1. limit(3)

2. skip(3)

3. take(3)

4. first(3)
  • 1.
  • 2.
  • 3.
  • 4.
The $set operator in an update() command does which of the following?
1. Changes an array to contain only distinct values

2. Creates a set

3. Creates or replaces an entire value of a field

4. Sets a value of an existing field, but does nothing if that field doesn't exist
  • 1.
  • 2.
  • 3.
  • 4.
Let's say you are setting up a MongoDB server to use when testing your application. You need to load a small amount of test data to populate the testing database. Fortunately, you have test data in another test server that you can reuse.

Fill in the blanks:
___________ can be used to extract the existing data
then, ___________ is used to load it into the new server.
1. mongoexport / mongorestore

2. mongodump / mongorestore

3. mongobackup / mongoimport

4. mongobackup / mongoload
  • 1.
  • 2.
  • 3.
  • 4.
When inserting a document into a replica set, write-concern of "majority" mongo will...
1. return success only after the majority of the cluster writes the new document.

2. return immediately, but provide a transaction id that you can use to track the document.

3. succeed as long as document is inserted into the primary node.

4. retry the operation until a majority of nodes receives the new document.
  • 1.
  • 2.
  • 3.
  • 4.
Which feature in MongoDB helps you overcome write capacity limitations?
1. Connection pool sizing

2. Sharding

3. Indexing

4. Replica Set
  • 1.
  • 2.
  • 3.
  • 4.
How can you update-or-insert a document?
1. It is automatic as long as the match criteria finds nothing

2. By using the Upsert command

3. By writing a stored procedure

4. By specifying the upsert option in an update() command
  • 1.
  • 2.
  • 3.
  • 4.
What can you do to reduce network saturation when dealing with large size documents?
1. Project only the fields your application needs.

2. Decrease the cursor batch size so that less documents are returned in a batch.

3. Open multiple connections to MongoDB.

4. Apply zlib storage compression.
  • 1.
  • 2.
  • 3.
  • 4.
Say you are running a query of a "people" collection to find everyone with brown hair, what's the most concise way to formulate this query?
1. { $eq: "brown" }

2. { $eq: { hair: "brown" } }

3. { hair: { $eq: "brown" } }

4. { hair: "brown" }
  • 1.
  • 2.
  • 3.
  • 4.
Collection "demo" has a document { "_id" : 1, "name" : "ogg"}. How can you change the _id to equal 2 using an update() command?
1. db.demo.update({"_id": 1}, {"_id": 2, "name": "ogg"}, {"upsert":false})

2. db.demo.update({"_id": 1}, {$set: {"_id": 2}})

3. db.demo.update({"name": "ogg"}, {"_id": 2})

4. You cannot update the value of the _id field.
  • 1.
  • 2.
  • 3.
  • 4.
Two instances of your application are running on 2 different servers. Each is inserting documents into the same collection with an _id of type ObjectId. At the same exact nanosecond, both applications inserted a document. Which of these statements is true with respect to the _id generated for the documents, assuming both were written sucessfully?
1. The ObjectId of the server that connected first would be written first and would be smaller than the other ObjectId

2. The two ObjectId values would be different.

3. The two ObjectIds would be merged and the document fields from the second command received prevailing.

4. The ObjectId for the document that hit the journal first would be smaller than the ObjectId of the second one.
  • 1.
  • 2.
  • 3.
  • 4.
Which statement is true with respect to storing a date using BSON date data type?
1. The date timezone offset is always assumed to be UTC.

2. MongoDB converts all dates to the offset of the OS that hosts the primary node.

3. You can update a date by one day by using {$inc:{"mydatefield":1}}

4. Dates are only accurate to the seconds level.
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following is the best resource to start with for getting your application to interact with a mongo database?
1. MongoDB Wire Protocol

2. HTTP API

3. Community Drivers

4. Official Drivers
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following schema migrations is implicit when using MongoDB documents?
1. Adding a field

2. Merging fields

3. Renaming a field

4. Deleting a field
  • 1.
  • 2.
  • 3.
  • 4.
An invoice document contains the fields "quantity" (a BSON int value) and "price" (a BSON decimal value). You run an aggregation pipeline with the single stage {$project: {total: {$multiply:["$price","$quantity"]}}}. What would the result BSON type be?
1. Double, if the number is below 2^63, or decimal if it is above

2. An error will occur. You must cast the quantity before the multiplication

3. Decimal

4. Long, with the fraction rounded down
  • 1.
  • 2.
  • 3.
  • 4.
Which of the following schema changes is most likely to prompt you to alter all documents in a collection?
1. Adding a field

2. Renaming a field

3. Creating a view

4. Deprecating a field
  • 1.
  • 2.
  • 3.
  • 4.
A Schema Validator is:
1. Attached to a collection

2. Stored in the "master" database

3. Applies to inserts only

4. Passed along from a client with queries at runtime
  • 1.
  • 2.
  • 3.
  • 4.
GridFS solves which one of these essential problems?
1. Processing documents in parallel

2. Storing metadata about a binary field

3. Storing large arbitrary files, exceeding the maximum MongoDB document size

4. Replicating databases with multi-master writes
  • 1.
  • 2.
  • 3.
  • 4.
Which MongoDB server command removes a document from a collection?
1. deleteSingle

2. drop

3. remove

4. dropDocuments
  • 1.
  • 2.
  • 3.
  • 4.
Say you're entering the following command into the mongo shell and you know that the command you want to run on a database starts with a `g` but you don't remember exactly what the command is called:
db.g

What can you do in the shell to see a list of commands that start with `g`?
1. <CTRL> + .

2. <TAB>

3. show commands g

4. show help
  • 1.
  • 2.
  • 3.
  • 4.
Get Started   

Or consider 76 other intentions.