0
Mongoid            Mongoid           Cyril Mougel          17 Janvier 2013
Mongoid Mongoid c’est ?      1    Mongoid c’est ?      2    Mais MongoDB ?      3    Mongoid c’est aussi ?
Mongoid Mongoid c’est ?      Qu’est ce que Mongoid ?              Un ODM Object Document Model              ´             ...
Mongoid Mongoid c’est ?      Exemple simple      class User        include Mongoid :: Document      end
Mongoid Mongoid c’est ?      R´sultat       e      > user = User . new      = > # < User _id : 50 f07c2444fd9947a7000001 ,...
Mongoid Mongoid c’est ?                   D´finition des champs                    e
Mongoid Mongoid c’est ?      class User        include Mongoid :: Document        field : first_name        field : last_n...
Mongoid Mongoid c’est ?      > user = User . new (: first_name = > 123 , : last_name            = > " Mougel " )      = > ...
Mongoid Mongoid c’est ?                   Gestion de la Coercion
Mongoid Mongoid c’est ?      class User        include Mongoid :: Document        field : first_name , : type = > String  ...
Mongoid Mongoid c’est ?      > user = User . new (: first_name = > 123 , : last_name            = > true )      = > # < Us...
Mongoid Mongoid c’est ?        Gestion d’un valeur par d´faut                                 e
Mongoid Mongoid c’est ?      class User        include Mongoid :: Document        field : first_name , : type = > String  ...
Mongoid Mongoid c’est ?      > user = User . new      = > # < User _id : 50 f07cbc44fd9947a7000004 , _type :          nil ...
Mongoid Mongoid c’est ?                   Multiple Type de base
Mongoid Mongoid c’est ?             BigDecimal   Date             Boolean      DateTime             Integer      Time     ...
Mongoid Mais MongoDB ?     1   Mongoid c’est ?     2   Mais MongoDB ?     3   Mongoid c’est aussi ?
Mongoid Mais MongoDB ?                  Base NoSQL                  NoSQL == Not Only SQL
Mongoid Mais MongoDB ?                  Base de donn´e orient´                              e        e                    ...
Mongoid Mais MongoDB ?                  Base de donn´e orient´                              e        e                    ...
Mongoid Mais MongoDB ?                  Pas de jointure
Mongoid Mais MongoDB ?                    Query Op´rator                            e            $in            $nin      ...
Mongoid Mongoid c’est aussi ?       1   Mongoid c’est ?       2   Mais MongoDB ?       3   Mongoid c’est aussi ?
Mongoid Mongoid c’est aussi ?                         Include ActiveModel              Gestion des erreurs              Ge...
Mongoid Mongoid c’est aussi ?                   Gestion des associations
Mongoid Mongoid c’est aussi ?              Association entre collection              has many :orders              belongs...
Mongoid Mongoid c’est aussi ?       class User         include Mongoid :: Document         has_many : posts       end     ...
Mongoid Mongoid c’est aussi ?       > user = User . new       > user . posts = [ Post . new ]       > user . save       > ...
Mongoid Mongoid c’est aussi ?              Association des documents                      embarqu´s                       ...
Mongoid Mongoid c’est aussi ?       class Post         include Mongoid :: Document         embeds_many : comments       en...
Mongoid Mongoid c’est aussi ?       > user = User . new       > user . comments = [ Comment . new ]       > user . save   ...
Mongoid Mongoid c’est aussi ?                             Criteria              Model.where           Model.asc           ...
Mongoid Mongoid c’est aussi ?              Les criterias sont chainable
Mongoid Mongoid c’est aussi ?             Les criterias sont ´valu´s de                                e    e             ...
Mongoid Mongoid c’est aussi ?                               Finder              Model.all              Model.first         ...
Mongoid Mongoid c’est aussi ?                                   Moped              MongoDB driver d´velopp´ par la communa...
Mongoid Mongoid c’est aussi ?                         Plus d’information ?                                    RTFM        ...
Upcoming SlideShare
Loading in...5
×

Mongoid

547

Published on

une simp

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

