Remote / foldkit-remote-drizzle
Windowed collection relations
A Selection can ask for a bounded connection instead of the full collection:
ts
import { Selection } from 'foldkit-remote'
const PostView = Selection.make(Post, {
id: true,
comments: Selection.connection(Comment, {
first: 10,
}),
})For several parent posts, the Source asks each parent for its own page in one
SQL statement: the requested page plus the extra row needed to determine the
boundary, with a limit per parent, as a collection read whole is bounded
above. The statement count does not grow with the number of parents.
The result carries:
ts
{
refs,
hasNext,
hasPrevious,
}first and last work per parent. after / before cursor pagination is only
accepted when the read targets one parent because a single cursor is ambiguous
across several parents.
When the client asks for another cursor page, Remote's reducer merges it onto
the stored relation page: after appends and before prepends.