Fetching contributors…
Cannot retrieve contributors at this time
44 lines (33 sloc) 1.73 KB
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and The ClojureWerkz
;; Team
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
"Batch operation execution"
(:require [ :as rest]
[ :as rec]
[cheshire.core :as json])
;; API
(defn perform
"Submits a batch of operations for execution, returning a lazy sequence of results. Operations must include
two keys:
:method (\"POST\", \"GET\", etc)
:to (a path relative to the database root URI)
and may or may not include
:data (a map of what would be in the request body in cases non-batch API was used)
:id (request id that is used to refer to previously executed operations in the same batch)
If you need to insert a batch of nodes at once, consider using
See for more information."
[^Connection connection ops]
(let [{:keys [status headers body]} (rest/POST connection (get-in connection [:endpoint :batch-uri])
:body (json/encode ops))
payload (map :body (json/decode body true))]
(map rec/instantiate-record-from payload)))