No Downloads
Views
Total Views
547
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
8
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Mongoid"

  1. 1. Mongoid Mongoid Cyril Mougel 17 Janvier 2013
  2. 2. Mongoid Mongoid c’est ? 1 Mongoid c’est ? 2 Mais MongoDB ? 3 Mongoid c’est aussi ?
  3. 3. Mongoid Mongoid c’est ? Qu’est ce que Mongoid ? Un ODM Object Document Model ´ Ecrit en Ruby API comme ActiveRecord
  4. 4. Mongoid Mongoid c’est ? Exemple simple class User include Mongoid :: Document end
  5. 5. Mongoid Mongoid c’est ? R´sultat e > user = User . new = > # < User _id : 50 f07c2444fd9947a7000001 , _type : nil >
  6. 6. Mongoid Mongoid c’est ? D´finition des champs e
  7. 7. Mongoid Mongoid c’est ? class User include Mongoid :: Document field : first_name field : last_name end
  8. 8. Mongoid Mongoid c’est ? > user = User . new (: first_name = > 123 , : last_name = > " Mougel " ) = > # < User _id : 50 f07c4c44fd9947a7000003 , _type : nil , first_name : 123 , last_name : " Mougel " > > user . first_name = > 123 > user . last_name = > " Mougel "
  9. 9. Mongoid Mongoid c’est ? Gestion de la Coercion
  10. 10. Mongoid Mongoid c’est ? class User include Mongoid :: Document field : first_name , : type = > String field : last_name , : type = > String end
  11. 11. Mongoid Mongoid c’est ? > user = User . new (: first_name = > 123 , : last_name = > true ) = > # < User _id : 50 f07c4c44fd9947a7000003 , _type : nil , first_name : "123" , last_name : " true " > > user . first_name = > " 123 " > user . last_name = > " true "
  12. 12. Mongoid Mongoid c’est ? Gestion d’un valeur par d´faut e
  13. 13. Mongoid Mongoid c’est ? class User include Mongoid :: Document field : first_name , : type = > String field : last_name , : type = > String field : location , : type = > String , : default = > " Nantes " end
  14. 14. Mongoid Mongoid c’est ? > user = User . new = > # < User _id : 50 f07cbc44fd9947a7000004 , _type : nil , first_name : nil , last_name : nil , location : " Nantes " > > user . first_name = > nil > user . location = > " Nantes "
  15. 15. Mongoid Mongoid c’est ? Multiple Type de base
  16. 16. Mongoid Mongoid c’est ? BigDecimal Date Boolean DateTime Integer Time String Array Symbol Hash Float
  17. 17. Mongoid Mais MongoDB ? 1 Mongoid c’est ? 2 Mais MongoDB ? 3 Mongoid c’est aussi ?
  18. 18. Mongoid Mais MongoDB ? Base NoSQL NoSQL == Not Only SQL
  19. 19. Mongoid Mais MongoDB ? Base de donn´e orient´ e e document stockage sous format BSON BSON == Binary JSON
  20. 20. Mongoid Mais MongoDB ? Base de donn´e orient´ e e document Cr´ation automatique du sch´ma e e Pas d’obligation d’homog´n´it´ des documents e e e
  21. 21. Mongoid Mais MongoDB ? Pas de jointure
  22. 22. Mongoid Mais MongoDB ? Query Op´rator e $in $nin $or $gt $lt etc..
  23. 23. Mongoid Mongoid c’est aussi ? 1 Mongoid c’est ? 2 Mais MongoDB ? 3 Mongoid c’est aussi ?
  24. 24. Mongoid Mongoid c’est aussi ? Include ActiveModel Gestion des erreurs Gestion des callbacks
  25. 25. Mongoid Mongoid c’est aussi ? Gestion des associations
  26. 26. Mongoid Mongoid c’est aussi ? Association entre collection has many :orders belongs to :user
  27. 27. Mongoid Mongoid c’est aussi ? class User include Mongoid :: Document has_many : posts end class Post include Mongoid :: Document belongs_to : user end
  28. 28. Mongoid Mongoid c’est aussi ? > user = User . new > user . posts = [ Post . new ] > user . save > user = > # < User _id : 50 f07c2444fd9947a7000001 , _type : nil > > user . posts = > [ # < Post _id : 50 f07c2444fd9947a7000002 , _type : nil >]
  29. 29. Mongoid Mongoid c’est aussi ? Association des documents embarqu´s e embeds many :comments embedded in :post
  30. 30. Mongoid Mongoid c’est aussi ? class Post include Mongoid :: Document embeds_many : comments end class Comment include Mongoid :: Document embedded_in : post end
  31. 31. Mongoid Mongoid c’est aussi ? > user = User . new > user . comments = [ Comment . new ] > user . save > user = > # < User _id : 50 f07c2444fd9947a7000001 , _type : nil > { ’ _id ’: 50 f07c2444fd9947a7000001 , ’ comments ’: [{ ’ _id ’: 50 f 0 7 c 2 4 4 4 f d 9 9 4 7 a 7 0 0 0 0 0 2 }] }
  32. 32. Mongoid Mongoid c’est aussi ? Criteria Model.where Model.asc Model.all in Model.desc Model.any in Model.limit Model.any of Model.only
  33. 33. Mongoid Mongoid c’est aussi ? Les criterias sont chainable
  34. 34. Mongoid Mongoid c’est aussi ? Les criterias sont ´valu´s de e e mani`re lazy e
  35. 35. Mongoid Mongoid c’est aussi ? Finder Model.all Model.first Model.last Model.exists ? Model.find
  36. 36. Mongoid Mongoid c’est aussi ? Moped MongoDB driver d´velopp´ par la communaut´ Mongoid e e e Gestion plus threadsafe par session
  37. 37. Mongoid Mongoid c’est aussi ? Plus d’information ? RTFM http ://mongoid.org
  1. A particular slide catching your eye?

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

×