Fork me on GitHub
#datomic
<
2021-04-30
>
ivana10:04:22

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.

tatut10:04:15

wouldn’t the VAET index be a good place?

ivana10:04:25

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

tatut12:04:41

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

tatut12:04:56

should work also, I think

ivana12:04:01

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

ivana10:04:59

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

ivana10:04:44

Something like

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

favila11:04:31

Typo in your find?

favila11:04:11

I would expect this to work

favila11:04:38

(Once you fix the typo)

ivana12:04:45

thanks, my shame! it works with typo fix )

fmnoise21:04:10

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)]

fmnoise21:04:37

I tend to think java typehinted call is faster

fmnoise21:04:14

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

benoit23:04:25

"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."

👍 6
3