Simplify finders that use document id
This commit is contained in:
parent
5145f45afa
commit
3e6a6fac44
1 changed files with 5 additions and 8 deletions
|
|
@ -92,20 +92,17 @@
|
||||||
|
|
||||||
(defn ^DBObject find-by-id
|
(defn ^DBObject find-by-id
|
||||||
([^String collection, id]
|
([^String collection, id]
|
||||||
(let [#^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)]
|
(find-one collection { :_id id }))
|
||||||
(.findOne coll (to-db-object { :_id id }))))
|
|
||||||
([^String collection, id, ^List fields]
|
([^String collection, id, ^List fields]
|
||||||
(let [#^DBCollection coll (.getCollection monger.core/*mongodb-database* collection)
|
(find-one collection { :_id id } fields)))
|
||||||
map-of-fields (fields-to-db-object fields)]
|
|
||||||
(.findOne #^DBCollection coll #^DBObject (to-db-object { :_id id }) #^DBObject (to-db-object map-of-fields)))))
|
|
||||||
|
|
||||||
(defn ^IPersistentMap find-map-by-id
|
(defn ^IPersistentMap find-map-by-id
|
||||||
([^String collection, id]
|
([^String collection, id]
|
||||||
(from-db-object ^DBObject (find-by-id collection id) true))
|
(from-db-object ^DBObject (find-one-as-map collection { :_id id }) true))
|
||||||
([^String collection, id, keywordize]
|
([^String collection, id, keywordize]
|
||||||
(from-db-object ^DBObject (find-by-id collection id) keywordize))
|
(from-db-object ^DBObject (find-one-as-map collection { :_id id }) keywordize))
|
||||||
([^String collection, id, ^List fields, keywordize]
|
([^String collection, id, ^List fields, keywordize]
|
||||||
(from-db-object ^DBObject (find-by-id collection id fields) keywordize)))
|
(from-db-object ^DBObject (find-one-as-map collection { :_id id } fields) keywordize)))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue