Skip to content

Instantly share code, notes, and snippets.

@jdkealy
Last active January 26, 2017 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdkealy/174741e33b88b09b66e6f0281e3cd6ca to your computer and use it in GitHub Desktop.
Save jdkealy/174741e33b88b09b66e6f0281e3cd6ca to your computer and use it in GitHub Desktop.
(defn cart-line-items [cid _db & [organization]]
(d/q '[:find ?e ?org ?name ?price ?dl_or_ph
:in $ ?cart
:where
[?e :line_item/cart ?cart]
[?cart :cart/subtotal ?subtotal]
[?e :line_item/content ?content]
[?e :line_item/dl_or_ph ?dl_or_ph]
[?e :line_item/price ?price]
[?content :content/collection ?coll]
[?coll :collection/organization ?org]
[?org :user/name ?name]]
_db cid))
;organization is optional... end up writing this wtf query...
(defn cart-line-items [cid _db & [organization]]
(if organization
(d/q '[:find ?e ?org ?name ?price ?dl_or_ph
:in $ ?cart ?org
:where
[?e :line_item/cart ?cart]
[?e :line_item/content ?content]
[?e :line_item/dl_or_ph ?dl_or_ph]
[?e :line_item/price ?price]
[?content :content/collection ?coll]
[?coll :collection/organization ?org]
[?org :user/name ?name]]
_db cid organization)
(d/q '[:find ?e ?org ?name ?price ?dl_or_ph
:in $ ?cart
:where
[?e :line_item/cart ?cart]
[?e :line_item/content ?content]
[?e :line_item/dl_or_ph ?dl_or_ph]
[?e :line_item/price ?price]
[?content :content/collection ?coll]
[?coll :collection/organization ?org]
[?org :user/name ?name]]
_db cid)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment