Getting Started
What is MongoDB?
Install / Config
C.R.U.D. Ops
Data Modeling
Database Mgmt
Create, Read, Update and Delete Operations
Adding Information: Database, Collection and Document
How do you create a new database?
.
Type
use
name
where
name
is the new database
Add a document to a collection
How do you create a new collection?
.
Select a database:
use name
Save a document:
db.name-of-collection.save({document})
A collection
name-of-collection
will be created
Alternatively use
insert()
instead of
save()
How do you insert a single document?
.
db.name-of-collection.save({document})
db.name-of-collection.insert({document})
How can you insert a group of documents in a batch?
.
db.name-of-collection.insert(array of [{document},{document}])
May want to specify the
write concern
Can you have different fields?
.
Yes
What problems can occur when adding information?
.
Beware of typos! You could accidentally create a new database or collection.
+
o
-