Created
August 9, 2011 05:33
-
-
Save kornysietsma/1133465 to your computer and use it in GitHub Desktop.
Mongo samples - ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db = Mongo::Connection.new.db("camellia") | |
| people = db["people"] | |
| people.insert({ :firstName => "Fred", :lastName => "Bloggs", :ssid => 8675309}) | |
| fred = people.find_one(:firstName => "Fred", :lastName => "Bloggs"); | |
| # or using Mongoid: | |
| class Person | |
| include Mongoid::Document | |
| field :firstName, type: String | |
| # etc | |
| end | |
| Person.where(name: "Fred Bloggs").first do |fred| | |
| # etc | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment