The database for you and me

Monday, Apr 13, 2020


Getting Started

Installing MongoDB

Configuring MongoDB

MongoDB config files are written in YAML, an example mongodb.conf file is provided below

Connecting to a MongoDB Atlas Server

# Using a single URI
mongo mongodb+srv://

# Using a URI and two flags
# Short Form
mongo 'mongodb+srv://' -u 'tommy' -p 'fighton'
# Long Form
mongo 'mongodb+srv://' --username 'tommy' --password 'fighton'

The MongoDB Shell


Tip: If the database doesn’t yet exist, switching to it will implicitly create it.

Warning: If you switch to a new database and don’t add anything, the command above won’t show you the current database you are using since there isn’t anything inside of it.

Basic Operations in the Shell

There are 4 basic operations

  1. Create
  2. Read
  3. Update
  4. Delete


Use the insert function to add a document to a collection.

Documents can be represented in JavaScript Object Notation JSON and then inserted, which helps add simplicity.