UNPKG

@conpago/mongo-cursor-pagination

Version:

Make it easy to return cursor-paginated results from a Mongo collection

24 lines (23 loc) 1.22 kB
import { QueryParams } from "../types"; /** * Sanitizes a `query` object received and merges it's changes to an optional `params` object * * @param {Object} query An object with the following properties: * -limit: If a numeric string, use it as the limit. If limit also passed in params * then this value cannot exceed it. * -next: If a non-empty string, use it as the next cursor. * -previous: If a non-empty string, use it as the previous cursor. * -fields: If a non-empty string, used to limit fields that are returned. Multiple fields * can be specified as a comma-delimited list. If field name used is not in params.fields, * it will be ignored. * @param {Object} params See documentation for `find()`, plus these options: * -overrideFields: an object containing fields that should override fields from the querystring, e.g. * {_id: 0} or {internalField: 1}. We only support field exclusion for _id, as we expect whitelists * for fields from both params.fields and params.overrideFields. */ declare const _default: (query: { limit?: string; next?: string | any; previous?: string | any; }, params: QueryParams) => QueryParams; export default _default;