Param
Represents an external bind parameter. Serializes to :name by default (a dialect extension may
render a different placeholder syntax). See
Raw SQL and Parameters for a full
walkthrough.
Constructor
Param(name: string, dataType?: DataType, isArray?: boolean): Param
Param(args: Param.Args): Param
new Param(...): Param
Dual-callable, with two argument forms:
interface Param.Args {
name: string;
dataType?: DataType;
isArray?: boolean;
}
import { Param, DataType } from '@sqb/builder';
Param('id');
Param('id', DataType.INTEGER, false);
Param({ name: 'id', dataType: DataType.INTEGER });
Properties
| Key | Type | Readonly | Description |
|---|---|---|---|
_type | SerializationType.EXTERNAL_PARAMETER | Yes | Discriminates this node during serialization. |
_name | string | No | Parameter name. |
_dataType | DataType | undefined | No | Optional data type hint, surfaced on GenerateResult.paramOptions. |
_isArray | boolean | undefined | No | Optional array-parameter hint. |
Methods
Param has no chainable methods — its serialization logic resolves the parameter's value from
ctx.params (populated from generate({ params }) or .values()), records it on
GenerateResult.params/paramOptions, and renders :name.
import { Select, Eq, Param } from '@sqb/builder';
const result = Select().from('customers').where(Eq('id', Param('id'))).generate({
params: { id: 1 },
});
result.sql; // select * from customers where id = :id
result.params; // { id: 1 }