Skip to Main Content

How to return row count with the data in the resultset

GadoDec 21 2022

Hello,
I am building an app using React, Node/Express and Oracle 19c.
To connect with database I am using node_oracledb v5.3.0
I am able to fetch data from database table and return it to the frontend as a Json object. But now I am trying to use pagination in the frontend. To do that I need to also have the total number of rows in the table along with the subset (page) of the data itself.
I know that I can add count(*) to the query but this will return the count in every row. What I am looking for is something like this:

{
info: {
totalRows: 1000
},
 data: [
{row1} , {row2} , ...
]
}

I hope this is clear enough.

Thanks,
Gado

Comments
Post Details
Added on Dec 21 2022
1 comment
32 views