Please help me with AdonisJS Pagination

Hi, I’m new to AdonisJS and I am having a problem with pagination.
I am getting and error (route" view global error: Expected “employee_id” to be a string) when I add the “.paginate(1,5)” at the end of my query.

Here is my code:

const employeedata = await Database
.select(‘employeedetails.employee_id’, Database.raw('DATE_FORMAT(datehired, “%m-%d-%Y”) as dhired))
.orderBy(‘employeedetails.employee_id’, ‘desc’)
.paginate(1, 5);

1 Like

Hi @akosialbean and welcome to community!

Most likely the problem is that when doing query without pagination you get array of objects (rows) back.

But when adding pagination returned data structure changes little bit

With pagination it will be object containing pagination data and that array of objects / rows is put into data property

1 Like