1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/packages/lib/services/rest/utils/paginatedResults.ts
2021-01-22 17:41:11 +00:00

14 lines
723 B
TypeScript

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';
export default async function(modelType: number, request: Request, whereQuery: WhereQuery = null): Promise<ModelFeedPage> {
const ModelClass = BaseItem.getClassByItemType(modelType);
const fields = requestFields(request, modelType);
const pagination = requestPaginationOptions(request);
return paginatedFeed(BaseModel.db(), ModelClass.tableName(), pagination, whereQuery, fields);
}