Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Updated readme about atomic updates.

  • Loading branch information...
commit 13c813fbe1c2dd213af1ecb293eb30961b244aa6 1 parent f70b91c
@jnunemaker authored
Showing with 21 additions and 1 deletion.
  1. +21 −1
@@ -25,7 +25,27 @@ Including Toy::Mongo includes Toy::Store and then does a few things:
* Sets the key factory to object id
* Overrides get so that it also works with string representation of object id
* Overrides get_multi so that it performs one query instead of one query per id
-* Adds instance method atomic_update_attributes for persisting only the changes (see #persistable_changes)
+### Atomic Updates
+class User
+ include Toy::Mongo
+ include Toy::Mongo::AtomicUpdates
+ adapter :mongo_atomic,'adapter')['testing']
+ attribute :name, String
+ attribute :bio, String
+user = User.create(:name => 'John', :bio => 'Awesome!') = 'Nunes' # Equivalent to update({:_id =>}, {'$set' => {'name' => 'Nunes'}})
+Caveat: At this time it only works with simple data types. Complex types like Hash, Array, and Set are not supported. Oddness will ensue if you expect them to work as they can be manipuled through means other than assignment.
## Contributing
Please sign in to comment.
Something went wrong with that request. Please try again.