Pagination with pivot table?


I have this query:

async show ({ request, params: { id }, view }) {
  const page = request.input('page', 1)

  const group = await Group.query()
    .where({ id })
    .with('users', (builder) => {'id', 'username').paginate(page, 50)

  if (! group) throw new HttpException('Page not found.', 404)
  return view.render('', { group: group.toJSON() })

But I am getting this error:

ER_NONUNIQ_TABLE: Not unique table/alias: 'pivot_group_user'

How can I solve that?
Thank you in advance.


@lffg : Can you share the details about the table mapping you created?

The error that you see is nothing in specific to adonisjs / lucid. but you have to check the underlying knex API for the details.

refer this to understand your issue & a suggested solution -