SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
nonSQL databases
     alexey gaziev
RDBMS


• Great for many apps
• Shortcomings
  • Scalability
  • Flexibility
Other DBMS

• Flat file
• Hierarchical
• Network
• Document-oriented
• Object-oriented
CAP Theorem

                                          Pick two

С             A                        • Consistency
                                       • Availability
    P                                  • Tolerance to network
                                          Partitions


    http://www.cs.berkeley.edu/~brewer/cs262b-2004/PODC-keynote.pdf
ACID & BASE

• Atomicity     • Basically Available
• Consistency   • Soft state
• Isolation     • Eventually consistent
• Durability
ACID vs. BASE
    ACID                      BASE
•   Strong consistency    •   Weak consistency

•   Isolation             •   Availability first

•   Focus on “commit”     •   Best effort

•   Nested transactions   •   Approximate answers

•   Availability?         •   Agressive (optimistic)

•   Conservative          •   Simpler!

•   Difficult evolution     •   Faster
    (schema)
                          •   Easier evolution
Scalability &                Intro
Performance
                memcached

                   Key/Values store




                                                RDBMS




                                      Depth of Functionality
Features
• Collection oriented storage: easy storage of object/
  JSON -style data
• Dynamic queries
• Full index support, including on inner objects and
  embedded arrays
• Query profiling
• Replication and fail-over support
• Efficient storage of binary data including large objects
  (e.g. photos and videos)
• Auto-sharding for cloud-level scalability (currently in
  alpha)
• Commercial support available
Great for

• Websites
• Caching
• High volume, low value
• High scalability
• Storage of program objects and json
Not as great for


• Highly transactional
• Ad-hoc business intelligence
• Problems requiring SQL
Installation
Collection

• Think table, but with no schema
• For grouping into smaller query sets (speed)
• Each top entity in your app would have its own
 collection (users, articles, etc.)

• Full index support
Document


• Stored in collection, think record or row
• Can have _id key that works like primary key in
 MySQL

• Two options for relationships: subdocument or
 db reference
Storage (BSON)

{ author: 'joe',
  created: Date('03-28-2009'),
  title: 'Yet another blog post',
  text: 'Here is the text...',
  tags: [ 'example', 'joe' ],
  comments: [ { author: 'jim', comment: 'I disagree' },
           { author: 'nancy', comment: 'Good post' }
  ]
}
Basics
$ bin/mongod &
$ bin/mongo
...
> use mydb
> j = { name: "mongo"};
{"name" : "mongo"}
> t = { x : 3 };
{ "x" : 3 }
> db.things.save(j);
> db.things.save(t);
> db.things.find();
in cursor for : DBQuery: example.things ->
{"name" : "mongo" , "_id" : "497cf60751712cf7758+dbb"}
{"x" : 3 , "_id" : "497cf61651712cf7758+dbc"}
>
Querying

•   db.collection.find({‘first_name’: ‘John’}) # finds all Johns

•   db.collection.find({‘first_name’: /^J/}) # regex

•   db.collection.find_first({‘_id’:1}) # finds first with _id of 1

•   db.collection.find({‘age’: {‘$gt’: 21}}) # finds possible drinkers

•   db.collection.find({‘author.first_name’:‘John’}) # subdocument

•   db.collection.find({$where:‘this.age >= 6 && this.age <= 18’})
Querying 2

•   $in, $nin, $all, $ne, $gt, $gte, $lt, $lte, $size, $where

•   :fields (like :select in active record)

•   :limit, :offset for pagination

•   :sort ascending or descending [[‘foo’, 1], [‘bar’, -1]]

•   count and group (uses map/reduce)
Dynamic querying
Ruby support

• mongo-ruby-driver
  • Pure Ruby, with optional C extension
• MongoRecord
  • ORM like functionality
• Other mappers
Ruby basics
• Connect:
  • db = Mongo.new.db(‘my-database’)
  • coll = db.collection(‘players’)
