DBA130 FINAL
new MongoDB("localhost")
How do you connect to the localhost MongoDB server from a MongoDB shell script?
find({score: {$gt: 90}}).count()
How would you get a count of documents from a collection object in the MongoDB shell of documents that have a field named score with a value higher than 90?
show users
What MongoDB shell command would you use to list users in the database
db.shutdownServer()
What command do you use to stop the MongoDB server from the admin database in the shell?
mongod --auth
What command line option for the MongoDB server would you use to require authentication to access the databases?
load("test.js")
What command line option would you use to execute a MongoDB shell JavaScript file named test.js from a from the MongoDB shell?
use admin
What command would you use in the MongoDB shell to switch to the admin database?
db.dropUser("me")
What command would you use to remove a user named me from the database?
{address: false}
What fields object in the MongoDB shell would you use to to exclude the address field from documents returned from the database?
{name: 1, address: 1}
What fields object in the MongoDB shell would you use to to only return the name and address fields in documents returned from the database?
27017
What is the default MongoDB server port?
mongod
What is the name of the executable file that starts the MongoDB database server?
mongo
What is the name of the executable file that starts the MongoDB shell?
createUser()
What method do you use to add a user to a database in our current MongoDB shell?
mapReduce()
What method on the collection object in the MongoDB shell allows you to apply a mapping to data that reduces the set of data and returns the manipulated results?
group() aggregate() mapReduce()
What method on the collection object in the MongoDB shell allows you to return documents collected together by a field value?
aggregate()
What method on the collection object in the MongoDB shell allows you to use a pipeline to manipulate data in a series of steps?
insert()
What method on the collection object in the MongoDB shell can you use to add a new document to a collection?
remove()
What method on the collection object in the MongoDB shell will remove all documents from a collection?
getCollection("myColl")
What method on the collection object would you use to retrive a single document from the database using the MongoDB shell?
stats()
What method on the colletion object would you use to display statisics for the collection in a MongoDB shell script?
drop()
What method on the colletion object would you use to remove the collection from the database in a MongoDB shell script?
getDB("admin")
What method on the connection object would you use to get a database object for the admin database in a MongoDB shell script?
limit(5)
What method on the cursor object in the MongoDB shell would you use to reduce the number of documents returned to just 5?
createCollection("myColl")
What method on the database object would you use the create a collection named myColl from the MongoDB shell?
getCollection("myColl")
What method on the database object would you use to get a collection object for the myColl collection in a MongoDB shell script?
dropDatabase()
What method on the database object would you use to remove the database from the server in a MongoDB shell script?
distinct('age')
What method would you use on a collection object to get a list of the distinct values of a field named age in the MongoDB shell?
distinct('height', {age: {$lt: 12}})
What method would you use on a collection object to get a list of the distinct values of a field named height where field age is less than 12 from the MongoDB shell?
count()
What method would you use on a cursor in the MongoDB shell to find out how many documents are represented by the cursor?
remove({score: 50}, true)
What method would you use on the collection object in the MongoDB shell to remove the first document that had a score field value of 50?
getLastError()
What method would you use on the database object in the MongoDB shell to determine if an error occurred on a write operation?
skip(10) and limit(10)
What operation(s) would you use on a cursor obejct to return back a page of documents from 11 through 20 in the MongoDB shell?
cond
What parameter in a group operation allows you to limit which documents to include in the grouping?
key
What parameter in group operations allows you to define which fields to group by?
finalize
What parameter in the group operation allows you to apply an operation to each group after the groupings have been created?
query, update, upsert, multi
What parameters does the update operation support in the MongoDB shell?
read
What role would you assign a user if you only wanted them to be able to read from the database?
userAdmin
What role would you assign a user if you wanted them to be able to create user accounts in the database?
What role would you assign a user if you wanted them to be able to read and write to the database?
What role would you assign a user if you wanted them to be able to read and write to the database?
dbAdmin
What role would you assign a user if you wanted them to be able to run validations on the database?
sort({score: 1})
What sort operation in the MongoDB shell would you use to sort the documents in a cursor by the score field in ascending order?
sort({score: -1})
What sort operation in the MongoDB shell would you use to sort the documents in a cursor by the score field in descending order?
$push
What update operator would you use to add an element to an array field?
$inc
What update operator would you use to increase the value of a number field by 1?
$sort
What update operator would you use to sort the element in an array?
$set
What update operator would you use to update the value of a string to a new value?
$group
Which aggregation operator allows you to group documents together by field valuse in the aggregation pipeline?
$match
Which aggregation operator allows you to limit which documents to include in the aggregation pipeline?
$project
Which aggregation operator allows you to set additional fields to be added to the output of the aggregation pipeline?
out
Which field in the map reduce arguments paramter allows you to specify to output the data to the screen or a collection?
show collections
Which of the following commands will list the collections for the current database in the MongoDB shell?
show dbs
Which of the following commands will list the databases in the MongoDB shell?
insert() update() save()
Which operation(s) can be used to add new document to a collection in the MongoDB shell?
mongod --config
Which parameter would you use to load configuration settings from a file when starting the MongoDB server?