Skip to content

Incorrect example for @beforePaginate() hook in Lucid docs #226

@noah-bar

Description

@noah-bar

Hello,

I noticed an issue in the documentation regarding the usage of the @beforePaginate() hook.

The current example suggests that the hook receives two separate arguments:

@beforePaginate()
static ignoreDeleted (
  countQuery: ModelQueryBuilderContract<typeof User>,
  query: ModelQueryBuilderContract<typeof User>
) {
  query.whereNull('is_deleted')
  countQuery.whereNull('is_deleted')
}

However, in reality, the hook receives a single array of queries as its argument. The correct implementation should be:

@beforePaginate()
static ignoreDeleted([countQuery, query]: [
  ModelQueryBuilderContract<typeof User>,
  ModelQueryBuilderContract<typeof User>,
]) {
  query.whereNull('is_deleted')
  countQuery.whereNull('is_deleted')
}

This discrepancy might be confusing for new users trying to implement pagination hooks.

Thank you for your amazing work on AdonisJS!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions