examples/keys.rb in mongo_mapper-0.8.2 vs examples/keys.rb in mongo_mapper-0.8.3
- old
+ new
@@ -11,27 +11,30 @@
key :last_name, String, :required => true
key :token, String, :default => lambda { 'some random string' }
key :age, Integer
key :skills, Array
key :friend_ids, Array, :typecast => 'ObjectId'
+ key :links, Hash
timestamps!
end
User.collection.remove # empties collection
john = User.create({
:first_name => 'John',
:last_name => 'Nunemaker',
:age => 28,
:skills => ['ruby', 'mongo', 'javascript'],
+ :links => {"Google" => "http://www.google.com"}
})
steve = User.create({
:first_name => 'Steve',
:last_name => 'Smith',
:age => 29,
:skills => ['html', 'css', 'javascript', 'design'],
})
john.friend_ids << steve.id.to_s # will get typecast to ObjectId
+john.links["Ruby on Rails"] = "http://www.rubyonrails.com"
john.save
pp john
\ No newline at end of file