I am new to sails js.In my controller, I am calling an api which gives me a large set of data, approximately 10000 records. I want to show this data in my front end using the datatables, 100 records per page.I don't want all data to be fetched in a single call. Data for each page should be loaded using pagination. Do anyone have any idea? It will be of great help. I am not using the database directly. Everything is via API.
Asked
Active
Viewed 972 times
0
-
1Welcome to StackOverflow! Please go through http://stackoverflow.com/help/asking. – Dan Cornilescu Feb 02 '16 at 18:03
-
You can try .limit() and .skip() in your api at controller for pagination. – Sangna Jani Feb 13 '16 at 11:51
-
You can use this https://www.npmjs.com/package/sails-hook-datatable. works pretty fine – Phil Nov 29 '16 at 11:57
-
1Possible duplicate of [Sails.Js - How I do pagination in sails.Js](https://stackoverflow.com/questions/26648059/sails-js-how-i-do-pagination-in-sails-js) – Noitidart Dec 15 '18 at 16:59
1 Answers
-1
See Sails.Js - How I do pagination in sails.Js:
In sails.js:
Model.find().paginate({page: 2, limit: 10});
Model.find({ where: { name: 'foo' }, limit: 10, skip: 10 });
(Source: https://stackoverflow.com/a/26653121/3340229)
In the frontend, you can add query parameters for this:
http://yourDomain.com/ModelName?skip=10&limit=10

Community
- 1
- 1

Iris Schaffer
- 804
- 8
- 18
-
-
I didn't have the privilege to flag back then, I was just trying to help. Flagged as duplicate now. – Iris Schaffer Dec 19 '18 at 10:07