Public Vars

Back

as-> (clj)

(source)

macro

(as-> expr name & forms)
Binds name to expr, evaluates the first form in the lexical context of that binding, then binds name to that result, repeating for each successive form, returning the result of the last form.

Examples

fluree/ledger
(ns fluree.db.ledger.general.todo-permissions
  (:require [clojure.test :refer :all]
            [clojure.core.async :as async]
            [clojure.string :as str]
            [fluree.db.test-helpers :as test]
            [fluree.db.ledger.docs.getting-started.basic-schema :as basic]
            [fluree.db.api :as fdb])
  (:import (clojure.lang ExceptionInfo)))

(deftest query-auth
  (testing "Verify auth records exist")
  (let [id-list (-> (basic/get-db test/ledger-todo)
                    (fdb/query-async {:select ["*"] :from "_auth" :opts {:meta true}})
                    async/<!!
                    (as-> res (reduce-kv
                                (fn [z _ v]
                                  (into z [(-> v (get "todo/auth") (get "_id"))]))
                                []
                                res)))]
    (is (= 5 (count id-list)))))