Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Mongodb With Mongoid

1 844 vues

Publié le

LightTalk in RubyConf Ar

  • Hi there! Get Your Professional Job-Winning Resume Here - Check our website! http://bit.ly/resumpro
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • Soyez le premier à aimer ceci

Mongodb With Mongoid

  1. 1. MongoDB from Mongoid Ing. Marcos Vanetta @malev http://blog.malev.com.ar Three Pillar Global
  2. 2. MongoDB from Mongoid MongoDB : (from "humongous") is a scalable, high-performance, open source, document-oriented database. Mongoid : Mongoid (pronounced mann-goyd) is an Object-Document-Mapper (ODM) for MongoDB written in Ruby.
  3. 3. The philosophy of Mongoid is to provide a familiar API to Ruby developers who have been using Active Record or Data Mapper
  4. 4. class User include Mongoid::Document field :name, :type => String field :email, :type => String #...
  5. 5. class User include Mongoid::Document field :name, :type => String field :email, :type => String field :phone, :type => String #...
  6. 6. class User include Mongoid::Document field :name, :type => String field :email, :type => String field :phone, :type => String field :tags, :type => Array field :info, :type => Hash #...
  7. 7. class User include Mongoid::Document field :name, :type => String field :email, :type => String field :auto_approved, :type => Boolean field :message, :type => String field :phone, :type => String embeds_many :devices
  8. 8. class User include Mongoid::Document field :name, :type => String field :email, :type => String field :auto_approved, :type => Boolean field :message, :type => String field :phone, :type => String embeds_many :devices has_many :cars
  9. 9. @user = User.first @user = User.find(params[:id]) @users = User.where(:phone => “123”) @users = @users .any_of({name: /abc*/i}) @user = User.where({"devices.token"=>”ff”}) @user.devices.where({token: params[:t]}) Person.where(:title.all => ["Sir"]) Person.where(:title.in => ["Sir", "Madam"])
  10. 10. Also has <ul><li>Validations
  11. 11. Callbacks
  12. 12. Index
  13. 13. Scopes
  14. 14. Paranoid
  15. 15. Versioning (not so good)
  16. 16. Timestamps </li></ul>
  17. 17. Migrations http://github.com/adacosta/mongoid_rails_migrations
  18. 18. At first it seems to be a sh*# But it works!
  19. 19. Questions? @malev

×