mongoDB
Overview
- noSQL database
- unstructured data
- document oriented
- instead of tables, mdb uses collecctions
- instead of rows, mdb uses documents

relational vs. documented oriented
rel db mgmt systems save data in rows w/in tables
mdb saves data as documents within collections

commands
> use [db name]
=> will find or create db by typed name
> db
- list current db
> help
> show dbs

# create, find, remove, update
insert
> db.[collection_name].insert({document object})
=> WriteResult({ 'nInserted': 1})

find
2. rectrieve document
db.[collection].find()

a query of equality (are case sensitive)
> db.[collection].find({'key'})
=> responds with all document info and all documents that match

remove
> db.[collection].remove({})
this will remove any documents that match

update
!!! update operators always start with "$" otherwise it will override whole document.

a single document
> db.[collection].update(
  { "query_param": "query_value" },
  { "$set", {"key_to_update": "value of update"}
)

multiple documents, with 'multi'
> db.[collection].update(
  { "query_param": "query_value" },
  { "$set", {"key_to_update": "value of update"}},
  { 'multi': true}
)

use $inc to increment
{"$inc": { 'count' : 1}}

find or create with 'upsert'
db.shirts.upudate(
 {'size': 'red'},
 {'upsert: true}
)

use $unset to remove a field from a document
> db.shirts.update(
  {},
{"$unset", {"color": ""}},
{'multi': true}
)

Types of data that cna be stored...
documents are BSON, a json-like format.
- strings
- numbers
- bool
- arrays
- objects
- null
+ object (ObjectID)
+ Date (ISODate)
!!! a new date uses 0-index, so months are off.
new Date(2012, 8, 13) is really september 13, 2012

VALIDATIONS
- unique _id
- no syntax errors
- document size less than 16mb