Mongodb With Mongoid

1,692 views
1,560 views

Published on

LightTalk in RubyConf Ar

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,692
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

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

×