Skip to content

Instantly share code, notes, and snippets.

@fahimbabarpatel
Created March 10, 2016 17:17
Show Gist options
  • Save fahimbabarpatel/d490bd8d0a0e04ba21f2 to your computer and use it in GitHub Desktop.
Save fahimbabarpatel/d490bd8d0a0e04ba21f2 to your computer and use it in GitHub Desktop.
ruby_mongoid_setup
# mongoid.yml
development:
  clients:
    default:
      database: test
      hosts:
        - localhost:27017


require "mongoid"
Mongoid.load!("mongoid.yml", :development)

class User
  include Mongoid::Document
  field :f_name
  field :l_name
  store_in collection: "user", database: "test"
end

User.count
YOU CAN FIND MORE queries explaintions https://docs.mongodb.org/ecosystem/tutorial/mongoid-queries/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment