0
有沒有辦法在Loopback中設置最大限制?我想是這樣的:在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濾鏡格式?
你也許找'極限filter'這齊頭並進與'跳過filter'? http://docs.strongloop.com/display/public/LB/Limit+filter – pulkitsinghal
是的,但我不知道如何操縱模型中自定義函數/終點的過濾器。我相信這是超級簡單的事情。 –
你的僞代碼看起來相當準確〜對我來說......你問過https://gitter.im/strongloop/loopback了嗎? – pulkitsinghal