Exploring the Future Potential of AI-Enabled Smartphone Processors
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]
}
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"]