• Insert:
  • coll.insert (“name” => “mike”, “age” => ...
• Query:
  • coll.find (“age” => 35)
Grid FS


• File storage in MongoDB

• IO-like API for Ruby
Other cool stuff



• Capped collections
• Upserts
• Multikeys
Resources
• http://spitfiresky.com/blog/recap-of-my-sdruby-
 presentation-on-mongodb.html

• http://railstips.org/2009/6/3/what-if-a-key-
 value-store-mated-with-a-relational-database-
 system

• http://www.mongodb.org/display/DOCS/
 Production+Deployments

• http://www.mongohq.com/home
Resources 2


• http://api.mongodb.org/ruby/0.15.1/index.html
• http://www.engineyard.com/blog/2009/
 mongodb-a-light-in-the-darkness-key-value-
 stores-part-5

• http://queue.acm.org/detail.cfm?id=1394128
thanks!

Weitere ähnliche Inhalte

Was ist angesagt?

MongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB Memory Management Demystified
MongoDB Memory Management Demystified
MongoDB
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
Krivoy Rog IT Community
 
Discover MongoDB - Israel
Discover MongoDB - IsraelDiscover MongoDB - Israel
Discover MongoDB - Israel
Michael Fiedler
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
Thomas Weinert
 
Website performance optimization QA
Website performance optimization QAWebsite performance optimization QA
Website performance optimization QA
Denis Dudaev
 
2012 mongo db_bangalore_roadmap_new
2012 mongo db_bangalore_roadmap_new2012 mongo db_bangalore_roadmap_new
2012 mongo db_bangalore_roadmap_new
MongoDB
 
MongoDB Basic Concepts
MongoDB Basic ConceptsMongoDB Basic Concepts
MongoDB Basic Concepts
MongoDB
 

Was ist angesagt? (20)

Optimize drupal using mongo db
Optimize drupal using mongo dbOptimize drupal using mongo db
Optimize drupal using mongo db
 
캐시 분산처리 인프라
캐시 분산처리 인프라캐시 분산처리 인프라
캐시 분산처리 인프라
 
COSCUP 2019 - The discussion between Knex.js and PostgreSQL
COSCUP 2019 - The discussion between Knex.js and PostgreSQLCOSCUP 2019 - The discussion between Knex.js and PostgreSQL
COSCUP 2019 - The discussion between Knex.js and PostgreSQL
 
MongoDB Memory Management Demystified
MongoDB Memory Management DemystifiedMongoDB Memory Management Demystified
MongoDB Memory Management Demystified
 
When Will Drupal Die? (Keynote talk)
When Will Drupal Die? (Keynote talk)When Will Drupal Die? (Keynote talk)
When Will Drupal Die? (Keynote talk)
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
 
Mongodb
MongodbMongodb
Mongodb
 
Discover MongoDB - Israel
Discover MongoDB - IsraelDiscover MongoDB - Israel
Discover MongoDB - Israel
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 
Website performance optimization QA
Website performance optimization QAWebsite performance optimization QA
Website performance optimization QA
 
CouchDB
CouchDBCouchDB
CouchDB
 
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
MongoDB Days UK: Using MongoDB to Build a Fast and Scalable Content Repositor...
 
2012 mongo db_bangalore_roadmap_new
2012 mongo db_bangalore_roadmap_new2012 mongo db_bangalore_roadmap_new
2012 mongo db_bangalore_roadmap_new
 
Web Optimization Level: Paranoid
Web Optimization Level: ParanoidWeb Optimization Level: Paranoid
Web Optimization Level: Paranoid
 
A faster web
A faster webA faster web
A faster web
 
MongoDB Basic Concepts
MongoDB Basic ConceptsMongoDB Basic Concepts
MongoDB Basic Concepts
 
Fluent 2012 v2
Fluent 2012   v2Fluent 2012   v2
Fluent 2012 v2
 
Connection
ConnectionConnection
Connection
 
Migrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDBMigrating from RDBMS to MongoDB
Migrating from RDBMS to MongoDB
 
MongoFr : MongoDB as a log Collector
MongoFr : MongoDB as a log CollectorMongoFr : MongoDB as a log Collector
MongoFr : MongoDB as a log Collector
 

Andere mochten auch

Andere mochten auch (7)

КИТ ДОД 2013
КИТ ДОД 2013КИТ ДОД 2013
КИТ ДОД 2013
 
Tarea1 cristina ruiz_gascon
Tarea1 cristina ruiz_gasconTarea1 cristina ruiz_gascon
Tarea1 cristina ruiz_gascon
 
Smalltalk в распределённых системах реального времени
Smalltalk в распределённых системах реального времениSmalltalk в распределённых системах реального времени
Smalltalk в распределённых системах реального времени
 
Tokyo Cabinet
Tokyo CabinetTokyo Cabinet
Tokyo Cabinet
 
Smalltalk: первое знакомство
Smalltalk: первое знакомствоSmalltalk: первое знакомство
Smalltalk: первое знакомство
 
Smalltalk в распределенных бизнес-приложениях
Smalltalk в распределенных бизнес-приложенияхSmalltalk в распределенных бизнес-приложениях
Smalltalk в распределенных бизнес-приложениях
 
КИТ 2013
КИТ 2013КИТ 2013
КИТ 2013
 

Ähnlich wie MongoDB

UNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptxUNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptx
Rahul Borate
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and models
Korea Sdec
 

Ähnlich wie MongoDB (20)

Drop acid
Drop acidDrop acid
Drop acid
 
MongoDB
MongoDBMongoDB
MongoDB
 
Scaling the Web: Databases & NoSQL
Scaling the Web: Databases & NoSQLScaling the Web: Databases & NoSQL
Scaling the Web: Databases & NoSQL
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Spring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_dataSpring one2gx2010 spring-nonrelational_data
Spring one2gx2010 spring-nonrelational_data
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Oracle Week 2016 - Modern Data Architecture
Oracle Week 2016 - Modern Data ArchitectureOracle Week 2016 - Modern Data Architecture
Oracle Week 2016 - Modern Data Architecture
 
Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)Using Spring with NoSQL databases (SpringOne China 2012)
Using Spring with NoSQL databases (SpringOne China 2012)
 
MongoDB SF Ruby
MongoDB SF RubyMongoDB SF Ruby
MongoDB SF Ruby
 
A Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - HabilelabsA Presentation on MongoDB Introduction - Habilelabs
A Presentation on MongoDB Introduction - Habilelabs
 
UNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptxUNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptx
 
UNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptxUNIT I Introduction to NoSQL.pptx
UNIT I Introduction to NoSQL.pptx
 
MongoDB London PHP
MongoDB London PHPMongoDB London PHP
MongoDB London PHP
 
No sql Database
No sql DatabaseNo sql Database
No sql Database
 
KeyValue Stores
KeyValue StoresKeyValue Stores
KeyValue Stores
 
No SQL : Which way to go? Presented at DDDMelbourne 2015
No SQL : Which way to go?  Presented at DDDMelbourne 2015No SQL : Which way to go?  Presented at DDDMelbourne 2015
No SQL : Which way to go? Presented at DDDMelbourne 2015
 
NoSQL, which way to go?
NoSQL, which way to go?NoSQL, which way to go?
NoSQL, which way to go?
 
Mongo DB
Mongo DB Mongo DB
Mongo DB
 
High-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and JavaHigh-Performance Storage Services with HailDB and Java
High-Performance Storage Services with HailDB and Java
 
SDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and modelsSDEC2011 NoSQL concepts and models
SDEC2011 NoSQL concepts and models
 

Mehr von ФПС СПбГПУ (6)

КИТ-2010
КИТ-2010КИТ-2010
КИТ-2010
 
День откртых дверей ФПС СПбГПУ 2009
День откртых дверей ФПС СПбГПУ 2009День откртых дверей ФПС СПбГПУ 2009
День откртых дверей ФПС СПбГПУ 2009
 
КИТ2009
КИТ2009КИТ2009
КИТ2009
 
Обзор программ обучения в области СХД
Обзор программ обучения в области СХДОбзор программ обучения в области СХД
Обзор программ обучения в области СХД
 
Windows Server 2003 Seminar
Windows Server  2003 SeminarWindows Server  2003 Seminar
Windows Server 2003 Seminar
 
Семинар «Windows Server 2003 R2»
Семинар «Windows Server 2003 R2»Семинар «Windows Server 2003 R2»
Семинар «Windows Server 2003 R2»
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

