Skip to main content
Version: 3.0 Alpha

Schema-Inferred Types

Most of the time, you don't need to explicitly type the input and output of the ORM methods, thanks to TypeScript's powerful inference capabilities. However, when you do have the need, you can rely on the following utilities to type things:

  • zenstack/models

    The zen generate command generates a models module that exports types for all models, types, and enums. The model types include all scalar fields (including computed ones).

  • zenstack/input

    The zen generate command generates an input module that exports types for input arguments of the ORM methods, such as UserCreateArgs, PostUpsertArgs, etc. You can use them to type intermediary variables that are later passed to the ORM methods.

  • ModelResult

    The ModelResult generic type from @zenstackhq/runtime allows you to infer the exact model type given field selection and relation inclusion information.

Samples

Click here to pop out if the embed doesn't load an interactive terminal.
Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below