Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
a67f6de06b
32 changed files with 151 additions and 241 deletions
11
.travis.yml
11
.travis.yml
|
|
@ -1,17 +1,20 @@
|
||||||
language: clojure
|
language: clojure
|
||||||
sudo: required
|
sudo: required
|
||||||
lein: lein
|
lein: lein
|
||||||
|
dist: xenial
|
||||||
before_script:
|
before_script:
|
||||||
- ./bin/ci/install_mongodb.sh
|
# Give MongoDB server some time to boot
|
||||||
|
- sleep 15
|
||||||
- mongod --version
|
- mongod --version
|
||||||
- ./bin/ci/before_script.sh
|
- ./bin/ci/before_script.sh
|
||||||
script: lein do clean, javac, test
|
script: lein do clean, javac, test
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- openjdk10
|
||||||
- oraclejdk9
|
- oraclejdk11
|
||||||
|
- openjdk12
|
||||||
services:
|
services:
|
||||||
- mongodb
|
- mongodb
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
- 3.0.x-stable
|
- 3.5.x-stable
|
||||||
|
|
|
||||||
24
ChangeLog.md
24
ChangeLog.md
|
|
@ -1,13 +1,31 @@
|
||||||
## Changes between 3.1.x and 3.2.0 (unreleased)
|
## Changes between 3.5.x and 3.6.0 (unreleased)
|
||||||
|
|
||||||
|
No changes yet.
|
||||||
|
|
||||||
|
|
||||||
|
## Changes between 3.1.x and 3.5.0 (Dec 10th, 2018)
|
||||||
|
|
||||||
### MongoDB Java Driver Update
|
### MongoDB Java Driver Update
|
||||||
|
|
||||||
MongoDB Java driver dependency has been updated to `3.4.x`.
|
MongoDB Java driver dependency has been updated to `3.9.x`.
|
||||||
|
|
||||||
This means that Monger now **requires JDK 7**.
|
This means that Monger now **requires JDK 8**.
|
||||||
|
|
||||||
Contributed by @Linicks.
|
Contributed by @Linicks.
|
||||||
|
|
||||||
|
### 3rd Party Library Compatibility
|
||||||
|
|
||||||
|
* Cheshire `5.8.x`
|
||||||
|
* clj-time `0.15.1`
|
||||||
|
* ring-core `0.15.1`
|
||||||
|
* Ragtime `0.7.x`.
|
||||||
|
|
||||||
|
### URI Connection Usability Improvement
|
||||||
|
|
||||||
|
URIs that don't specify a database will now be rejected as invalid.
|
||||||
|
|
||||||
|
Contributed by Chris Broome.
|
||||||
|
|
||||||
|
|
||||||
## Changes between 3.0.x and 3.1.0 (September 17th, 2016)
|
## Changes between 3.0.x and 3.1.0 (September 17th, 2016)
|
||||||
|
|
||||||
|
|
|
||||||
24
README.md
24
README.md
|
|
@ -2,13 +2,18 @@
|
||||||
[](https://travis-ci.org/xingzhefeng/monger)
|
[](https://travis-ci.org/xingzhefeng/monger)
|
||||||
Monger is an idiomatic [Clojure MongoDB driver](http://clojuremongodb.info) for a more civilized age.
|
Monger is an idiomatic [Clojure MongoDB driver](http://clojuremongodb.info) for a more civilized age.
|
||||||
|
|
||||||
It has batteries included, offers powerful expressive query DSL, strives to support every MongoDB 2.0+ feature and has sane defaults. Monger is built from for modern Clojure versions and sits on top of the official MongoDB Java driver.
|
It has batteries included, offers powerful expressive query DSL,
|
||||||
|
strives to support modern MongoDB features and have the "look and feel" and
|
||||||
|
flexibility of the MongoDB shell.
|
||||||
|
|
||||||
|
Monger is built from for modern Clojure versions and sits on top of
|
||||||
|
the official MongoDB Java driver.
|
||||||
|
|
||||||
|
|
||||||
## Project Goals
|
## Project Goals
|
||||||
|
|
||||||
There is one MongoDB client for Clojure that has been around since 2009. So, why create another one? Monger authors
|
There is one MongoDB client for Clojure that has been around since 2009. So, why create another one? Monger authors
|
||||||
wanted a client that will
|
wanted a client that would
|
||||||
|
|
||||||
* Support most of modern MongoDB features, focus on those that really matter.
|
* Support most of modern MongoDB features, focus on those that really matter.
|
||||||
* Be [well documented](http://clojuremongodb.info).
|
* Be [well documented](http://clojuremongodb.info).
|
||||||
|
|
@ -45,14 +50,14 @@ Maven, add the following repository definition to your `pom.xml`:
|
||||||
|
|
||||||
With Leiningen:
|
With Leiningen:
|
||||||
|
|
||||||
[com.novemberain/monger "3.1.0"]
|
[com.novemberain/monger "3.5.0"]
|
||||||
|
|
||||||
With Maven:
|
With Maven:
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.novemberain</groupId>
|
<groupId>com.novemberain</groupId>
|
||||||
<artifactId>monger</artifactId>
|
<artifactId>monger</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -70,15 +75,13 @@ questions, too!
|
||||||
|
|
||||||
Please see our [documentation guides site](http://clojuremongodb.info/) and [API reference](http://reference.clojuremongodb.info).
|
Please see our [documentation guides site](http://clojuremongodb.info/) and [API reference](http://reference.clojuremongodb.info).
|
||||||
|
|
||||||
Our [test
|
Our [test suite](https://github.com/michaelklishin/monger/tree/master/test/monger/test)
|
||||||
suite](https://github.com/michaelklishin/monger/tree/master/test/monger/test)
|
|
||||||
also has many code examples.
|
also has many code examples.
|
||||||
|
|
||||||
|
|
||||||
## Community
|
## Community
|
||||||
|
|
||||||
[Monger has a mailing
|
[Monger has a mailing list](https://groups.google.com/forum/#!forum/clojure-mongodb). Feel
|
||||||
list](https://groups.google.com/forum/#!forum/clojure-mongodb). Feel
|
|
||||||
free to join it and ask any questions you may have.
|
free to join it and ask any questions you may have.
|
||||||
|
|
||||||
To subscribe for announcements of releases, important changes and so
|
To subscribe for announcements of releases, important changes and so
|
||||||
|
|
@ -88,14 +91,13 @@ on Twitter.
|
||||||
|
|
||||||
## Supported Clojure versions
|
## Supported Clojure versions
|
||||||
|
|
||||||
Monger requires Clojure 1.6+. The most recent
|
Monger requires Clojure 1.8+. The most recent
|
||||||
stable release is highly recommended.
|
stable release is highly recommended.
|
||||||
|
|
||||||
|
|
||||||
## Continuous Integration Status
|
## Continuous Integration Status
|
||||||
|
|
||||||
[](http://travis-ci.org/michaelklishin/monger)
|
[](http://travis-ci.org/michaelklishin/monger)
|
||||||
[](http://jarkeeper.com/michaelklishin/monger)
|
|
||||||
|
|
||||||
|
|
||||||
## Monger Is a ClojureWerkz Project
|
## Monger Is a ClojureWerkz Project
|
||||||
|
|
@ -120,7 +122,7 @@ on Github.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Copyright (C) 2011-2016 [Michael S. Klishin](http://twitter.com/michaelklishin), Alex Petrov, and the ClojureWerkz team.
|
Copyright (C) 2011-2018 [Michael S. Klishin](http://twitter.com/michaelklishin), Alex Petrov, and the ClojureWerkz team.
|
||||||
|
|
||||||
Double licensed under the [Eclipse Public License](http://www.eclipse.org/legal/epl-v10.html) (the same as Clojure) or
|
Double licensed under the [Eclipse Public License](http://www.eclipse.org/legal/epl-v10.html) (the same as Clojure) or
|
||||||
the [Apache Public License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
|
the [Apache Public License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# MongoDB seems to need some time to boot first. MK.
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
# MongoDB Java driver won't run authentication twice on the same DB instance,
|
# MongoDB Java driver won't run authentication twice on the same DB instance,
|
||||||
# so we need to use multiple DBs.
|
# so we need to use multiple DBs.
|
||||||
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"]})' monger-test
|
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"], mechanisms: ["SCRAM-SHA-1"], passwordDigestor: "client"})' monger-test
|
||||||
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"]})' monger-test2
|
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"], mechanisms: ["SCRAM-SHA-1"], passwordDigestor: "client"})' monger-test2
|
||||||
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"]})' monger-test3
|
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"], mechanisms: ["SCRAM-SHA-1"], passwordDigestor: "client"})' monger-test3
|
||||||
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"]})' monger-test4
|
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"], mechanisms: ["SCRAM-SHA-1"], passwordDigestor: "client"})' monger-test4
|
||||||
|
|
|
||||||
11
bin/ci/before_script_server_3.6.x.sh
Executable file
11
bin/ci/before_script_server_3.6.x.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# MongoDB seems to need some time to boot first. MK.
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# MongoDB Java driver won't run authentication twice on the same DB instance,
|
||||||
|
# so we need to use multiple DBs.
|
||||||
|
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"], passwordDigestor: "client"})' monger-test
|
||||||
|
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"], passwordDigestor: "client"})' monger-test2
|
||||||
|
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"], passwordDigestor: "client"})' monger-test3
|
||||||
|
mongo --eval 'db.createUser({"user": "clojurewerkz/monger", "pwd": "monger", roles: ["dbAdmin"], passwordDigestor: "client"})' monger-test4
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
|
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
|
||||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 0C49F3730359A14518585931BC711F9BA15703C6
|
|
||||||
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org.list
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
|
||||||
|
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y mongodb-org
|
sudo apt-get install -y mongodb-org
|
||||||
|
|
|
||||||
43
project.clj
43
project.clj
|
|
@ -1,11 +1,11 @@
|
||||||
(defproject com.novemberain/monger "3.2.0-SNAPSHOT"
|
(defproject com.novemberain/monger "3.6.0-SNAPSHOT"
|
||||||
:description "Monger is a Clojure MongoDB client for a more civilized age: friendly, flexible and with batteries included"
|
:description "Monger is a Clojure MongoDB client for a more civilized age: friendly, flexible and with batteries included"
|
||||||
:url "http://clojuremongodb.info"
|
:url "http://clojuremongodb.info"
|
||||||
:min-lein-version "2.5.1"
|
:min-lein-version "2.5.1"
|
||||||
:license {:name "Eclipse Public License"
|
:license {:name "Eclipse Public License"
|
||||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||||
:dependencies [[org.clojure/clojure "1.8.0"]
|
:dependencies [[org.clojure/clojure "1.9.0"]
|
||||||
[org.mongodb/mongodb-driver "3.6.0-beta2"]
|
[org.mongodb/mongodb-driver "3.9.1"]
|
||||||
[clojurewerkz/support "1.1.0"]]
|
[clojurewerkz/support "1.1.0"]]
|
||||||
:test-selectors {:default (fn [m]
|
:test-selectors {:default (fn [m]
|
||||||
(and (not (:performance m))
|
(and (not (:performance m))
|
||||||
|
|
@ -27,35 +27,32 @@
|
||||||
:all (constantly true)}
|
:all (constantly true)}
|
||||||
:source-paths ["src/clojure"]
|
:source-paths ["src/clojure"]
|
||||||
:java-source-paths ["src/java"]
|
:java-source-paths ["src/java"]
|
||||||
:javac-options ["-target" "1.7" "-source" "1.7"]
|
:javac-options ["-target" "1.8" "-source" "1.8"]
|
||||||
:mailing-list {:name "clojure-mongodb"
|
:mailing-list {:name "clojure-mongodb"
|
||||||
:archive "https://groups.google.com/group/clojure-mongodb"
|
:archive "https://groups.google.com/group/clojure-mongodb"
|
||||||
:post "clojure-mongodb@googlegroups.com"}
|
:post "clojure-mongodb@googlegroups.com"}
|
||||||
:profiles {:dj02x {:dependencies [[org.clojure/data.json "0.2.6" :exclusions [org.clojure/clojure]]]}
|
:profiles {:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
|
||||||
:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
|
:master {:dependencies [[org.clojure/clojure "1.10.0-master-SNAPSHOT"]]}
|
||||||
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
|
|
||||||
:1.9 {:dependencies [[org.clojure/clojure "1.9.0-alpha13"]]}
|
|
||||||
:master {:dependencies [[org.clojure/clojure "1.9.0-master-SNAPSHOT"]]}
|
|
||||||
:dev {:resource-paths ["test/resources"]
|
:dev {:resource-paths ["test/resources"]
|
||||||
:dependencies [[clj-time "0.8.0" :exclusions [org.clojure/clojure]]
|
:dependencies [[clj-time "0.15.1" :exclusions [org.clojure/clojure]]
|
||||||
[cheshire "5.5.0" :exclusions [org.clojure/clojure]]
|
[cheshire "5.8.1" :exclusions [org.clojure/clojure]]
|
||||||
[org.clojure/data.json "0.2.5" :exclusions [org.clojure/clojure]]
|
[org.clojure/data.json "0.2.6" :exclusions [org.clojure/clojure]]
|
||||||
[org.clojure/tools.cli "0.3.1" :exclusions [org.clojure/clojure]]
|
[org.clojure/tools.cli "0.4.1" :exclusions [org.clojure/clojure]]
|
||||||
[org.clojure/core.cache "0.6.3" :exclusions [org.clojure/clojure]]
|
[org.clojure/core.cache "0.7.1" :exclusions [org.clojure/clojure]]
|
||||||
[ring/ring-core "1.3.0" :exclusions [org.clojure/clojure]]
|
[ring/ring-core "1.7.1" :exclusions [org.clojure/clojure]]
|
||||||
[com.novemberain/validateur "2.4.2" :exclusions [org.clojure/clojure]]
|
[com.novemberain/validateur "2.6.0" :exclusions [org.clojure/clojure]]
|
||||||
[ch.qos.logback/logback-classic "1.1.3" :exclusions [org.slf4j/slf4j-api]]
|
[ch.qos.logback/logback-classic "1.2.3" :exclusions [org.slf4j/slf4j-api]]
|
||||||
[ragtime/ragtime.core "0.3.7" :exclusions [org.clojure/clojure]]]
|
[ragtime/core "0.7.2" :exclusions [org.clojure/clojure]]]
|
||||||
:plugins [[lein-codox "0.9.0"]]
|
:plugins [[lein-codox "0.10.5"]]
|
||||||
:codox {:source-paths ["src/clojure"]
|
:codox {:source-paths ["src/clojure"]
|
||||||
:namespaces [#"^monger\.(?!internal)"]}}
|
:namespaces [#"^monger\.(?!internal)"]}}
|
||||||
;; only clj-time/JodaTime available, used to test monger.joda-time w/o clojure.data.json
|
;; only clj-time/JodaTime available, used to test monger.joda-time w/o clojure.data.json
|
||||||
:dev2 {:resource-paths ["test/resources"]
|
:dev2 {:resource-paths ["test/resources"]
|
||||||
:dependencies [[clj-time "0.8.0" :exclusions [org.clojure/clojure]]]}}
|
:dependencies [[clj-time "0.15.1" :exclusions [org.clojure/clojure]]]}}
|
||||||
:aliases {"all" ["with-profile" "dev:dev,1.6:dev,1.8:dev,dj02x"]}
|
:aliases {"all" ["with-profile" "dev:dev,1.8:dev,master"]}
|
||||||
:repositories {"sonatype" {:url "http://oss.sonatype.org/content/repositories/releases"
|
:repositories {"sonatype" {:url "https://oss.sonatype.org/content/repositories/releases"
|
||||||
:snapshots false
|
:snapshots false
|
||||||
:releases {:checksum :fail :update :always}}
|
:releases {:checksum :fail :update :always}}
|
||||||
"sonatype-snapshots" {:url "http://oss.sonatype.org/content/repositories/snapshots"
|
"sonatype-snapshots" {:url "https://oss.sonatype.org/content/repositories/snapshots"
|
||||||
:snapshots true
|
:snapshots true
|
||||||
:releases {:checksum :fail :update :always}}})
|
:releases {:checksum :fail :update :always}}})
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;; Copyright (c) 2012 Toby Hede
|
;; Copyright (c) 2012 Toby Hede
|
||||||
;; Copyright (c) 2012 Baishampayan Ghose
|
;; Copyright (c) 2012 Baishampayan Ghose
|
||||||
;;
|
;;
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; Copyright (c) 2012 Toby Hede
|
;; Copyright (c) 2012 Toby Hede
|
||||||
;; Copyright (c) 2012 Baishampayan Ghose
|
;; Copyright (c) 2012 Baishampayan Ghose
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;; Copyright (c) 2012 Toby Hede
|
;; Copyright (c) 2012 Toby Hede
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; Copyright (c) 2012 Toby Hede
|
;; Copyright (c) 2012 Toby Hede
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Portions of the code are Copyright (c) 2009 Andrew Boekhoff
|
;; Portions of the code are Copyright (c) 2009 Andrew Boekhoff
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Portions of the code are Copyright (c) 2009 Andrew Boekhoff
|
;; Portions of the code are Copyright (c) 2009 Andrew Boekhoff
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
@ -233,10 +233,11 @@
|
||||||
Commonly used for PaaS-based applications, for example, running on Heroku.
|
Commonly used for PaaS-based applications, for example, running on Heroku.
|
||||||
If username and password are provided, performs authentication."
|
If username and password are provided, performs authentication."
|
||||||
[^String uri-string]
|
[^String uri-string]
|
||||||
(let [uri (MongoClientURI. uri-string)
|
(let [uri (MongoClientURI. uri-string)
|
||||||
conn (MongoClient. uri)
|
conn (MongoClient. uri)]
|
||||||
db (.getDB conn (.getDatabase uri))]
|
(if-let [dbName (.getDatabase uri)]
|
||||||
{:conn conn :db db}))
|
{:conn conn :db (.getDB conn dbName)}
|
||||||
|
(throw (IllegalArgumentException. "No database name specified in URI. Monger requires a database to be explicitly configured.")))))
|
||||||
|
|
||||||
(defn ^com.mongodb.CommandResult command
|
(defn ^com.mongodb.CommandResult command
|
||||||
"Runs a database command (please check MongoDB documentation for the complete list of commands).
|
"Runs a database command (please check MongoDB documentation for the complete list of commands).
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;; Copyright (c) 2012 Toby Hede
|
;; Copyright (c) 2012 Toby Hede
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; Copyright (c) 2012 Toby Hede
|
;; Copyright (c) 2012 Toby Hede
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
@ -184,6 +184,9 @@
|
||||||
;; (mgcol/update "docs" { :_id oid } { $push { :tags "modifiers" } })
|
;; (mgcol/update "docs" { :_id oid } { $push { :tags "modifiers" } })
|
||||||
(defoperator $push)
|
(defoperator $push)
|
||||||
|
|
||||||
|
;; $position modifies the behavior of $push per https://docs.mongodb.com/manual/reference/operator/update/position/
|
||||||
|
(defoperator $position)
|
||||||
|
|
||||||
;; $each is a modifier for the $push and $addToSet operators for appending multiple values to an array field.
|
;; $each is a modifier for the $push and $addToSet operators for appending multiple values to an array field.
|
||||||
;; Without the $each modifier $push and $addToSet will append an array as a single value.
|
;; Without the $each modifier $push and $addToSet will append an array as a single value.
|
||||||
;; MongoDB 2.4 adds support for the $each modifier to the $push operator.
|
;; MongoDB 2.4 adds support for the $each modifier to the $push operator.
|
||||||
|
|
@ -193,14 +196,6 @@
|
||||||
;; (mgcol/update coll { :_id oid } { $push { :tags { $each ["mongodb" "docs"] } } })
|
;; (mgcol/update coll { :_id oid } { $push { :tags { $each ["mongodb" "docs"] } } })
|
||||||
(defoperator $each)
|
(defoperator $each)
|
||||||
|
|
||||||
;; $pushAll appends each value in value_array to field, if field is an existing array, otherwise sets field to the array value_array
|
|
||||||
;; if field is not present. If field is present but is not an array, an error condition is raised.
|
|
||||||
;; Deprecated since MongoDB 2.4, $push with $each modifier should be used instead.
|
|
||||||
;;
|
|
||||||
;; EXAMPLES:
|
|
||||||
;; (mgcol/update coll { :_id oid } { $pushAll { :tags ["mongodb" "docs"] } })
|
|
||||||
(defoperator $pushAll)
|
|
||||||
|
|
||||||
;; $addToSet Adds value to the array only if its not in the array already, if field is an existing array, otherwise sets field to the
|
;; $addToSet Adds value to the array only if its not in the array already, if field is an existing array, otherwise sets field to the
|
||||||
;; array value if field is not present. If field is present but is not an array, an error condition is raised.
|
;; array value if field is not present. If field is present but is not an array, an error condition is raised.
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
[monger.conversion :refer :all]
|
[monger.conversion :refer :all]
|
||||||
[monger.operators :refer :all])
|
[monger.operators :refer :all])
|
||||||
(:import [com.mongodb DB DBCollection DBObject DBCursor ReadPreference]
|
(:import [com.mongodb DB DBCollection DBObject DBCursor ReadPreference]
|
||||||
|
[java.util.concurrent TimeUnit]
|
||||||
java.util.List))
|
java.util.List))
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -96,6 +97,7 @@
|
||||||
snapshot
|
snapshot
|
||||||
read-preference
|
read-preference
|
||||||
keywordize-fields
|
keywordize-fields
|
||||||
|
max-time
|
||||||
options]
|
options]
|
||||||
:or { limit 0 batch-size 256 skip 0 } }]
|
:or { limit 0 batch-size 256 skip 0 } }]
|
||||||
(with-open [cursor (doto (.find collection (to-db-object query) (as-field-selector fields))
|
(with-open [cursor (doto (.find collection (to-db-object query) (as-field-selector fields))
|
||||||
|
|
@ -109,6 +111,8 @@
|
||||||
(.hint cursor (to-db-object hint)))
|
(.hint cursor (to-db-object hint)))
|
||||||
(when read-preference
|
(when read-preference
|
||||||
(.setReadPreference cursor read-preference))
|
(.setReadPreference cursor read-preference))
|
||||||
|
(when max-time
|
||||||
|
(.maxTime cursor max-time TimeUnit/MILLISECONDS))
|
||||||
(when options
|
(when options
|
||||||
(add-options cursor options))
|
(add-options cursor options))
|
||||||
(map (fn [x] (from-db-object x keywordize-fields))
|
(map (fn [x] (from-db-object x keywordize-fields))
|
||||||
|
|
@ -154,6 +158,10 @@
|
||||||
[m ^ReadPreference rp]
|
[m ^ReadPreference rp]
|
||||||
(merge m { :read-preference rp }))
|
(merge m { :read-preference rp }))
|
||||||
|
|
||||||
|
(defn max-time
|
||||||
|
[m ^long max-time]
|
||||||
|
(merge m { :max-time max-time }))
|
||||||
|
|
||||||
(defn options
|
(defn options
|
||||||
[m opts]
|
[m opts]
|
||||||
(merge m { :options opts }))
|
(merge m { :options opts }))
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
(ns monger.ragtime
|
(ns monger.ragtime
|
||||||
"Ragtime integration"
|
"Ragtime integration"
|
||||||
(:refer-clojure :exclude [find sort])
|
(:refer-clojure :exclude [find sort])
|
||||||
(:require [ragtime.core :as ragtime]
|
(:require [ragtime.protocols :as proto]
|
||||||
[monger.core :as mg]
|
[monger.core :as mg]
|
||||||
[monger.collection :as mc]
|
[monger.collection :as mc]
|
||||||
[monger.query :refer [with-collection find sort]])
|
[monger.query :refer [with-collection find sort]])
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
|
|
||||||
(extend-type com.mongodb.DB
|
(extend-type com.mongodb.DB
|
||||||
ragtime/Migratable
|
proto/DataStore
|
||||||
(add-migration-id [db id]
|
(add-migration-id [db id]
|
||||||
(mc/insert db migrations-collection {:_id id :created_at (Date.)} WriteConcern/FSYNC_SAFE))
|
(mc/insert db migrations-collection {:_id id :created_at (Date.)} WriteConcern/FSYNC_SAFE))
|
||||||
(remove-migration-id [db id]
|
(remove-migration-id [db id]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
;; The APL v2.0:
|
;; The APL v2.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team
|
||||||
;;
|
;;
|
||||||
;; Licensed under the Apache License, Version 2.0 (the "License");
|
;; Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
;; you may not use this file except in compliance with the License.
|
;; you may not use this file except in compliance with the License.
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
;; The EPL v1.0:
|
;; The EPL v1.0:
|
||||||
;;
|
;;
|
||||||
;; ----------------------------------------------------------------------------------
|
;; ----------------------------------------------------------------------------------
|
||||||
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
;; Copyright (c) 2011-2018 Michael S. Klishin, Alex Petrov, and the ClojureWerkz Team.
|
||||||
;; All rights reserved.
|
;; All rights reserved.
|
||||||
;;
|
;;
|
||||||
;; This program and the accompanying materials are made available under the terms of
|
;; This program and the accompanying materials are made available under the terms of
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,7 @@
|
||||||
|
|
||||||
|
|
||||||
;; this is a common mistake, I leave it here to demonstrate it. You almost never
|
;; this is a common mistake, I leave it here to demonstrate it. You almost never
|
||||||
;; actually want to do this! What you really want is to use $pushAll instead of $push. MK.
|
;; actually want to do this! What you really want is to use $push with $each instead of $push. MK.
|
||||||
(deftest add-array-value-to-an-existing-array-using-$push-modifier
|
(deftest add-array-value-to-an-existing-array-using-$push-modifier
|
||||||
(let [coll "docs"
|
(let [coll "docs"
|
||||||
oid (ObjectId.)
|
oid (ObjectId.)
|
||||||
|
|
@ -228,34 +228,34 @@
|
||||||
(mc/find-map-by-id db coll oid)))))
|
(mc/find-map-by-id db coll oid)))))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; $pushAll
|
;; $push + $each (formerly $pushAll)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(deftest initialize-an-array-using-$pushAll-modifier
|
(deftest initialize-an-array-using-$push-and-$each-modifiers
|
||||||
(let [coll "docs"
|
(let [coll "docs"
|
||||||
oid (ObjectId.)
|
oid (ObjectId.)
|
||||||
title "$pushAll modifier appends multiple values to field"]
|
title "$pushAll modifier appends multiple values to field"]
|
||||||
(mc/insert db coll {:_id oid :title title})
|
(mc/insert db coll {:_id oid :title title})
|
||||||
(mc/update db coll {:_id oid} {$pushAll {:tags ["mongodb" "docs"]}})
|
(mc/update db coll {:_id oid} {$push {:tags {$each ["mongodb" "docs"]}}})
|
||||||
(is (= {:_id oid :title title :tags ["mongodb" "docs"]}
|
(is (= {:_id oid :title title :tags ["mongodb" "docs"]}
|
||||||
(mc/find-map-by-id db coll oid)))))
|
(mc/find-map-by-id db coll oid)))))
|
||||||
|
|
||||||
(deftest add-value-to-an-existing-array-using-$pushAll-modifier
|
(deftest add-value-to-an-existing-array-using-$push-and-$each-modifier
|
||||||
(let [coll "docs"
|
(let [coll "docs"
|
||||||
oid (ObjectId.)
|
oid (ObjectId.)
|
||||||
title "$pushAll modifier appends multiple values to field"]
|
title "$pushAll modifier appends multiple values to field"]
|
||||||
(mc/insert db coll {:_id oid :title title :tags ["mongodb"]})
|
(mc/insert db coll {:_id oid :title title :tags ["mongodb"]})
|
||||||
(mc/update db coll {:_id oid} {$pushAll {:tags ["modifiers" "docs"]}})
|
(mc/update db coll {:_id oid} {$push {:tags {$each ["modifiers" "docs"]}}})
|
||||||
(is (= {:_id oid :title title :tags ["mongodb" "modifiers" "docs"]}
|
(is (= {:_id oid :title title :tags ["mongodb" "modifiers" "docs"]}
|
||||||
(mc/find-map-by-id db coll oid)))))
|
(mc/find-map-by-id db coll oid)))))
|
||||||
|
|
||||||
|
|
||||||
(deftest double-add-value-to-an-existing-array-using-$pushAll-modifier
|
(deftest double-add-value-to-an-existing-array-using-$push-and-$each-modifier
|
||||||
(let [coll "docs"
|
(let [coll "docs"
|
||||||
oid (ObjectId.)
|
oid (ObjectId.)
|
||||||
title "$pushAll modifier appends multiple values to field"]
|
title "$pushAll modifier appends multiple values to field"]
|
||||||
(mc/insert db coll {:_id oid :title title :tags ["mongodb" "docs"]})
|
(mc/insert db coll {:_id oid :title title :tags ["mongodb" "docs"]})
|
||||||
(mc/update db coll {:_id oid} {$pushAll {:tags ["modifiers" "docs"]}})
|
(mc/update db coll {:_id oid} {$push {:tags {$each ["modifiers" "docs"]}}})
|
||||||
(is (= {:_id oid :title title :tags ["mongodb" "docs" "modifiers" "docs"]}
|
(is (= {:_id oid :title title :tags ["mongodb" "docs" "modifiers" "docs"]}
|
||||||
(mc/find-map-by-id db coll oid)))))
|
(mc/find-map-by-id db coll oid)))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
(is (-> conn .getAddress (.sameHost "127.0.0.1")))))
|
(is (-> conn .getAddress (.sameHost "127.0.0.1")))))
|
||||||
|
|
||||||
(deftest ^{:authentication true} connect-to-mongo-via-uri-with-valid-credentials
|
(deftest ^{:authentication true} connect-to-mongo-via-uri-with-valid-credentials
|
||||||
(let [{:keys [conn db]} (mg/connect-via-uri "mongodb://clojurewerkz/monger:monger@127.0.0.1/monger-test4")]
|
(let [{:keys [conn db]} (mg/connect-via-uri "mongodb://clojurewerkz%2Fmonger:monger@127.0.0.1/monger-test4")]
|
||||||
(is (= "monger-test4" (.getName db)))
|
(is (= "monger-test4" (.getName db)))
|
||||||
(is (-> conn .getAddress (.sameHost "127.0.0.1")))
|
(is (-> conn .getAddress (.sameHost "127.0.0.1")))
|
||||||
(mc/remove db "documents")
|
(mc/remove db "documents")
|
||||||
|
|
|
||||||
|
|
@ -1,126 +0,0 @@
|
||||||
(ns monger.test.cache-test
|
|
||||||
(:require [monger.core :as mg]
|
|
||||||
[monger.collection :as mc]
|
|
||||||
[clojure.core.cache :refer :all]
|
|
||||||
[clojure.test :refer :all]
|
|
||||||
[monger.cache :refer :all])
|
|
||||||
(:import [clojure.core.cache BasicCache FIFOCache LRUCache TTLCache]
|
|
||||||
java.util.UUID))
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Playground/Tests. These were necessary because clojure.core.cache has
|
|
||||||
;; little documentation, incomplete test suite and
|
|
||||||
;; slightly non-standard (although necessary to support all those cache variations)
|
|
||||||
;; cache operations protocol.
|
|
||||||
;;
|
|
||||||
;; This is by no means clear or complete either but it did the job of helping me
|
|
||||||
;; explore the API.
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-has?-with-basic-cache
|
|
||||||
(testing "that has? returns false for misses"
|
|
||||||
(let [c (BasicCache. {})]
|
|
||||||
(are [v] (is (false? (has? c v)))
|
|
||||||
:missing-key
|
|
||||||
"missing-key"
|
|
||||||
(gensym "missing-key"))))
|
|
||||||
(testing "that has? returns true for hits"
|
|
||||||
(let [c (BasicCache. {:skey "Value" :lkey (Long/valueOf 10000) "kkey" :keyword})]
|
|
||||||
(are [v] (is (has? c v))
|
|
||||||
:skey
|
|
||||||
:lkey
|
|
||||||
"kkey"))))
|
|
||||||
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-lookup-with-basic-cache
|
|
||||||
(testing "that lookup returns nil for misses"
|
|
||||||
(let [c (BasicCache. {})]
|
|
||||||
(are [v] (is (nil? (lookup c v)))
|
|
||||||
:missing-key
|
|
||||||
"missing-key"
|
|
||||||
(gensym "missing-key"))))
|
|
||||||
(testing "that lookup returns cached values for hits"
|
|
||||||
(let [l (Long/valueOf 10000)
|
|
||||||
c (BasicCache. {:skey "Value" :lkey l "kkey" :keyword})]
|
|
||||||
(are [v k] (is (= v (lookup c k)))
|
|
||||||
"Value" :skey
|
|
||||||
l :lkey
|
|
||||||
:keyword "kkey"))))
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-evict-with-basic-cache
|
|
||||||
(testing "that evict has no effect for keys that do not exist"
|
|
||||||
(let [c (atom (BasicCache. {:a 1 :b 2}))]
|
|
||||||
(swap! c evict :missing-key)
|
|
||||||
(is (has? @c :a))
|
|
||||||
(is (has? @c :b))))
|
|
||||||
(testing "that evict removes keys that did exist"
|
|
||||||
(let [c (atom (BasicCache. {:skey "Value" "kkey" :keyword}))]
|
|
||||||
(is (has? @c :skey))
|
|
||||||
(is (= "Value" (lookup @c :skey)))
|
|
||||||
(swap! c evict :skey)
|
|
||||||
(is (not (has? @c :skey)))
|
|
||||||
(is (= nil (lookup @c :skey)))
|
|
||||||
(is (has? @c "kkey"))
|
|
||||||
(is (= :keyword (lookup @c "kkey"))))))
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-seed-with-basic-cache
|
|
||||||
(testing "that seed returns a new value"
|
|
||||||
(let [c (atom (BasicCache. {}))]
|
|
||||||
(swap! c seed {:a 1 :b "b" "c" :d})
|
|
||||||
(are [k v] (do
|
|
||||||
(is (has? @c k))
|
|
||||||
(is (= v (lookup @c k))))
|
|
||||||
:a 1
|
|
||||||
:b "b"
|
|
||||||
"c" :d))))
|
|
||||||
|
|
||||||
|
|
||||||
;;
|
|
||||||
;; Tests
|
|
||||||
;;
|
|
||||||
|
|
||||||
(let [conn (mg/connect)
|
|
||||||
db (mg/get-db conn "monger-test")]
|
|
||||||
(use-fixtures :each (fn [f]
|
|
||||||
(mc/remove db "basic_monger_cache_entries")
|
|
||||||
(f)
|
|
||||||
(mc/remove db "basic_monger_cache_entries")))
|
|
||||||
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-has?-with-basic-monger-cache
|
|
||||||
(testing "that has? returns false for misses"
|
|
||||||
(let [coll "basic_monger_cache_entries"
|
|
||||||
c (basic-monger-cache-factory db coll)]
|
|
||||||
(is (not (has? c (str (UUID/randomUUID)))))
|
|
||||||
(is (not (has? c (str (UUID/randomUUID)))))))
|
|
||||||
(testing "that has? returns true for hits"
|
|
||||||
(let [coll "basic_monger_cache_entries"
|
|
||||||
c (basic-monger-cache-factory db coll {"a" 1 "b" "cache" "c" 3/4})]
|
|
||||||
(is (has? c "a"))
|
|
||||||
(is (has? c "b"))
|
|
||||||
(is (has? c "c"))
|
|
||||||
(is (not (has? c "d"))))))
|
|
||||||
|
|
||||||
|
|
||||||
(deftest ^{:cache true}
|
|
||||||
test-lookup-with-basic-monger-cache
|
|
||||||
(testing "that lookup returns nil for misses"
|
|
||||||
(let [coll "basic_monger_cache_entries"
|
|
||||||
c (basic-monger-cache-factory db coll)]
|
|
||||||
(are [v] (is (nil? (lookup c v)))
|
|
||||||
:missing-key
|
|
||||||
"missing-key"
|
|
||||||
(gensym "missing-key"))))
|
|
||||||
(testing "that lookup returns cached values for hits"
|
|
||||||
(let [l (Long/valueOf 10000)
|
|
||||||
coll "basic_monger_cache_entries"
|
|
||||||
c (basic-monger-cache-factory db coll {:skey "Value" :lkey l "kkey" :keyword})]
|
|
||||||
(are [v k] (is (= v (lookup c k)))
|
|
||||||
"Value" :skey
|
|
||||||
l :lkey
|
|
||||||
"keyword" "kkey")))))
|
|
||||||
|
|
||||||
|
|
@ -70,3 +70,7 @@
|
||||||
:cursor-finalizer-enabled true
|
:cursor-finalizer-enabled true
|
||||||
:required-replica-set-name "rs"}]
|
:required-replica-set-name "rs"}]
|
||||||
(is (instance? com.mongodb.MongoClientOptions$Builder (mg/mongo-options-builder opts)))))
|
(is (instance? com.mongodb.MongoClientOptions$Builder (mg/mongo-options-builder opts)))))
|
||||||
|
|
||||||
|
(deftest connect-to-uri-without-db-name
|
||||||
|
(let [uri "mongodb://localhost:27017"]
|
||||||
|
(is (thrown? IllegalArgumentException (mg/connect-via-uri uri)))))
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
(:require [monger.core :as mg]
|
(:require [monger.core :as mg]
|
||||||
[monger.collection :as mc]
|
[monger.collection :as mc]
|
||||||
monger.ragtime
|
monger.ragtime
|
||||||
[ragtime.core :refer :all]
|
[ragtime.protocols :refer :all]
|
||||||
[clojure.test :refer :all]))
|
[clojure.test :refer :all]))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue