Sails.Js - How I do pagination in sails.Js

sasitha999 picture sasitha999 · Oct 30, 2014 · Viewed 16k times · Source

I want to create paginated table using sails.js, mongodb and waterline-ORM.

Is there a any specific way to do pagination in sails.js?

Answer

Martin Malinda picture Martin Malinda · Oct 30, 2014

http://sailsjs.org/#/documentation/concepts/ORM/Querylanguage.html

Model.find().paginate({page: 2, limit: 10});

Model.find({ where: { name: 'foo' }, limit: 10, skip: 10 });

If you want the pagination to work asynchronously, its very easy to do with JQUERY $$.getJSON and on the server res.json();

Theres a lot of info in waterline and sails docs.