Add utility function that generates BSON object ids
This commit is contained in:
parent
e5d5b0b248
commit
21119e80db
2 changed files with 6 additions and 1 deletions
|
|
@ -101,6 +101,7 @@
|
|||
(let [^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)]
|
||||
(.count coll (to-db-object conditions)))))
|
||||
|
||||
|
||||
;; monger.collection/update
|
||||
|
||||
(defn ^WriteResult update
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns monger.util
|
||||
(:import (java.security SecureRandom) (java.math BigInteger)))
|
||||
(:import (java.security SecureRandom) (java.math BigInteger) (org.bson.types ObjectId)))
|
||||
|
||||
;;
|
||||
;; API
|
||||
|
|
@ -24,6 +24,10 @@
|
|||
[^long n, ^long num-base]
|
||||
(.toString (new BigInteger n (SecureRandom.)) num-base))
|
||||
|
||||
(defn ^ObjectId object-id
|
||||
"Returns a new BSON object id"
|
||||
[]
|
||||
(ObjectId.))
|
||||
|
||||
(defmacro with-ns
|
||||
"Evaluates body in another namespace. ns is either a namespace object or a symbol.
|
||||
|
|
|
|||
Loading…
Reference in a new issue