Your SlideShare is downloading. ×
0
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Rails + mongo db
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Rails + mongo db

336

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
336
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Rails + MongoDB = <3 Sérgio Santos @sdsantos Improve Coimbra
  • 2. Introduction / Disclamer
  • 3. Bundlr MongoDB stats MongoDB from the start ~ 3½ years of development ~ 6 GB of data ~ 6 million documents Cloud hosted on MongoHQ
  • 4. MongoDB 101
  • 5. Documents
  • 6. Collections
  • 7. References
  • 8. Embeds
  • 9. Rails MongoDB ORMs
  • 10. Mongoid vs MongoMapper
  • 11. Mongoid
  • 12. Models class Person include Mongoid::Document end person = Person.new person[:name] = 'Sérgio' person[:age] = 26 person.save
  • 13. Models class Person include Mongoid::Document field :name, type: String field :age, type: Integer end person = Person.new person.name = 'Sérgio' person.age = 26 person.save
  • 14. Persistence person = Person.create(name: 'Sérgio', age: 26) person.update_attributes(name: 'Sérgio Santos') person.touch person.delete person.destroy person.rename(:name, :first_name)
  • 15. Querying person = Person.find("4baa56f1230048567300485c") people = Person.where(age: 18) people = Person.where(name: 'Sérgio').not(age: 26) Person.count Person.all.avg(:age) -- INSERT MAP/REDUCE CLEVER EXAMPLE HERE --
  • 16. References class Band include Mongoid::Document has_many :members end class Member include Mongoid::Document field :name, type: String belongs_to :band end
  • 17. References # The parent band document. { "_id" : ObjectId("4d3ed089fb60ab534684b7e9") } # The child member document. { "_id" : ObjectId("4d3ed089fb60ab534684b7f1"), "name" : "Matt Berninger" "band_id" : ObjectId("4d3ed089fb60ab534684b7e9") }
  • 18. Embeds class Band include Mongoid::Document embeds_many :albums end class Album include Mongoid::Document field :name, type: String embedded_in :band end
  • 19. Embeds { "_id" : ObjectId("4d3ed089fb60ab534684b7e9"), "albums" : [ { "_id" : ObjectId("4d3ed089fb60ab534684b7e0"), "name" : "Boxer", } ] }
  • 20. Extras identity map & cache paranoia versioning timestamps geo full text search
  • 21. Cloud Hosting
  • 22. Wrapping up…
  • 23. Rails + MongoDB = <3 Sérgio Santos @sdsantos me@sergiosantos.info We’re hiring! nourishcare.co.uk/careers/

×