Skip to content
Discussion options

You must be logged in to vote

I think I cracked it

I wrote something like this:

await Model.query()
        .joinRaw(
          Database.raw(
            `inner join (select order_id, max(updated_at) as updated_at from order_statuses group by order_id) tbl on order_statuses.order_id = tbl.order_id and order_statuses.updated_at = tbl.updated_at`
          )
        )
        .preload('order', (query) => {
          query.preload('user')
        })
        .paginate(request.input('page', 1), request.input('limit', 25))

and now I am able to use the full power of Lucid models :)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by melokki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant