customLabels: typescript
torquan opened this issue · 2 comments
torquan commented
Hi,
is it possible to customize the PaginateModel
to use my custom labels?
The Readme helped me with the paginationResult, but I'm stuck with those labels.
HamoBoker commented
Hi @torquan
you can achive this be override the interface of the results by creating mongoose/index.d.ts
in your types folder if you don't have one and add the code below into the file
declare module 'mongoose' {
interface PaginateResult<T> {
docs: T[]
data: T[]
totalDocs: number
limit: number
hasPrevPage: boolean
hasNextPage: boolean
page?: number | undefined
totalPages: number
offset: number
prevPage?: number | null | undefined
nextPage?: number | null | undefined
pagingCounter: number
meta?: any
// You can add your customLabels here, for example:
perPage: number
}
}
also you can remove the whole keys above and replace them with your custom labels if you have set your custom labels in plugin global options
Hope this help
torquan commented
Thanks, @HamoBoker!