SlideShare a Scribd company logo
1 of 15
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 1
MongoDB & Ruby in 10 Minutes
Tobias.Trelle@codecentric.de @tobiastrelle
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 2
Tobias Trelle
- Senior IT Consultant @
codecentric AG (Düsseldorf)
- Organizer of MongoDB
User Group Düsseldorf
- Authoring a MongoDB book
(dpunkt-Verlag)
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 3
MongoDB
NoSQL data store / Open Source
Single records are called documents
Replication & Sharding out-of-the-box
Map/Reduce
Geospatial Indexes / Queries
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 4
MongoDB Overview
Server
Database
Collection
Document
Field
Tabelle
Zeile
Spalte
Relationales
Pendant Aber …
Flexibles
Schema
- Arrays
- Rekursiv
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 5
Documents
Ordered set of key/values pairs
Values can be an array, document or simple type
Max size = 16 MB
Logical namespaces for documents are called collections
Schemaless
Format: BSON = Binary JSON != JSON
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 6
Documents
{}
{ hello: "MongoDB" }
{ foo:
{ bar: "baz"},
a: [1,2,3,5,8]
}
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 7
MongoDB Gems
$ gem install mongo
Fetching: bson-1.9.0.gem (100%)
Fetching: mongo-1.9.0.gem (100%)
Successfully installed bson-1.9.0
Successfully installed mongo-1.9.0
2 gems installed
...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 8
MongoDB Gems
$ gem install bson_ext
Fetching: bson_ext-1.9.0.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a
while...
Successfully installed bson_ext-1.9.0
1 gem installed...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 9
Ruby Driver API
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 10
Ruby Driver
irb(main):001:0> require 'mongo'
=> true
irb(main):002:0> include Mongo
=> Object
irb(main):003:0> client = MongoClient.new
...
irb(main):004:0> db = client["test"]
...
irb(main):005:0> coll = db["foo"]
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 11
Ruby Driver
irb(main):006:0> coll.remove
=> {"n"=>3, "connectionId"=>2, "err"=>nil, "ok"=>1.0}
irb(main):007:0> coll.insert :hello => "MongoDB"
=> BSON::ObjectId('51d1100ec9f0b10b78000001')
irb(main):008:0> doc = coll.find_one
=>
{"_id"=>BSON::ObjectId('51d1100ec9f0b10b78000001'),
"hello"=>"MongoDB"}
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 12
Ruby Driver
irb(main):013:0> coll.insert :a => 1, b: [1,2,3,4,5]
=> BSON::ObjectId('51d1108ac9f0b10b78000002')
irb(main):014:0> crsr = coll.find
=> <Mongo::Cursor:0x158e2a8 namespace='test.foo'
@selector={} @cursor_id=>
irb(main):016:0> crsr.each{ |doc| puts doc }
{"_id"=>BSON::ObjectId('51d1100ec9f0b10b78000001'),
"hello"=>"MongoDB"}
{"_id"=>BSON::ObjectId('51d1108ac9f0b10b78000002'),
"a"=>1, "b"=>[1, 2, 3, 4, 5]}
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 13
Persistence Frameworks
Mongoid
http://mongoid.org/
MongoMapper
http://mongomapper.com/
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 14
MongoDB User Group Düsseldorf
https://www.xing.com/net/mongodb-dus
@MongoDUS
Meetup #7: Schema Design w/ MongoDB
18.07.2013 19:00
https://www.xing.com/events/7-treffen-schema-
design-mongodb-1268228
MUG Düsseldorf
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 15
QUESTIONS?
Tobias Trelle
codecentric AG
Merscheider Str. 1
42699 Solingen
tel +49 (0) 212.233628.47
fax +49 (0) 212.233628.79
mail Tobias.Trelle@codecentric.de
twitter @tobiastrelle
www.codecentric.de
blog.codecentric.de/en/author/tobias-trelle
www.xing.com/net/mongodb-dus

More Related Content

What's hot

Блохин Леонид - "Mist, как часть Hydrosphere"
Блохин Леонид - "Mist, как часть Hydrosphere"Блохин Леонид - "Mist, как часть Hydrosphere"
Блохин Леонид - "Mist, как часть Hydrosphere"
Provectus
 
