Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: paginate type for _find #3421

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/adapter-commons/src/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ export interface InternalServiceMethods<
*
* @param _params - Service call parameters {@link Params}
*/
_find(_params?: Params & { paginate?: PaginationOptions }): Promise<Paginated<Result>>
_find(_params?: Params & { paginate: false }): Promise<Result[]>
_find(params?: Params): Promise<Result[] | Paginated<Result>>
_find(_params?: Params & { paginate: PaginationOptions }): Promise<Paginated<Result>>
_find(_params?: Params & { paginate?: false }): Promise<Result[]>
_find(
params?: (Params & { paginate: PaginationOptions }) | (Params & { paginate?: false })
): Promise<Result[] | Paginated<Result>>

/**
* Retrieve a single resource matching the given ID, skipping any service-level hooks.
Expand Down
8 changes: 5 additions & 3 deletions packages/adapter-commons/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ export abstract class AdapterBase<
*
* @param _params - Service call parameters {@link ServiceParams}
*/
abstract _find(_params?: ServiceParams & { paginate?: PaginationOptions }): Promise<Paginated<Result>>
abstract _find(_params?: ServiceParams & { paginate: false }): Promise<Result[]>
abstract _find(params?: ServiceParams): Promise<Result[] | Paginated<Result>>
abstract _find(_params?: ServiceParams & { paginate: PaginationOptions }): Promise<Paginated<Result>>
abstract _find(_params?: ServiceParams & { paginate?: false }): Promise<Result[]>
abstract _find(
params?: (ServiceParams & { paginate: PaginationOptions }) | (ServiceParams & { paginate?: false })
): Promise<Result[] | Paginated<Result>>

/**
* Retrieve a single resource matching the given ID, skipping any service-level hooks.
Expand Down
2 changes: 1 addition & 1 deletion packages/feathers/src/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export interface PaginationOptions {
max?: number
}

export type PaginationParams = false | PaginationOptions
export type PaginationParams = PaginationOptions

export interface Http {
/**
Expand Down
9 changes: 5 additions & 4 deletions packages/knex/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ export class KnexAdapter<
}
}

async _find(params?: ServiceParams & { paginate?: PaginationOptions }): Promise<Paginated<Result>>
async _find(params?: ServiceParams & { paginate: false }): Promise<Result[]>
async _find(params?: ServiceParams): Promise<Paginated<Result> | Result[]>
async _find(params: ServiceParams = {} as ServiceParams): Promise<Paginated<Result> | Result[]> {
async _find(params?: ServiceParams & { paginate: PaginationOptions }): Promise<Paginated<Result>>
async _find(params?: ServiceParams & { paginate?: false }): Promise<Result[]>
async _find(
params?: (ServiceParams & { paginate: PaginationOptions }) | (ServiceParams & { paginate?: false })
): Promise<Paginated<Result> | Result[]> {
const { filters, paginate } = this.filterQuery(params)
const { name, id } = this.getOptions(params)
const builder = params.knex ? params.knex.clone() : this.createQuery(params)
Expand Down
Loading