Skip to content

Commit

Permalink
Merge pull request #11 from strika/master
Browse files Browse the repository at this point in the history
Fix upsert docs
  • Loading branch information
michaelklishin committed Mar 9, 2014
2 parents 4aa3607 + 400509b commit e2bd82b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions articles/updating.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ MongoDB supports upserts, "update or insert" operations. To do an upsert with Mo

``` clojure
(ns my.service
(:require [monger.collection :as mc]))
(:require [monger.collection :as mc]
[monger.operators :refer :all]))

;; updates score for player "sam" if it exists; creates a new document otherwise
(mc/update "scores" {:player "sam"} {:score 1088} :upsert true)
(mc/update "scores" {:player "sam"} {$set {:score 1088}} :upsert true)
```

Note that upsert only inserts one document. Learn more about upserts
Expand Down

0 comments on commit e2bd82b

Please sign in to comment.