Easy deployment & management of cloud apps
Easy deployment & management of cloud appsEasy deployment & management of cloud apps
Easy deployment & management of cloud apps
David Cunningham
 

What's hot (20)

NoSQL and SQL Anti Patterns
NoSQL and SQL Anti PatternsNoSQL and SQL Anti Patterns
NoSQL and SQL Anti Patterns
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
Блохин Леонид - "Mist, как часть Hydrosphere"
Блохин Леонид - "Mist, как часть Hydrosphere"Блохин Леонид - "Mist, как часть Hydrosphere"
Блохин Леонид - "Mist, как часть Hydrosphere"
 
Yesplan: 10 Years later
Yesplan: 10 Years laterYesplan: 10 Years later
Yesplan: 10 Years later
 
Embulk at Treasure Data
Embulk at Treasure DataEmbulk at Treasure Data
Embulk at Treasure Data
 
ElasticSearch Introduction
ElasticSearch IntroductionElasticSearch Introduction
ElasticSearch Introduction
 
Aggregation APi in Ibexa DXP by Adam Wójs
Aggregation APi in Ibexa DXP by Adam WójsAggregation APi in Ibexa DXP by Adam Wójs
Aggregation APi in Ibexa DXP by Adam Wójs
 
Embuk internals
Embuk internalsEmbuk internals
Embuk internals
 
REST Web API with MongoDB
REST Web API with MongoDBREST Web API with MongoDB
REST Web API with MongoDB
 
Easy deployment & management of cloud apps
Easy deployment & management of cloud appsEasy deployment & management of cloud apps
Easy deployment & management of cloud apps
 
JBoss Fuse Workshop 101 part 6
JBoss Fuse Workshop 101 part 6JBoss Fuse Workshop 101 part 6
JBoss Fuse Workshop 101 part 6
 
High Performance API Mashups with Node.js and ql.io
High Performance API Mashups with Node.js and ql.ioHigh Performance API Mashups with Node.js and ql.io
High Performance API Mashups with Node.js and ql.io
 
Jsonnet, terraform & packer
Jsonnet, terraform & packerJsonnet, terraform & packer
Jsonnet, terraform & packer
 
Scripting Embulk Plugins
Scripting Embulk PluginsScripting Embulk Plugins
Scripting Embulk Plugins
 
Embulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loaderEmbulk, an open-source plugin-based parallel bulk data loader
Embulk, an open-source plugin-based parallel bulk data loader
 
Docker Monitoring Webinar
Docker Monitoring  WebinarDocker Monitoring  Webinar
Docker Monitoring Webinar
 
What's new in Ansible 2.0
What's new in Ansible 2.0What's new in Ansible 2.0
What's new in Ansible 2.0
 
Ansible with AWS
Ansible with AWSAnsible with AWS
Ansible with AWS
 
Tamir Dresher - Async Streams in C#
Tamir Dresher - Async Streams in C#Tamir Dresher - Async Streams in C#
Tamir Dresher - Async Streams in C#
 
Automating Workflows for Analytics Pipelines
Automating Workflows for Analytics PipelinesAutomating Workflows for Analytics Pipelines
Automating Workflows for Analytics Pipelines
 

Viewers also liked

Deepak ib solved paper
Deepak ib solved paperDeepak ib solved paper
Deepak ib solved paper
Deepak R Gorad
 
Ppt newton's law
Ppt newton's lawPpt newton's law
Ppt newton's law
mamardc
 
deepak gorad Final csr
deepak gorad Final csrdeepak gorad Final csr
deepak gorad Final csr
Deepak R Gorad
 
Deepak strategic managemt -apple
Deepak  strategic managemt -appleDeepak  strategic managemt -apple
Deepak strategic managemt -apple
Deepak R Gorad
 
