codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 1
MongoDB & Ruby in 10 Minutes
Tobias.Trelle@codecentric.de ...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 2
Tobias Trelle
- Senior IT Consultant @
codecentric AG (Düs...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 3
MongoDB
NoSQL data store / Open Source
Single records are ...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 4
MongoDB Overview
Server
Database
Collection
Document
Field...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 5
Documents
Ordered set of key/values pairs
Values can be an...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 6
Documents
{}
{ hello: "MongoDB" }
{ foo:
{ bar: "baz"},
a:...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 7
MongoDB Gems
$ gem install mongo
Fetching: bson-1.9.0.gem ...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 8
MongoDB Gems
$ gem install bson_ext
Fetching: bson_ext-1.9...
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(...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 11
Ruby Driver
irb(main):006:0> coll.remove
=> {"n"=>3, "con...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 12
Ruby Driver
irb(main):013:0> coll.insert :a => 1, b: [1,2...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 13
Persistence Frameworks
Mongoid
http://mongoid.org/
MongoM...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 14
MongoDB User Group Düsseldorf
https://www.xing.com/net/mo...
codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 15
QUESTIONS?
Tobias Trelle
codecentric AG
Merscheider Str. ...
Upcoming SlideShare
Loading in...5
×

An introduction to MongoDB and Ruby

2,850

Published on

A short introduction to MongoDB and the Ruby driver for MongoDB.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,850
On Slideshare
0
From Embeds
0
Number of Embeds
21
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

An introduction to MongoDB and Ruby

  1. 1. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 1 MongoDB & Ruby in 10 Minutes Tobias.Trelle@codecentric.de @tobiastrelle
  2. 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. 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. 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. 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. 6. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 6 Documents {} { hello: "MongoDB" } { foo: { bar: "baz"}, a: [1,2,3,5,8] }
  7. 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. 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. 9. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 9 Ruby Driver API
  10. 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. 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. 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. 13. codecentric AG / Tobias Trelle / MongoDB & Ruby in 10 Minutes 13 Persistence Frameworks Mongoid http://mongoid.org/ MongoMapper http://mongomapper.com/
  14. 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. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×