type PostRow { id: data.post.id, created_at: DateTime, title: Text, author_id: data.author.id, note: Text? } type AuthorRow { id: data.author.id, created_at: DateTime, name: Text, note: Text?, posts: List } type Page { items: List, page: Int, size: Int, total: Int, pages: Int } type Error { error NotLoaded } loop posts(rows: List) (out: List) | each row in rows | result | | out | list PostRow { id = row.id, created_at = row.created_at, title = row.title, author_id = row.author_id, note = row.note } | rule loaded(value: Related>) (out: List) | value | out | | Loaded(rows) | posts(rows) | | Unloaded | fail(Error.NotLoaded) | loop authors(rows: List) (out: List) | each row in rows | result | | out | list AuthorRow { id = row.id, created_at = row.created_at, name = row.name, note = row.note, posts = loaded(row.posts) } | flow page(page: Int, size: Int) (out: Page) | step | kind | do | | found | data | data.author.page(order = id.asc, with = [posts], page = page, size = size) | | items | loop | authors(found.items) | | out | calc | Page { items = items, page = found.page, size = found.size, total = found.total, pages = found.pages } |