 (defn- keystr [x]
   (if (keyword? x) (name x) (str x)))
 
-(defn- make-attr-list [keyvals]
+(defn- make-attr-list
+  "Given a map of key=>value or key=>[values], return a List of
+  ItemAttribute objects."
+  [keyvals]
   (let [attrs (ArrayList.)]
     (doseq [[k v] keyvals]
       (if (coll? v)

                               query-string))))

(defn select-items
  ([domain-name query-string]
     (select-items domain-name query-string nil))
  ([domain-name query-string next-token]
     (reduce (fn [m [k v]] (assoc m k (parse-attr-list v)))
             {} (.getItems (.selectItems (get-domain domain-name)
                                         query-string next-token)))))

(defn delete-where [domain-name query-string]
  (doseq [item (list-items domain-name query-string)]
    (delete-item domain-name (.getIdentifier item))))

    (.putAttributes item (make-attr-list keyvals))))

(defn get-attrs
  "Returns attributes (a map of key=>item or key=>collection).
  Arguments may be either an Item object by itself or strings naming a
  domain and an item."
  ([item] (parse-attr-list (.getAttributes item)))
  ([domain-name item-name]
     (let [item (get-item domain-name item-name)]
       (parse-attr-list (.getAttributes item)))))

(defn delete-item
  "Delete the item from the domain."
  [domain-name item-name]
  (.deleteItem (get-domain domain-name) (keystr item-name)))

(defn list-items
  "Get the list of Item objects, optionally filtered by a Query
  string."
  ([domain-name]
     (.getItemList (.listItems (get-domain domain-name))))
  ([domain-name query-string]