MongoDB

  • 1. nonSQL databases alexey gaziev
  • 2. RDBMS • Great for many apps • Shortcomings • Scalability • Flexibility
  • 3. Other DBMS • Flat file • Hierarchical • Network • Document-oriented • Object-oriented
  • 4. CAP Theorem Pick two С A • Consistency • Availability P • Tolerance to network Partitions http://www.cs.berkeley.edu/~brewer/cs262b-2004/PODC-keynote.pdf
  • 5. ACID & BASE • Atomicity • Basically Available • Consistency • Soft state • Isolation • Eventually consistent • Durability
  • 6. ACID vs. BASE ACID BASE • Strong consistency • Weak consistency • Isolation • Availability first • Focus on “commit” • Best effort • Nested transactions • Approximate answers • Availability? • Agressive (optimistic) • Conservative • Simpler! • Difficult evolution • Faster (schema) • Easier evolution
  • 7.
  • 8. Scalability & Intro Performance memcached Key/Values store RDBMS Depth of Functionality
  • 9. Features • Collection oriented storage: easy storage of object/ JSON -style data • Dynamic queries • Full index support, including on inner objects and embedded arrays • Query profiling • Replication and fail-over support • Efficient storage of binary data including large objects (e.g. photos and videos) • Auto-sharding for cloud-level scalability (currently in alpha) • Commercial support available
  • 10. Great for • Websites • Caching • High volume, low value • High scalability • Storage of program objects and json
  • 11. Not as great for • Highly transactional • Ad-hoc business intelligence • Problems requiring SQL
  • 13. Collection • Think table, but with no schema • For grouping into smaller query sets (speed) • Each top entity in your app would have its own collection (users, articles, etc.) • Full index support
  • 14. Document • Stored in collection, think record or row • Can have _id key that works like primary key in MySQL • Two options for relationships: subdocument or db reference
  • 15. Storage (BSON) { author: 'joe', created: Date('03-28-2009'), title: 'Yet another blog post', text: 'Here is the text...', tags: [ 'example', 'joe' ], comments: [ { author: 'jim', comment: 'I disagree' }, { author: 'nancy', comment: 'Good post' } ] }
  • 16. Basics $ bin/mongod & $ bin/mongo ... > use mydb > j = { name: "mongo"}; {"name" : "mongo"} > t = { x : 3 }; { "x" : 3 } > db.things.save(j); > db.things.save(t); > db.things.find(); in cursor for : DBQuery: example.things -> {"name" : "mongo" , "_id" : "497cf60751712cf7758+dbb"} {"x" : 3 , "_id" : "497cf61651712cf7758+dbc"} >
  • 17. Querying • db.collection.find({‘first_name’: ‘John’}) # finds all Johns • db.collection.find({‘first_name’: /^J/}) # regex • db.collection.find_first({‘_id’:1}) # finds first with _id of 1 • db.collection.find({‘age’: {‘$gt’: 21}}) # finds possible drinkers • db.collection.find({‘author.first_name’:‘John’}) # subdocument • db.collection.find({$where:‘this.age >= 6 && this.age <= 18’})
  • 18. Querying 2 • $in, $nin, $all, $ne, $gt, $gte, $lt, $lte, $size, $where • :fields (like :select in active record) • :limit, :offset for pagination • :sort ascending or descending [[‘foo’, 1], [‘bar’, -1]] • count and group (uses map/reduce)
  • 20. Ruby support • mongo-ruby-driver • Pure Ruby, with optional C extension • MongoRecord • ORM like functionality • Other mappers
  • 21. Ruby basics • Connect: • db = Mongo.new.db(‘my-database’) • coll = db.collection(‘players’) • Insert: • coll.insert (“name” => “mike”, “age” => ... • Query: • coll.find (“age” => 35)
  • 22. Grid FS • File storage in MongoDB • IO-like API for Ruby
  • 23. Other cool stuff • Capped collections • Upserts • Multikeys
  • 24. Resources • http://spitfiresky.com/blog/recap-of-my-sdruby- presentation-on-mongodb.html • http://railstips.org/2009/6/3/what-if-a-key- value-store-mated-with-a-relational-database- system • http://www.mongodb.org/display/DOCS/ Production+Deployments • http://www.mongohq.com/home
  • 25. Resources 2 • http://api.mongodb.org/ruby/0.15.1/index.html • http://www.engineyard.com/blog/2009/ mongodb-a-light-in-the-darkness-key-value- stores-part-5 • http://queue.acm.org/detail.cfm?id=1394128