         int-imap))
     imap imap))
 
-(defn- q-insert [db {:keys [record]}]
-  (assert record)
-  (let [id   (:id record)
-        {old-rmap :rmap old-imap :imap} db]
-    (assert id)
-    (assert (not (contains? old-rmap id)))
-    (let [new-rmap (assoc old-rmap id record)
-          new-imap (indexes-insert old-imap record)]
-      (assoc db :rmap new-rmap :imap new-imap))))
+(defn- q-insert [db {:keys [records]}]
+  (let [{old-rmap :rmap old-imap :imap} db
+        [new-rmap new-imap]
+          (reduce
+            (fn [[int-rmap int-imap] record]
+              (let [id (:id record)]
+                (assert id)
+                (assert (not (contains? int-rmap id)))
+                [(assoc int-rmap id record)
+                 (indexes-insert int-imap record)]))
+            [old-rmap old-imap]
+            records)]
+    [(assoc db :rmap new-rmap :imap new-imap) (count records)]))
 
 (def- conj-op?
   #{:and :or})

      (sorted-map)
      (vals (:rmap db)))))

(def- query-fns
  {:select q-select
   :count  q-count
   :insert q-insert
   :update q-update
   :delete q-delete
   :index  q-index})

(defn exec [db [query-type opts]]
  (if-let [queryfn (query-fns query-type)]

    (nil? op)
      (constantly true)
    :else
      (raise (str "where op " op " not recognized"))))

(defn- order-keyfn [attr dir]
  (assert (#{:asc :dsc} dir))
