DataMapper In 20 min

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

  • + maraby Matt Todd 2 years ago
    Really cool presentation man, really got a lot from it, especially still being nubile with DM.
Post a comment
Embed Video
Edit your comment Cancel

11 Favorites

DataMapper In 20 min - Presentation Transcript

  1. DataMapper i n 2 0 m i n
  2. Matt Aimonetti Me irc: m a t t e t t i
  3. Consultant Me based in San Diego, CA
  4. Blogs: http://merbist.com http://railsontherun.com
  5. DataMapper i n 2 0 m i n DM = Object Relational Mapper
  6. DataMapper ORM i n 2 0 m i n Databases scalar values da ta objects Object Oriented Languages
  7. DataMapper i n 2 0 m i n SELECT * FROM Book WHERE price > 100.00 ORDER BY title; Raw SQL statements FTL
  8. DataMapper i n 2 0 m i n Book.all( :price.gt => 100.00, :order => [:title.asc] ) Pure Ruby FTW
  9. DataMapper i n 2 0 m i n Book.find( :all, :conditions => [\"price > ?\", 100.00], :order => \"title\" ) ¿SQL/Ruby FAIL?
  10. DataMapper i n 2 0 m i n DM is MORE THAN THAT
  11. DataMapper identity map i n 2 0 m i n @parent = Parent.find_by_name(\"Bob\") @parent.children.each do |child| @parent.object_id.should == child.parent.object_id end FAILS with ActiveRecord PASSES with DataMapper
  12. DataMapper i n 2 0 m i n Does what ActiveRecord does but differently
  13. DataMapper Data Objects i n 2 0 m i n Copyright - Merb in Action - Manning db drivers using 1 unified interface
  14. DataMapper Lazy loading + i n 2 0 m i n Strategic Eager Loader Procrastination becomes an ORM value
  15. DataMapper Lazy loading + SEL i n 2 0 m i n #first, #each, #count, #map... DM only generates a query when encountering a kicker
  16. DataMapper Lazy loading + SEL i n 2 0 m i n zoos = Zoo.all zoos.each do |zoo| zoo.exhibits.map{|e| e.name} end
  17. DataMapper Lazy loading + SEL i n 2 0 m i n SELECT * FROM \"zoos\" SELECT * FROM \"exhibits\" WHERE (\"exhibits\".zoo_id = 1) SELECT * FROM \"exhibits\" WHERE (\"exhibits\".zoo_id = 2) SELECT * FROM \"exhibits\" WHERE (\"exhibits\".zoo_id = 3) 4 requests ActiveRecord
  18. DataMapper Lazy loading + SEL i n 2 0 m i n SELECT \"id\", \"name\" FROM \"zoos\" ORDER BY \"id\" SELECT \"id\", \"name\", \"zoo_id\" FROM \"exhibits\" WHERE (\"zoo_id\" IN (1, 3, 2)) ORDER BY \"id\" 2 requests DataMapper
  19. DataMapper Lazy load i n 2 0 m i n DM doesn’t load all properties for each request unless required
  20. DataMapper Multiple Repos i n 2 0 m i n production: adapter: mysql encoding: utf8 database: production-app username: root database.yml password: top-s3ckit host: localhost repositories: nightly_backup: adapter: sqlite3 database: shared/nightly.db weekly_backup: adapter: sqlite3 database: shared/weekly.db
  21. DataMapper Multiple Repos i n 2 0 m i n Article.copy(:default, :nightly_backup, :created.gt => 1.day.ago )
  22. DataMapper Multiple Repos i n 2 0 m i n Article.copy(:nightly_backup, :weekly_backup, :created.gt => 1.week.ago )
  23. DataMapper Legacy Data i n 2 0 m i n class Page include DataMapper::Resource property :id, Serial property :name, String repository(:legacy) do property :name, String, :field => \"title\" end
  24. DataMapper Adapters i n 2 0 m i n Provide an interface between your models and a data store.
  25. DataMapper Adapters i n 2 0 m i n imap file system salesforce API REST couchdb ferret google video - http scraper
  26. DataMapper Lazy Attributes i n 2 0 m i n google video - http scraper DM adapter 80 LOC only required to implement - a read method - handling query conditions
  27. DataMapper Lazy Attributes i n 2 0 m i n Sales Force read-write DM adapter 200 LOC
  28. DataMapper Migrations i n 2 0 m i n automigrate autoupdate migration
  29. DataMapper Custom Types i n 2 0 m i n Load / Dump
  30. DataMapper Plugins i n 2 0 m i n modular structure migration, validation, model factory, state machine, constraints, lists, tagging... DM facilitates extensions by offering nice hooks
  31. DataMapper Query::Path i n 2 0 m i n Find all people with an address that has street in the street name Person.all(Person.addresses.street.like => \"%street%\" ) SELECT \"people\".\"id\", \"people\".\"name\" FROM \"people\" INNER JOIN \"addresses\" ON (\"people\".\"id\" = \"addresses\".\"person_id\") WHERE (\"addresses\".\"street\" LIKE '%street%') ORDER BY \"people\".\"id\"
  32. DataMapper Query::Path i n 2 0 m i n Find all people with an address that has street in the street name Person.all(\"addresses.street.like\" => \"%street%\" ) SELECT \"people\".\"id\", \"people\".\"name\" FROM \"people\" INNER JOIN \"addresses\" ON (\"people\".\"id\" = \"addresses\".\"person_id\") WHERE (\"addresses\".\"street\" LIKE '%street%') ORDER BY \"people\".\"id\"
  33. DataMapper i n 2 0 m i n Credits people who helped with this presentation: dbussink, dkubb, afrench, wycats

+ Matt AimonettiMatt Aimonetti, 2 years ago

custom

4764 views, 11 favs, 3 embeds more stats

Overview of DataMapper and the differences between more

More info about this document

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Go to text version

  • Total Views 4764
    • 4640 on SlideShare
    • 124 from embeds
  • Comments 1
  • Favorites 11
  • Downloads 119
Most viewed embeds
  • 66 views on http://merbist.com
  • 45 views on http://www.merboverheard.com
  • 13 views on http://merboverheard.com

more

All embeds
  • 66 views on http://merbist.com
  • 45 views on http://www.merboverheard.com
  • 13 views on http://merboverheard.com

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories