SlideShare a Scribd company logo
open-­‐source,	
 Ā high-­‐performance,	
 Ā 
 document-­‐oriented	
 Ā database
Non-relational
                         Operational Stores
                                    (ā€œNoSQLā€)




New Gen. OLAP                                     RDBMS
(vertica,	
 Ā aster,	
 Ā greenplum)               (Oracle,	
 Ā MySQL)
NoSQL Really Means:
 non-­‐relational,	
 Ā next-­‐generation	
 Ā 
 operational	
 Ā datastores	
 Ā and	
 Ā databases
no	
 Ā joins
+   no	
 Ā complex	
 Ā transactions

Horizontally Scalable
        Architectures
no	
 Ā joins
+   no	
 Ā complex	
 Ā transactions

    New Data Models
New Data Models
improved	
 Ā ways	
 Ā to	
 Ā develop	
 Ā applications?
Data Models
           Key	
 Ā /	
 Ā Value
      memcached,	
 Ā Dynamo

             Tabular
              BigTable

     Document	
 Ā Oriented
MongoDB,	
 Ā CouchDB,	
 Ā JSON	
 Ā stores
• memcached
scalability	
 Ā &	
 Ā performance



                                      • key/value



                                                                            •   RDBMS




                                             depth	
 Ā of	
 Ā functionality
JSON-style Documents
           represented	
 Ā as	
 Ā BSON

      {ā€œhelloā€:	
 Ā ā€œworldā€}

  x16x00x00x00x02hello
  x00x06x00x00x00world
  x00x00


                            http://bsonspec.org
Flexible ā€œSchemasā€

                        {ā€œauthorā€:	
 Ā ā€œeliotā€,
{ā€œauthorā€:	
 Ā ā€œmikeā€,
                        	
 Ā ā€œtextā€:	
 Ā ā€œ...ā€,
	
 Ā ā€œtextā€:	
 Ā ā€œ...ā€}
                        	
 Ā ā€œtagsā€:	
 Ā [ā€œmongodbā€]}
Dynamic Queries
Atomic Update
  Modifiers
Focus on Performance
Replication
                            master   slave

        master
                            master   slave


slave       slave   slave   master   master

                             slave   master
Auto-sharding
                   Shards
          mongod   mongod    mongod
                                            ...
Config     mongod   mongod    mongod
Servers

mongod

mongod

mongod
                   mongos    mongos   ...


                    client
Many Supported
Platforms / Languages
Best Use Cases
                                        T

Scaling	
 Ā Out
                              Caching
                 The	
 Ā Web

            High	
 Ā Volume
Less Good At
     highly	
 Ā transactional


ad-­‐hoc	
 Ā business	
 Ā intelligence


problems	
 Ā that	
 Ā require	
 Ā SQL
A Quick Aside
_id                  special	
 Ā key
  present	
 Ā in	
 Ā all	
 Ā documents
 unique	
 Ā across	
 Ā a	
 Ā Collection
           any	
 Ā type	
 Ā you	
 Ā want
Post

{author:	
 Ā ā€œmikeā€,
	
 Ā date:	
 Ā new	
 Ā Date(),
	
 Ā text:	
 Ā ā€œmy	
 Ā blog	
 Ā post...ā€,
	
 Ā tags:	
 Ā [ā€œmongodbā€,	
 Ā ā€œintroā€]}
Comment

{author:	
 Ā ā€œeliotā€,
	
 Ā date:	
 Ā new	
 Ā Date(),
	
 Ā text:	
 Ā ā€œgreat	
 Ā post!ā€}
New Post
post	
 Ā =	
 Ā {author:	
 Ā ā€œmikeā€,
	
 Ā 	
 Ā date:	
 Ā new	
 Ā Date(),
	
 Ā 	
 Ā text:	
 Ā ā€œmy	
 Ā blog	
 Ā post...ā€,
	
 Ā 	
 Ā tags:	
 Ā [ā€œmongodbā€,	
 Ā ā€œintroā€]}

