Fork me on GitHub

I guess I'm doing this wrong, according to I must return a string if I'm exposing some fn as lambda. Maybe the hodur-example-app is a bit obsolete?


i've tried the ion-starter project too and that also returns base64 response:

$ curl -s -d ':shirt' 
then i guess the problem might be how i setup the api gw 😕


i think i've found the missing step in the docs: i had to set all (`*/*`) content types to be treated as binary


I am working through day-of-datomic-cloud. Im on tutorial/constructor.clj. When I try to execute the following line:

(d/with (d/with-db conn) {:tx-data [{:user/email ""
                                     :user/name "John Doe"
                                     :db/ensure :user/validate}]}) I get an error:
Execution error (ExceptionInfo) at datomic.client.api.async/ares (async.clj:58).'datomic/ion-config.edn' is not on the classpath
` I had no issues with several previous tutorials. I am using Cursive with IntelliJ. The REPL is configured to ‘Run with Deps.’ I restarted the REPL and stuff like that. My deps.edn includes “resources” under the :paths key. And the file datomic/ion-config.edn is there in the resources directory. I suspect this has something to do with the datomic/ion-config.edn being unavailable in the cloud instance. Am I on the right track? I did not configure anything pertaining to ions on the cloud instance.


Is there a way to set the blank > &lt; in a variable passed to query. I am doing a query where if the I am filtering on values in a field, but the filter might be empty so this case I want to get any and all values for that field . Was trying to pass in a variable like ' or ` or '' or "" ( the blank ) if the value was nil but to no avail.


(d/q '[:find (pull ?e pattern)
       :in $ pattern ?customer-id
       [?e :invoice/customer ?customer-id]]
  db '[*] customer-id)
so for example the customer-id might have an id or might be nil ( but I can't use nil and need a blank )

Joe Lane14:12:17

@dansudol The query is a datastructure so you can construct it on the fly using a cond depending on customer-id's presence then conj either [?e :invoice/customer ?customer-id] or [?e :invoice/customer]. I wouldn't use an if because filters always seem to expand the cases they handle.


another option is a rule which uses a sentinel


thanks @lanejo01 I did not know I could use cond .. good idea .. not sure what a sentinel is @favila


A value you pick to represent “no filter” which is not in the space of matchable values


'[[(invoice-with-customer ?e ?cust)
    [(!= ?cust :any)]
    [?e :invoice/customer ?cust]]
   [(invoice-with-customer ?e ?cust)
    [(= ?cust :any)]]


(for e.g.)


datalog refuses nil values


i know .. kind of tricky


i see your query .. i just don't get it .. hard to grok


is invoice-with-customer an on the fly function you are defining ?


its a rule


whoa .. this is fancy .. very interesting too .. trying this out


@lanejo01 could you do me a favour and write that query with the cond .. i was hacking around and could not get it

Joe Lane14:12:28

Sure, hang on.

Joe Lane15:12:02

(defn customers
  [db {:keys [customer-id] :as arg-map}]
  (let [the-query (cond-> {:query {:find  ['(pull ?e pattern)]
                                   :in    ['$ 'pattern]
                                   :where []}
                           :args  [db '[*]]}
                          customer-id (->
                                        (update-in [:query :where] conj '[?e :invoice/customer ?customer-id])
                                        (update-in [:query :in] conj '?customer-id)
                                        (update-in [:args] conj customer-id))
                          (nil? customer-id) (-> (update-in [:query :where] conj '[?e :invoice/customer])))]
    (d/q the-query)))

Joe Lane15:12:59

I think that should work. You might want to extract the right hand side of the first cond-> clause to be its own fn, but I thought I'd include it all in one place for now.


ahh .. update-in .. ok .. very clever


turned out to be super whacky .. ( i have way more clauses and variable ) BUT .. that sucker worked .. i am well shocked .. and thanks for the days surprise of whacky code .. very interesting

Joe Lane17:12:25

I use an extended variation of this with about 30 small clauses to construct and expose a domain specific pseudo-sql query language (in json!) to the mobile developer on one of my projects. They love it and have implemented several features without even talking to me about it. It's pretty cool 🙂 I use the cond-> pattern whenever I have possibly nillable values and I'm constructing queries/tx-data. It's one of my top 5 fav language tools. Glad the above was helpful.

👍 4

super nifty .. thanks again 🙂


You might want to change your password :P


(Jokes aside, please be aware that we have at least 2 public logs of these channels 😬)


For those working with Datomic Cloud, here's a short script that will automatically delete the durable storage for you so you don't have to go through the manual steps listed in the docs. We've found this useful to integrate with our infra-as-code tools and just generally making spinning up and down Datomic systems a bit easier.

👍 24