I use infinite scroll at my site and I have to return two variables.
The first one is data like 10 users.
the second one is total. Total all users from my whole table.
Now my query is this:
const total= await pg.query('SELECT COUNT(*) as total FROM users;');
const users = await pg.query('SELECT * FROM users LIMIT 50 OFFSET $1', [offset]);
I do not fetch all users directly I set a limit, but I have to say to my infinite scroll how much users I have in my users table so I wrote two queries but it is possible to write it in one query ?