Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Document the options hash that can be passed to all modifier methods #416

Merged
merged 1 commit into from

2 participants

@balexand

No description provided.

@brianhempel brianhempel merged commit ae62bfe into mongomapper:gh-pages
@brianhempel brianhempel referenced this pull request from a commit in brianhempel/mongomapper
@brianhempel brianhempel Allow passing update options for set and unset modifiers as documente…
…d in #416
e582032
@brianhempel

@balexand Okay, got that in the docs after tidying it up to match the other examples. MongoMapper's code needed a bit of work to make the docs correct though, so that's in master now as well.

http://mongomapper.com/documentation/plugins/modifiers.html#options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 0 deletions.
  1. +10 −0 documentation/plugins/modifiers.textile
View
10 documentation/plugins/modifiers.textile
@@ -141,6 +141,16 @@ Page.pop(@page.id, @page2.id, :tags => 1)
Note that if you pass *-1*, it will remove the *first element* from the array.
+h2(#options). Options
+
+An options hash can be passed as the final argument. These options will be passed to the Ruby driver's "update method":http://api.mongodb.org/ruby/current/Mongo/Collection.html#update-instance_method. For example, to do an upsert:
+
+{% highlight ruby %}
+HitCount.increment({:path => "/about"}, {:count => 1}, :upsert => true)
+{% endhighlight %}
+
+Please note that MongoMapper always sets the @:multi@ option to @true@. This cannot be overridden.
+
h2(#notes). Notes
When applying a modifier operation on a variable (local or instance), make sure to reload the variable. MongoMapper does not update the state of the variable unless you explicitly tell it to like so:
Something went wrong with that request. Please try again.