Static Take

Configure default take amounts for your queries.

Project Toolchain Usage

This feature makes use of these Project Toolchain APIs: Middleware, Extensions. Because of this usage, it defines the following modules:

staticTake

This module defines the following middleware and extensions identifiers that can be imported via Project Toolchain, along with their descriptions:

  • alterFindMany - Alter all findMany queries to include the configured take amount.

To enable this optional feature, add the staticTake element to your optionalFeatures array, then use the generated middleware or extension inside of your code.

Feature Effect

Config Input

For this example, we're going to use the following configuration for the take property:

prisma-util/config.mjs
take: {
    $global: 20
}

Query Input

For this example, we'll pass the following input to the findMany operation on a model:

Test Input
{
    where: {
        id: 5
    }
}

Query Result

The input above will be manipulated and Prisma will receive this input:

Test Output
{
    where: {
        id: 5
    },
    take: 20
}

Last updated