db.posts.save(post)
Embedding a Comment

c	
 Ā =	
 Ā {author:	
 Ā ā€œeliotā€,
	
 Ā 	
 Ā date:	
 Ā new	
 Ā Date(),
	
 Ā 	
 Ā text:	
 Ā ā€œgreat	
 Ā post!ā€}

db.posts.update({_id:	
 Ā post._id},	
 Ā 
	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā {$push:	
 Ā {comments:	
 Ā c}})
Posts by Author


db.posts.find({author:	
 Ā ā€œmikeā€})
Last 10 Posts

db.posts.find()
	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā .sort({date:	
 Ā -­‐1})
	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā .limit(10)
Posts Since April 1

april_1	
 Ā =	
 Ā new	
 Ā Date(2010,	
 Ā 3,	
 Ā 1)

db.posts.find({date:	
 Ā {$gt:	
 Ā april_1}})
Posts Ending With ā€˜Tech’


db.posts.find({text:	
 Ā /Tech$/})
Posts With a Tag
db.posts.find({tags:	
 Ā ā€œmongodbā€})


          ...and Fast
                 (multi-­‐key	
 Ā indexes)

db.posts.ensureIndex({tags:	
 Ā 1})
Indexing / Querying
    on Embedded Docs
                            (dot	
 Ā notation)

db.posts.ensureIndex({ā€œcomments.authorā€:	
 Ā 1})

db.posts.find({ā€œcomments.authorā€:	
 Ā ā€œeliotā€})
Counting Posts


db.posts.count()

db.posts.find({author:	
 Ā ā€œmikeā€}).count()
Basic Paging

page	
 Ā =	
 Ā 2
page_size	
 Ā =	
 Ā 15

db.posts.find().limit(page_size)
	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā .skip(page	
 Ā *	
 Ā page_size)
Migration: Adding Titles
                                        (just	
 Ā start	
 Ā adding	
 Ā them)

post	
 Ā =	
 Ā {author:	
 Ā ā€œmikeā€,
	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā date:	
 Ā new	
 Ā Date(),
	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā text:	
 Ā ā€œanother	
 Ā blog	
 Ā post...ā€,
	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā tags:	
 Ā [ā€œmongodbā€],
     	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā title:	
 Ā ā€œMongoDB	
 Ā for	
 Ā Fun	
 Ā and	
 Ā Profitā€}

post_id	
 Ā =	
 Ā db.posts.save(post)
Advanced Queries

             $gt,	
 Ā $lt,	
 Ā $gte,	
 Ā $lte,	
 Ā $ne,	
 Ā $all,	
 Ā $in,	
 Ā $nin


db.posts.find({$where:	
 Ā ā€œthis.author	
 Ā ==	
 Ā ā€˜mike’	
 Ā ||
	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā 	
 Ā this.title	
 Ā ==	
 Ā ā€˜fooā€™ā€})
Other Cool Stuff
aggregation	
 Ā and	
 Ā map/reduce
capped	
 Ā collections
unique	
 Ā indexes
mongo	
 Ā shell
GridFS
geo
slides	
 Ā will	
 Ā be	
 Ā up	
 Ā on	
 Ā http://dirolf.com




Download MongoDB
         http://www.mongodb.org




   and	
 Ā let	
 Ā us	
 Ā know	
 Ā what	
 Ā you	
 Ā think
       @mdirolf	
 Ā 	
 Ā 	
 Ā 	
 Ā @mongodb

More Related Content

What's hot (20)

PDF
Cassandra Introduction & Features
DataStax Academy
Ā 
PDF
Intro to HBase
alexbaranau
Ā 
PDF
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
mumrah
Ā 
KEY
Introduction to memcached
Jurriaan Persyn
Ā 
PDF
Introduction to Redis
Dvir Volk
Ā 
PPTX
Introduction to Storm
Chandler Huang
Ā 
PDF
MongoDB Fundamentals
MongoDB
Ā 
PPTX
Introduction to Apache ZooKeeper
Saurav Haloi
Ā 
PPTX
Apache Spark Architecture
Alexey Grishchenko
Ā 
PPTX
HBase and HDFS: Understanding FileSystem Usage in HBase
enissoz
Ā 
PDF
Etsy Activity Feeds Architecture
Dan McKinley
Ā 
PPT
Introduction to mongodb
neela madheswari
Ā 
PPTX
Introduction to Redis
Arnab Mitra
Ā 
PDF
Scalability, Availability & Stability Patterns
Jonas BonƩr
Ā 
PDF
Monitoring Kubernetes with Prometheus
Grafana Labs
Ā 
PDF
MongoDB Sharding Fundamentals
Antonios Giannopoulos
Ā 
PPTX
Introduction to Redis
Maarten Smeets
Ā 
PDF
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
ScaleGrid.io
Ā 
PPTX
MongoDB.pptx
Sigit52
Ā 
PPTX
Elastic Stack Introduction
Vikram Shinde
Ā 
Cassandra Introduction & Features
DataStax Academy
Ā 
Intro to HBase
alexbaranau
Ā 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
mumrah
Ā 
Introduction to memcached
Jurriaan Persyn
Ā 
Introduction to Redis
Dvir Volk
Ā 
Introduction to Storm
Chandler Huang
Ā 
MongoDB Fundamentals
MongoDB
Ā 
Introduction to Apache ZooKeeper
Saurav Haloi
Ā 
Apache Spark Architecture
Alexey Grishchenko
Ā 
HBase and HDFS: Understanding FileSystem Usage in HBase
enissoz
Ā 
Etsy Activity Feeds Architecture
Dan McKinley
Ā 
Introduction to mongodb
neela madheswari
Ā 
Introduction to Redis
Arnab Mitra
Ā 
Scalability, Availability & Stability Patterns
Jonas BonƩr
Ā 
Monitoring Kubernetes with Prometheus
Grafana Labs
Ā 
MongoDB Sharding Fundamentals
Antonios Giannopoulos
Ā 
Introduction to Redis
Maarten Smeets
Ā 
What’s the Best PostgreSQL High Availability Framework? PAF vs. repmgr vs. Pa...
ScaleGrid.io
Ā 
MongoDB.pptx
Sigit52
Ā 
Elastic Stack Introduction
Vikram Shinde
Ā 

Similar to Introduction to MongoDB (20)

PDF
MongoDB at FrozenRails
Mike Dirolf
Ā 
KEY
MongoDB at CodeMash 2.0.1.0
Mike Dirolf
Ā 
KEY
Mongodb intro
christkv
Ā 
PDF
MongoDB.pdf
KuldeepKumar778733
Ā 
KEY
MongoDB
Steven Francia
Ā 
KEY
MongoDB Strange Loop 2009
Mike Dirolf
Ā 
PDF
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
Ā 
PDF
10gen MongoDB Video Presentation at WebGeek DevCup
WebGeek Philippines
Ā 
PPT
9. Document Oriented Databases
Fabio Fumarola
Ā 
KEY
MongoDB at RuPy
Mike Dirolf
Ā 
PDF
MongoDB: a gentle, friendly overview
Antonio Pintus
Ā 
KEY
MongoDB at ZPUGDC
Mike Dirolf
Ā 
PPTX
Intro to mongodb mongouk jun2010
Skills Matter
Ā 
KEY
2012 phoenix mug
Paul Pedersen
Ā 
PDF
Mongo db transcript
foliba
Ā 
PPT
MongoDB Pros and Cons
johnrjenson
Ā 
PDF
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
boychatmate1
Ā 
PDF
MongoDB Basics
Sarang Shravagi
Ā 
PDF
MongoDB NoSQL database a deep dive -MyWhitePaper
Rajesh Kumar
Ā 
PDF
Building your first app with MongoDB
Norberto Leite
Ā 
MongoDB at FrozenRails
Mike Dirolf
Ā 
MongoDB at CodeMash 2.0.1.0
Mike Dirolf
Ā 
Mongodb intro
christkv
Ā 
MongoDB.pdf
KuldeepKumar778733
Ā 
MongoDB
Steven Francia
Ā 
MongoDB Strange Loop 2009
Mike Dirolf
Ā 
OSDC 2012 | Building a first application on MongoDB by Ross Lawley
NETWAYS
Ā 
10gen MongoDB Video Presentation at WebGeek DevCup
WebGeek Philippines
Ā 
9. Document Oriented Databases
Fabio Fumarola
Ā 
MongoDB at RuPy
Mike Dirolf
Ā 
MongoDB: a gentle, friendly overview
Antonio Pintus
Ā 
MongoDB at ZPUGDC
Mike Dirolf
Ā 
Intro to mongodb mongouk jun2010
Skills Matter
Ā 
2012 phoenix mug
Paul Pedersen
Ā 
Mongo db transcript
foliba
Ā 
MongoDB Pros and Cons
johnrjenson
Ā 
Introduction to Mongo DB-open-­‐source, high-­‐performance, document-­‐orient...
boychatmate1
Ā 
MongoDB Basics
Sarang Shravagi
Ā 
MongoDB NoSQL database a deep dive -MyWhitePaper
Rajesh Kumar
Ā 
Building your first app with MongoDB
Norberto Leite
Ā 
Ad

