Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Type-hint arguments.

  • Loading branch information...
commit a581860d657c9dcef3d2ede7902a1eba54d588e3 1 parent e82966b
John Hume authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/appengine_clj/datastore.clj
11 src/appengine_clj/datastore.clj
View
@@ -1,18 +1,23 @@
(ns appengine-clj.datastore
- (:import (com.google.appengine.api.datastore DatastoreServiceFactory)))
+ (:import (com.google.appengine.api.datastore
+ DatastoreServiceFactory
+ Entity
+ Query)))
(defn entity-to-map
"Converts an instance of com.google.appengine.api.datastore.Entity
to a PersistentHashMap with properties stored under keyword keys,
plus the entity's kind stored under :kind and key stored under :key."
- [entity]
+ [#^Entity entity]
(reduce #(assoc %1 (keyword (key %2)) (val %2))
{:kind (.getKind entity) :key (.getKey entity)}
(.entrySet (.getProperties entity))))
(defn find-all
- [query]
+ "Executes the given com.google.appengine.api.datastore.Query
+ and returns the results as a lazy sequence of items converted with entity-to-map."
+ [#^Query query]
(let [data-service (DatastoreServiceFactory/getDatastoreService)
results (.asIterable (.prepare data-service query))]
(map entity-to-map results)))
Please sign in to comment.
Something went wrong with that request. Please try again.