MongoDB CRUD Operations


Previous Article: Data Storage Internals

Create Documents

Assuming you are in the test database in Mongo and you want to find out the tables (There are no tables in Mongo) and collections (only collections) in the database.

>DB
Test
>Show collections
>db.Foo.Save({_id:1, x:10})
>db.Foo.find()
{"_id":1, "x":10}
>Show collections()
foo
system.indexes
>db.Bar.Save({_id:1, x:10})
>show collections()
Foo
Bar
System.indexes

Since it is a test DB there are no collections.

Remember that collections in Mongo defines the scope of interaction with documents

Continue reading

Advertisements