More from Mike Dirolf (15)

PDF
Indexing
Mike Dirolf
Ā 
PDF
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
Ā 
KEY
Inside PyMongo - MongoNYC
Mike Dirolf
Ā 
PDF
FrozenRails Training
Mike Dirolf
Ā 
KEY
Python Development (MongoSF)
Mike Dirolf
Ā 
KEY
MongoDB: How it Works
Mike Dirolf
Ā 
KEY
MongoDB hearts Django? (Django NYC)
Mike Dirolf
Ā 
PDF
MongoDB at RubyConf
Mike Dirolf
Ā 
KEY
MongoDB at RubyEnRails 2009
Mike Dirolf
Ā 
KEY
MongoDB Hadoop DC
Mike Dirolf
Ā 
KEY
MongoDB London PHP
Mike Dirolf
Ā 
KEY
MongoDB EuroPython 2009
Mike Dirolf
Ā 
KEY
MongoDB NYC Python
Mike Dirolf
Ā 
KEY
MongoDB SF Python
Mike Dirolf
Ā 
KEY
MongoDB SF Ruby
Mike Dirolf
Ā 
Indexing
Mike Dirolf
Ā 
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
Ā 
Inside PyMongo - MongoNYC
Mike Dirolf
Ā 
FrozenRails Training
Mike Dirolf
Ā 
Python Development (MongoSF)
Mike Dirolf
Ā 
MongoDB: How it Works
Mike Dirolf
Ā 
MongoDB hearts Django? (Django NYC)
Mike Dirolf
Ā 
MongoDB at RubyConf
Mike Dirolf
Ā 
MongoDB at RubyEnRails 2009
Mike Dirolf
Ā 
MongoDB Hadoop DC
Mike Dirolf
Ā 
MongoDB London PHP
Mike Dirolf
Ā 
MongoDB EuroPython 2009
Mike Dirolf
Ā 
MongoDB NYC Python
Mike Dirolf
Ā 
MongoDB SF Python
Mike Dirolf
Ā 
MongoDB SF Ruby
Mike Dirolf
Ā 
Ad

Recently uploaded (20)

PDF
šŸš€ Let’s Build Our First Slack Workflow! šŸ”§.pdf
SanjeetMishra29
Ā 
PDF
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
Ā 
PDF
ā€œComputer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,ā€ a ...
Edge AI and Vision Alliance
Ā 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
Ā 
PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
Ā 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
Ā 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
Ā 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
Ā 
PDF
ā€œONNX and Python to C++: State-of-the-art Graph Compilation,ā€ a Presentation ...
Edge AI and Vision Alliance
Ā 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
Ā 
PDF
NASA A Researcher’s Guide to International Space Station : Earth Observations
Dr. PANKAJ DHUSSA
Ā 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
Ā 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
Ā 
PDF
Home Cleaning App Development Services.pdf
V3cube
Ā 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
Ā 
PDF
Kit-Works Team Study_20250627_ķ•œė‹¬ė§Œģ—ė§Œė“ ģ‚¬ė‚“ģ„œė¹„ģŠ¤ķ‚¤ė§(ģ–‘ė‹¤ģœ—).pdf
Wonjun Hwang
Ā 
PPTX
Essential Content-centric Plugins for your Website
Laura Byrne
Ā 
PDF
Evolution: How True AI is Redefining Safety in Industry 4.0
vikaassingh4433
Ā 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
Ā 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
Ā 
šŸš€ Let’s Build Our First Slack Workflow! šŸ”§.pdf
SanjeetMishra29
Ā 
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
Ā 
ā€œComputer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,ā€ a ...
Edge AI and Vision Alliance
Ā 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
Ā 
CapCut Pro PC Crack Latest Version Free Free
josanj305
Ā 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
Ā 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
Ā 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
Ā 
ā€œONNX and Python to C++: State-of-the-art Graph Compilation,ā€ a Presentation ...
Edge AI and Vision Alliance
Ā 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
Ā 
NASA A Researcher’s Guide to International Space Station : Earth Observations
Dr. PANKAJ DHUSSA
Ā 
Wondershare Filmora Crack Free Download 2025
josanj305
Ā 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
Ā 
Home Cleaning App Development Services.pdf
V3cube
Ā 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
Ā 
Kit-Works Team Study_20250627_ķ•œė‹¬ė§Œģ—ė§Œė“ ģ‚¬ė‚“ģ„œė¹„ģŠ¤ķ‚¤ė§(ģ–‘ė‹¤ģœ—).pdf
Wonjun Hwang
Ā 
Essential Content-centric Plugins for your Website
Laura Byrne
Ā 
Evolution: How True AI is Redefining Safety in Industry 4.0
vikaassingh4433
Ā 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
Ā 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
Ā 

