Basic Usage
String Parameters
p.string()
String parameter.
p.uuid()
UUID parameter.
Integer Parameters
p.int8()
8-bit signed integer
p.int16()
16-bit signed integer
p.int32()
32-bit signed integer
p.int64()
64-bit signed integer
p.uint8()
8-bit unsigned integer
p.uint16()
16-bit unsigned integer
p.uint32()
32-bit unsigned integer
p.uint64()
64-bit unsigned integer
Float Parameters
p.float32()
32-bit floating point parameter.
p.float64()
64-bit floating point parameter.
Boolean
p.boolean()
Boolean parameter.
Date/Time Parameters
p.date()
Date parameter in YYYY-MM-DD format.
p.dateTime()
DateTime parameter in YYYY-MM-DD HH:MM:SS format.
p.dateTime64()
DateTime64 parameter with fractional seconds.
Array Parameters
p.array(element, separator?)
Array parameter - values can be passed as comma-separated or repeated params.
Special Parameters
p.column()
Column reference parameter - allows dynamic column selection.
p.json()
JSON parameter for passing complex structured data.
Modifiers
.optional(defaultValue?)
Make a parameter optional with an optional default value.- If a default value is provided, the parameter type remains the base type
- If no default value is provided, the parameter type becomes
T | undefined
.required()
Explicitly mark a parameter as required (this is the default)..describe(description)
Add a description for documentation purposes.Complete Example
Using Parameters in SQL
When using parameters in your SQL queries, wrap them with the appropriate type function:Conditional Parameters
Use Jinja2 templating for optional parameters:Type Inference
Best Practices
Use Optional with Defaults
Provide sensible defaults for optional parameters to improve API usability.
Add Descriptions
Document your parameters for better developer experience.
Use Appropriate Types
Choose the most specific type for your use case (e.g.,
p.uint32() for IDs).Validate in SQL
Add additional validation in your SQL queries when needed.