Title: Intergalactic Bounty Hunter Database
Type: Deliverable
Duration: 1-2 hours
Creator: Karolin Rafalski
Adapted From: WDI Remote - Mongo Lab
You've been going to meetup events and networking. You've been telling everyone you're so excited to get a dev job that you'll take any job.
You run into a shadowy stranger, who asks you three times 'Really? Any job?' and you continue to agree enthusiastically. Things go dark, and you wake up in a strange place.
The shadowy stranger greets you and says 'Welcome to your new job! You are now our dev who will be building an intergalactic bounty hunter database for us!'
You look around, notice some high end coffee and tea machines, an air hockey table, nap rooms and floor to ceiling windows with a view of outer space. The shadowy stranger takes you to your desk which has a fancy sit-to stand adjustable hight desk with a swing bar, two big monitors, and Herman Miller chair. You say to yourself 'Not bad! Not bad at all!'
- Fork and Clone this repository!
- Do the assignment!
- To turn this assignment in:
- Record your terminal command history inside the
answers.txt
file! - Push to your fork of the repository
- Make a Pull Request against the base repository
- Record your terminal command history inside the
Start Mongo
, by typing mongod
, if you don't already have it running.
Open a new tab and start a Mongo shell if you don't have it running by typing mongo
connect to a new sub-database by typing
use hunters
Note: If this database does not exist, it will be created. Yay Mongo!
Let's create a collection for all the beings that have bounties.
db.createCollection('bounties')
We should get an ok
message.
Let's add our first bounty
db.bounties.insert(
{
name: 'Han Solo',
wantedFor : 'Owing money',
client : 'Jabba the Hut',
reward : 1000000,
ship: 'Millennium Falcon',
hunters :['Bobba Fett', 'Dengar', 'IG-88', 'Zuckuss', 'Greedo', 'Bossk', '4-LOM'],
captured: false
}
)
You should get an ok message that looks similar to this:
Using the above template, make another bounty
Now insert a few more bounties
db.bounties.insert([
{
name: 'Han Solo',
wantedFor : 'Owing money',
client : 'Jabba the Hut',
reward : 1000000,
ship: 'Millennium Falcon',
hunters :['Bobba Fett', 'Dengar', 'IG-88', 'Zuckuss', 'Greedo', 'Bossk', '4-LOM'],
captured: false
},
{
name: 'Rocket',
wantedFor : 'Stealing Batteries',
client : 'Ayesha High Priestess of the Sovereign',
reward : 1000000000,
ship: 'The Milano',
hunters :['Nebula', 'Ravagers'],
captured: false
},
{
name: 'Sara Lance',
wantedFor : 'Screwing up the timeline, causing anachronisms',
client : 'Time Bureau',
reward : 50000,
ship: 'Waverider',
hunters :['Chronos'],
captured: false
},
{
name: 'Malcolm Reynolds',
wantedFor : 'Aiming to misbehave',
client : 'The Alliance',
reward : 40000,
ship: 'Serenity',
hunters :['Jubal Early'],
captured: false
},
{
name: 'Starbuck',
wantedFor : "Disobeying Captain's orders",
client : 'Captain Adama',
ship: 'Demetrius',
reward : 1000,
hunters :['Apollo'],
captured: true
}
])
- Do a query to see all the bounties
- Do a query to find the bounty whose client is
Time Bureau
- Do a query to find the bounties who have been
captured
- Do a query specific to the bounty you inserted
- Do a query to just return the names of all the bounties
- Starbuck and the Captain have come to an understanding. Remove her record
- find and remove the duplicate record - be sure to JUST remove the one copy
Update Sara Lance
's name to be her superhero alias 'White Canary'
Update Rocket's ship to be The Milano 2
Check out the Intermediate Mongo lecture notes in the instructor notes directory. Follow through each of the explanations. Follow the commands and perform appropriate finds after each update call to see the results
-
Find the bounties that are greater than
100000
-
Find the bounties that are less than
1000
-
Find the bounties that are less than or equal to
1000
-
Find the bounty with the hunter
Nebula
-
Find the bounty with the ship
Waverider
ORSerenity
-
Find the bounty who is not captured AND has whose client is
Ayesha High Priestess of the Sovereign
-
Increase all the bounties by 333333
-
Multiply all the bounties by 2
-
Add
Bobba Fett
as a hunter forMalcolm Reynolds
-
Add
Bobba Fett
as a hunter for the one that has the shipWaverider
-
Find and remove
Dengar
the bounty hunter -
Upserts will insert a value if it doesn't exist, if it does it will update it
-
Try giving a new field of
lastSeen
to Han Solo, with the propertyyesterday
set upsert to true -
Try giving all bounties a new field of
lastSeen
- with a value oflast week
and set upsert tofalse
Put your terminal output (let's say the last 50 lines or so, not everything you ever did!) into the file in this directory called answers.txt
. Commit and push your changes, then make a pull request against the base fork.
Get your Mongo shell history with the following command: cat ~/.dbshell
Did you have any questions or comments about this deliverable? Please add it to the text of your pull request!
Ahh... time to relax!