Skip to content

Instantly share code, notes, and snippets.

@kornysietsma
Created August 9, 2011 05:33
Show Gist options
  • Save kornysietsma/1133465 to your computer and use it in GitHub Desktop.
Save kornysietsma/1133465 to your computer and use it in GitHub Desktop.
Mongo samples - ruby
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