diff --git a/src/monger/core.clj b/src/monger/core.clj index 249213e..586cdd9 100644 --- a/src/monger/core.clj +++ b/src/monger/core.clj @@ -26,7 +26,7 @@ (declare ^:dynamic ^Mongo *mongodb-connection*) (declare ^:dynamic ^DB *mongodb-database*) -(def ^:dynamic ^WriteConcern *mongodb-write-concern* WriteConcern/NORMAL) +(def ^:dynamic ^WriteConcern *mongodb-write-concern* WriteConcern/SAFE) ;; @@ -84,6 +84,11 @@ (def ^:dynamic *mongodb-database* db)) +(defn set-write-concern! + [wc] + (def ^:dynamic *mongodb-write-concern* wc)) + + (defprotocol Countable (count [this] "Returns size of the object")) diff --git a/test/monger/test/collection.clj b/test/monger/test/collection.clj index 88daa1e..14ac6cf 100644 --- a/test/monger/test/collection.clj +++ b/test/monger/test/collection.clj @@ -44,6 +44,7 @@ (use-fixtures :each purge-people-collection purge-docs-collection purge-things-collection purge-libraries-collection) +(monger.core/set-write-concern! WriteConcern/SAFE) ;; ;; insert diff --git a/test/monger/test/stress.clj b/test/monger/test/stress.clj index 5fc37dc..09f77a8 100644 --- a/test/monger/test/stress.clj +++ b/test/monger/test/stress.clj @@ -27,6 +27,8 @@ ;; Tests ;; +(monger.core/set-write-concern! WriteConcern/NORMAL) + (deftest insert-large-batches-of-documents-without-object-ids (doseq [n [1000 10000 100000]] (let [collection "things"