- Launch a MongoDB Instance
- Create a user that can administer users in any database in our MongoDB instance. You may use the following credentials: username: securityofficer password: doughnuts
- Restart the MongoDB server such that only authenticated users may connect.
- Connect to the MongoDB server from the mongo shell authenticating as user securityofficer
- Do a find() on the system.users collection.
import structure5.*; | |
public class SelectionSort | |
{ | |
public static void main(String args[]) | |
{ | |
ReadStream r = new ReadStream(); | |
int n = r.readInt(); | |
int data[] = new int[n]; | |
int i; |
- Configure and launch a three member MongoDB replica set on your local computer.
- Connect to the primary from the mongo shell and create a database called
catalog
, then insert one document as follows.
use catalog db.products.insertOne({name: "Coffee Mug", price: 4})
Assume you have a MongoDB instance running on the default port. Using bash, powershell, or a similar application, write a statement that will drop a MongoDB database called products_test
from the command line.
Suppose you have a users
collection in a database named people
. Documents in the users
collection resemble the following:
{
_id: 1,
name: "Gram Parsons",
DOB: "1946-11-05"
}
Suppose you have a collection called people
containing documents that resemble the following:
{
name : "Kay",
favoriteFoods : ["mango", "salmon", "quinoa"]
}
In the mongo shell, how would you query for all people listing "mango" as a favorite food?
Suppose you have a collection called stories
containing documents that resemble the following:
{
_id : ObjectId("579b8063a2f12bdaf5684505"),
author : "John Henry",
name : "Building a Railroad"
}
Suppose you have a collection called figures containing the following documents.
{
"_id" : 1
"shapes" : [
{ "shape": "square", "color": "blue" },
{ "shape": "circle", "color": "red" }
]
Suppose you have data about books split into two collections. The first collection, called books, contains the following documents.
{
"isbn": "978-3-16-148410-0",
"title": "Some cool book",
"author": "John Doe"
}
{
Suppose the document below is stored in a collection stories
within the database folklore
. How would you add a field called year
with the value 1913
to this document?
{
_id : 13,
author : "John Henry",
name : "Building a Railroad"
}