MongoDB Project Tasks

Project tasks

Build a MongoDB database of people and phone numbers. Display the result of each task.

  1. create a database containing the test data
  2. add several other people to the database. (John Doe, Betty Boop, and Jonathan L. Seagull)
  3. add an age field to
    • John Doe age 45
    • Arleen Pete age 21
    • John Seagull age 40
  4. count the entries; display the count
  5. delete Betty Boop
  6. search the database/collection for
    1. every entry
    2. every entry with the last name Pete
    3. every entry over the age of 40
    4. every entry under the age 42
    5. every entry with the phone prefix 626
    6. every entry without a phone number
    7. every entry entry with no last name
    8. every entry who's last name field has the letter 't' in it
  7. add 5 to Jonathan L. Seagull's age
  8. delete every entry with the last name of Pete
  9. delete the collections "xyz" and "phones"
  10. delete the database

If using Linux and mongo shell, create Bash scripts to do the tasks?

Hints

When using the mongo shell, write/edit commands in a text editor. Then copy and paste them into the command shell. This will make changes and corrections easier to do.

Test data

First NameLast NameNicknamePhone Number
TommyRot666-555-8888
JudyZedZ626-555-9999
PiccoloPete626-555-1234
ArleenPeteButtercup