Introduction to MongoDB

  • 1. open-­‐source, Ā high-­‐performance, Ā  document-­‐oriented Ā database
  • 2. Non-relational Operational Stores (ā€œNoSQLā€) New Gen. OLAP RDBMS (vertica, Ā aster, Ā greenplum) (Oracle, Ā MySQL)
  • 3. NoSQL Really Means: non-­‐relational, Ā next-­‐generation Ā  operational Ā datastores Ā and Ā databases
  • 4. no Ā joins + no Ā complex Ā transactions Horizontally Scalable Architectures
  • 5. no Ā joins + no Ā complex Ā transactions New Data Models
  • 6. New Data Models improved Ā ways Ā to Ā develop Ā applications?
  • 7. Data Models Key Ā / Ā Value memcached, Ā Dynamo Tabular BigTable Document Ā Oriented MongoDB, Ā CouchDB, Ā JSON Ā stores
  • 8. • memcached scalability Ā & Ā performance • key/value • RDBMS depth Ā of Ā functionality
  • 9. JSON-style Documents represented Ā as Ā BSON {ā€œhelloā€: Ā ā€œworldā€} x16x00x00x00x02hello x00x06x00x00x00world x00x00 http://bsonspec.org
  • 10. Flexible ā€œSchemasā€ {ā€œauthorā€: Ā ā€œeliotā€, {ā€œauthorā€: Ā ā€œmikeā€, Ā ā€œtextā€: Ā ā€œ...ā€, Ā ā€œtextā€: Ā ā€œ...ā€} Ā ā€œtagsā€: Ā [ā€œmongodbā€]}
  • 12. Atomic Update Modifiers
  • 14. Replication master slave master master slave slave slave slave master master slave master
  • 15. Auto-sharding Shards mongod mongod mongod ... Config mongod mongod mongod Servers mongod mongod mongod mongos mongos ... client
  • 17. Best Use Cases T Scaling Ā Out Caching The Ā Web High Ā Volume
  • 18. Less Good At highly Ā transactional ad-­‐hoc Ā business Ā intelligence problems Ā that Ā require Ā SQL
  • 19. A Quick Aside _id special Ā key present Ā in Ā all Ā documents unique Ā across Ā a Ā Collection any Ā type Ā you Ā want
  • 20. Post {author: Ā ā€œmikeā€, Ā date: Ā new Ā Date(), Ā text: Ā ā€œmy Ā blog Ā post...ā€, Ā tags: Ā [ā€œmongodbā€, Ā ā€œintroā€]}
  • 21. Comment {author: Ā ā€œeliotā€, Ā date: Ā new Ā Date(), Ā text: Ā ā€œgreat Ā post!ā€}
  • 22. New Post post Ā = Ā {author: Ā ā€œmikeā€, Ā  Ā date: Ā new Ā Date(), Ā  Ā text: Ā ā€œmy Ā blog Ā post...ā€, Ā  Ā tags: Ā [ā€œmongodbā€, Ā ā€œintroā€]} db.posts.save(post)
  • 23. Embedding a Comment c Ā = Ā {author: Ā ā€œeliotā€, Ā  Ā date: Ā new Ā Date(), Ā  Ā text: Ā ā€œgreat Ā post!ā€} db.posts.update({_id: Ā post._id}, Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā {$push: Ā {comments: Ā c}})
  • 24. Posts by Author db.posts.find({author: Ā ā€œmikeā€})
  • 25. Last 10 Posts db.posts.find() Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā .sort({date: Ā -­‐1}) Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā .limit(10)
  • 26. Posts Since April 1 april_1 Ā = Ā new Ā Date(2010, Ā 3, Ā 1) db.posts.find({date: Ā {$gt: Ā april_1}})
  • 27. Posts Ending With ā€˜Tech’ db.posts.find({text: Ā /Tech$/})
  • 28. Posts With a Tag db.posts.find({tags: Ā ā€œmongodbā€}) ...and Fast (multi-­‐key Ā indexes) db.posts.ensureIndex({tags: Ā 1})
  • 29. Indexing / Querying on Embedded Docs (dot Ā notation) db.posts.ensureIndex({ā€œcomments.authorā€: Ā 1}) db.posts.find({ā€œcomments.authorā€: Ā ā€œeliotā€})
  • 31. Basic Paging page Ā = Ā 2 page_size Ā = Ā 15 db.posts.find().limit(page_size) Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā .skip(page Ā * Ā page_size)
  • 32. Migration: Adding Titles (just Ā start Ā adding Ā them) post Ā = Ā {author: Ā ā€œmikeā€, Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā date: Ā new Ā Date(), Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā text: Ā ā€œanother Ā blog Ā post...ā€, Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā tags: Ā [ā€œmongodbā€], Ā  Ā  Ā  Ā  Ā  Ā  Ā title: Ā ā€œMongoDB Ā for Ā Fun Ā and Ā Profitā€} post_id Ā = Ā db.posts.save(post)
  • 33. Advanced Queries $gt, Ā $lt, Ā $gte, Ā $lte, Ā $ne, Ā $all, Ā $in, Ā $nin db.posts.find({$where: Ā ā€œthis.author Ā == Ā ā€˜mike’ Ā || Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā  Ā this.title Ā == Ā ā€˜fooā€™ā€})
  • 34. Other Cool Stuff aggregation Ā and Ā map/reduce capped Ā collections unique Ā indexes mongo Ā shell GridFS geo
  • 35. slides Ā will Ā be Ā up Ā on Ā http://dirolf.com Download MongoDB http://www.mongodb.org and Ā let Ā us Ā know Ā what Ā you Ā think @mdirolf Ā  Ā  Ā  Ā @mongodb