Node.js API with express & mysql - Getting record count, page number, … & provide pagination
- 阅读更多 关于 Node.js API with express & mysql - Getting record count, page number, … & provide pagination
问题 I would like to get and provide the total total_record_count, page_number, page_size, total_pages, has_more information in the response and being able to paginate through the result since I LIMIT the query to 100. What's the best way to do this? That's my current setup: router.get('/?', function(req, res, next) { const sql = "SELECT * from users "; const existingParams = ["title", "active"].filter(field => req.query[field]); if (existingParams.length) { sql += " WHERE "; sql += existingParams