datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
cjmurphy 2020-10-07T00:08:06.287Z

Is there a library out there such that whether using :peer or :client is mostly unknown from your application code's point of view?

cjmurphy 2020-10-07T08:42:15.290200Z

Yes, in a sense the peer library is on the way out?? I was asking because I use such a peer/client ambivalent library internally, and was thinking to make it open source.

2020-10-07T09:01:05.290400Z

Well I’m not at cognitect, so I can’t answer that. But if you intend to migrate from on-prem to the cloud at some point, you are better off with the client api, so it appears to be ‘good advice’ to start new projects with the client api

2020-10-07T09:06:52.290600Z

Also; there are quite a few subtle differences between the api’s. The query dialect is slightly different (most notably, not all :find specs in peer are supported in client), and many functions have slightly different arguments/return values (for example, many functions return deref’able things in peer, but direct results in client).

cjmurphy 2020-10-07T14:01:38.299600Z

I must have ignored the 'good advice' initially, hence the compatibility library. For the :find differences I've just changed all the queries to work for the client, which means they can work for both. Other subtleties I've found have just been taken care of by the library - basically it is a map that includes some wrapper functions that choose to use one function or the other - for example either one of the two variants of transact , depending on the 'mode' being used.

mruzekw 2020-10-07T01:27:46.287500Z

Is there an alternative for this? ^

2020-10-07T06:32:59.290Z

You can use the client library to connect to an on-prem peer server. The client library is the lowest common denominator in that sense ^^

cjmurphy 2020-10-07T08:42:15.290200Z

Yes, in a sense the peer library is on the way out?? I was asking because I use such a peer/client ambivalent library internally, and was thinking to make it open source.

2020-10-07T09:01:05.290400Z

Well I’m not at cognitect, so I can’t answer that. But if you intend to migrate from on-prem to the cloud at some point, you are better off with the client api, so it appears to be ‘good advice’ to start new projects with the client api

2020-10-07T09:06:52.290600Z

Also; there are quite a few subtle differences between the api’s. The query dialect is slightly different (most notably, not all :find specs in peer are supported in client), and many functions have slightly different arguments/return values (for example, many functions return deref’able things in peer, but direct results in client).

xceno 2020-10-07T10:28:39.290800Z

Hi guys, just found this thread because I'm working on the exact same thing right now (trying to deploy an SPA as ion / lambda proxy) I got confused by the mismatch between the Ion tutorial and the API Gateway console, so just to clarify once more: What the Datomic Ion docs are talking about is now called REST API on AWS? And the HTTP API is a new thing, that is not officially supported?

xceno 2020-10-07T12:07:44.294Z

Can't I build/push a datomic ion that includes an alias? Meaning: I have an application and bundle datomic-ion specific stuff under a :datomic alias. I then want to push it like this: clojure -M:datomic:ion-dev '{:op :push}', but when I check the zip file that's generated all the stuff from my alias (specific namespaces & resources) is missing. Am I doing something wrong or is this just not supported?

jeff.terrell 2020-10-07T13:41:44.294100Z

Yes, REST is the old kind that the docs implicitly refer to. HTTP can work, but it's not what the docs describe specifically.

marshall 2020-10-07T13:54:29.294500Z

@rob703 I believe you want -A:aliases

marshall 2020-10-07T13:54:33.294700Z

not -M

alexmiller 2020-10-07T13:58:00.297700Z

not with new clj ...

xceno 2020-10-07T13:59:07.298500Z

I actually tried both and various combinations thereof yesterday. My initial cmd was clojure -A:datomic -M:ion-dev ... and I also tried the variant straight from the docs: clojure -A:datomic:ion-dev -m datomic.ion.dev '{:op :push (options)}' to no avail. But I can double check again. On another note: Right now, I've pulled all my deps from the alias into my main deps so I can at least try the deployment of my lambda proxy. Now I'm a step further, I see in the Api Gateway console that my app is returning a proper ring response, but the lambda crashes with a 502 error: > Wed Oct 07 13:51:50 UTC 2020 : Execution failed due to configuration error: Malformed Lambda proxy response > Wed Oct 07 13:51:50 UTC 2020 : Method completed with status: 502 The only thing I don't see in my response body is the isBase64Encoded flag, so maybe that's the issue right now

xceno 2020-10-07T13:59:27.298900Z

Ah yeah and I updated to the latest clj yesterday

xceno 2020-10-07T13:59:50.299300Z

so that's why I converted to -M

xceno 2020-10-07T14:00:30.299400Z

Understood, thank you!

cjmurphy 2020-10-07T14:01:38.299600Z

I must have ignored the 'good advice' initially, hence the compatibility library. For the :find differences I've just changed all the queries to work for the client, which means they can work for both. Other subtleties I've found have just been taken care of by the library - basically it is a map that includes some wrapper functions that choose to use one function or the other - for example either one of the two variants of transact , depending on the 'mode' being used.

alexmiller 2020-10-07T14:09:29.300200Z

yes, that clj syntax is fine with the new clj (but I don't think that has anything to do with your issue)

vncz 2020-10-07T14:09:47.300700Z

Hey, how do I create a new database in Datomic-Local?

marshall 2020-10-07T14:10:15.301400Z

@rob703 what versions of the various ion tools are you using? I’m going to try to reproduce/investigate

marshall 2020-10-07T14:11:40.301500Z

If you mean dev-local, once you’ve made a client (https://docs.datomic.com/cloud/dev-local.html#using) you can use it exactly the same way as you would using client against cloud (i.e. you can call create-database https://docs.datomic.com/client-api/datomic.client.api.html#var-create-database)

vncz 2020-10-07T14:12:37.301700Z

I do recall creating the database from the cmd line argument when using Datomic on premise locally on my computer

vncz 2020-10-07T14:12:42.301900Z

My memory might be flaking though

xceno 2020-10-07T14:13:09.302100Z

Thank you! This is part of my deps edn:

xceno 2020-10-07T14:13:45.302500Z

So initially, all those deps where under my :datomic alias

xceno 2020-10-07T14:19:49.302700Z

Oh and I'm using the latest ion-dev tools as an alias in my user config

xceno 2020-10-07T14:19:58.302900Z

basically just following the tutorial

marshall 2020-10-07T14:39:28.303100Z

@rob703 the zip file that is created will not contain all of your deps themselves

marshall 2020-10-07T14:39:38.303300Z

it only contains your ion code The deps are fetched when you deploy

marshall 2020-10-07T14:39:45.303500Z

were you seeing a problem with your actual deploy

marshall 2020-10-07T14:40:32.303700Z

generally that would not be the case unless you were just using peer-server with a mem database

vncz 2020-10-07T14:41:03.303900Z

Totally my memory flaking then

xceno 2020-10-07T14:41:28.304100Z

> it only contains your ion code Yes, that's the other part of my problem, it's not only the deps but also the additional paths. For example:

:aliases {:datomic {:extra-paths ["src/datomic"]}}
My entire code in the datomic folder is missing

alexmiller 2020-10-07T14:49:41.304300Z

which doc was clojure -A:datomic:ion-dev -m datomic.ion.dev '{:op :push (options)}' from ?

marshall 2020-10-07T14:50:56.304500Z

yep, I’ve reproduced that behavior. looking into it further now

xceno 2020-10-07T14:53:47.304700Z

Thank you!

marshall 2020-10-07T14:54:15.304900Z

for now I would say you’ll want to put those extra paths in the main body of the deps, not in an alias

xceno 2020-10-07T14:55:50.305100Z

Yeah I moved everything from my alias up for now. I'm now battling with AWS itself, trying to get the lambda proxy to work. But that's another issue in itself

xceno 2020-10-07T15:06:41.305300Z

From what I've seen so far it's every command in the ion tutorials, e.g. https://docs.datomic.com/cloud/ions/ions-reference.html#push

xceno 2020-10-07T15:08:05.305500Z

The ion tutorials would also need some updates regarding the new AWS Api-Gateway Options, see here: https://clojurians.slack.com/archives/C03RZMDSH/p1601380150089100

alexmiller 2020-10-07T15:09:45.305800Z

thanks those commands seem wrong - if using :ion-dev with a :main-opts, the -m datomic.ion.dev isn't need there /cc @marshall

marshall 2020-10-07T15:46:38.306Z

I’ve updated the commands in the reference doc. Thanks @rob703

1👍
2020-10-07T23:14:49.307300Z

Is there a clear example of using :db.entity/preds? I have defined it as {:db/ident :transaction/pred :db.entity/preds 'ledger.transaction/existing-transaction-entity-pred}

2020-10-07T23:15:55.307800Z

When I try and transact with (d/transact conn {:tx-data [{:transaction/user-id #uuid "9550f401-fb16-4e42-8940-d683dbad3a3d" :transaction/txn-hash "Pl3b9f7ba2-eb0d-412d-b305-f76b5150c711" :db/ensure :transaction/pred}]})

2020-10-07T23:16:39.308200Z

I get Execution error (IndexOutOfBoundsException) at datomic.core.datalog/bound-consts$fn (datalog.clj:1570).

2020-10-07T23:16:42.308400Z

Any hints?

2020-10-07T23:19:39.309Z

After taking a closer look at the stack trace, the predicate is being called but erroring