Imagine I had actors and movies. How can I write a single query that for a given list of actors returns a list of 5-tuples of five most recent movies the actor participated in (sorted descending by movie date)?
More specifically: given a list of :db/id called actors and models are as follows:
Actor:
:db/id
:actor/name str
:actor/movie ref
Movie:
:db/id
:db/name str
:db/date inst
I want to write a query like:
(d/q '[:find ?actor ???????
:in $ [?actor ...]
:where ??????????] snapshot actors)
Expected results:
[[1 [2 3 4 5 6]
7 [8 9 10 11 12]]
Where 1
and 7
are actor ids and 2,3,4,5,6,8,9,10,11,12
are movie ids.
Now, I have a strong feeling that such a query cannot be constructed. If I am right, how can I get this information in chunks (imagine that each actor has tons and tons of movies they were cast in, too many to fit in memory)?