datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
2021-04-30T10:35:22.428100Z

Hello. Can I check if datomic entity have any link on it somewhow? Links may be in a lot or resources so it would be hard to hardcode all the possible attributes to check.

2021-04-30T10:37:59.429800Z

I just want to implement a logic if there are any links I'l mark entity as deleted (by setting its field) but if there are no links - just retruct it from db

2021-04-30T10:42:44.430400Z

Something like

[:find (count l?)
 :where
 [?e :worker/id 1018]
 [?l _ ?e]]
but this blank doesn't work...

tatut 2021-04-30T10:43:15.430500Z

wouldn’t the VAET index be a good place?

2021-04-30T10:44:25.430700Z

Possibly yes, I need to read some about it and how to query it

2021-04-30T10:44:38.430900Z

Thanks!

favila 2021-04-30T11:56:31.431300Z

Typo in your find?

favila 2021-04-30T11:57:11.431800Z

I would expect this to work

favila 2021-04-30T11:57:38.432300Z

(Once you fix the typo)

tatut 2021-04-30T12:06:41.432500Z

(d/q '[:find ?e :where [_ _ ?e] :in $ ?e] db entity-id)

tatut 2021-04-30T12:06:56.432700Z

should work also, I think

2021-04-30T12:50:01.432900Z

I choosed (*seq* (*d/datoms* db :vaet eid)) and seems it works, even for cardinality many attributes

2021-04-30T12:52:45.433200Z

thanks, my shame! it works with typo fix )

fmnoise 2021-04-30T21:26:10.435700Z

hi everyone, what do you think, which way of date comparison is faster in datomic query?

[(.after ^java.util.Date ?exp ^java.util.Date ?now)]
or
[(> ?exp ?now)]

fmnoise 2021-05-01T09:12:11.437200Z

thanks @me1740

fmnoise 2021-04-30T21:26:37.435900Z

I tend to think java typehinted call is faster

fmnoise 2021-04-30T21:27:14.436100Z

but maybe datomic implements it under the hood for > when used with dates

benoit 2021-04-30T23:35:25.436600Z

"The predicates `=`, `!=`, `<=`, `<`, `>`, and `>=` are special, in that they take direct advantage of Datomic's AVET index. This makes them much more efficient than equivalent formulations using ordinary predicates."

2👍1