6. • SaaS platform
• we provide an API for carriers and merchants
Wednesday, 23 January 13
7. • SaaS platform
• we provide an API for carriers and merchants
• customers can chose between a delivery either:
Wednesday, 23 January 13
8. • SaaS platform
• we provide an API for carriers and merchants
• customers can chose between a delivery either:
within 90 minutes of purchase
Wednesday, 23 January 13
9. • SaaS platform
• we provide an API for carriers and merchants
• customers can chose between a delivery either:
within 90 minutes of purchase
or a 1 hour window of their choice
Wednesday, 23 January 13
10. • SaaS platform
• we provide an API for carriers and merchants
• customers can chose between a delivery either:
within 90 minutes of purchase
or a 1 hour window of their choice
(same day or any day)
Wednesday, 23 January 13
11. • SaaS platform
• we provide an API for carriers and merchants
• customers can chose between a delivery either:
within 90 minutes of purchase
or a 1 hour window of their choice
(same day or any day)
• fastest delivery to date 14:00 min
Wednesday, 23 January 13
12. • SaaS platform
• we provide an API for carriers and merchants
• customers can chose between a delivery either:
within 90 minutes of purchase
or a 1 hour window of their choice
(same day or any day)
• fastest delivery to date 14:00 min
• customers: Argos, Maplins, DrEd.com ...
Wednesday, 23 January 13
13. • SaaS platform
• we provide an API for carriers and merchants
• customers can chose between a delivery either:
within 90 minutes of purchase
or a 1 hour window of their choice
(same day or any day)
• fastest delivery to date 14:00 min
• customers: Argos, Maplins, DrEd.com ...
• json api
Wednesday, 23 January 13
14. • SaaS platform
• we provide an API for carriers and merchants
• customers can chose between a delivery either:
within 90 minutes of purchase
or a 1 hour window of their choice
(same day or any day)
• fastest delivery to date 14:00 min
• customers: Argos, Maplins, DrEd.com ...
• json api
•built with sinatra, jruby, neo4j and mongodb
Wednesday, 23 January 13
16. Shutl Main Red: Shutl Accent Red:
Pantone 485 C Pantone 484 C
Let’s get going:
C0 M100 Y99 K4 C0 M100 Y99 K4
R208 G31 B40 R208 G31 B40
red on white HEX D01F28 HEX D01F28
red on lighter tones
Shutl Black: Shutl Accent Grey:
Pantone BLACK Pantone BLACK
C0 M0 Y0 K0100 C0 M0 Y0 K70
@ 70%
Please note:
Black on white Reverse (white) on darker tones The black logo should never
appear on in any ‘dark’ colour
background.
5 Branding Guidelines
Wednesday, 23 January 13
17. Shutl Main Red: Shutl Accent Red:
Pantone 485 C Pantone 484 C
Let’s get going:
C0 M100 Y99 K4 C0 M100 Y99 K4
R208 G31 B40 R208 G31 B40
red on white HEX D01F28 HEX D01F28
red on lighter tones
Shutl Black: Shutl Accent Grey:
Pantone BLACK Pantone BLACK
• install mongodb with brew install mongodb
C0 M0 Y0 K0100 C0 M0 Y0 K70
@ 70%
Please note:
Black on white Reverse (white) on darker tones The black logo should never
appear on in any ‘dark’ colour
background.
5 Branding Guidelines
Wednesday, 23 January 13
18. Shutl Main Red: Shutl Accent Red:
Pantone 485 C Pantone 484 C
Let’s get going:
C0 M100 Y99 K4 C0 M100 Y99 K4
R208 G31 B40 R208 G31 B40
red on white HEX D01F28 HEX D01F28
red on lighter tones
Shutl Black: Shutl Accent Grey:
Pantone BLACK Pantone BLACK
• install mongodb with brew install mongodb
C0 M0 Y0 K0100 C0 M0 Y0 K70
@ 70%
Please note:
Black on white Reverse (white) on darker tones The black logo should never
appear on in any ‘dark’ colour
• in your gemfile:
background.
5 Branding Guidelines
Wednesday, 23 January 13
19. Shutl Main Red: Shutl Accent Red:
Pantone 485 C Pantone 484 C
Let’s get going:
C0 M100 Y99 K4 C0 M100 Y99 K4
R208 G31 B40 R208 G31 B40
red on white HEX D01F28 HEX D01F28
red on lighter tones
Shutl Black: Shutl Accent Grey:
Pantone BLACK Pantone BLACK
• install mongodb with brew install mongodb
C0 M0 Y0 K0100 C0 M0 Y0 K70
@ 70%
Please note:
Black on white Reverse (white) on darker tones The black logo should never
appear on in any ‘dark’ colour
• in your gemfile:
background.
5 Branding Guidelines
• gem ‘mongo’
Wednesday, 23 January 13
20. Shutl Main Red: Shutl Accent Red:
Pantone 485 C Pantone 484 C
Let’s get going:
C0 M100 Y99 K4 C0 M100 Y99 K4
R208 G31 B40 R208 G31 B40
red on white HEX D01F28 HEX D01F28
red on lighter tones
Shutl Black: Shutl Accent Grey:
Pantone BLACK Pantone BLACK
• install mongodb with brew install mongodb
C0 M0 Y0 K0100 C0 M0 Y0 K70
@ 70%
Please note:
Black on white Reverse (white) on darker tones The black logo should never
appear on in any ‘dark’ colour
• in your gemfile:
background.
5 Branding Guidelines
• gem ‘mongo’
• gem ‘bson’
Wednesday, 23 January 13
21. Shutl Main Red: Shutl Accent Red:
Pantone 485 C Pantone 484 C
Let’s get going:
C0 M100 Y99 K4 C0 M100 Y99 K4
R208 G31 B40 R208 G31 B40
red on white HEX D01F28 HEX D01F28
red on lighter tones
Shutl Black: Shutl Accent Grey:
Pantone BLACK Pantone BLACK
• install mongodb with brew install mongodb
C0 M0 Y0 K0100 C0 M0 Y0 K70
@ 70%
Please note:
Black on white Reverse (white) on darker tones The black logo should never
appear on in any ‘dark’ colour
• in your gemfile:
background.
5 Branding Guidelines
• gem ‘mongo’
• gem ‘bson’
• gem ‘bson_ext’
Wednesday, 23 January 13
22. Shutl Main Red: Shutl Accent Red:
Pantone 485 C Pantone 484 C
Let’s get going:
C0 M100 Y99 K4 C0 M100 Y99 K4
R208 G31 B40 R208 G31 B40
red on white HEX D01F28 HEX D01F28
red on lighter tones
Shutl Black: Shutl Accent Grey:
Pantone BLACK Pantone BLACK
• install mongodb with brew install mongodb
C0 M0 Y0 K0100 C0 M0 Y0 K70
@ 70%
Please note:
Black on white Reverse (white) on darker tones The black logo should never
appear on in any ‘dark’ colour
• in your gemfile:
background.
5 Branding Guidelines
• gem ‘mongo’
• gem ‘bson’
• gem ‘bson_ext’
• run bundle install
Wednesday, 23 January 13
24. MongoMapper
• http://mongomapper.com/
Wednesday, 23 January 13
25. MongoMapper
• http://mongomapper.com/
• written by John Nunemaker (github)
Wednesday, 23 January 13
26. MongoMapper
• http://mongomapper.com/
• written by John Nunemaker (github)
• code at https://github.com/jnunemaker/
mongomapper
Wednesday, 23 January 13
36. First document:
class User
include MongoMapper::Document
key :name, String, required: true
key :age, Integer
one :address
many :notes
timestamps!
end
Wednesday, 23 January 13
37. embedded document:
class Note
include MongoMapper::EmbeddedDocument
key :text, String
end
Wednesday, 23 January 13
38. create a document:
user = User.new(name:'James Chester')
user.notes.build(text:'a note')
user.save!
User.where(:name => 'James Chester').first
Wednesday, 23 January 13
39. What is an embedded document?
Wednesday, 23 January 13
40. What is an embedded document?
• a document has it’s own collection in the database (table)
Wednesday, 23 January 13
41. What is an embedded document?
• a document has it’s own collection in the database (table)
• an embedded document can only reside inside a document
or another embedded document
Wednesday, 23 January 13
42. What is an embedded document?
• a document has it’s own collection in the database (table)
• an embedded document can only reside inside a document
or another embedded document
• the alternative in sql without join table would be to serialize
Wednesday, 23 January 13
43. What is an embedded document?
• a document has it’s own collection in the database (table)
• an embedded document can only reside inside a document
or another embedded document
• the alternative in sql without join table would be to serialize
• in MongoDB it is possible to query inside embedded
documents and structures and also to index inside them
Wednesday, 23 January 13
44. When to use embedded and when not to
Wednesday, 23 January 13
45. When to use embedded and when not to
• only embed when the document will be shown in the
context of the parent document
Wednesday, 23 January 13
46. When to use embedded and when not to
• only embed when the document will be shown in the
context of the parent document
• if you need to access to the documents on it’s own use
associations (i.e. all notes)
Wednesday, 23 January 13
47. When to use embedded and when not to
• only embed when the document will be shown in the
context of the parent document
• if you need to access to the documents on it’s own use
associations (i.e. all notes)
• they work the same way but declare a normal document
instead of an embedded one
Wednesday, 23 January 13
50. types:
• mongomapper supports the ruby data types:
Integer, Float, String, Array, Hash, Object, Time, NilClass
Wednesday, 23 January 13
51. types:
• mongomapper supports the ruby data types:
Integer, Float, String, Array, Hash, Object, Time, NilClass
• additionally mongomapper adds support for:
Binary, Boolean, Date, ObjectId and Set
Wednesday, 23 January 13
52. types:
• mongomapper supports the ruby data types:
Integer, Float, String, Array, Hash, Object, Time, NilClass
• additionally mongomapper adds support for:
Binary, Boolean, Date, ObjectId and Set
• ability to add custom types
Wednesday, 23 January 13
53. custom types:
class UpcaseString
def self.to_mongo(value)
value.nil? ? nil : value.to_s.upcase
end
def self.from_mongo(value)
to_mongo(value)
end
end
Wednesday, 23 January 13
60. dynamic querying:
• MongoMapper uses plucky to the allow the construction of query
proxy objects that only get executed when needed
Wednesday, 23 January 13
61. dynamic querying:
• MongoMapper uses plucky to the allow the construction of query
proxy objects that only get executed when needed
• https://github.com/jnunemaker/plucky
Wednesday, 23 January 13
62. dynamic querying:
• MongoMapper uses plucky to the allow the construction of query
proxy objects that only get executed when needed
• https://github.com/jnunemaker/plucky
• User.where(:created_at.gte => 3.days.ago).sort(:created.desc)
Wednesday, 23 January 13
63. dynamic querying:
• MongoMapper uses plucky to the allow the construction of query
proxy objects that only get executed when needed
• https://github.com/jnunemaker/plucky
• User.where(:created_at.gte => 3.days.ago).sort(:created.desc)
• .where, .count, .field, .sort/.order, .limit,
.skip, .offset
Wednesday, 23 January 13
65. operators:
• all mongodb operators can be used directly in mongomapper
Wednesday, 23 January 13
66. operators:
• all mongodb operators can be used directly in mongomapper
• http://docs.mongodb.org/manual/reference/operators/
Wednesday, 23 January 13
67. operators:
• all mongodb operators can be used directly in mongomapper
• http://docs.mongodb.org/manual/reference/operators/
• User.where(:age => {:$gt => 20, :$lt => 45})
Wednesday, 23 January 13
68. operators:
• all mongodb operators can be used directly in mongomapper
• http://docs.mongodb.org/manual/reference/operators/
• User.where(:age => {:$gt => 20, :$lt => 45})
• or shorthand:
Wednesday, 23 January 13
69. operators:
• all mongodb operators can be used directly in mongomapper
• http://docs.mongodb.org/manual/reference/operators/
• User.where(:age => {:$gt => 20, :$lt => 45})
• or shorthand:
• User.where(:age.gt => 25)
Wednesday, 23 January 13
79. indexes: • put indexes into the initializer
Wednesday, 23 January 13
80. indexes: • put indexes into the initializer
• index on single field:
User.ensure_index(:name)
Wednesday, 23 January 13
81. indexes: • put indexes into the initializer
• index on single field:
User.ensure_index(:name)
• index multiple keys:
User.ensure_index([[:name, 1], [:age, -1]])
Wednesday, 23 January 13
82. indexes: • put indexes into the initializer
• index on single field:
User.ensure_index(:name)
• index multiple keys:
User.ensure_index([[:name, 1], [:age, -1]])
• the order of keys is important in
compound indexes
Wednesday, 23 January 13
83. indexes: • put indexes into the initializer
• index on single field:
User.ensure_index(:name)
• index multiple keys:
User.ensure_index([[:name, 1], [:age, -1]])
• the order of keys is important in
compound indexes
• unique index:
User.ensure_index [[:name, 1]], :unique => true
Wednesday, 23 January 13
84. indexes: • put indexes into the initializer
• index on single field:
User.ensure_index(:name)
• index multiple keys:
User.ensure_index([[:name, 1], [:age, -1]])
• the order of keys is important in
compound indexes
• unique index:
User.ensure_index [[:name, 1]], :unique => true
• delete index:
User.drop_index(:name)
Wednesday, 23 January 13
85. using the decorator/presenter pattern for schemaless dbs
decorator
‘decorates’ object for presentation
controller
passes decorated object to view
retrieves object
view
mongo
DB
Wednesday, 23 January 13
86. Any questions?
Volker Pacher
volker@shutl.co.uk shutl.co.uk
@vpacher @shutl
Wednesday, 23 January 13