How can I use UNION in Adonis?

I need to vertical join for displaying all of transactions regarding to a business those split in two tables in a table in the front-end with pagination.
I need to use UNION method, but I don’t how I can use it in the Adonis!

1 Like

Adonis is using Knex internally. So just check all the API available on their website:

http://knexjs.org/#Builder-union

2 Likes
let data = await this.db.select('*').table(this.table)
    .where('id', user_id)
    .union(
        [
            this.db.table(this.table).select('*')
            .where('id', another_id)
        ]
    )