Ask questions on the official Q&A site at https://ask.datomic.com!
zilti 2020-10-09T11:52:25.412500Z

Is there a way to query for entities that don't have a certain attribute? Something like "show me all entities that have a :company/id but don't have a :company/owner"


Check out missing? in the query docs

souenzzo 2020-10-09T13:59:35.413800Z

@zilti you can also do

[?e .....]
(not [?e :attr])

souenzzo 2020-10-09T19:33:37.416600Z

Looks like that datomic-peer do not respect socks proxy JVM props -DsocksProxyHost= -DsocksProxyPort=5000 Is it a know issue? slurp respect this settings both for dns resolution and packages. Datomic do not respect the proxy for names resolution I can't know about packages

Chicão 2020-10-09T20:33:34.419300Z

Hi, I want to restore my backup db then I run bin/transctor the transactor

datomic-pro-0.9.5561 bin/transactor config/dev-transactor-template.properties
Launching with Java options -server -Xms1g -Xmx1g -XX:+UseG1GC -XX:MaxGCPauseMillis=50
Starting datomic:<dev://localhost:4334/&lt;DB-NAME>&gt;, storing data in: data ...
System started datomic:<dev://localhost:4334/&lt;DB-NAME>&gt;, storing data in: data
and I ran this command and I got an error
datomic-pro-0.9.5561 bin/datomic restore-db backup.tgz datomic:<dev://localhost:4334/hummingbirg-dev>                                                                                        
java.lang.IllegalArgumentException: :storage/invalid-uri Unsupported protocol:
        at datomic.error$arg.invokeStatic(error.clj:57)
        at datomic.error$arg.invoke(error.clj:52)
        at datomic.error$arg.invokeStatic(error.clj:55)
        at datomic.error$arg.invoke(error.clj:52)
        at datomic.backup$fn__19707.invokeStatic(backup.clj:306)
        at datomic.backup$fn__19707.invoke(backup.clj:304)
        at clojure.lang.MultiFn.invoke(MultiFn.java:233)
Can someone help me?

marshall 2020-10-09T20:34:31.419700Z

your backup (source) needs to be an unzipped backup, not a tar

Chicão 2020-10-09T20:35:06.420100Z

I got the same error when I unzipped

marshall 2020-10-09T20:35:19.420300Z


marshall 2020-10-09T20:35:23.420500Z

it should be a directory

marshall 2020-10-09T20:36:29.421Z

a top level dir with roots and values dirs inside of it

Chicão 2020-10-09T20:38:02.421300Z

backup ls
owner  roots  values

marshall 2020-10-09T20:38:17.421500Z


marshall 2020-10-09T20:38:22.421800Z

you need to make a URI for it

marshall 2020-10-09T20:38:23.421900Z


marshall 2020-10-09T20:38:38.422300Z

it will be like: file:///User/Home/backup/

Chicão 2020-10-09T20:42:03.423Z

it worked

Chicão 2020-10-09T20:42:08.423200Z

thanks !

marshall 2020-10-09T20:42:11.423400Z

no problem


I'm now debugging this 401 issue in my own case, where Datomic fails to download consistently on Github Actions for CI purposes but not locally on my machine.

zilti 2020-10-09T22:35:28.426700Z

Okay, I don't get it... or-join works completely different from what I expect. When there's no result fulfilling any of the clauses in or-join it will match everything. Is that on purpose? How can I avoid that?

zilti 2020-10-09T22:53:14.427100Z

I thought this:

(d/q '[:find ?eid .
       :in $ ?comp-domain ?comp-name
       (or-join [?eid]
                [?eid :company/name ?comp-name]
                [?eid :company/domain ?comp-domain])]
     db comp-domain (:company/name data)))
Would be equivalent to this:
(or (d/q '[:find ?eid .
       :in $ ?comp-domain ?comp-name
       [?eid :company/domain ?comp-domain]]
     db comp-domain))
     (d/q '[:find ?eid .
       :in $ ?comp-domain ?comp-name
       [?eid :company/name ?comp-name]]
     db (:company/name data))))
But it is not.


In the first query, you are getting all ?eid s because the or-join you specify does not unify with ?comp-name nor ?comp-domain. So, practically, the ?comp-domain/`?comp-name` in your :in clause are not the same as the ones you use in the or branches of your or-join


So your first query now says “Give me al entity ids of entities that have either a name, or a domain”, the bindings in your :in make no difference


If you change (or-join [?eid] ...) to (or-join [?eid ?comp-domain ?comp-name] ...), do you get what you want?

zilti 2020-10-09T23:00:49.427900Z

I'm trying...

zilti 2020-10-09T23:01:23.428100Z

Yes, that gives me an empty result, which is correct in this case

zilti 2020-10-09T23:02:41.428300Z

And it works for a valid binding too. Thanks! I misinterpreted how that first vector works in or-join, I thought that is to declare the common variable.

steveb8n 2020-10-09T23:03:47.429400Z

Q: what’s the best way to query for the most recently created entity (with other conditions) in Datalog?


It declares what variables from outside the or-join to unify with ^^

steveb8n 2020-10-09T23:04:22.429700Z

I can include a :where [?e :some/attr _ ?t] and then sort all results by ?t but it feels like there must be some way to use max to do this

zilti 2020-10-09T23:04:52.429900Z



Here are some interesting time rules: https://github.com/Datomic/day-of-datomic/blob/master/tutorial/time-rules.clj maybe that helps ^^

steveb8n 2020-10-09T23:06:02.430500Z

perfect! thank you 🙂


Not sure if your use is exactly in there, but I often use it as a reference if I want to find something history related 🙂

steveb8n 2020-10-09T23:08:47.430900Z

it’s a good start. I’ll be able to make it work from this


haha, teach a man to fish, and all 🙂

steveb8n 2020-10-09T23:09:37.431300Z

exactly. you supplied the bait