This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-02
Channels
- # aleph (2)
- # announcements (3)
- # babashka (12)
- # beginners (55)
- # calva (11)
- # clj-http (12)
- # cljs-dev (41)
- # cljtogether (2)
- # clojure (51)
- # clojure-denmark (2)
- # clojure-europe (32)
- # clojure-nl (17)
- # clojure-norway (2)
- # clojure-switzerland (1)
- # clojure-uk (3)
- # clojurescript (34)
- # cursive (20)
- # data-science (3)
- # datahike (23)
- # datomic (3)
- # events (1)
- # fulcro (1)
- # honeysql (4)
- # inf-clojure (2)
- # interop (38)
- # java (3)
- # kaocha (8)
- # lsp (51)
- # luminus (2)
- # malli (2)
- # nextjournal (5)
- # off-topic (21)
- # pedestal (2)
- # polylith (12)
- # re-frame (4)
- # reagent (8)
- # reitit (4)
- # releases (1)
- # ring (4)
- # shadow-cljs (179)
- # spacemacs (2)
- # specter (1)
- # xtdb (13)
Yes. Use a https://docs.datomic.com/on-prem/query/query.html#not-clauses:
:where
(not [?e :some-attribute])
I tried that. And it seems this is not working. This are my datums:
#datahike/Datom [452 :fulfillment/delivery-date #inst "2022-03-01T21:17:18.000-00:00" 536871802 true]
#datahike/Datom [452 :invoice/date #inst "2022-02-25T00:00:00.000-00:00" 536871378 true]
#datahike/Datom [452 :invoice/date-due #inst "2022-03-25T00:00:00.000-00:00" 536871378 true]
#datahike/Datom [452 :invoice/id "b44c84a1-d837-4dc2-bf2c-b13241981834" 536871378 true]
#datahike/Datom [452 :invoice/invoice-number "INV-8036" 536871378 true]
#datahike/Datom [452 :invoice/name "Jon Don / Seattle" 536871378 true]
#datahike/Datom [452 :invoice/paid 0.0 536871378 true]
#datahike/Datom [452 :invoice/reference "766557" 536871378 true]
#datahike/Datom [452 :invoice/status "AUTHORISED" 536871378 true]
#datahike/Datom [452 :invoice/total 232.16 536871378 true]
#datahike/Datom [452 :invoice/type "ACCREC" 536871378 true]
This works:
(def xero-orders-fulfillment-shipping
'[:find [(pull ?id [* {:tracking/_invoice [:tracking/tag :tracking/number]}]) ...]
:in $
:where
[?id :invoice/type "ACCREC"]
[?id :invoice/status ?status]
[(contains? #{"AUTHORISED" "PAID"} ?status)]
(not [?id :fulfillment/delivery-date])])
(def xero-orders-fulfillment-shipping
'[:find [(pull ?id [* {:tracking/_invoice [:tracking/tag :tracking/number]}]) ...]
:in $
:where
[?id :invoice/type "ACCREC"]
[?id :invoice/status ?status]
[(contains? #{"AUTHORISED" "PAID"} ?status)]
[(not [?id :fulfillment/delivery-date])]])
(def xero-orders-fulfillment-delivered
'[:find [(pull ?id [* {:tracking/_invoice [:tracking/tag :tracking/number]}]) ...]
:in $
:where
[?id :invoice/type "ACCREC"]
[?id :invoice/status ?status]
[(contains? #{"AUTHORISED" "PAID"} ?status)]
[?id :fulfillment/delivery-date _]
])
isn't the difference that putting it into brackets makes it a predicate to run, and you're calling not on a vector, and vectors are truthy?
so it just always returns false
This might be. I dont know. But I have this in brackets: [(contains? #{"AUTHORISED" "PAID"} ?status)] And this works. I dont quite get it @U5NCUG8NR
That seems like it's an actual predicate, and it's not trying to make a tuple syntax inside an arbitrary piece of syntax. A not
around a tuple definition is special syntax specified by datalog, not an expression.
Does datahike support a query where I can sort the items, and then return say a page with the first 20 items ?
No; Sorting and pagination are not supported. You'd have to run the query, and explicitly do this with regular ol clojure code.
Not good 🙂 Thanks for the info @U05100J3V
Yeah; To be fair, this is in following with datomic & datascript (etc), and to some extent makes sense from a relational perspective (you always get a set back, which is inherently unordered). But, it would be nice/convenient, and the team might be open to supporting if you raise an issue.
Right, currently it is not possible because how we query and unify the results from the indices. As for pagination you can do that already if you query with a hashmap. Have a look at the example in the https://cljdoc.org/d/io.replikativ/datahike/0.4.1484/api/datahike.api#q .
Fantastic! I stand corrected then (regarding pagination).
For me unfortunately paging alone without sorting does not make too much sense. I want to display say recently arrived orders. Obviously I am interested the most in those who arrived latest. And in case my page-size is not big enoguht, and I want to go back more, then I go to the next page.