Project titles for eee, ece, eie - M.E, B.E, Ph.D, EEE, ECE, EIE Projects
Project titles for  eee, ece, eie - M.E, B.E, Ph.D, EEE, ECE, EIE Projects Project titles for  eee, ece, eie - M.E, B.E, Ph.D, EEE, ECE, EIE Projects
Project titles for eee, ece, eie - M.E, B.E, Ph.D, EEE, ECE, EIE Projects
Senthil Kumar
 
Embedded project list
Embedded project listEmbedded project list
Embedded project list
Senthil Kumar
 

Viewers also liked (20)

Deepak ib solved paper
Deepak ib solved paperDeepak ib solved paper
Deepak ib solved paper
 
Being A Socially Responsible Social Developer: Mobile App Security
Being A Socially Responsible Social Developer: Mobile App SecurityBeing A Socially Responsible Social Developer: Mobile App Security
Being A Socially Responsible Social Developer: Mobile App Security
 
Circuitanlys2
Circuitanlys2Circuitanlys2
Circuitanlys2
 
Dft2
Dft2Dft2
Dft2
 
Ppt newton's law
Ppt newton's lawPpt newton's law
Ppt newton's law
 
XPRESS VACATIONS
XPRESS VACATIONSXPRESS VACATIONS
XPRESS VACATIONS
 
Windows7
Windows7Windows7
Windows7
 
Reechal bday
Reechal bdayReechal bday
Reechal bday
 
Meatco AGM 2012 - CEO Presentation
Meatco AGM 2012 - CEO PresentationMeatco AGM 2012 - CEO Presentation
Meatco AGM 2012 - CEO Presentation
 
Communication projects
Communication projectsCommunication projects
Communication projects
 
Sante1 slideshare
Sante1 slideshareSante1 slideshare
Sante1 slideshare
 
deepak gorad Final csr
deepak gorad Final csrdeepak gorad Final csr
deepak gorad Final csr
 
Power
PowerPower
Power
 
Deepak strategic managemt -apple
Deepak  strategic managemt -appleDeepak  strategic managemt -apple
Deepak strategic managemt -apple
 
Mscc抜粋版
Mscc抜粋版Mscc抜粋版
Mscc抜粋版
 
Entrepreneurship
EntrepreneurshipEntrepreneurship
Entrepreneurship
 
Project titles for eee, ece, eie - M.E, B.E, Ph.D, EEE, ECE, EIE Projects
Project titles for  eee, ece, eie - M.E, B.E, Ph.D, EEE, ECE, EIE Projects Project titles for  eee, ece, eie - M.E, B.E, Ph.D, EEE, ECE, EIE Projects
Project titles for eee, ece, eie - M.E, B.E, Ph.D, EEE, ECE, EIE Projects
 
Drgorad sm project
Drgorad sm projectDrgorad sm project
Drgorad sm project
 
Port folio 20121005
Port folio 20121005Port folio 20121005
Port folio 20121005
 
Embedded project list
Embedded project listEmbedded project list
Embedded project list
 

Similar to An introduction to MongoDB and Ruby

BedCon 2013 - Java Persistenz-Frameworks für MongoDB
BedCon 2013 - Java Persistenz-Frameworks für MongoDBBedCon 2013 - Java Persistenz-Frameworks für MongoDB
BedCon 2013 - Java Persistenz-Frameworks für MongoDB
Tobias Trelle
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
MongoDB
 
introtomongodb
introtomongodbintrotomongodb
introtomongodb
saikiran
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
Alex Bilbie
 
