Created
September 14, 2016 17:45
-
-
Save Jannis/cc2e803f2edd9ee0e9c88d90f02531ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; Deep destructuring characteristics | |
;; Regular properties | |
Query: [a b] | |
Result: {:a <aval> :b <bval>} | |
Bindings: | |
a -> <aval> | |
b -> <bval> | |
;; Links | |
Query: [[a _] [b 1]] | |
Result: {:a <aval> :b <bval>} | |
Bindings: | |
a -> <aval> | |
b -> <bval> | |
;; Joins with property sources | |
(defview User | |
(query [user [name email]])) | |
Query: [{a [b c]} {d ...} {e 5} {f User}] | |
Result: {:a {:b <bval> :c <cval>} ;; Or a collection! [{:b ... :c ...}] | |
:d <dval> | |
:e <eval> | |
:f <fval>} | |
Bindings: | |
a -> {:b <bval> :c <cval>} ;; Or a collection! | |
b -> <bval> ;; Undefined if the above is a collection? | |
c -> <cval> ;; Undefined if the above is a collection? | |
d -> <dval> ;; Don't know anything more specific about its value | |
e -> <eval> ;; Don't know anything more specific about its value | |
f -> <fval> ;; Don't know anything more specific about its value | |
;; Joins with link sources | |
Query: [{[a _] [b c]} {[d _] ...}] | |
Result: {:a {:b <bval> :c <cval>} ;; Or a collection! [{:b ... :c ...}] | |
:d <dval>} | |
Bindings: | |
a -> {:b <bval> :c <cval>} ;; Or a collection! | |
b -> <bval> ;; Undefined if the above is a collection? | |
c -> <cval> ;; Undefined if the above is a collection? | |
d -> <dval> ;; Don't know anything more specific about its value | |
;; Prefixed properties | |
Query: [a [b c] d [e f]] | |
Result: {:a/b <abval> :a/c <acval> :d/e <deval> :d/f <dfval>} | |
Bindings: | |
b -> <abval> ;; Doable with {:keys [a/b]} or {a/b :a/b} | |
c -> <acval> ;; Doable with {:keys [a/c]} or {a/c :a/c} | |
e -> <deval> ;; Doable with {:keys [d/e]} or {d/e :d/e} | |
f -> <dfval> ;; Doable with {:keys [d/f]} or {d/f :d/f} | |
;; Aliased properties | |
Query: [a :as b b :as c] | |
Result: {:a <aval> :b <bval>} | |
Bindings: | |
b -> <aval> ;; Doable with (let [{b :a c :b} ...]) | |
c -> <bval> ;; Doable with (let [{b :a c :b} ...]) | |
;; Aliased links | |
Query: [[a _] :as b [b _] :as c] | |
Result: {:a <aval> :b <bval>} | |
Bindings: | |
b -> <aval> ;; Doable with (let [{b :a} ...]) | |
c -> <bval> ;; Doable with (let [{c :b} ...]) | |
;; Aliased joins | |
Query: [{a [b]} :as c {b [d]} :as e] | |
Result: {:a {:b <abval>} ;; Or a collection! [{:b ...} {:b ...}] | |
:c {:d <cdval>}} | |
Bindings: | |
b -> <abval> ;; Doable with {{b :b} :a} | |
;; Undefined if the above is a collection? | |
d -> <cdval> ;; Doable with {{d :d} :b} | |
;; Undefined if the above is a collection? | |
c -> {:b <abval>} ;; Doable with {c :b} | |
e -> {:d <cdval>} ;; Doable with {e :d} | |
;; Aliased prefixed properties | |
To be continued tomorrow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment