0
如何在Monger中使用find-maps時設置ReadPreference?該蒙格文件只規定如這樣做是設置讀取偏好,同時連接到蒙戈以下在Clojure MongoDb驅動程序Monger中設置ReadPreference
(ns my.service.server
(:refer-clojure :exclude [sort find])
(:require [monger.core :as mg]
[monger.query :refer :all])
(:import com.mongodb.ReadPreference))
(let [conn (mg/connect)
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)
(with-collection db coll
(find {:email "[email protected]"})
(read-preference (ReadPreference/primary))))