WHAT IS:
Type of NoSQL
Document database - can store pretty much anything
MongoDB stores data in the form of JSON like objects
The most simplest models are key/value pairs
Benefit - if data structure changes a lot - don't have to change the schema
A "document" is like a record - e.g. in the commands below, we insert 2 documents
COMMANDS (in order):
mongo
show dbs
use shop
db
db.inventory.insertOne({ item: "journal", qty: 25, status: "A", size: { h:14, w: 21, uom: 'cm' }, tags: ['blank', 'red'] })
db.inventory.find()
db.inventory.insertMany([ { item: "notebook", qty: 50, status: "A", size: {h: 8.5, w: 11, uom: "in" }, tags: [ 'red', 'blank' ] } ])
db.inventory.find({ status: "A" })[0].tags
db.inventory.find({ "size.h": 14 })
EXTRA COMMAND:
To update a record, e.g.:
db.students.updateOne({ _id: ObjectId("5b1f53578081f2bddc14b7d0")}, { $set: { name: "Yeezy", songs: [{ song: "blah1" }, { song: "blah2" }] } })