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?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])]
Maybe (not [(identity ?cur-r) ?r])
works
Returns all ?r's
?cur-r is passed in as a list of lookup refs
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 🙂
(not [(datomic.api/entid $ ?cur-r) ?r])
Ooo, nice! Is datomic.api documented somewhere?
It’s the peer api
Oh, right - I'm on cloud.
It might still be there
Perhaps. Not documented though: https://docs.datomic.com/client-api/datomic.client.api.html
It would just be on the server’s classpath
Yeah. Curious if that's able to be depended on though haha.
If you know they are lookup refs you can decompose and resolve the ref
If not you could reimplement entid as a rule
:in [[?cur-a ?cur-v]] :where [?cur-r ?cur-a ?cur-v]
Ah, that seems like it’d work! Will try it in a bit. Thanks @favila
As a rule [[(entid [?x] ?eid)[(vector? ?x)]...] [(entid [?x] ?eid) [(int? ?x)][(identity ?x) ?eid]]
and a keyword case looking up ident
Sorry I can’t type out the whole thing, on a phone
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:<postgresql://localhost:5432/datomic?user=datomic&password=datomic>, you may need to change the user and password parameters to work with your jdbc driver
...
System started datomic:sql://<DB-NAME>?jdbc:<postgresql://localhost:5432/datomic?user=datomic&password=datomic>, 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
this is my config/properties...
protocol=sql
host=localhost
port=4334
sql-url=jdbc:<postgresql://localhost:5432/datomic>
sql-user=datomic
sql-password=datomic
sql-driver-class=org.postgresql.Driver
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;
I can see that's where creating that table is documented.