有没有办法在Loopback中设置最大限制。我想象这样的事情:
MyModel.paginateFind = function(filter, page, cb){
// Set max limit of 1000
if (filter.limit > 1000) filter.limit = 1000;
// Set pagination
filter.skip = filter.limit * (page - 1);
// Call the standard find function with the new filter
MyModel.find(filter, function(err, res){
cb(err, res);
});
}
MyModel.remoteMethod(
'paginatedFind',
{
http: {path: '/', verb: 'get'},
accepts: [
{arg: 'filter', type: 'object'},
{arg: 'page', type: 'number'}
],
returns: {arg: 'result', type: 'object'}
}
);
当过滤器格式化为json时,这种方式有效,但不是这种格式:http://localhost:3000/api/MyModel?filter=[where][country]=DE
。如何使用标准的StongLoop过滤器格式?