Added get-write-concern function.
This commit is contained in:
parent
14508e11ba
commit
611d9666bd
2 changed files with 31 additions and 1 deletions
|
|
@ -164,3 +164,25 @@
|
|||
DBCursor
|
||||
(count [^com.mongodb.DBCursor this]
|
||||
(.count this)))
|
||||
|
||||
(defn ^DBObject get-last-error
|
||||
"Returns the the error (if there is one) from the previous operation on this connection.
|
||||
|
||||
The result of this command looks like:
|
||||
|
||||
#<CommandResult { \"serverUsed\" : \"127.0.0.1:27017\" , \"n\" : 0 , \"connectionId\" : 66 , \"err\" : null , \"ok\" : 1.0}>\"
|
||||
|
||||
The value for err will be null if no error occurred, or a description otherwise.
|
||||
|
||||
Important note: when calling this method directly, it is undefined which connection \"getLastError\" is called on.
|
||||
You may need to explicitly use a \"consistent Request\", see requestStart() For most purposes it is better not to call this method directly but instead use WriteConcern."
|
||||
([]
|
||||
(.getLastError ^DB *mongodb-database*))
|
||||
([^DB database]
|
||||
(.getLastError ^DB database))
|
||||
([^DB database ^Integer w ^Integer wtimeout ^Boolean fsync]
|
||||
(.getLastError ^DB database w wtimeout fsync))
|
||||
([^DB database ^WriteConcern write-concern]
|
||||
(.getLastError ^DB database write-concern)))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
(ns monger.test.core
|
||||
(:require [monger core collection util result])
|
||||
(:import (com.mongodb Mongo DB))
|
||||
(:import (com.mongodb Mongo DB WriteConcern))
|
||||
(:use [clojure.test]))
|
||||
|
||||
|
||||
|
|
@ -42,3 +42,11 @@
|
|||
{ :collstats "things" :scale (* 1024 1024) }
|
||||
{ :getLastError 1 }]]
|
||||
(is (monger.result/ok? (monger.core/command c))))))
|
||||
|
||||
(deftest get-last-error
|
||||
(let [connection (monger.core/connect)
|
||||
db (monger.core/get-db connection "monger-test")]
|
||||
(is (monger.result/ok? (monger.core/get-last-error)))
|
||||
(is (monger.result/ok? (monger.core/get-last-error db)))
|
||||
(is (monger.result/ok? (monger.core/get-last-error db WriteConcern/NORMAL)))
|
||||
(is (monger.result/ok? (monger.core/get-last-error db 1 100 true)))))
|
||||
Loading…
Reference in a new issue