Skip to content

Commit

Permalink
Merge pull request #23 from Ephemera/patch-1
Browse files Browse the repository at this point in the history
Fix missing `conn` parameter
  • Loading branch information
michaelklishin committed Jan 18, 2017
2 parents 035ce1a + a8b7e4d commit f289233
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions articles/collections.md
Expand Up @@ -56,7 +56,7 @@ To create an index on a collection, use `monger.collection/ensure-index`. It wil
[monger.collection :as mc]))

(let [conn (mg/connect)
db (mg/get-db "monger-test")
db (mg/get-db conn "monger-test")
coll "documents"]
;; create an index
;; the index created as { :language 1 } will be named "language_1"
Expand Down Expand Up @@ -94,7 +94,7 @@ To drop an index or all indexes on a collection, use
[monger.collection :as mc]))

(let [conn (mg/connect)
db (mg/get-db "monger-test")]
db (mg/get-db conn "monger-test")]
;; drop all indexes from a collection
(mc/drop-indexes db "events")

Expand All @@ -118,7 +118,7 @@ function like so:
[monger.collection :as mc]))

(let [conn (mg/connect)
db (mg/get-db "monger-test")]
db (mg/get-db conn "monger-test")]
(mc/create db "recent_events" {}))
```

Expand Down Expand Up @@ -153,7 +153,7 @@ To create a collection as capped, use the same
(* n 1024 1024))

(let [conn (mg/connect)
db (mg/get-db "monger-test")]
db (mg/get-db conn "monger-test")]

;; creates a collection capped at 16 megabytes
(mc/create db "recent_events" {:capped true :size (-> 16 megabytes)})
Expand All @@ -178,7 +178,7 @@ field with the `:expireAfterSeconds` option:
[monger.collection :as mc]))

(let [conn (mg/connect)
db (mg/get-db "monger-test")]
db (mg/get-db conn "monger-test")]
;; expire documents with the `created-at` field value 120 seconds or more in the past.
;; expiration operation is performed about once a minute
(mc/ensure-index db "recent_events" {:created-at 1} {:expireAfterSeconds 120})
Expand Down
16 changes: 8 additions & 8 deletions articles/querying.md
Expand Up @@ -551,7 +551,7 @@ necessary to map (`clojure.core/map`) with
[monger.conversion :refer [from-db-object]])

(let [conn (mg/connect)
db (mg/get-db "monger-test")
db (mg/get-db conn "monger-test")
coll "posts"]
;; get distinct values from the posts collection for the field category.
(mc/distinct db coll "category")
Expand Down Expand Up @@ -592,7 +592,7 @@ Sorting documents are specified exactly as they are in the MongoDB shell (1 for
[monger.query :refer :all]))

(let [conn (mg/connect)
db (mg/get-db "monger-test")
db (mg/get-db conn "monger-test")
coll "scores"]
;; find top 10 scores that will be returned as Clojure maps
(with-collection db coll
Expand Down Expand Up @@ -631,7 +631,7 @@ common that Monger provides a DSL extension for that:
[monger.query :refer :all]))

(let [conn (mg/connect)
db (mg/get-db "monger-test")
db (mg/get-db conn "monger-test")
coll "scores"]
;; find top 10 scores
(with-collection db coll
Expand Down Expand Up @@ -665,7 +665,7 @@ slightly out of date data to be returned):
(:import com.mongodb.ReadPreference))

(let [conn (mg/connect)
db (mg/get-db "monger-test")
db (mg/get-db conn "monger-test")
coll "scores"]
;; reads from primary (master) to guarantee consistency
;; (at the cost of putting extra load on the primary)
Expand Down Expand Up @@ -709,7 +709,7 @@ Here is how to snapshot a cursor with Monger query DSL:
[monger.query :refer :all]))

(let [conn (mg/connect)
db (mg/get-db "monger-test")
db (mg/get-db conn "monger-test")
coll "documents"]
;; performs a snapshotted query
(with-collection db coll
Expand All @@ -730,7 +730,7 @@ While not necessary in most cases, it is possible to force query to use the give
[monger.operators :refer [$gt $lt]])))

(let [conn (mg/connect)
db (mg/get-db "monger-test")]
db (mg/get-db conn "monger-test")]
(with-collection db coll
(find {:age_in_days {$gt 365} :number_of_signins {$lt 3}})
(sort {:age_in_days -1 :number_of_signins 1})
Expand All @@ -756,7 +756,7 @@ number of documents returned by the server:
[monger.operators :refer [$gt]])))

(let [conn (mg/connect)
db (mg/get-db "monger-test")]
db (mg/get-db conn "monger-test")]
(with-collection db coll
(find {:age_in_days {$gt 365}})
(sort {:age_in_days -1})
Expand All @@ -778,7 +778,7 @@ need to send a request to close the cursor server-side.
Use `monger.collection/count`, `monger.collection/empty?` and `monger.collection/any?`:

(let [conn (mg/connect)
db (mg/get-db "monger-test")
db (mg/get-db conn "monger-test")
coll "documents"]
(mc/any? db coll)
;= false
Expand Down

0 comments on commit f289233

Please sign in to comment.