Fork me on GitHub
#datomic
<
2019-12-16
>
onetom01:12:40

I guess I'm doing this wrong, according to https://docs.datomic.com/cloud/ions/ions-reference.html#lambda-ion I must return a string if I'm exposing some fn as lambda. Maybe the hodur-example-app is a bit obsolete? https://github.com/hodur-org/hodur-example-app

onetom03:12:48

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

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

onetom03:12:31

i think i've found the missing step in the docs: https://docs.datomic.com/cloud/ions/ions-tutorial.html#org6d06b38 i had to set all (`*/*`) content types to be treated as binary

Georgiy Grigoryan11:12:11

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}]})
https://github.com/cognitect-labs/day-of-datomic-cloud/blob/master/tutorial/constructor.clj#L37 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.

daniel.spaniel12:12:12

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.

daniel.spaniel12:12:41

(d/q '[:find (pull ?e pattern)
       :in $ pattern ?customer-id
       :where
       [?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.

favila14:12:14

another option is a rule which uses a sentinel

daniel.spaniel14:12:54

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

favila14:12:48

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

favila15:12:05

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

favila15:12:09

(for e.g.)

favila15:12:18

datalog refuses nil values

daniel.spaniel15:12:10

i know .. kind of tricky

daniel.spaniel15:12:24

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

daniel.spaniel15:12:21

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

favila15:12:28

its a rule

daniel.spaniel15:12:12

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

daniel.spaniel14:12:57

@joe.lane 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.

daniel.spaniel15:12:29

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

daniel.spaniel16:12:38

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
daniel.spaniel17:12:57

super nifty .. thanks again 🙂

aisamu20:12:33

You might want to change your password :P

aisamu21:12:48

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

kenny23:12:08

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. https://github.com/ComputeSoftware/datomic-cloud-tools. 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