Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Peer API by

When I try pull attributes together with max, min or count I received only 2 attributes.

I want the same output from Example 1, but instead a new query to :where, I want use (pull).

My problem its on example 2, I'm missing or a did something wrong?

Exemple 1, happens correctly:

(defn resume [db]

  (d/q '[:find ?name-cat (min ?price) (max ?price) (count ?price)
         :keys category min max qtd
         :with ?product
         :where [?product :product/price ?price]
         [?product :product/category ?category]
         [?category :category/nome ?name-cat]]

       db))
[{:category "Eletronics",

  :min 15M,

  :max 15M,

  :qtd 10}]

Exemplo2, using (pull)

(defn resume [db]

  (d/q '[:find (pull ?category [:category/nome])
         (min ?price)
         (max ?price)
         (count ?price)
         ;:keys category min max qtd ;cant use kays because Indexoutbound happen

        :with ?product ;using with because it is a conj, so now it allow if a product has same price
         :where [?product :product/price ?price]
         [?product :product/category ?category]]

       db))

output

[{:category/id 34 :category/name "test"} 10

Please log in or register to answer this question.

...