From 21119e80db4739e67cc097c3ba89c7ab164d1b86 Mon Sep 17 00:00:00 2001 From: "Michael S. Klishin" Date: Wed, 31 Aug 2011 16:49:35 +0400 Subject: [PATCH] Add utility function that generates BSON object ids --- src/monger/collection.clj | 1 + src/monger/util.clj | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/monger/collection.clj b/src/monger/collection.clj index 2cbae45..0bd9e57 100644 --- a/src/monger/collection.clj +++ b/src/monger/collection.clj @@ -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 diff --git a/src/monger/util.clj b/src/monger/util.clj index 1588353..4d5cf18 100644 --- a/src/monger/util.clj +++ b/src/monger/util.clj @@ -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.