diff --git a/README.md b/README.md index 4463f05..58da60a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ For Leinengen, add this to your project.clj: ```clojure ;; The underlying driver -- any newer version can also be used -[org.mongodb/mongodb-driver-sync "4.7.1"] +[org.mongodb/mongodb-driver-sync "4.11.1"] ;; This wrapper library [mongo-driver-3 "0.7.0"] @@ -104,6 +104,10 @@ As an example: ;; Find a single document or return nil (mc/find-one db "test" {:v "world"} {:keywordize? false}) ; => {"v" "world"} + +;; Avoid laziness in queries +(mc/find db "test" {} {:realise-fn (partial into [])} +; => [...] ``` While most options are supported directly, sometimes you may need to some extra control. @@ -181,6 +185,13 @@ use `with-open` so the session is closed after both successful and failed transa (mc/insert-one my-db "coll" {:name "world"}))) ``` +## Development + +1. Run mongo (e.g. via docker): + - `docker run -it --rm -p 27017:27017 mongo` +2. Run tests + - `lein test` + ## License Released under the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/test/mongo_driver_3/collection_test.clj b/test/mongo_driver_3/collection_test.clj index 9ad419a..18c357d 100644 --- a/test/mongo_driver_3/collection_test.clj +++ b/test/mongo_driver_3/collection_test.clj @@ -144,7 +144,11 @@ (is (instance? FindIterable (mc/find db "test" {} {:raw? true})))) (testing "keywordize" - (is (= [{"id" 1}] (mc/find db "test" {} {:keywordize? false :projection {:_id 0 :id 1} :limit 1})))))) + (is (= [{"id" 1}] (mc/find db "test" {} {:keywordize? false :projection {:_id 0 :id 1} :limit 1})))) + + (testing "realise-fn" + (is (seq? (mc/find db "test" {}))) + (is (vector? (mc/find db "test" {} {:realise-fn (partial into [])})))))) (deftest ^:integration test-find-one (let [db (new-db @client) @@ -382,7 +386,11 @@ (deftest ^:integration test-list-indexes (let [db (new-db @client) _ (mc/create db "test")] - (is (= 1 (count (mc/list-indexes db "test"))) "has default index"))) + (is (= 1 (count (mc/list-indexes db "test"))) "has default index") + + (testing "realise-fn" + (is (seq? (mc/list-indexes db "test"))) + (is (vector? (mc/list-indexes db "test" {:realise-fn (partial into [])})))))) (deftest ^:integration test-create-index (let [db (new-db @client)