Tikal Fuse Day Access Layer Implementation (C#) Based On Mongo Db
Tikal Fuse Day   Access Layer Implementation (C#) Based On Mongo DbTikal Fuse Day   Access Layer Implementation (C#) Based On Mongo Db
Tikal Fuse Day Access Layer Implementation (C#) Based On Mongo Db
Tikal Knowledge
 

Similar to An introduction to MongoDB and Ruby (20)

BedCon 2013 - Java Persistenz-Frameworks für MongoDB
BedCon 2013 - Java Persistenz-Frameworks für MongoDBBedCon 2013 - Java Persistenz-Frameworks für MongoDB
BedCon 2013 - Java Persistenz-Frameworks für MongoDB
 
MongoDB at FrozenRails
MongoDB at FrozenRailsMongoDB at FrozenRails
MongoDB at FrozenRails
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHP
 
MongoDB
MongoDBMongoDB
MongoDB
 
introtomongodb
introtomongodbintrotomongodb
introtomongodb
 
Morphia, Spring Data & Co.
Morphia, Spring Data & Co.Morphia, Spring Data & Co.
Morphia, Spring Data & Co.
 
MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling MongoDB Introduction and Data Modelling
MongoDB Introduction and Data Modelling
 
DrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and DrupalDrupalCon Chicago Practical MongoDB and Drupal
DrupalCon Chicago Practical MongoDB and Drupal
 
Battle of NoSQL stars: Amazon's SDB vs MongoDB vs CouchDB vs RavenDB
Battle of NoSQL stars: Amazon's SDB vs MongoDB vs CouchDB vs RavenDBBattle of NoSQL stars: Amazon's SDB vs MongoDB vs CouchDB vs RavenDB
Battle of NoSQL stars: Amazon's SDB vs MongoDB vs CouchDB vs RavenDB
 
Code as Data workshop: Using source{d} Engine to extract insights from git re...
Code as Data workshop: Using source{d} Engine to extract insights from git re...Code as Data workshop: Using source{d} Engine to extract insights from git re...
Code as Data workshop: Using source{d} Engine to extract insights from git re...
 
Introduction to MongoDB with PHP
Introduction to MongoDB with PHPIntroduction to MongoDB with PHP
Introduction to MongoDB with PHP
 
Building your first app with MongoDB
Building your first app with MongoDBBuilding your first app with MongoDB
Building your first app with MongoDB
 
Optimizing MongoDB: Lessons Learned at Localytics
Optimizing MongoDB: Lessons Learned at LocalyticsOptimizing MongoDB: Lessons Learned at Localytics
Optimizing MongoDB: Lessons Learned at Localytics
 
Hosting MongoDB & our experience with database as a service
Hosting MongoDB & our experience with database as a serviceHosting MongoDB & our experience with database as a service
Hosting MongoDB & our experience with database as a service
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Tikal Fuse Day Access Layer Implementation (C#) Based On Mongo Db
Tikal Fuse Day   Access Layer Implementation (C#) Based On Mongo DbTikal Fuse Day   Access Layer Implementation (C#) Based On Mongo Db
Tikal Fuse Day Access Layer Implementation (C#) Based On Mongo Db
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 
Webinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.jsWebinar: Building Your First App in Node.js
Webinar: Building Your First App in Node.js
 

More from Tobias Trelle

MongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenMongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwalten
Tobias Trelle
 
Morphia, Spring Data & Co
Morphia, Spring Data & CoMorphia, Spring Data & Co
Morphia, Spring Data & Co
Tobias Trelle
 

More from Tobias Trelle (12)

TDD mit JUnit und Mockito
TDD mit JUnit und MockitoTDD mit JUnit und Mockito
TDD mit JUnit und Mockito
 
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4jNoSQL - Einführung in Graphen-Datenbanken mit Neo4j
NoSQL - Einführung in Graphen-Datenbanken mit Neo4j
 
Einführung in NoSQL-Datenbanken
Einführung in NoSQL-DatenbankenEinführung in NoSQL-Datenbanken
Einführung in NoSQL-Datenbanken
 
MongoDB Einführung
MongoDB EinführungMongoDB Einführung
MongoDB Einführung
 
MongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwaltenMongoDB - Riesige Datenmengen schemafrei verwalten
MongoDB - Riesige Datenmengen schemafrei verwalten
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL Databases
 
Morphia, Spring Data & Co
Morphia, Spring Data & CoMorphia, Spring Data & Co
Morphia, Spring Data & Co
 
Spring Data, Jongo & Co.
Spring Data, Jongo & Co.Spring Data, Jongo & Co.
Spring Data, Jongo & Co.
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
OOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDBOOP 2013: Praktische Einführung in MongoDB
OOP 2013: Praktische Einführung in MongoDB
 
MongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDBMongoDB Munich 2012: Spring Data MongoDB
MongoDB Munich 2012: Spring Data MongoDB
 
MongoDB Live Hacking
MongoDB Live HackingMongoDB Live Hacking
MongoDB Live Hacking
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

An introduction to MongoDB and Ruby

  • 1. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 1 MongoDB & Ruby in 10 Minutes Tobias.Trelle@codecentric.de @tobiastrelle
  • 2. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 2 Tobias Trelle - Senior IT Consultant @ codecentric AG (Düsseldorf) - Organizer of MongoDB User Group Düsseldorf - Authoring a MongoDB book (dpunkt-Verlag)
  • 3. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 3 MongoDB NoSQL data store / Open Source Single records are called documents Replication & Sharding out-of-the-box Map/Reduce Geospatial Indexes / Queries
  • 4. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 4 MongoDB Overview Server Database Collection Document Field Tabelle Zeile Spalte Relationales Pendant Aber … Flexibles Schema - Arrays - Rekursiv
  • 5. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 5 Documents Ordered set of key/values pairs Values can be an array, document or simple type Max size = 16 MB Logical namespaces for documents are called collections Schemaless Format: BSON = Binary JSON != JSON
  • 6. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 6 Documents {} { hello: "MongoDB" } { foo: { bar: "baz"}, a: [1,2,3,5,8] }
  • 7. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 7 MongoDB Gems $ gem install mongo Fetching: bson-1.9.0.gem (100%) Fetching: mongo-1.9.0.gem (100%) Successfully installed bson-1.9.0 Successfully installed mongo-1.9.0 2 gems installed ...
  • 8. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 8 MongoDB Gems $ gem install bson_ext Fetching: bson_ext-1.9.0.gem (100%) Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... Successfully installed bson_ext-1.9.0 1 gem installed...
  • 9. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 9 Ruby Driver API
  • 10. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 10 Ruby Driver irb(main):001:0> require 'mongo' => true irb(main):002:0> include Mongo => Object irb(main):003:0> client = MongoClient.new ... irb(main):004:0> db = client["test"] ... irb(main):005:0> coll = db["foo"]
  • 11. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 11 Ruby Driver irb(main):006:0> coll.remove => {"n"=>3, "connectionId"=>2, "err"=>nil, "ok"=>1.0} irb(main):007:0> coll.insert :hello => "MongoDB" => BSON::ObjectId('51d1100ec9f0b10b78000001') irb(main):008:0> doc = coll.find_one => {"_id"=>BSON::ObjectId('51d1100ec9f0b10b78000001'), "hello"=>"MongoDB"}
  • 12. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 12 Ruby Driver irb(main):013:0> coll.insert :a => 1, b: [1,2,3,4,5] => BSON::ObjectId('51d1108ac9f0b10b78000002') irb(main):014:0> crsr = coll.find => <Mongo::Cursor:0x158e2a8 namespace='test.foo' @selector={} @cursor_id=> irb(main):016:0> crsr.each{ |doc| puts doc } {"_id"=>BSON::ObjectId('51d1100ec9f0b10b78000001'), "hello"=>"MongoDB"} {"_id"=>BSON::ObjectId('51d1108ac9f0b10b78000002'), "a"=>1, "b"=>[1, 2, 3, 4, 5]}
  • 13. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 13 Persistence Frameworks Mongoid http://mongoid.org/ MongoMapper http://mongomapper.com/
  • 14. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 14 MongoDB User Group Düsseldorf https://www.xing.com/net/mongodb-dus @MongoDUS Meetup #7: Schema Design w/ MongoDB 18.07.2013 19:00 https://www.xing.com/events/7-treffen-schema- design-mongodb-1268228 MUG Düsseldorf
  • 15. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 15 QUESTIONS? Tobias Trelle codecentric AG Merscheider Str. 1 42699 Solingen tel +49 (0) 212.233628.47 fax +49 (0) 212.233628.79 mail Tobias.Trelle@codecentric.de twitter @tobiastrelle www.codecentric.de blog.codecentric.de/en/author/tobias-trelle www.xing.com/net/mongodb-dus