Fork me on GitHub
#datomic
<
2020-10-17
>
kenny16:10:57

I have a query that looks like this .

'[:find ?r
  :in $ ?c [?cur-r ...]
  :where
  [?c ::rs ?r]]
I'd like to restrict ?r to be all ?r's that are not in ?cur-r. Is there a way to do this?

kenny16:10:35

I could make ?cur-r a data source but that requires me to have ?cur-r db ids for cur-r. Currently only have a list of lookup refs.

'[:find ?r
  :in $ $cur-r ?c
  :where
  [?c ::rs ?r]
  (not [$cur-r ?r])]

Lennart Buit16:10:34

Maybe (not [(identity ?cur-r) ?r]) works

kenny16:10:21

Returns all ?r's

kenny16:10:08

?cur-r is passed in as a list of lookup refs

kenny16:10:17

I may just have to convert the ?cur-r lookup refs to eids. Not a big deal but it seems like there should be a way to make this happen in a single query 🙂

favila18:10:48

(not [(datomic.api/entid $ ?cur-r) ?r])

kenny18:10:39

Ooo, nice! Is datomic.api documented somewhere?

favila18:10:49

It’s the peer api

kenny18:10:57

Oh, right - I'm on cloud.

favila18:10:10

It might still be there

favila18:10:47

It would just be on the server’s classpath

kenny18:10:02

Yeah. Curious if that's able to be depended on though haha.

favila18:10:45

If you know they are lookup refs you can decompose and resolve the ref

favila18:10:10

If not you could reimplement entid as a rule

favila18:10:57

:in [[?cur-a ?cur-v]] :where [?cur-r ?cur-a ?cur-v]

kenny18:10:18

Ah, that seems like it’d work! Will try it in a bit. Thanks @U09R86PA4

favila18:10:39

As a rule [[(entid [?x] ?eid)[(vector? ?x)]...] [(entid [?x] ?eid) [(int? ?x)][(identity ?x) ?eid]] and a keyword case looking up ident

favila18:10:17

Sorry I can’t type out the whole thing, on a phone

Chicão19:10:33

Hi, does anyone know how to solve this problem?

bin/transactor config/dev-transactor-template.properties               
Launching with Java options -server -Xms1g -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=50
Starting datomic:sql://<DB-NAME>?jdbc:, you may need to change the user and password parameters to work with your jdbc driver
...
System started datomic:sql://<DB-NAME>?jdbc:, you may need to change the user and password parameters to work with your jdbc d
river
Terminating process - Lifecycle thread failed
java.util.concurrent.ExecutionException: org.postgresql.util.PSQLException: ERROR: relation "datomic_kvs" does not exist
  Position: 31
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at clojure.core$deref_future.invokeStatic(core.clj:2300)
        at clojure.core$future_call$reify__8454.deref(core.clj:6974)
        at clojure.core$deref.invokeStatic(core.clj:2320)
        at clojure.core$deref.invoke(core.clj:2306)
        at datomic.lifecycle_ext$standby_loop.invokeStatic(lifecycle_ext.clj:42)
        at datomic.lifecycle_ext$standby_loop.invoke(lifecycle_ext.clj:40)
        at clojure.lang.Var.invoke(Var.java:384)
        at datomic.lifecycle$start$fn__28718.invoke(lifecycle.clj:73)
        at clojure.lang.AFn.run(AFn.java:22)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.postgresql.util.PSQLException: ERROR: relation "datomic_kvs" does not exist
  Position: 31

Chicão19:10:16

this is my config/properties...

protocol=sql
host=localhost
port=4334
sql-url=jdbc:
sql-user=datomic
sql-password=datomic
sql-driver-class=org.postgresql.Driver

Chicão20:10:00

I solve this problem running

CREATE TABLE datomic_kvs (id text NOT NULL, rev integer, map text, val bytea, CONSTRAINT pk_id PRIMARY KEY (id)) WITH (OIDS = FALSE);
ALTER TABLE datomic_kvs OWNER TO datomic; GRANT ALL ON TABLE datomic_kvs TO datomic; GRANT ALL ON TABLE datomic_kvs TO public;

cjmurphy21:10:45

I can see that's where creating that table is documented.