1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/lib/services/rest/utils/paginatedResults.ts

14 lines
723 B
TypeScript
Raw Normal View History

2020-11-05 18:58:23 +02:00
import { Request } from '../Api';
import requestFields from './requestFields';
import BaseModel from '../../../BaseModel';
import requestPaginationOptions from './requestPaginationOptions';
import paginatedFeed, { WhereQuery, ModelFeedPage } from '../../../models/utils/paginatedFeed';
import BaseItem from '../../../models/BaseItem';
2020-11-05 18:58:23 +02:00
export default async function(modelType: number, request: Request, whereQuery: WhereQuery = null): Promise<ModelFeedPage> {
2020-11-05 18:58:23 +02:00
const ModelClass = BaseItem.getClassByItemType(modelType);
const fields = requestFields(request, modelType);
const pagination = requestPaginationOptions(request);
return paginatedFeed(BaseModel.db(), ModelClass.tableName(), pagination, whereQuery, fields);
2020-11-05 18:58:23 +02:00
}