2014-10-30 89 views

回答

23

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

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

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

如果你想分页异步工作,它很容易做到与jQuery $$.getJSON和服务器res.json();

上Theres很多在水线和帆文档信息的。

+2

我写了一些蓝图帮助分页https://github.com/randallmeeker/SailsBluePrintActions/tree/master/pagination – Meeker 2014-10-30 20:14:16

7

还有另外一种方法。

,如果你想获取从前端数据,并已经把蓝图上,你也可以尝试: http://yourDomain.com/ModelName?skip=10&limit=10

参考: 1.officer网站:http://sailsjs.org/#/documentation/reference/blueprint-api/Find.html

+6

这是真棒...但为了在前面生成一个功能paginator en我需要获得初始值我的(角) app ...通过初始我的意思是:项目总数和items_per_page(如果没有指定它应该是蓝图中的默认值)。 ...什么是适当的模式来获得这些? – 2015-11-23 12:25:06