Use clojure.core/array-map with ensure-index in all examples
To preserve ordering which is important. References #50
This commit is contained in:
parent
51bb055936
commit
496325a417
3 changed files with 8 additions and 7 deletions
|
|
@ -544,9 +544,10 @@
|
|||
EXAMPLES
|
||||
|
||||
;; create a regular index
|
||||
(monger.collection/ensure-index \"documents\" {\"language\" 1})
|
||||
;; clojure.core/array-map produces an ordered map
|
||||
(monger.collection/ensure-index \"documents\" (array-map \"language\" 1))
|
||||
;; create a unique index
|
||||
(monger.collection/ensure-index \"pages\" {:url 1} {:unique true})
|
||||
(monger.collection/ensure-index \"pages\" (array-map :url 1) {:unique true})
|
||||
"
|
||||
([^String collection ^Map keys]
|
||||
(.ensureIndex (.getCollection monger.core/*mongodb-database* (name collection)) (as-field-selector keys)))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
(deftest ^{:edge-features true :search true} test-basic-full-text-search-query
|
||||
(let [coll "docs"]
|
||||
(mc/ensure-index coll {:subject "text" :content "text"})
|
||||
(mc/ensure-index coll (array-map :subject "text" :content "text"))
|
||||
(mc/insert coll {:subject "hello there" :content "this should be searchable"})
|
||||
(mc/insert coll {:subject "untitled" :content "this is just noize"})
|
||||
(let [res (ms/search coll "hello")
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@
|
|||
(mc/create-index collection ["language"])
|
||||
(mc/drop-index collection "language_1")
|
||||
(is (nil? (second (mc/indexes-on collection))))
|
||||
(mc/ensure-index collection { "language" 1 } {:unique true})
|
||||
(mc/ensure-index collection (array-map "language" 1) {:unique true})
|
||||
(is (= "language_1"
|
||||
(:name (second (mc/indexes-on collection)))))
|
||||
(mc/ensure-index collection { "language" 1 })
|
||||
(mc/ensure-index collection { "language" 1 } { :unique true })
|
||||
(mc/ensure-index collection (array-map "language" 1))
|
||||
(mc/ensure-index collection (array-map "language" 1) { :unique true })
|
||||
(mc/drop-indexes collection)))
|
||||
|
||||
(deftest ^{:indexing true :edge-features true :time-consuming true} test-ttl-collections
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
ttl 30
|
||||
sleep 120]
|
||||
(mc/remove coll)
|
||||
(mc/ensure-index coll {:created-at 1} {:expireAfterSeconds ttl})
|
||||
(mc/ensure-index coll (array-map :created-at 1) {:expireAfterSeconds ttl})
|
||||
(dotimes [i 100]
|
||||
(mc/insert coll {:type "signup" :created-at (-> i secs ago) :i i}))
|
||||
(dotimes [i 100]
|
||||
|
|
|
|||
Loading…
Reference in a new issue