Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 572
sasitha999 Avatar asked Oct 30 '14 08:10

sasitha999


People also ask

What is waterline in sails JS?

Waterline is a next-generation storage and retrieval engine, and the default ORM used in the Sails framework.

How does sails JS work?

Sails. js uses Grunt as a build tool for building front-end assets. If you're building an app for the browser, you're in luck. Sails ships with Grunt — which means your entire front-end asset workflow is completely customizable, and comes with support for all of the great Grunt modules which are already out there.

What is sails in node JS?

js (or Sails) is a model–view–controller (MVC) web application framework developed atop the Node. js environment, released as free and open-source software under the MIT License. It is designed to make it easy to build custom, enterprise-grade Node. js web applications and APIs.


1 Answers

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.

like image 183
Martin Malinda Avatar answered Oct 14 '22 20:10

Martin Malinda