---
url: /unthrown/api/drizzle/index-1.md
---
[**@unthrown/drizzle**](index.md)

***

[@unthrown/drizzle](index.md) / index

# index

## Builders

### PgUnthrownCountBuilder

Defined in: [packages/drizzle/src/pg-core/count.ts:37](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/count.ts#L37)

A `$count` query that resolves to an `AsyncResult`.

#### Remarks

The one builder with no `_prepare`: it inherits from drizzle's `PgCountBuilder`,
which is itself an `SQL` fragment, so it can be embedded in a larger query as
well as run on its own. Running it prepares the count inline.

#### Extends

* `PgCountBuilder`

#### Constructors

##### Constructor

```ts
new PgUnthrownCountBuilder(__namedParameters): PgUnthrownCountBuilder;
```

Defined in: [packages/drizzle/src/pg-core/count.ts:42](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/count.ts#L42)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `__namedParameters` | { `dialect`: `PgDialect`; `filters?`: `SQL`<`unknown`>; `session`: [`PgUnthrownSession`](#abstract-pgunthrownsession)<`unknown`>; `source`: | `PgTable`<`TableConfig`> | `PgViewBase`<`ViewConfig`<`ColumnsSelection`>> | `SQL`<`unknown`> | `SQLWrapper`<`unknown`>; } |
| `__namedParameters.dialect` | `PgDialect` |
| `__namedParameters.filters?` | `SQL`<`unknown`> |
| `__namedParameters.session` | [`PgUnthrownSession`](#abstract-pgunthrownsession)<`unknown`> |
| `__namedParameters.source` | | `PgTable`<`TableConfig`> | `PgViewBase`<`ViewConfig`<`ColumnsSelection`>> | `SQL`<`unknown`> | `SQLWrapper`<`unknown`> |

###### Returns

[`PgUnthrownCountBuilder`](#pgunthrowncountbuilder)

###### Overrides

`PgCountBuilder.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `public` | `object` | `undefined` | - | - | `PgCountBuilder._` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:60 |
| `_.brand` | `public` | `"SQL"` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:61 |
| `_.type` | `public` | `number` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:62 |
|  `queryChunks` | `readonly` | `SQLChunk`\[] | `undefined` | - | - | `PgCountBuilder.queryChunks` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:58 |
|  `then` | `readonly` | [`ResultThen`](#resultthen)<`number`, `never`> | `...` | The `then` that makes a query builder awaitable, resolving to a `Result`. **Remarks** Drizzle's promise and Effect trees each make their builders runnable the same way: the builder carries a `then` that defers to `execute()`. The promise tree gets it from the `QueryPromise` mixin, whose `then` is literally `this.execute().then(onFulfilled, onRejected)`. This package cannot reuse that mixin. `QueryPromise<T>` declares `execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` — so merging its type would contradict the very method it delegates to. (Its `applyMixins` helper is `@internal` and absent from drizzle's published `.d.ts` besides.) Each builder therefore declares this `then` itself, built by `resultThen`, with the awaited type it actually produces. Awaiting a builder yields a `Result`, never a rejection: `execute()` returns an `AsyncResult`, whose internal promise never rejects, and the compilation step ahead of it runs inside the same boundary — see `runQuery`. `catch` and `finally` are deliberately not offered: there is no rejection for them to observe. `onRejected` is still forwarded, exactly as `AsyncResult.then` forwards it, so a hypothetical internal rejection settles the `await` instead of hanging it. | - | - | [packages/drizzle/src/pg-core/count.ts:83](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/count.ts#L83) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownCountBuilder"` | - | `PgCountBuilder.[entityKind]` | - | [packages/drizzle/src/pg-core/count.ts:38](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/count.ts#L38) |

#### Methods

##### append()

```ts
append(query): this;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:65

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `query` | `SQL` |

###### Returns

`this`

###### Inherited from

`PgCountBuilder.append`

##### as()

###### Call Signature

```ts
as(alias): Aliased<number>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:71

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `alias` | `string` |

###### Returns

`Aliased`<`number`>

###### Inherited from

`PgCountBuilder.as`

###### Call Signature

```ts
as<TData>(): SQL<TData>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:76

###### Type Parameters

| Type Parameter |
| ------ |
|  `TData` |

###### Returns

`SQL`<`TData`>

###### Deprecated

Use ``sql\<DataType\>`query`.as(alias)`` instead.

###### Inherited from

`PgCountBuilder.as`

###### Call Signature

```ts
as<TData>(alias): Aliased<TData>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:81

###### Type Parameters

| Type Parameter |
| ------ |
|  `TData` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `alias` | `string` |

###### Returns

`Aliased`<`TData`>

###### Deprecated

Use ``sql\<DataType\>`query`.as(alias)`` instead.

###### Inherited from

`PgCountBuilder.as`

##### buildQueryFromSourceParams()

```ts
buildQueryFromSourceParams(chunks, _config): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:67

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `chunks` | `SQLChunk`\[] |
| `_config` | `BuildQueryConfig` |

###### Returns

`Query`

###### Inherited from

`PgCountBuilder.buildQueryFromSourceParams`

##### execute()

```ts
execute(placeholderValues?): AsyncResult<number, never>;
```

Defined in: [packages/drizzle/src/pg-core/count.ts:66](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/count.ts#L66)

Run the count, resolving to the number of matching rows.

The error channel is `never` — a count is a read, so every failure it can
hit is a defect. See `runSafeQuery`.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> |

###### Returns

`AsyncResult`<`number`, `never`>

##### getSQL()

```ts
getSQL(): SQL<number>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:70

###### Returns

`SQL`<`number`>

###### Inherited from

`PgCountBuilder.getSQL`

##### if()

```ts
if(condition): PgUnthrownCountBuilder | undefined;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:91

This method is used to conditionally include a part of the query.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `condition` | `any` | Condition to check |

###### Returns

[`PgUnthrownCountBuilder`](#pgunthrowncountbuilder) | `undefined`

itself if the condition is `true`, otherwise `undefined`

###### Inherited from

`PgCountBuilder.if`

##### inlineParams()

```ts
inlineParams(): this;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:84

###### Returns

`this`

###### Inherited from

`PgCountBuilder.inlineParams`

##### mapWith()

```ts
mapWith<TDecoder>(decoder): SQL<GetDecoderResult<TDecoder>>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:82

###### Type Parameters

| Type Parameter |
| ------ |
|  `TDecoder` *extends* | `DriverValueDecoder`<`any`, `number`> | `DriverValueDecoderFn`<`any`, `number`> |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `decoder` | `TDecoder` |

###### Returns

`SQL`<`GetDecoderResult`<`TDecoder`>>

###### Inherited from

`PgCountBuilder.mapWith`

##### nullable()

```ts
nullable(): SQL<number | null>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:83

###### Returns

`SQL`<`number` | `null`>

###### Inherited from

`PgCountBuilder.nullable`

##### toQuery()

```ts
toQuery(config): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:66

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `config` | `BuildQueryConfig` |

###### Returns

`Query`

###### Inherited from

`PgCountBuilder.toQuery`

***

### PgUnthrownDeleteBase

Defined in: [packages/drizzle/src/pg-core/delete.ts:58](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/delete.ts#L58)

A `delete` query that resolves to an `AsyncResult`.

#### Remarks

Deleting a row another table still references raises a
[ForeignKeyViolation](#foreignkeyviolation), which lands in the error channel rather than as a
rejection.

#### Extends

* `PgDeleteBase`<[`PgUnthrownDeleteHKT`](#pgunthrowndeletehkt), `TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>

#### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `TTable` *extends* `PgTable` | - |
|  `TQueryResult` *extends* `PgQueryResultHKT` | - |
|  `TSelectedFields` *extends* `ColumnsSelection` | `undefined` | `undefined` |
|  `TReturning` *extends* `Record`<`string`, `unknown`> | `undefined` | `undefined` |
|  `TDynamic` *extends* `boolean` | `false` |
|  `TExcludedMethods` *extends* `string` | `never` |

#### Constructors

##### Constructor

```ts
new PgUnthrownDeleteBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>(
   table, 
   session, 
   dialect, 
   withList?
): PgUnthrownDeleteBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:66

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `table` | `TTable` |
| `session` | `PgSession` |
| `dialect` | `PgDialect` |
| `withList?` | `Subquery`<`string`, `Record`<`string`, `unknown`>>\[] |

###### Returns

[`PgUnthrownDeleteBase`](#pgunthrowndeletebase)<`TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>

###### Inherited from

`PgDeleteBase<PgUnthrownDeleteHKT, TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | `undefined` | - | - | `PgDeleteBase._` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:49 |
| `_.dialect` | `readonly` | `"pg"` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:50 |
| `_.dynamic` | `readonly` | `TDynamic` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:56 |
| `_.excludedMethods` | `readonly` | `TExcludedMethods` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:57 |
| `_.hkt` | `readonly` | [`PgUnthrownDeleteHKT`](#pgunthrowndeletehkt) | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:51 |
| `_.queryResult` | `readonly` | `TQueryResult` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:53 |
| `_.result` | `readonly` | `TReturning` *extends* `undefined` ? `PgQueryResultKind`<`TQueryResult`, `never`> : `TReturning`\[] | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:58 |
| `_.returning` | `readonly` | `TReturning` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:55 |
| `_.selectedFields` | `readonly` | `TSelectedFields` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:54 |
| `_.table` | `readonly` | `TTable` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:52 |
|  `then` | `readonly` | [`ResultThen`](#resultthen)<[`DeleteResult`](#deleteresult)<`TQueryResult`, `TReturning`>> | `...` | The `then` that makes a query builder awaitable, resolving to a `Result`. **Remarks** Drizzle's promise and Effect trees each make their builders runnable the same way: the builder carries a `then` that defers to `execute()`. The promise tree gets it from the `QueryPromise` mixin, whose `then` is literally `this.execute().then(onFulfilled, onRejected)`. This package cannot reuse that mixin. `QueryPromise<T>` declares `execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` — so merging its type would contradict the very method it delegates to. (Its `applyMixins` helper is `@internal` and absent from drizzle's published `.d.ts` besides.) Each builder therefore declares this `then` itself, built by `resultThen`, with the awaited type it actually produces. Awaiting a builder yields a `Result`, never a rejection: `execute()` returns an `AsyncResult`, whose internal promise never rejects, and the compilation step ahead of it runs inside the same boundary — see `runQuery`. `catch` and `finally` are deliberately not offered: there is no rejection for them to observe. `onRejected` is still forwarded, exactly as `AsyncResult.then` forwards it, so a hypothetical internal rejection settles the `await` instead of hanging it. | - | - | [packages/drizzle/src/pg-core/delete.ts:121](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/delete.ts#L121) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownDelete"` | - | `PgDeleteBase.[entityKind]` | - | [packages/drizzle/src/pg-core/delete.ts:74](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/delete.ts#L74) |

#### Methods

##### $dynamic()

```ts
$dynamic(): PgUnthrownDeleteBase<Assume<TTable, PgTable<TableConfig>>>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:125

###### Returns

[`PgUnthrownDeleteBase`](#pgunthrowndeletebase)<`Assume`<`TTable`, `PgTable`<`TableConfig`>>>

###### Inherited from

`PgDeleteBase.$dynamic`

##### comment()

```ts
comment(comment): PgDeleteWithout<PgUnthrownDeleteBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>, TDynamic, "comment">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:122

Attach [sqlcommenter](https://google.github.io/sqlcommenter) comment to a query

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `comment` | `CommentInput` |

###### Returns

`PgDeleteWithout`<[`PgUnthrownDeleteBase`](#pgunthrowndeletebase)<`TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"comment"`>

###### Inherited from

`PgDeleteBase.comment`

##### execute()

```ts
execute(placeholderValues?): AsyncResult<DeleteResult<TQueryResult, TReturning>, PgQueryError>;
```

Defined in: [packages/drizzle/src/pg-core/delete.ts:113](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/delete.ts#L113)

Run the delete, resolving to its result or a [PgQueryError](#pgqueryerror).

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> |

###### Returns

`AsyncResult`<[`DeleteResult`](#deleteresult)<`TQueryResult`, `TReturning`>, [`PgQueryError`](#pgqueryerror)>

##### getSQL()

```ts
getSQL(): SQL;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:123

###### Returns

`SQL`

###### Inherited from

`PgDeleteBase.getSQL`

##### prepare()

```ts
prepare(name): PgUnthrownPreparedQuery<PreparedQueryConfig & object>;
```

Defined in: [packages/drizzle/src/pg-core/delete.ts:104](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/delete.ts#L104)

Create a prepared statement for this query. This allows the database to
remember this query for the given session and call it by name, rather than
specifying the full query.

[Postgres prepare documentation](https://www.postgresql.org/docs/current/sql-prepare.html)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |

###### Returns

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery)<`PreparedQueryConfig` & `object`>

##### returning()

###### Call Signature

```ts
returning(): PgDeleteWithout<PgDeleteKind<PgUnthrownDeleteHKT, TTable, TQueryResult, TTable["_"]["columns"], TTable["$inferSelect"], TDynamic, TExcludedMethods>, TDynamic>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:117

Adds a `returning` clause to the query.

Calling this method will return the specified fields of the deleted rows. If no fields are specified, all fields will be returned.

See docs: <https://orm.drizzle.team/docs/delete#delete-with-return>

###### Returns

`PgDeleteWithout`<`PgDeleteKind`<[`PgUnthrownDeleteHKT`](#pgunthrowndeletehkt), `TTable`, `TQueryResult`, `TTable`\[`"_"`]\[`"columns"`], `TTable`\[`"$inferSelect"`], `TDynamic`, `TExcludedMethods`>, `TDynamic`>

###### Example

```ts
// Delete all cars with the green color and return all fields
const deletedCars: Car[] = await db.delete(cars)
  .where(eq(cars.color, 'green'))
  .returning();

// Delete all cars with the green color and return only their id and brand fields
const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars)
  .where(eq(cars.color, 'green'))
  .returning({ id: cars.id, brand: cars.brand });
```

###### Inherited from

`PgDeleteBase.returning`

###### Call Signature

```ts
returning<TSelectedFields>(fields): PgDeleteWithout<PgDeleteKind<PgUnthrownDeleteHKT, TTable, TQueryResult, TSelectedFields, { [K in string | number | symbol]: { [Key in string | number | symbol]: SelectResultField<TSelectedFields[Key], true> }[K] }, TDynamic, TExcludedMethods>, TDynamic, "returning">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:118

Adds a `returning` clause to the query.

Calling this method will return the specified fields of the deleted rows. If no fields are specified, all fields will be returned.

See docs: <https://orm.drizzle.team/docs/delete#delete-with-return>

###### Type Parameters

| Type Parameter |
| ------ |
|  `TSelectedFields` *extends* `SelectedFieldsFlat` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `TSelectedFields` |

###### Returns

`PgDeleteWithout`<`PgDeleteKind`<[`PgUnthrownDeleteHKT`](#pgunthrowndeletehkt), `TTable`, `TQueryResult`, `TSelectedFields`, { \[K in string | number | symbol]: { \[Key in string | number | symbol]: SelectResultField\<TSelectedFields\[Key], true> }\[K] }, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"returning"`>

###### Example

```ts
// Delete all cars with the green color and return all fields
const deletedCars: Car[] = await db.delete(cars)
  .where(eq(cars.color, 'green'))
  .returning();

// Delete all cars with the green color and return only their id and brand fields
const deletedCarsIdsAndBrands: { id: number, brand: string }[] = await db.delete(cars)
  .where(eq(cars.color, 'green'))
  .returning({ id: cars.id, brand: cars.brand });
```

###### Inherited from

`PgDeleteBase.returning`

##### shouldOmitSQLParens()?

```ts
shouldOmitSQLParens?(): boolean;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:48

###### Returns

`boolean`

###### Inherited from

`PgDeleteBase.shouldOmitSQLParens`

##### toSQL()

```ts
toSQL(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:124

###### Returns

`Query`

###### Inherited from

`PgDeleteBase.toSQL`

##### where()

```ts
where(where): PgDeleteWithout<PgUnthrownDeleteBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>, TDynamic, "where">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:96

Adds a `where` clause to the query.

Calling this method will delete only those rows that fulfill a specified condition.

See docs: <https://orm.drizzle.team/docs/delete>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `where` | `SQL`<`unknown`> | `undefined` | the `where` clause. |

###### Returns

`PgDeleteWithout`<[`PgUnthrownDeleteBase`](#pgunthrowndeletebase)<`TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"where"`>

###### Example

You can use conditional operators and `sql function` to filter the rows to be deleted.

```ts
// Delete all cars with green color
await db.delete(cars).where(eq(cars.color, 'green'));
// or
await db.delete(cars).where(sql`${cars.color} = 'green'`)
```

You can logically combine conditional operators with `and()` and `or()` operators:

```ts
// Delete all BMW cars with a green color
await db.delete(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));

// Delete all cars with the green or blue color
await db.delete(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
```

###### Inherited from

`PgDeleteBase.where`

***

### PgUnthrownInsertBase

Defined in: [packages/drizzle/src/pg-core/insert.ts:57](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/insert.ts#L57)

An `insert` query that resolves to an `AsyncResult`.

#### Remarks

This is where the package earns its keep: a unique index, a foreign key or a
`NOT NULL` column turns a write into a modeled [PgQueryError](#pgqueryerror) instead of
a rejection, so the caller branches on it exhaustively.

#### Extends

* `PgInsertBase`<[`PgUnthrownInsertHKT`](#pgunthrowninserthkt), `TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>

#### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `TTable` *extends* `PgTable` | - |
|  `TQueryResult` *extends* `PgQueryResultHKT` | - |
|  `TSelectedFields` | `undefined` |
|  `TReturning` | `undefined` |
|  `TDynamic` *extends* `boolean` | `false` |
|  `TExcludedMethods` *extends* `string` | `never` |

#### Constructors

##### Constructor

```ts
new PgUnthrownInsertBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>(
   table, 
   values, 
   session, 
   dialect, 
   withList?, 
   select?, 
   columnList?, 
   overridingSystemValue_?
): PgUnthrownInsertBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:118

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `table` | `TTable` |
| `values` | | `SQL`<`unknown`> | `Record`<`string`, `unknown`>\[] | `TypedQueryBuilder`<{ }, `unknown`, `unknown`> |
| `session` | `PgSession` |
| `dialect` | `PgDialect` |
| `withList?` | `Subquery`<`string`, `Record`<`string`, `unknown`>>\[] |
| `select?` | `boolean` |
| `columnList?` | `string`\[] |
| `overridingSystemValue_?` | `boolean` |

###### Returns

[`PgUnthrownInsertBase`](#pgunthrowninsertbase)<`TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>

###### Inherited from

`PgInsertBase<PgUnthrownInsertHKT, TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | `undefined` | - | - | `PgInsertBase._` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:101 |
| `_.dialect` | `readonly` | `"pg"` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:102 |
| `_.dynamic` | `readonly` | `TDynamic` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:108 |
| `_.excludedMethods` | `readonly` | `TExcludedMethods` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:109 |
| `_.hkt` | `readonly` | [`PgUnthrownInsertHKT`](#pgunthrowninserthkt) | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:103 |
| `_.queryResult` | `readonly` | `TQueryResult` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:105 |
| `_.result` | `readonly` | `TReturning` *extends* `undefined` ? `PgQueryResultKind`<`TQueryResult`, `never`> : `TReturning`\[] | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:110 |
| `_.returning` | `readonly` | `TReturning` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:107 |
| `_.selectedFields` | `readonly` | `TSelectedFields` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:106 |
| `_.table` | `readonly` | `TTable` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:104 |
|  `then` | `readonly` | [`ResultThen`](#resultthen)<[`InsertResult`](#insertresult)<`TQueryResult`, `TReturning`>> | `...` | The `then` that makes a query builder awaitable, resolving to a `Result`. **Remarks** Drizzle's promise and Effect trees each make their builders runnable the same way: the builder carries a `then` that defers to `execute()`. The promise tree gets it from the `QueryPromise` mixin, whose `then` is literally `this.execute().then(onFulfilled, onRejected)`. This package cannot reuse that mixin. `QueryPromise<T>` declares `execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` — so merging its type would contradict the very method it delegates to. (Its `applyMixins` helper is `@internal` and absent from drizzle's published `.d.ts` besides.) Each builder therefore declares this `then` itself, built by `resultThen`, with the awaited type it actually produces. Awaiting a builder yields a `Result`, never a rejection: `execute()` returns an `AsyncResult`, whose internal promise never rejects, and the compilation step ahead of it runs inside the same boundary — see `runQuery`. `catch` and `finally` are deliberately not offered: there is no rejection for them to observe. `onRejected` is still forwarded, exactly as `AsyncResult.then` forwards it, so a hypothetical internal rejection settles the `await` instead of hanging it. | - | - | [packages/drizzle/src/pg-core/insert.ts:120](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/insert.ts#L120) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownInsert"` | - | `PgInsertBase.[entityKind]` | - | [packages/drizzle/src/pg-core/insert.ts:73](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/insert.ts#L73) |

#### Methods

##### $dynamic()

```ts
$dynamic(): PgUnthrownInsertBase<Assume<TTable, PgTable<TableConfig>>>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:203

###### Returns

[`PgUnthrownInsertBase`](#pgunthrowninsertbase)<`Assume`<`TTable`, `PgTable`<`TableConfig`>>>

###### Inherited from

`PgInsertBase.$dynamic`

##### comment()

```ts
comment(comment): PgInsertWithout<PgUnthrownInsertBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>, TDynamic, "comment">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:200

Attach [sqlcommenter](https://google.github.io/sqlcommenter) comment to a query

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `comment` | `CommentInput` |

###### Returns

`PgInsertWithout`<[`PgUnthrownInsertBase`](#pgunthrowninsertbase)<`TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"comment"`>

###### Inherited from

`PgInsertBase.comment`

##### execute()

```ts
execute(placeholderValues?): AsyncResult<InsertResult<TQueryResult, TReturning>, PgQueryError>;
```

Defined in: [packages/drizzle/src/pg-core/insert.ts:112](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/insert.ts#L112)

Run the insert, resolving to its result or a [PgQueryError](#pgqueryerror).

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> |

###### Returns

`AsyncResult`<[`InsertResult`](#insertresult)<`TQueryResult`, `TReturning`>, [`PgQueryError`](#pgqueryerror)>

##### getSQL()

```ts
getSQL(): SQL;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:201

###### Returns

`SQL`

###### Inherited from

`PgInsertBase.getSQL`

##### onConflictDoNothing()

```ts
onConflictDoNothing(config?): PgInsertWithout<PgUnthrownInsertBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>, TDynamic, "onConflictDoNothing" | "onConflictDoUpdate">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:163

Adds an `on conflict do nothing` clause to the query.

Calling this method simply avoids inserting a row as its alternative action.

See docs: <https://orm.drizzle.team/docs/insert#on-conflict-do-nothing>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `config?` | { `target?`: `IndexColumn` | `IndexColumn`\[]; `where?`: `SQL`<`unknown`>; } | The `target` and `where` clauses. |
| `config.target?` | `IndexColumn` | `IndexColumn`\[] | - |
| `config.where?` | `SQL`<`unknown`> | - |

###### Returns

`PgInsertWithout`<[`PgUnthrownInsertBase`](#pgunthrowninsertbase)<`TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"onConflictDoNothing"` | `"onConflictDoUpdate"`>

###### Example

```ts
// Insert one row and cancel the insert if there's a conflict
await db.insert(cars)
  .values({ id: 1, brand: 'BMW' })
  .onConflictDoNothing();

// Explicitly specify conflict target
await db.insert(cars)
  .values({ id: 1, brand: 'BMW' })
  .onConflictDoNothing({ target: cars.id });
```

###### Inherited from

`PgInsertBase.onConflictDoNothing`

##### onConflictDoUpdate()

```ts
onConflictDoUpdate(config): PgInsertWithout<PgUnthrownInsertBase<TTable, TQueryResult, TSelectedFields, TReturning, TDynamic, TExcludedMethods>, TDynamic, "onConflictDoNothing" | "onConflictDoUpdate">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:196

Adds an `on conflict do update` clause to the query.

Calling this method will update the existing row that conflicts with the row proposed for insertion as its alternative action.

See docs: <https://orm.drizzle.team/docs/insert#upserts-and-conflicts>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `config` | `PgInsertOnConflictDoUpdateConfig`<[`PgUnthrownInsertBase`](#pgunthrowninsertbase)<`TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>> | The `target`, `set` and `where` clauses. |

###### Returns

`PgInsertWithout`<[`PgUnthrownInsertBase`](#pgunthrowninsertbase)<`TTable`, `TQueryResult`, `TSelectedFields`, `TReturning`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"onConflictDoNothing"` | `"onConflictDoUpdate"`>

###### Example

```ts
// Update the row if there's a conflict
await db.insert(cars)
  .values({ id: 1, brand: 'BMW' })
  .onConflictDoUpdate({
    target: cars.id,
    set: { brand: 'Porsche' }
  });

// Upsert with 'where' clause
await db.insert(cars)
  .values({ id: 1, brand: 'BMW' })
  .onConflictDoUpdate({
    target: cars.id,
    set: { brand: 'newBMW' },
    targetWhere: sql`${cars.createdAt} > '2023-01-01'::date`,
  });
```

###### Inherited from

`PgInsertBase.onConflictDoUpdate`

##### prepare()

```ts
prepare(name): PgUnthrownPreparedQuery<PreparedQueryConfig & object>;
```

Defined in: [packages/drizzle/src/pg-core/insert.ts:103](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/insert.ts#L103)

Create a prepared statement for this query. This allows the database to
remember this query for the given session and call it by name, rather than
specifying the full query.

[Postgres prepare documentation](https://www.postgresql.org/docs/current/sql-prepare.html)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |

###### Returns

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery)<`PreparedQueryConfig` & `object`>

##### returning()

###### Call Signature

```ts
returning(): PgInsertWithout<PgInsertKind<PgUnthrownInsertHKT, TTable, TQueryResult, TTable["_"]["columns"], TTable["$inferSelect"], TDynamic, TExcludedMethods>, TDynamic>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:139

Adds a `returning` clause to the query.

Calling this method will return the specified fields of the inserted rows. If no fields are specified, all fields will be returned.

See docs: <https://orm.drizzle.team/docs/insert#insert-returning>

###### Returns

`PgInsertWithout`<`PgInsertKind`<[`PgUnthrownInsertHKT`](#pgunthrowninserthkt), `TTable`, `TQueryResult`, `TTable`\[`"_"`]\[`"columns"`], `TTable`\[`"$inferSelect"`], `TDynamic`, `TExcludedMethods`>, `TDynamic`>

###### Example

```ts
// Insert one row and return all fields
const insertedCar: Car[] = await db.insert(cars)
  .values({ brand: 'BMW' })
  .returning();

// Insert one row and return only the id
const insertedCarId: { id: number }[] = await db.insert(cars)
  .values({ brand: 'BMW' })
  .returning({ id: cars.id });
```

###### Inherited from

`PgInsertBase.returning`

###### Call Signature

```ts
returning<TSelectedFields>(fields): PgInsertWithout<PgInsertKind<PgUnthrownInsertHKT, TTable, TQueryResult, TSelectedFields, { [K in string | number | symbol]: { [Key in string | number | symbol]: SelectResultField<TSelectedFields[Key], true> }[K] }, TDynamic, TExcludedMethods>, TDynamic, "returning">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:140

Adds a `returning` clause to the query.

Calling this method will return the specified fields of the inserted rows. If no fields are specified, all fields will be returned.

See docs: <https://orm.drizzle.team/docs/insert#insert-returning>

###### Type Parameters

| Type Parameter |
| ------ |
|  `TSelectedFields` *extends* `SelectedFieldsFlat` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `TSelectedFields` |

###### Returns

`PgInsertWithout`<`PgInsertKind`<[`PgUnthrownInsertHKT`](#pgunthrowninserthkt), `TTable`, `TQueryResult`, `TSelectedFields`, { \[K in string | number | symbol]: { \[Key in string | number | symbol]: SelectResultField\<TSelectedFields\[Key], true> }\[K] }, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"returning"`>

###### Example

```ts
// Insert one row and return all fields
const insertedCar: Car[] = await db.insert(cars)
  .values({ brand: 'BMW' })
  .returning();

// Insert one row and return only the id
const insertedCarId: { id: number }[] = await db.insert(cars)
  .values({ brand: 'BMW' })
  .returning({ id: cars.id });
```

###### Inherited from

`PgInsertBase.returning`

##### shouldOmitSQLParens()?

```ts
shouldOmitSQLParens?(): boolean;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:48

###### Returns

`boolean`

###### Inherited from

`PgInsertBase.shouldOmitSQLParens`

##### toSQL()

```ts
toSQL(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:202

###### Returns

`Query`

###### Inherited from

`PgInsertBase.toSQL`

***

### PgUnthrownRaw

Defined in: [packages/drizzle/src/pg-core/raw.ts:22](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/raw.ts#L22)

A raw `db.execute(sql\`…\`)`query that resolves to an`AsyncResult\`.

#### Remarks

Unlike every other builder, this one is handed an already-prepared query — the
database prepared it when building the fragment — so `_prepare` simply returns
it and `execute` runs it.

#### Extends

* `PgRaw`<`TResult`>

#### Type Parameters

| Type Parameter | Description |
| ------ | ------ |
|  `TResult` | the driver's result for the statement. |

#### Constructors

##### Constructor

```ts
new PgUnthrownRaw<TResult>(
   prepared, 
   sql, 
   query
): PgUnthrownRaw<TResult>;
```

Defined in: [packages/drizzle/src/pg-core/raw.ts:31](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/raw.ts#L31)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `prepared` | [`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery)<{ `execute`: `TResult`; }> |
| `sql` | `SQL` |
| `query` | `Query` |

###### Returns

[`PgUnthrownRaw`](#pgunthrownraw)<`TResult`>

###### Overrides

`PgRaw<TResult>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | `undefined` | - | - | `PgRaw._` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/raw.d.ts:12 |
| `_.dialect` | `readonly` | `"pg"` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/raw.d.ts:13 |
| `_.result` | `readonly` | `TResult` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/raw.d.ts:14 |
|  `then` | `readonly` | [`ResultThen`](#resultthen)<`TResult`> | `...` | The `then` that makes a query builder awaitable, resolving to a `Result`. **Remarks** Drizzle's promise and Effect trees each make their builders runnable the same way: the builder carries a `then` that defers to `execute()`. The promise tree gets it from the `QueryPromise` mixin, whose `then` is literally `this.execute().then(onFulfilled, onRejected)`. This package cannot reuse that mixin. `QueryPromise<T>` declares `execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` — so merging its type would contradict the very method it delegates to. (Its `applyMixins` helper is `@internal` and absent from drizzle's published `.d.ts` besides.) Each builder therefore declares this `then` itself, built by `resultThen`, with the awaited type it actually produces. Awaiting a builder yields a `Result`, never a rejection: `execute()` returns an `AsyncResult`, whose internal promise never rejects, and the compilation step ahead of it runs inside the same boundary — see `runQuery`. `catch` and `finally` are deliberately not offered: there is no rejection for them to observe. `onRejected` is still forwarded, exactly as `AsyncResult.then` forwards it, so a hypothetical internal rejection settles the `await` instead of hanging it. | - | - | [packages/drizzle/src/pg-core/raw.ts:46](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/raw.ts#L46) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownRaw"` | - | `PgRaw.[entityKind]` | - | [packages/drizzle/src/pg-core/raw.ts:23](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/raw.ts#L23) |

#### Methods

##### \_prepare()

```ts
_prepare(): PgUnthrownPreparedQuery<{
  execute: TResult;
}>;
```

Defined in: [packages/drizzle/src/pg-core/raw.ts:40](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/raw.ts#L40)

###### Returns

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery)<{
`execute`: `TResult`;
}>

##### execute()

```ts
execute(placeholderValues?): AsyncResult<TResult, PgQueryError>;
```

Defined in: [packages/drizzle/src/pg-core/raw.ts:36](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/raw.ts#L36)

Run the statement, resolving to the driver's result.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> |

###### Returns

`AsyncResult`<`TResult`, [`PgQueryError`](#pgqueryerror)>

##### getQuery()

```ts
getQuery(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/raw.d.ts:18

###### Returns

`Query`

###### Inherited from

`PgRaw.getQuery`

##### getSQL()

```ts
getSQL(): SQL<unknown>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/raw.d.ts:17

###### Returns

`SQL`<`unknown`>

###### Inherited from

`PgRaw.getSQL`

##### shouldOmitSQLParens()?

```ts
shouldOmitSQLParens?(): boolean;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:48

###### Returns

`boolean`

###### Inherited from

`PgRaw.shouldOmitSQLParens`

***

### PgUnthrownRefreshMaterializedView

Defined in: [packages/drizzle/src/pg-core/refresh-materialized-view.ts:18](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/refresh-materialized-view.ts#L18)

A `refresh materialized view` statement that resolves to an `AsyncResult`.

#### Extends

* `PgRefreshMaterializedView`<`TQueryResult`>

#### Type Parameters

| Type Parameter |
| ------ |
|  `TQueryResult` *extends* `PgQueryResultHKT` |

#### Constructors

##### Constructor

```ts
new PgUnthrownRefreshMaterializedView<TQueryResult>(
   view, 
   session, 
   dialect
): PgUnthrownRefreshMaterializedView<TQueryResult>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.d.ts:20

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `view` | `PgMaterializedView` |
| `session` | `PgSession` |
| `dialect` | `PgDialect` |

###### Returns

[`PgUnthrownRefreshMaterializedView`](#pgunthrownrefreshmaterializedview)<`TQueryResult`>

###### Inherited from

`PgRefreshMaterializedView<TQueryResult>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | `undefined` | - | - | `PgRefreshMaterializedView._` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.d.ts:11 |
| `_.dialect` | `readonly` | `"pg"` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.d.ts:12 |
| `_.result` | `readonly` | `PgQueryResultKind`<`TQueryResult`, `never`> | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.d.ts:13 |
|  `then` | `readonly` | [`ResultThen`](#resultthen)<`PgQueryResultKind`<`TQueryResult`, `never`>, `never`> | `...` | The `then` that makes a query builder awaitable, resolving to a `Result`. **Remarks** Drizzle's promise and Effect trees each make their builders runnable the same way: the builder carries a `then` that defers to `execute()`. The promise tree gets it from the `QueryPromise` mixin, whose `then` is literally `this.execute().then(onFulfilled, onRejected)`. This package cannot reuse that mixin. `QueryPromise<T>` declares `execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` — so merging its type would contradict the very method it delegates to. (Its `applyMixins` helper is `@internal` and absent from drizzle's published `.d.ts` besides.) Each builder therefore declares this `then` itself, built by `resultThen`, with the awaited type it actually produces. Awaiting a builder yields a `Result`, never a rejection: `execute()` returns an `AsyncResult`, whose internal promise never rejects, and the compilation step ahead of it runs inside the same boundary — see `runQuery`. `catch` and `finally` are deliberately not offered: there is no rejection for them to observe. `onRejected` is still forwarded, exactly as `AsyncResult.then` forwards it, so a hypothetical internal rejection settles the `await` instead of hanging it. | - | - | [packages/drizzle/src/pg-core/refresh-materialized-view.ts:88](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/refresh-materialized-view.ts#L88) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownRefreshMaterializedView"` | - | `PgRefreshMaterializedView.[entityKind]` | - | [packages/drizzle/src/pg-core/refresh-materialized-view.ts:21](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/refresh-materialized-view.ts#L21) |

#### Methods

##### concurrently()

```ts
concurrently(): this;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.d.ts:21

###### Returns

`this`

###### Inherited from

`PgRefreshMaterializedView.concurrently`

##### execute()

```ts
execute(placeholderValues?): AsyncResult<PgQueryResultKind<TQueryResult, never>, never>;
```

Defined in: [packages/drizzle/src/pg-core/refresh-materialized-view.ts:80](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/refresh-materialized-view.ts#L80)

Run the refresh, resolving to the driver's result.

The error channel is `never`, and here that is a *judgement*, not an
impossibility. A refresh **can** raise `23505` — it repopulates a heap, and
`REFRESH … CONCURRENTLY` (the inherited `.concurrently()`) requires a unique
index, so a view whose own query yields duplicates violates it.

It is still a defect, by this package's "would you branch on it?" rule: a
materialized view whose query produces duplicates is a bug in the *view
definition*, which you log and 500 on — exactly what `match`'s `defect` arm
already does. Nobody writes a recovery path for it, and modelling it would
put an arm at every refresh call site duplicating that same defect arm.
Runtime and type agree either way; see `runSafeQuery`.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> |

###### Returns

`AsyncResult`<`PgQueryResultKind`<`TQueryResult`, `never`>, `never`>

##### getSQL()

```ts
getSQL(): SQL;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.d.ts:23

###### Returns

`SQL`

###### Inherited from

`PgRefreshMaterializedView.getSQL`

##### prepare()

```ts
prepare(name): PgUnthrownSafePreparedQuery<PreparedQueryConfig & object>;
```

Defined in: [packages/drizzle/src/pg-core/refresh-materialized-view.ts:57](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/refresh-materialized-view.ts#L57)

Create a prepared statement for this query. This allows the database to
remember this query for the given session and call it by name, rather than
specifying the full query.

Its `execute()` carries the same `never` error channel as this builder's —
see [PgUnthrownSafePreparedQuery](#pgunthrownsafepreparedquery).

[Postgres prepare documentation](https://www.postgresql.org/docs/current/sql-prepare.html)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |

###### Returns

[`PgUnthrownSafePreparedQuery`](#pgunthrownsafepreparedquery)<`PreparedQueryConfig` & `object`>

##### toSQL()

```ts
toSQL(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.d.ts:24

###### Returns

`Query`

###### Inherited from

`PgRefreshMaterializedView.toSQL`

##### withNoData()

```ts
withNoData(): this;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/refresh-materialized-view.d.ts:22

###### Returns

`this`

###### Inherited from

`PgRefreshMaterializedView.withNoData`

***

### PgUnthrownRelationalQuery

Defined in: [packages/drizzle/src/pg-core/query.ts:34](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/query.ts#L34)

A relational (`db.query.…`) query that resolves to an `AsyncResult`.

#### Extends

* `PgRelationalQuery`<[`PgUnthrownRelationalQueryHKT`](#pgunthrownrelationalqueryhkt), `TResult`>

#### Type Parameters

| Type Parameter | Description |
| ------ | ------ |
|  `TResult` | the shape the relational query builds; an array for `findMany`, a single row or `undefined` for `findFirst`. |

#### Constructors

##### Constructor

```ts
new PgUnthrownRelationalQuery<TResult>(
   schema, 
   table, 
   tableConfig, 
   dialect, 
   session, 
   config, 
   mode, 
   parseJson
): PgUnthrownRelationalQuery<TResult>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/query.d.ts:51

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `schema` | `TablesRelationalConfig` |
| `table` | `PgTable` |
| `tableConfig` | `TableRelationalConfig` |
| `dialect` | `PgDialect` |
| `session` | `PgSession` |
| `config` | `true` | `DBQueryConfigWithComment`<`"many"` | `"one"`> |
| `mode` | `"many"` | `"first"` |
| `parseJson` | `boolean` |

###### Returns

[`PgUnthrownRelationalQuery`](#pgunthrownrelationalquery)<`TResult`>

###### Inherited from

`PgRelationalQuery<PgUnthrownRelationalQueryHKT, TResult>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | `undefined` | - | - | `PgRelationalQuery._` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/query.d.ts:46 |
| `_.dialect` | `readonly` | `"pg"` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/query.d.ts:47 |
| `_.hkt` | `readonly` | [`PgUnthrownRelationalQueryHKT`](#pgunthrownrelationalqueryhkt) | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/query.d.ts:48 |
| `_.result` | `readonly` | `TResult` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/query.d.ts:49 |
|  `then` | `readonly` | [`ResultThen`](#resultthen)<`TResult`, `never`> | `...` | The `then` that makes a query builder awaitable, resolving to a `Result`. **Remarks** Drizzle's promise and Effect trees each make their builders runnable the same way: the builder carries a `then` that defers to `execute()`. The promise tree gets it from the `QueryPromise` mixin, whose `then` is literally `this.execute().then(onFulfilled, onRejected)`. This package cannot reuse that mixin. `QueryPromise<T>` declares `execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` — so merging its type would contradict the very method it delegates to. (Its `applyMixins` helper is `@internal` and absent from drizzle's published `.d.ts` besides.) Each builder therefore declares this `then` itself, built by `resultThen`, with the awaited type it actually produces. Awaiting a builder yields a `Result`, never a rejection: `execute()` returns an `AsyncResult`, whose internal promise never rejects, and the compilation step ahead of it runs inside the same boundary — see `runQuery`. `catch` and `finally` are deliberately not offered: there is no rejection for them to observe. `onRejected` is still forwarded, exactly as `AsyncResult.then` forwards it, so a hypothetical internal rejection settles the `await` instead of hanging it. | - | - | [packages/drizzle/src/pg-core/query.ts:95](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/query.ts#L95) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownRelationalQuery"` | - | `PgRelationalQuery.[entityKind]` | - | [packages/drizzle/src/pg-core/query.ts:38](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/query.ts#L38) |

#### Methods

##### execute()

```ts
execute(placeholderValues?): AsyncResult<TResult, never>;
```

Defined in: [packages/drizzle/src/pg-core/query.ts:89](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/query.ts#L89)

Run the relational query, resolving to its rows.

The error channel is `never` — `db.query.*` is a read, so every failure it
can hit is a defect. See `runSafeQuery`.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> |

###### Returns

`AsyncResult`<`TResult`, `never`>

##### getSQL()

```ts
getSQL(): SQL;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/query.d.ts:53

###### Returns

`SQL`

###### Inherited from

`PgRelationalQuery.getSQL`

##### prepare()

```ts
prepare(name): PgUnthrownSafePreparedQuery<PreparedQueryConfig & object>;
```

Defined in: [packages/drizzle/src/pg-core/query.ts:79](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/query.ts#L79)

Create a prepared statement for this query. This allows the database to
remember this query for the given session and call it by name, rather than
specifying the full query.

Its `execute()` carries the same `never` error channel as this builder's —
see [PgUnthrownSafePreparedQuery](#pgunthrownsafepreparedquery).

[Postgres prepare documentation](https://www.postgresql.org/docs/current/sql-prepare.html)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |

###### Returns

[`PgUnthrownSafePreparedQuery`](#pgunthrownsafepreparedquery)<`PreparedQueryConfig` & `object`>

##### toSQL()

```ts
toSQL(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/query.d.ts:58

###### Returns

`Query`

###### Inherited from

`PgRelationalQuery.toSQL`

***

### PgUnthrownSelectBase

Defined in: [packages/drizzle/src/pg-core/select.ts:127](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L127)

A `select` query that resolves to an `AsyncResult`.

#### Remarks

Every chaining method comes from drizzle's `PgSelectBase`; this subclass adds
only the execution half — `_prepare`, `prepare`, `execute` — plus the `then`
that makes `await db.select().from(users)` yield a `Result`.

The error channel is **`never`** for a read: a `SELECT` writes nothing, so it
cannot violate an integrity constraint; a database that will not answer is an
infrastructure failure, which is a defect. That is enforced at runtime as well
as declared — see `runSafeQuery`.

The exception is a select built by `db.with(…)` over a CTE that may write —
`db.$with("x").as(db.insert(t).values(…).returning())`, which Postgres runs
as a real `INSERT`. That select carries `PgQueryError` and is qualified
exactly as the insert would be, so its 23505 is an `Err` rather than a
defect. A CTE over raw SQL counts as writing, since its text cannot be read.

#### Extends

* `PgSelectBase`<[`PgUnthrownSelectHKT`](#pgunthrownselecthkt)<`TError`>, `TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`>

#### Type Parameters

| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
|  `TTableName` *extends* `string` | `undefined` | - | - |
|  `TSelection` *extends* `ColumnsSelection` | `undefined` | - | - |
|  `TSelectMode` *extends* `SelectMode` | - | - |
|  `TNullabilityMap` *extends* `Record`<`string`, `JoinNullability`> | `TTableName` *extends* `string` ? `Record`<`TTableName`, `"not-null"`> : `Record`<`string`, `never`> | - |
|  `TDynamic` *extends* `boolean` | `false` | - |
|  `TExcludedMethods` *extends* `string` | `never` | - |
|  `TResult` *extends* `unknown`\[] | `SelectResult`<`TSelection`, `TSelectMode`, `TNullabilityMap`>\[] | - |
|  `TSelectedFields` *extends* `ColumnsSelection` | `BuildSubquerySelection`<`Assume`<`TSelection`, `ColumnsSelection`>, `TNullabilityMap`> | - |
|  `TError` | `never` | `never` for a read, `PgQueryError` when the `WITH` list may write. Set by `db.with(…)`, never by hand. |

#### Constructors

##### Constructor

```ts
new PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>(config): PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:87

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `config` | { `dialect`: `PgDialect`; `distinct`: | `boolean` | { `on`: ( | `SQLWrapper`<`unknown`> | `PgColumn`<`any`, `PgColumnBaseConfig`<`any`>, { }>)\[]; } | `undefined`; `fields`: `Record`<`string`, `unknown`>; `isPartialSelect`: `boolean`; `session`: `PgSession` | `undefined`; `table`: | `PgTable`<`TableConfig`> | `PgViewBase`<`ViewConfig`<`ColumnsSelection`>> | `SQL`<`unknown`> | `Subquery`<`string`, `Record`<`string`, `unknown`>>; `tagged?`: `boolean`; `withList`: `Subquery`<`string`, `Record`<`string`, `unknown`>>\[]; } |
| `config.dialect` | `PgDialect` |
| `config.distinct` | | `boolean` | { `on`: ( | `SQLWrapper`<`unknown`> | `PgColumn`<`any`, `PgColumnBaseConfig`<`any`>, { }>)\[]; } | `undefined` |
| `config.fields` | `Record`<`string`, `unknown`> |
| `config.isPartialSelect` | `boolean` |
| `config.session` | `PgSession` | `undefined` |
| `config.table` | | `PgTable`<`TableConfig`> | `PgViewBase`<`ViewConfig`<`ColumnsSelection`>> | `SQL`<`unknown`> | `Subquery`<`string`, `Record`<`string`, `unknown`>> |
| `config.tagged?` | `boolean` |
| `config.withList` | `Subquery`<`string`, `Record`<`string`, `unknown`>>\[] |

###### Returns

[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>

###### Inherited from

`PgSelectBase<PgUnthrownSelectHKT<TError>, TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | `undefined` | - | - | `PgSelectBase._` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:66 |
| `_.config` | `readonly` | `PgSelectConfig` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:77 |
| `_.dialect` | `readonly` | `"pg"` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:67 |
| `_.dynamic` | `readonly` | `TDynamic` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:73 |
| `_.excludedMethods` | `readonly` | `TExcludedMethods` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:74 |
| `_.hkt` | `readonly` | [`PgUnthrownSelectHKT`](#pgunthrownselecthkt) | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:68 |
| `_.nullabilityMap` | `readonly` | `TNullabilityMap` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:72 |
| `_.result` | `readonly` | `TResult` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:75 |
| `_.selectedFields` | `readonly` | `TSelectedFields` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:76 |
| `_.selection` | `readonly` | `TSelection` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:70 |
| `_.selectMode` | `readonly` | `TSelectMode` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:71 |
| `_.tableName` | `readonly` | `TTableName` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:69 |
|  `crossJoin` | `public` | `PgSelectCrossJoinFn`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `false`> | `undefined` | Executes a `cross join` operation by combining rows from two tables into a new table. Calling this method retrieves all rows from both main and joined tables, merging all rows from each table. See docs: <https://orm.drizzle.team/docs/joins#cross-join> **Param** **table** the table to join. **Example** `// Select all users, each user with every pet const usersWithPets: { user: User; pets: Pet; }[] = await db.select() .from(users) .crossJoin(pets) // Select userId and petId const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({ userId: users.id, petId: pets.id, }) .from(users) .crossJoin(pets)` | - | `PgSelectBase.crossJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:286 |
|  `crossJoinLateral` | `public` | `PgSelectCrossJoinFn`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `true`> | `undefined` | Executes a `cross join lateral` operation by combining rows from two queries into a new table. A `lateral` join allows the right-hand expression to refer to columns from the left-hand side. Calling this method retrieves all rows from both main and joined queries, merging all rows from each query. See docs: <https://orm.drizzle.team/docs/joins#cross-join-lateral> **Param** **table** the query to join. **Example** `// Pair each city with every row its correlated subquery produces; cities with none are dropped const sq = db.select({ userId: users.id }).from(users).where(eq(users.cityId, cities.id)).as('sq'); const rows: { cities: City; sq: { userId: number } }[] = await db.select() .from(cities) .crossJoinLateral(sq)` | - | `PgSelectBase.crossJoinLateral` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:309 |
|  `except` | `public` | <`TValue`>(`rightSelection`) => `PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `PgSetOperatorExcludedMethods`, `true`> | `undefined` | Adds `except` set operator to the query. Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query. See docs: <https://orm.drizzle.team/docs/set-operations#except> **Example** `// Select all courses offered in department A but not in department B await db.select({ courseName: depA.courseName }) .from(depA) .except( db.select({ courseName: depB.courseName }).from(depB) ); // or import { except } from 'drizzle-orm/pg-core' await except( db.select({ courseName: depA.courseName }).from(depA), db.select({ courseName: depB.courseName }).from(depB) );` | - | `PgSelectBase.except` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:455 |
|  `exceptAll` | `public` | <`TValue`>(`rightSelection`) => `PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `PgSetOperatorExcludedMethods`, `true`> | `undefined` | Adds `except all` set operator to the query. Calling this method will retrieve all rows from the left query, except for the rows that are present in the result set of the right query. See docs: <https://orm.drizzle.team/docs/set-operations#except-all> **Example** `// Select all products that are ordered by regular customers but not by VIP customers await db.select({ productId: regularCustomerOrders.productId, quantityOrdered: regularCustomerOrders.quantityOrdered, }) .from(regularCustomerOrders) .exceptAll( db.select({ productId: vipCustomerOrders.productId, quantityOrdered: vipCustomerOrders.quantityOrdered, }) .from(vipCustomerOrders) ); // or import { exceptAll } from 'drizzle-orm/pg-core' await exceptAll( db.select({ productId: regularCustomerOrders.productId, quantityOrdered: regularCustomerOrders.quantityOrdered }) .from(regularCustomerOrders), db.select({ productId: vipCustomerOrders.productId, quantityOrdered: vipCustomerOrders.quantityOrdered }) .from(vipCustomerOrders) );` | - | `PgSelectBase.exceptAll` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:496 |
|  `fullJoin` | `public` | `PgSelectJoinFn`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"full"`, `false`> | `undefined` | Executes a `full join` operation by combining rows from two tables into a new table. Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns. See docs: <https://orm.drizzle.team/docs/joins#full-join> **Param** **table** the table to join. **Param** **on** the `on` clause. **Example** `// Select all users and their pets const usersWithPets: { user: User \| null; pets: Pet \| null; }[] = await db.select() .from(users) .fullJoin(pets, eq(users.id, pets.ownerId)) // Select userId and petId const usersIdsAndPetIds: { userId: number \| null; petId: number \| null; }[] = await db.select({ userId: users.id, petId: pets.id, }) .from(users) .fullJoin(pets, eq(users.id, pets.ownerId))` | - | `PgSelectBase.fullJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:259 |
|  `innerJoin` | `public` | `PgSelectJoinFn`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"inner"`, `false`> | `undefined` | Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values. Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs. See docs: <https://orm.drizzle.team/docs/joins#inner-join> **Param** **table** the table to join. **Param** **on** the `on` clause. **Example** `// Select all users and their pets const usersWithPets: { user: User; pets: Pet; }[] = await db.select() .from(users) .innerJoin(pets, eq(users.id, pets.ownerId)) // Select userId and petId const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({ userId: users.id, petId: pets.id, }) .from(users) .innerJoin(pets, eq(users.id, pets.ownerId))` | - | `PgSelectBase.innerJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:207 |
|  `innerJoinLateral` | `public` | `PgSelectJoinFn`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"inner"`, `true`> | `undefined` | Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values. A `lateral` join allows the right-hand expression to refer to columns from the left-hand side. Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs. See docs: <https://orm.drizzle.team/docs/joins#inner-join-lateral> **Param** **table** the subquery to join. **Param** **on** the `on` clause. **Example** `// Select only the cities that have users, along with those users const sq = db.select({ userId: users.id }).from(users).where(eq(users.cityId, cities.id)).as('sq'); const rows: { cities: City; sq: { userId: number } }[] = await db.select() .from(cities) .innerJoinLateral(sq, sql`true`)` | - | `PgSelectBase.innerJoinLateral` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:231 |
|  `intersect` | `public` | <`TValue`>(`rightSelection`) => `PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `PgSetOperatorExcludedMethods`, `true`> | `undefined` | Adds `intersect` set operator to the query. Calling this method will retain only the rows that are present in both result sets and eliminate duplicates. See docs: <https://orm.drizzle.team/docs/set-operations#intersect> **Example** `// Select course names that are offered in both departments A and B await db.select({ courseName: depA.courseName }) .from(depA) .intersect( db.select({ courseName: depB.courseName }).from(depB) ); // or import { intersect } from 'drizzle-orm/pg-core' await intersect( db.select({ courseName: depA.courseName }).from(depA), db.select({ courseName: depB.courseName }).from(depB) );` | - | `PgSelectBase.intersect` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:388 |
|  `intersectAll` | `public` | <`TValue`>(`rightSelection`) => `PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `PgSetOperatorExcludedMethods`, `true`> | `undefined` | Adds `intersect all` set operator to the query. Calling this method will retain only the rows that are present in both result sets including all duplicates. See docs: <https://orm.drizzle.team/docs/set-operations#intersect-all> **Example** `// Select all products and quantities that are ordered by both regular and VIP customers await db.select({ productId: regularCustomerOrders.productId, quantityOrdered: regularCustomerOrders.quantityOrdered }) .from(regularCustomerOrders) .intersectAll( db.select({ productId: vipCustomerOrders.productId, quantityOrdered: vipCustomerOrders.quantityOrdered }) .from(vipCustomerOrders) ); // or import { intersectAll } from 'drizzle-orm/pg-core' await intersectAll( db.select({ productId: regularCustomerOrders.productId, quantityOrdered: regularCustomerOrders.quantityOrdered }) .from(regularCustomerOrders), db.select({ productId: vipCustomerOrders.productId, quantityOrdered: vipCustomerOrders.quantityOrdered }) .from(vipCustomerOrders) );` | - | `PgSelectBase.intersectAll` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:429 |
|  `leftJoin` | `public` | `PgSelectJoinFn`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"left"`, `false`> | `undefined` | Executes a `left join` operation by adding another table to the current query. Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null. See docs: <https://orm.drizzle.team/docs/joins#left-join> **Param** **table** the table to join. **Param** **on** the `on` clause. **Example** `// Select all users and their pets const usersWithPets: { user: User; pets: Pet \| null; }[] = await db.select() .from(users) .leftJoin(pets, eq(users.id, pets.ownerId)) // Select userId and petId const usersIdsAndPetIds: { userId: number; petId: number \| null; }[] = await db.select({ userId: users.id, petId: pets.id, }) .from(users) .leftJoin(pets, eq(users.id, pets.ownerId))` | - | `PgSelectBase.leftJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:127 |
|  `leftJoinLateral` | `public` | `PgSelectJoinFn`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"left"`, `true`> | `undefined` | Executes a `left join lateral` operation by adding subquery to the current query. A `lateral` join allows the right-hand expression to refer to columns from the left-hand side. Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null. See docs: <https://orm.drizzle.team/docs/joins#left-join-lateral> **Param** **table** the subquery to join. **Param** **on** the `on` clause. **Example** `// Select every city and, for each, the users that live in it const sq = db.select({ userId: users.id }).from(users).where(eq(users.cityId, cities.id)).as('sq'); const rows: { cities: City; sq: { userId: number } \| null }[] = await db.select() .from(cities) .leftJoinLateral(sq, sql`true`)` | - | `PgSelectBase.leftJoinLateral` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:151 |
|  `rightJoin` | `public` | `PgSelectJoinFn`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"right"`, `false`> | `undefined` | Executes a `right join` operation by adding another table to the current query. Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null. See docs: <https://orm.drizzle.team/docs/joins#right-join> **Param** **table** the table to join. **Param** **on** the `on` clause. **Example** `// Select all users and their pets const usersWithPets: { user: User \| null; pets: Pet; }[] = await db.select() .from(users) .rightJoin(pets, eq(users.id, pets.ownerId)) // Select userId and petId const usersIdsAndPetIds: { userId: number \| null; petId: number; }[] = await db.select({ userId: users.id, petId: pets.id, }) .from(users) .rightJoin(pets, eq(users.id, pets.ownerId))` | - | `PgSelectBase.rightJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:179 |
|  `then` | `readonly` | [`ResultThen`](#resultthen)<`TResult`, `TError`> | `...` | The `then` that makes a query builder awaitable, resolving to a `Result`. **Remarks** Drizzle's promise and Effect trees each make their builders runnable the same way: the builder carries a `then` that defers to `execute()`. The promise tree gets it from the `QueryPromise` mixin, whose `then` is literally `this.execute().then(onFulfilled, onRejected)`. This package cannot reuse that mixin. `QueryPromise<T>` declares `execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` — so merging its type would contradict the very method it delegates to. (Its `applyMixins` helper is `@internal` and absent from drizzle's published `.d.ts` besides.) Each builder therefore declares this `then` itself, built by `resultThen`, with the awaited type it actually produces. Awaiting a builder yields a `Result`, never a rejection: `execute()` returns an `AsyncResult`, whose internal promise never rejects, and the compilation step ahead of it runs inside the same boundary — see `runQuery`. `catch` and `finally` are deliberately not offered: there is no rejection for them to observe. `onRejected` is still forwarded, exactly as `AsyncResult.then` forwards it, so a hypothetical internal rejection settles the `await` instead of hanging it. | - | - | [packages/drizzle/src/pg-core/select.ts:246](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L246) |
|  `union` | `public` | <`TValue`>(`rightSelection`) => `PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `PgSetOperatorExcludedMethods`, `true`> | `undefined` | Adds `union` set operator to the query. Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them. See docs: <https://orm.drizzle.team/docs/set-operations#union> **Example** `// Select all unique names from customers and users tables await db.select({ name: users.name }) .from(users) .union( db.select({ name: customers.name }).from(customers) ); // or import { union } from 'drizzle-orm/pg-core' await union( db.select({ name: users.name }).from(users), db.select({ name: customers.name }).from(customers) );` | - | `PgSelectBase.union` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:336 |
|  `unionAll` | `public` | <`TValue`>(`rightSelection`) => `PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `PgSetOperatorExcludedMethods`, `true`> | `undefined` | Adds `union all` set operator to the query. Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them. See docs: <https://orm.drizzle.team/docs/set-operations#union-all> **Example** `// Select all transaction ids from both online and in-store sales await db.select({ transaction: onlineSales.transactionId }) .from(onlineSales) .unionAll( db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales) ); // or import { unionAll } from 'drizzle-orm/pg-core' await unionAll( db.select({ transaction: onlineSales.transactionId }).from(onlineSales), db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales) );` | - | `PgSelectBase.unionAll` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:362 |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownSelect"` | - | `PgSelectBase.[entityKind]` | - | [packages/drizzle/src/pg-core/select.ts:153](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L153) |

#### Methods

##### $dynamic()

```ts
$dynamic(): PgSelectDynamic<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:649

###### Returns

`PgSelectDynamic`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>>

###### Inherited from

`PgSelectBase.$dynamic`

##### $withCache()

```ts
$withCache(config?): this;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:650

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `config?` | | `false` | { `autoInvalidate?`: `boolean`; `config?`: `CacheConfig`; `tag?`: `string`; } |

###### Returns

`this`

###### Inherited from

`PgSelectBase.$withCache`

##### as()

```ts
as<TAlias>(alias): SubqueryWithSelection<TSelectedFields, TAlias>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:648

###### Type Parameters

| Type Parameter |
| ------ |
|  `TAlias` *extends* `string` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `alias` | `TAlias` |

###### Returns

`SubqueryWithSelection`<`TSelectedFields`, `TAlias`>

###### Inherited from

`PgSelectBase.as`

##### comment()

```ts
comment(comment): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "comment">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:645

Attach [sqlcommenter](https://google.github.io/sqlcommenter) comment to a query

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `comment` | `CommentInput` |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"comment"`>

###### Inherited from

`PgSelectBase.comment`

##### execute()

```ts
execute(placeholderValues?): AsyncResult<TResult, TError>;
```

Defined in: [packages/drizzle/src/pg-core/select.ts:233](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L233)

Run the query, resolving to the selected rows.

The error channel is `never` for a read — every failure a read can hit is
a defect, and `runSafeQuery` is what makes that true at runtime, not just
in the type. A select over a writing CTE carries `PgQueryError`.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> |

###### Returns

`AsyncResult`<`TResult`, `TError`>

##### for()

```ts
for(strength, config?): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "for">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:641

Adds a `for` clause to the query.

Calling this method will specify a lock strength for this query that controls how strictly it acquires exclusive access to the rows being queried.

See docs: <https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `strength` | `LockStrength` | the lock strength. |
| `config?` | `LockConfig` | the lock configuration. |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"for"`>

###### Inherited from

`PgSelectBase.for`

##### getSQL()

```ts
getSQL(): SQL;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:646

###### Returns

`SQL`

###### Inherited from

`PgSelectBase.getSQL`

##### groupBy()

###### Call Signature

```ts
groupBy(builder): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "groupBy">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:569

Adds a `group by` clause to the query.

Calling this method will group rows that have the same values into summary rows, often used for aggregation purposes.

See docs: <https://orm.drizzle.team/docs/select#aggregations>

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `builder` | (`aliases`) => `ValueOrArray`< | `SQL`<`unknown`> | `PgColumn`<`any`, `PgColumnBaseConfig`<`any`>, { }> | `Aliased`<`unknown`>> |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"groupBy"`>

###### Example

```ts
// Group and count people by their last names
await db.select({
   lastName: people.lastName,
   count: sql<number>`cast(count(*) as int)`
})
  .from(people)
  .groupBy(people.lastName);
```

###### Inherited from

`PgSelectBase.groupBy`

###### Call Signature

```ts
groupBy(...columns): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "groupBy">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:570

Adds a `group by` clause to the query.

Calling this method will group rows that have the same values into summary rows, often used for aggregation purposes.

See docs: <https://orm.drizzle.team/docs/select#aggregations>

###### Parameters

| Parameter | Type |
| ------ | ------ |
| ...`columns` | ( | `SQL`<`unknown`> | `PgColumn`<`any`, `PgColumnBaseConfig`<`any`>, { }> | `Aliased`<`unknown`>)\[] |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"groupBy"`>

###### Example

```ts
// Group and count people by their last names
await db.select({
   lastName: people.lastName,
   count: sql<number>`cast(count(*) as int)`
})
  .from(people)
  .groupBy(people.lastName);
```

###### Inherited from

`PgSelectBase.groupBy`

##### having()

```ts
having(having): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "having">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:549

Adds a `having` clause to the query.

Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.

See docs: <https://orm.drizzle.team/docs/select#aggregations>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `having` | | `SQL`<`unknown`> | ((`aliases`) => `SQL`<`unknown`> | `undefined`) | `undefined` | the `having` clause. |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"having"`>

###### Example

```ts
// Select all brands with more than one car
await db.select({
	brand: cars.brand,
	count: sql<number>`cast(count(${cars.id}) as int)`,
})
  .from(cars)
  .groupBy(cars.brand)
  .having(({ count }) => gt(count, 1));
```

###### Inherited from

`PgSelectBase.having`

##### limit()

```ts
limit(limit): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "limit">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:613

Adds a `limit` clause to the query.

Calling this method will set the maximum number of rows that will be returned by this query.

See docs: <https://orm.drizzle.team/docs/select#limit--offset>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `limit` | `number` | `Placeholder`<`string`, `any`> | the `limit` clause. |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"limit"`>

###### Example

```ts
// Get the first 10 people from this query.
await db.select().from(people).limit(10);
```

###### Inherited from

`PgSelectBase.limit`

##### offset()

```ts
offset(offset): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "offset">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:630

Adds an `offset` clause to the query.

Calling this method will skip a number of rows when returning results from this query.

See docs: <https://orm.drizzle.team/docs/select#limit--offset>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `offset` | `number` | `Placeholder`<`string`, `any`> | the `offset` clause. |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"offset"`>

###### Example

```ts
// Get the 10th-20th people from this query.
await db.select().from(people).offset(10).limit(10);
```

###### Inherited from

`PgSelectBase.offset`

##### orderBy()

###### Call Signature

```ts
orderBy(builder): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "orderBy">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:595

Adds an `order by` clause to the query.

Calling this method will sort the result-set in ascending or descending order. By default, the sort order is ascending.

See docs: <https://orm.drizzle.team/docs/select#order-by>

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `builder` | (`aliases`) => `ValueOrArray`< | `SQL`<`unknown`> | `PgColumn`<`any`, `PgColumnBaseConfig`<`any`>, { }> | `Aliased`<`unknown`>> |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"orderBy"`>

###### Example

```
// Select cars ordered by year
await db.select().from(cars).orderBy(cars.year);
```

You can specify whether results are in ascending or descending order with the `asc()` and `desc()` operators.

```ts
// Select cars ordered by year in descending order
await db.select().from(cars).orderBy(desc(cars.year));

// Select cars ordered by year and price
await db.select().from(cars).orderBy(asc(cars.year), desc(cars.price));
```

###### Inherited from

`PgSelectBase.orderBy`

###### Call Signature

```ts
orderBy(...columns): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "orderBy">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:596

Adds an `order by` clause to the query.

Calling this method will sort the result-set in ascending or descending order. By default, the sort order is ascending.

See docs: <https://orm.drizzle.team/docs/select#order-by>

###### Parameters

| Parameter | Type |
| ------ | ------ |
| ...`columns` | ( | `SQL`<`unknown`> | `PgColumn`<`any`, `PgColumnBaseConfig`<`any`>, { }> | `Aliased`<`unknown`>)\[] |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"orderBy"`>

###### Example

```
// Select cars ordered by year
await db.select().from(cars).orderBy(cars.year);
```

You can specify whether results are in ascending or descending order with the `asc()` and `desc()` operators.

```ts
// Select cars ordered by year in descending order
await db.select().from(cars).orderBy(desc(cars.year));

// Select cars ordered by year and price
await db.select().from(cars).orderBy(asc(cars.year), desc(cars.price));
```

###### Inherited from

`PgSelectBase.orderBy`

##### prepare()

```ts
prepare(name): PgUnthrownSelectPreparedQuery<PreparedQueryConfig & object, TError>;
```

Defined in: [packages/drizzle/src/pg-core/select.ts:220](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L220)

Create a prepared statement for this query. This allows the database to
remember this query for the given session and call it by name, rather than
specifying the full query.

Its `execute()` carries the same error channel as this builder's — `never`
for a read, see [PgUnthrownSafePreparedQuery](#pgunthrownsafepreparedquery).

[Postgres prepare documentation](https://www.postgresql.org/docs/current/sql-prepare.html)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |

###### Returns

[`PgUnthrownSelectPreparedQuery`](#pgunthrownselectpreparedquery)<`PreparedQueryConfig` & `object`, `TError`>

##### toSQL()

```ts
toSQL(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:647

###### Returns

`Query`

###### Inherited from

`PgSelectBase.toSQL`

##### where()

```ts
where(where): PgSelectWithout<PgUnthrownSelectBase<TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields, TError>, TDynamic, "where">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.d.ts:526

Adds a `where` clause to the query.

Calling this method will select only those rows that fulfill a specified condition.

See docs: <https://orm.drizzle.team/docs/select#filtering>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `where` | | `SQL`<`unknown`> | ((`aliases`) => `SQL`<`unknown`> | `undefined`) | `undefined` | the `where` clause. |

###### Returns

`PgSelectWithout`<[`PgUnthrownSelectBase`](#pgunthrownselectbase)<`TTableName`, `TSelection`, `TSelectMode`, `TNullabilityMap`, `TDynamic`, `TExcludedMethods`, `TResult`, `TSelectedFields`, `TError`>, `TDynamic`, `"where"`>

###### Example

You can use conditional operators and `sql function` to filter the rows to be selected.

```ts
// Select all cars with green color
await db.select().from(cars).where(eq(cars.color, 'green'));
// or
await db.select().from(cars).where(sql`${cars.color} = 'green'`)
```

You can logically combine conditional operators with `and()` and `or()` operators:

```ts
// Select all BMW cars with a green color
await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));

// Select all cars with the green or blue color
await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
```

###### Inherited from

`PgSelectBase.where`

***

### PgUnthrownUpdateBase

Defined in: [packages/drizzle/src/pg-core/update.ts:60](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/update.ts#L60)

An `update` query that resolves to an `AsyncResult`.

#### Extends

* `PgUpdateBase`<[`PgUnthrownUpdateHKT`](#pgunthrownupdatehkt), `TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>

#### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `TTable` *extends* `PgTable` | - |
|  `TQueryResult` *extends* `PgQueryResultHKT` | - |
|  `TFrom` *extends* `PgTable` | `Subquery` | `PgViewBase` | `SQL` | `undefined` | `undefined` |
|  `TSelectedFields` *extends* `ColumnsSelection` | `undefined` | `undefined` |
|  `TReturning` *extends* `Record`<`string`, `unknown`> | `undefined` | `undefined` |
|  `TNullabilityMap` *extends* `Record`<`string`, `JoinNullability`> | `Record`<`TTable`\[`"_"`]\[`"name"`], `"not-null"`> |
|  `TJoins` *extends* `Join`\[] | \[] |
|  `TDynamic` *extends* `boolean` | `false` |
|  `TExcludedMethods` *extends* `string` | `never` |

#### Constructors

##### Constructor

```ts
new PgUnthrownUpdateBase<TTable, TQueryResult, TFrom, TSelectedFields, TReturning, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>(
   table, 
   set, 
   session, 
   dialect, 
   withList?
): PgUnthrownUpdateBase<TTable, TQueryResult, TFrom, TSelectedFields, TReturning, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:119

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `table` | `TTable` |
| `set` | `UpdateSet` |
| `session` | `PgSession` |
| `dialect` | `PgDialect` |
| `withList?` | `Subquery`<`string`, `Record`<`string`, `unknown`>>\[] |

###### Returns

[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>

###### Inherited from

`PgUpdateBase<PgUnthrownUpdateHKT, TTable, TQueryResult, TFrom, TSelectedFields, TReturning, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | `undefined` | - | - | `PgUpdateBase._` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:97 |
| `_.dialect` | `readonly` | `"pg"` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:98 |
| `_.dynamic` | `readonly` | `TDynamic` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:107 |
| `_.excludedMethods` | `readonly` | `TExcludedMethods` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:108 |
| `_.from` | `readonly` | `TFrom` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:104 |
| `_.hkt` | `readonly` | [`PgUnthrownUpdateHKT`](#pgunthrownupdatehkt) | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:99 |
| `_.joins` | `readonly` | `TJoins` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:101 |
| `_.nullabilityMap` | `readonly` | `TNullabilityMap` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:102 |
| `_.queryResult` | `readonly` | `TQueryResult` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:103 |
| `_.result` | `readonly` | `TReturning` *extends* `undefined` ? `PgQueryResultKind`<`TQueryResult`, `never`> : `TReturning`\[] | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:109 |
| `_.returning` | `readonly` | `TReturning` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:106 |
| `_.selectedFields` | `readonly` | `TSelectedFields` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:105 |
| `_.table` | `readonly` | `TTable` | `undefined` | - | - | - | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:100 |
|  `fullJoin` | `public` | `PgUpdateJoinFn`<[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"full"`> | `undefined` | - | - | `PgUpdateBase.fullJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:126 |
|  `innerJoin` | `public` | `PgUpdateJoinFn`<[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"inner"`> | `undefined` | - | - | `PgUpdateBase.innerJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:125 |
|  `leftJoin` | `public` | `PgUpdateJoinFn`<[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"left"`> | `undefined` | - | - | `PgUpdateBase.leftJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:123 |
|  `rightJoin` | `public` | `PgUpdateJoinFn`<[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"right"`> | `undefined` | - | - | `PgUpdateBase.rightJoin` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:124 |
|  `then` | `readonly` | [`ResultThen`](#resultthen)<[`UpdateResult`](#updateresult)<`TQueryResult`, `TReturning`>> | `...` | The `then` that makes a query builder awaitable, resolving to a `Result`. **Remarks** Drizzle's promise and Effect trees each make their builders runnable the same way: the builder carries a `then` that defers to `execute()`. The promise tree gets it from the `QueryPromise` mixin, whose `then` is literally `this.execute().then(onFulfilled, onRejected)`. This package cannot reuse that mixin. `QueryPromise<T>` declares `execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` — so merging its type would contradict the very method it delegates to. (Its `applyMixins` helper is `@internal` and absent from drizzle's published `.d.ts` besides.) Each builder therefore declares this `then` itself, built by `resultThen`, with the awaited type it actually produces. Awaiting a builder yields a `Result`, never a rejection: `execute()` returns an `AsyncResult`, whose internal promise never rejects, and the compilation step ahead of it runs inside the same boundary — see `runQuery`. `catch` and `finally` are deliberately not offered: there is no rejection for them to observe. `onRejected` is still forwarded, exactly as `AsyncResult.then` forwards it, so a hypothetical internal rejection settles the `await` instead of hanging it. | - | - | [packages/drizzle/src/pg-core/update.ts:134](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/update.ts#L134) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownUpdate"` | - | `PgUpdateBase.[entityKind]` | - | [packages/drizzle/src/pg-core/update.ts:82](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/update.ts#L82) |

#### Methods

##### $dynamic()

```ts
$dynamic(): PgUnthrownUpdateBase<Assume<TTable, PgTable<TableConfig>>>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:191

###### Returns

[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`Assume`<`TTable`, `PgTable`<`TableConfig`>>>

###### Inherited from

`PgUpdateBase.$dynamic`

##### comment()

```ts
comment(comment): PgUpdateWithout<PgUnthrownUpdateBase<TTable, TQueryResult, TFrom, TSelectedFields, TReturning, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>, TDynamic, "comment">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:188

Attach [sqlcommenter](https://google.github.io/sqlcommenter) comment to a query

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `comment` | `CommentInput` |

###### Returns

`PgUpdateWithout`<[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"comment"`>

###### Inherited from

`PgUpdateBase.comment`

##### execute()

```ts
execute(placeholderValues?): AsyncResult<UpdateResult<TQueryResult, TReturning>, PgQueryError>;
```

Defined in: [packages/drizzle/src/pg-core/update.ts:126](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/update.ts#L126)

Run the update, resolving to its result or a [PgQueryError](#pgqueryerror).

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> |

###### Returns

`AsyncResult`<[`UpdateResult`](#updateresult)<`TQueryResult`, `TReturning`>, [`PgQueryError`](#pgqueryerror)>

##### from()

```ts
from<TFrom>(source): PgUpdateWithJoins<this, TDynamic, TFrom>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:120

###### Type Parameters

| Type Parameter |
| ------ |
|  `TFrom` *extends* | `PgTable`<`TableConfig`> | `PgViewBase`<`ViewConfig`<`ColumnsSelection`>> | `SQL`<`unknown`> | `Subquery`<`string`, `Record`<`string`, `unknown`>> |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `source` | `CheckTableLikeSelection`<`TFrom`> |

###### Returns

`PgUpdateWithJoins`<`this`, `TDynamic`, `TFrom`>

###### Inherited from

`PgUpdateBase.from`

##### getSQL()

```ts
getSQL(): SQL;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:189

###### Returns

`SQL`

###### Inherited from

`PgUpdateBase.getSQL`

##### prepare()

```ts
prepare(name): PgUnthrownPreparedQuery<PreparedQueryConfig & object>;
```

Defined in: [packages/drizzle/src/pg-core/update.ts:117](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/update.ts#L117)

Create a prepared statement for this query. This allows the database to
remember this query for the given session and call it by name, rather than
specifying the full query.

[Postgres prepare documentation](https://www.postgresql.org/docs/current/sql-prepare.html)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |

###### Returns

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery)<`PreparedQueryConfig` & `object`>

##### returning()

###### Call Signature

```ts
returning(): PgUpdateWithout<PgUpdateKind<PgUnthrownUpdateHKT, TTable, TQueryResult, TFrom, Equal<TJoins, []> extends true ? TTable["_"]["columns"] : { [K in string | number | symbol]: (Record<TTable["_"]["name"], TTable["_"]["columns"]> & { [K in string | number | symbol as (...)[(...)]["table"]["_"]["name"]]: (...)[(...)]["table"]["_"]["columns"] })[K] }, SelectPartialResult<AccumulateToResult<PgUnthrownUpdateBase<TTable, TQueryResult, TFrom, TSelectedFields, TReturning, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>, "single", TJoins, GetSelectTableSelection<TTable>>, TNullabilityMap>, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>, TDynamic>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:183

Adds a `returning` clause to the query.

Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.

See docs: <https://orm.drizzle.team/docs/update#update-with-returning>

###### Returns

`PgUpdateWithout`<`PgUpdateKind`<[`PgUnthrownUpdateHKT`](#pgunthrownupdatehkt), `TTable`, `TQueryResult`, `TFrom`, `Equal`<`TJoins`, \[]> *extends* `true` ? `TTable`\[`"_"`]\[`"columns"`] : { \[K in string | number | symbol]: (Record\<TTable\["\_"]\["name"], TTable\["\_"]\["columns"]> & { \[K in string | number | symbol as (...)\[(...)]\["table"]\["\_"]\["name"]]: (...)\[(...)]\["table"]\["\_"]\["columns"] })\[K] }, `SelectPartialResult`<`AccumulateToResult`<[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `"single"`, `TJoins`, `GetSelectTableSelection`<`TTable`>>, `TNullabilityMap`>, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `TDynamic`>

###### Example

```ts
// Update all cars with the green color and return all fields
const updatedCars: Car[] = await db.update(cars)
  .set({ color: 'red' })
  .where(eq(cars.color, 'green'))
  .returning();

// Update all cars with the green color and return only their id and brand fields
const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)
  .set({ color: 'red' })
  .where(eq(cars.color, 'green'))
  .returning({ id: cars.id, brand: cars.brand });
```

###### Inherited from

`PgUpdateBase.returning`

###### Call Signature

```ts
returning<TSelectedFields>(fields): PgUpdateWithout<PgUpdateKind<PgUnthrownUpdateHKT, TTable, TQueryResult, TFrom, TSelectedFields, SelectPartialResult<AccumulateToResult<PgUnthrownUpdateBase<TTable, TQueryResult, TFrom, TSelectedFields, TReturning, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>, "partial", TJoins, TSelectedFields>, TNullabilityMap>, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>, TDynamic, "returning">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:184

Adds a `returning` clause to the query.

Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.

See docs: <https://orm.drizzle.team/docs/update#update-with-returning>

###### Type Parameters

| Type Parameter |
| ------ |
|  `TSelectedFields` *extends* `SelectedFields` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `TSelectedFields` |

###### Returns

`PgUpdateWithout`<`PgUpdateKind`<[`PgUnthrownUpdateHKT`](#pgunthrownupdatehkt), `TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `SelectPartialResult`<`AccumulateToResult`<[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `"partial"`, `TJoins`, `TSelectedFields`>, `TNullabilityMap`>, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"returning"`>

###### Example

```ts
// Update all cars with the green color and return all fields
const updatedCars: Car[] = await db.update(cars)
  .set({ color: 'red' })
  .where(eq(cars.color, 'green'))
  .returning();

// Update all cars with the green color and return only their id and brand fields
const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)
  .set({ color: 'red' })
  .where(eq(cars.color, 'green'))
  .returning({ id: cars.id, brand: cars.brand });
```

###### Inherited from

`PgUpdateBase.returning`

##### shouldOmitSQLParens()?

```ts
shouldOmitSQLParens?(): boolean;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/sql/sql.d.ts:48

###### Returns

`boolean`

###### Inherited from

`PgUpdateBase.shouldOmitSQLParens`

##### toSQL()

```ts
toSQL(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:190

###### Returns

`Query`

###### Inherited from

`PgUpdateBase.toSQL`

##### where()

```ts
where(where): PgUpdateWithout<PgUnthrownUpdateBase<TTable, TQueryResult, TFrom, TSelectedFields, TReturning, TNullabilityMap, TJoins, TDynamic, TExcludedMethods>, TDynamic, "where">;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:160

Adds a 'where' clause to the query.

Calling this method will update only those rows that fulfill a specified condition.

See docs: <https://orm.drizzle.team/docs/update>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `where` | `SQL`<`unknown`> | `undefined` | the 'where' clause. |

###### Returns

`PgUpdateWithout`<[`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`TTable`, `TQueryResult`, `TFrom`, `TSelectedFields`, `TReturning`, `TNullabilityMap`, `TJoins`, `TDynamic`, `TExcludedMethods`>, `TDynamic`, `"where"`>

###### Example

You can use conditional operators and `sql function` to filter the rows to be updated.

```ts
// Update all cars with green color
await db.update(cars).set({ color: 'red' })
  .where(eq(cars.color, 'green'));
// or
await db.update(cars).set({ color: 'red' })
  .where(sql`${cars.color} = 'green'`)
```

You can logically combine conditional operators with `and()` and `or()` operators:

```ts
// Update all BMW cars with a green color
await db.update(cars).set({ color: 'red' })
  .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));

// Update all cars with the green or blue color
await db.update(cars).set({ color: 'red' })
  .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
```

###### Inherited from

`PgUpdateBase.where`

***

### PgUnthrownDeleteHKT

Defined in: [packages/drizzle/src/pg-core/delete.ts:37](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/delete.ts#L37)

The higher-kinded type that keeps every chained `delete` method returning an
unthrown builder rather than drizzle's own.

#### Remarks

See [PgUnthrownSelectHKT](#pgunthrownselecthkt) for why this is an `interface`.

#### Extends

* `PgDeleteHKTBase`

#### Properties

| Property | Type | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ |
|  `_type` | [`PgUnthrownDeleteBase`](#pgunthrowndeletebase)<`PgTable`<`TableConfig`>, `PgQueryResultHKT`, `ColumnsSelection` | `undefined`, `Record`<`string`, `unknown`> | `undefined`, `boolean`, `string`> | `PgDeleteHKTBase._type` | - | [packages/drizzle/src/pg-core/delete.ts:38](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/delete.ts#L38) |
|  `dynamic` | `boolean` | - | `PgDeleteHKTBase.dynamic` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:33 |
|  `excludedMethods` | `string` | - | `PgDeleteHKTBase.excludedMethods` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:34 |
|  `queryResult` | `unknown` | - | `PgDeleteHKTBase.queryResult` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:30 |
|  `returning` | `unknown` | - | `PgDeleteHKTBase.returning` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:32 |
|  `selectedFields` | `unknown` | - | `PgDeleteHKTBase.selectedFields` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:31 |
|  `table` | `unknown` | - | `PgDeleteHKTBase.table` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/delete.d.ts:29 |

***

### PgUnthrownInsertHKT

Defined in: [packages/drizzle/src/pg-core/insert.ts:36](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/insert.ts#L36)

The higher-kinded type that keeps every chained `insert` method returning an
unthrown builder rather than drizzle's own.

#### Remarks

See [PgUnthrownSelectHKT](#pgunthrownselecthkt) for why this is an `interface`.

#### Extends

* `PgInsertHKTBase`

#### Properties

| Property | Type | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ |
|  `_type` | [`PgUnthrownInsertBase`](#pgunthrowninsertbase)<`PgTable`<`TableConfig`>, `PgQueryResultHKT`, `unknown`, `unknown`, `boolean`, `string`> | `PgInsertHKTBase._type` | - | [packages/drizzle/src/pg-core/insert.ts:37](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/insert.ts#L37) |
|  `dynamic` | `boolean` | - | `PgInsertHKTBase.dynamic` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:70 |
|  `excludedMethods` | `string` | - | `PgInsertHKTBase.excludedMethods` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:71 |
|  `queryResult` | `unknown` | - | `PgInsertHKTBase.queryResult` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:67 |
|  `result` | `unknown` | - | `PgInsertHKTBase.result` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:72 |
|  `returning` | `unknown` | - | `PgInsertHKTBase.returning` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:69 |
|  `selectedFields` | `unknown` | - | `PgInsertHKTBase.selectedFields` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:68 |
|  `table` | `unknown` | - | `PgInsertHKTBase.table` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/insert.d.ts:66 |

***

### PgUnthrownRelationalQueryHKT

Defined in: [packages/drizzle/src/pg-core/query.ts:22](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/query.ts#L22)

The higher-kinded type that makes `db.query.<table>.findMany()` build an
unthrown relational query rather than drizzle's own.

#### Remarks

See [PgUnthrownSelectHKT](#pgunthrownselecthkt) for why this is an `interface`.

#### Extends

* `PgRelationalQueryHKTBase`

#### Properties

| Property | Type | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ |
|  `_type` | [`PgUnthrownRelationalQuery`](#pgunthrownrelationalquery)<`unknown`> | `PgRelationalQueryHKTBase._type` | - | [packages/drizzle/src/pg-core/query.ts:23](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/query.ts#L23) |
|  `result` | `unknown` | - | `PgRelationalQueryHKTBase.result` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/query.d.ts:27 |

***

### PgUnthrownSelectHKT

Defined in: [packages/drizzle/src/pg-core/select.ts:42](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L42)

The higher-kinded type that keeps every chained `select` method returning an
unthrown builder rather than drizzle's own.

#### Remarks

Drizzle's base builders are container-agnostic: `.where()`, `.limit()` and the
joins all rebuild `this` through `PgSelectKind<THKT, …>`, and the tree the
query stays in is decided by this one type. It must be an `interface` — the
pattern reads `this["tableName"]` and the polymorphic `this` type only exists
inside an interface or class declaration.

#### Extends

* `PgSelectHKTBase`

#### Type Parameters

| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
|  `TError` | `never` | the select's modeled error channel, carried through every chained method — see [PgUnthrownSelectBase](#pgunthrownselectbase). |

#### Properties

| Property | Type | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ |
|  `_type` | [`PgUnthrownSelectBase`](#pgunthrownselectbase)<`string` | `undefined`, `ColumnsSelection`, `SelectMode`, `Record`<`string`, `JoinNullability`>, `boolean`, `string`, `unknown`\[], `ColumnsSelection`, `TError`> | `PgSelectHKTBase._type` | - | [packages/drizzle/src/pg-core/select.ts:43](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L43) |
|  `dynamic` | `boolean` | - | `PgSelectHKTBase.dynamic` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.types.d.ts:95 |
|  `excludedMethods` | `string` | - | `PgSelectHKTBase.excludedMethods` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.types.d.ts:96 |
|  `nullabilityMap` | `unknown` | - | `PgSelectHKTBase.nullabilityMap` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.types.d.ts:94 |
|  `result` | `unknown` | - | `PgSelectHKTBase.result` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.types.d.ts:97 |
|  `selectedFields` | `unknown` | - | `PgSelectHKTBase.selectedFields` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.types.d.ts:98 |
|  `selection` | `unknown` | - | `PgSelectHKTBase.selection` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.types.d.ts:92 |
|  `selectMode` | `SelectMode` | - | `PgSelectHKTBase.selectMode` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.types.d.ts:93 |
|  `tableName` | `string` | `undefined` | - | `PgSelectHKTBase.tableName` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/select.types.d.ts:91 |

***

### PgUnthrownUpdateHKT

Defined in: [packages/drizzle/src/pg-core/update.ts:41](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/update.ts#L41)

The higher-kinded type that keeps every chained `update` method returning an
unthrown builder rather than drizzle's own.

#### Remarks

See [PgUnthrownSelectHKT](#pgunthrownselecthkt) for why this is an `interface`.

#### Extends

* `PgUpdateHKTBase`

#### Properties

| Property | Type | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ |
|  `_type` | [`PgUnthrownUpdateBase`](#pgunthrownupdatebase)<`PgTable`<`TableConfig`>, `PgQueryResultHKT`, | `PgTable`<`TableConfig`> | `PgViewBase`<`ViewConfig`<`ColumnsSelection`>> | `SQL`<`unknown`> | `Subquery`<`string`, `Record`<`string`, `unknown`>> | `undefined`, `ColumnsSelection` | `undefined`, `Record`<`string`, `unknown`> | `undefined`, `Record`<`string`, `JoinNullability`>, `Join`\[], `boolean`, `string`> | `PgUpdateHKTBase._type` | - | [packages/drizzle/src/pg-core/update.ts:42](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/update.ts#L42) |
|  `dynamic` | `boolean` | - | `PgUpdateHKTBase.dynamic` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:76 |
|  `excludedMethods` | `string` | - | `PgUpdateHKTBase.excludedMethods` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:77 |
|  `from` | `unknown` | - | `PgUpdateHKTBase.from` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:73 |
|  `joins` | `unknown` | - | `PgUpdateHKTBase.joins` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:70 |
|  `nullabilityMap` | `unknown` | - | `PgUpdateHKTBase.nullabilityMap` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:71 |
|  `queryResult` | `unknown` | - | `PgUpdateHKTBase.queryResult` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:72 |
|  `returning` | `unknown` | - | `PgUpdateHKTBase.returning` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:75 |
|  `selectedFields` | `unknown` | - | `PgUpdateHKTBase.selectedFields` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:74 |
|  `table` | `unknown` | - | `PgUpdateHKTBase.table` | node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/query-builders/update.d.ts:69 |

***

### PgUnthrownSelectBuilder

```ts
type PgUnthrownSelectBuilder<TSelection, TError> = PgSelectBuilder<TSelection, PgUnthrownSelectHKT<TError>>;
```

Defined in: [packages/drizzle/src/pg-core/select.ts:65](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L65)

The builder `db.select()` returns, before a table has been chosen.

#### Type Parameters

| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
|  `TSelection` *extends* `SelectedFields` | `undefined` | - | - |
|  `TError` | `never` | the select's modeled error channel: `never` for a read, `PgQueryError` for a select whose `WITH` list may write — see [PgUnthrownSelectBase](#pgunthrownselectbase). |

***

### PgUnthrownSelectPreparedQuery

```ts
type PgUnthrownSelectPreparedQuery<T, TError> = [TError] extends [never] ? PgUnthrownSafePreparedQuery<T> : PgUnthrownPreparedQuery<T>;
```

Defined in: [packages/drizzle/src/pg-core/select.ts:97](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/select.ts#L97)

The prepared statement a select hands back: the defect-only one for a read,
the qualified one for a select whose `WITH` list may write.

#### Type Parameters

| Type Parameter |
| ------ |
|  `T` *extends* `PreparedQueryConfig` |
|  `TError` |

***

### ResultThen

```ts
type ResultThen<T, E> = <TResult1, TResult2>(onFulfilled?, onRejected?) => PromiseLike<TResult1 | TResult2>;
```

Defined in: [packages/drizzle/src/pg-core/awaitable.ts:54](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/awaitable.ts#L54)

The `then` that makes a query builder awaitable, resolving to a `Result`.

#### Type Parameters

| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
|  `T` | - | the value the query succeeds with; the awaited type is `Result<T, E>`. |
|  `E` | [`PgQueryError`](#pgqueryerror) | the query's modeled error channel. Defaults to [PgQueryError](#pgqueryerror), which is what a **write** carries; the four read builders pass `never`, because a read has no modeled failure at all — see `runSafeQuery`. |

#### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `TResult1` | `Result`<`T`, `E`> |
|  `TResult2` | `never` |

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `onFulfilled?` | ((`value`) => `TResult1` | `PromiseLike`<`TResult1`>) | `null` |
| `onRejected?` | ((`reason`) => `TResult2` | `PromiseLike`<`TResult2`>) | `null` |

#### Returns

`PromiseLike`<`TResult1` | `TResult2`>

#### Remarks

Drizzle's promise and Effect trees each make their builders runnable the same
way: the builder carries a `then` that defers to `execute()`. The promise tree
gets it from the `QueryPromise` mixin, whose `then` is literally
`this.execute().then(onFulfilled, onRejected)`.

This package cannot reuse that mixin. `QueryPromise<T>` declares
`execute(): Promise<T>`, and ours returns an `AsyncResult<T, PgQueryError>` —
so merging its type would contradict the very method it delegates to. (Its
`applyMixins` helper is `@internal` and absent from drizzle's published
`.d.ts` besides.) Each builder therefore declares this `then` itself, built by
`resultThen`, with the awaited type it actually produces.

Awaiting a builder yields a `Result`, never a rejection: `execute()` returns
an `AsyncResult`, whose internal promise never rejects, and the compilation
step ahead of it runs inside the same boundary — see `runQuery`. `catch`
and `finally` are deliberately not offered: there is no rejection for them to
observe. `onRejected` is still forwarded, exactly as `AsyncResult.then`
forwards it, so a hypothetical internal rejection settles the `await` instead
of hanging it.

## Database

### PgUnthrownDatabase

Defined in: [packages/drizzle/src/pg-core/db.ts:136](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L136)

A Postgres database whose every query resolves to an `AsyncResult`.

#### Remarks

The unthrown sibling of drizzle's own `PgAsyncDatabase` (promises) and
`PgEffectDatabase` (Effects). The entry points below only *build* queries —
every one of them hands back a builder from this package's tree, and nothing
touches the database until that builder is awaited or `execute`d. That is why
their bodies are drizzle's, unchanged but for the builder classes.

#### Extended by

* [`NodePgUnthrownDatabase`](node-postgres.md#nodepgunthrowndatabase)
* [`NodePgUnthrownTransaction`](node-postgres.md#nodepgunthrowntransaction)

#### Type Parameters

| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
|  `TQueryResult` *extends* `PgQueryResultHKT` | - | the driver's result kind, which decides what a write without `.returning()` resolves to. |
|  `TRelations` *extends* `AnyRelations` | `EmptyRelations` | the relational schema backing [query](#query). |

#### Constructors

##### Constructor

```ts
new PgUnthrownDatabase<TQueryResult, TRelations>(
   dialect, 
   session, 
   relations, 
   parseRqbJson?, 
   tagged?
): PgUnthrownDatabase<TQueryResult, TRelations>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:159](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L159)

###### Parameters

| Parameter | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| `dialect` | `PgDialect` | `undefined` | - |
| `session` | [`PgUnthrownSession`](#abstract-pgunthrownsession)<`unknown`> | `undefined` | - |
| `relations` | `TRelations` | `undefined` | - |
| `parseRqbJson?` | `boolean` | `false` | - |
| `tagged?` | `boolean` | `false` | - |

###### Returns

[`PgUnthrownDatabase`](#pgunthrowndatabase)<`TQueryResult`, `TRelations`>

#### Properties

| Property | Modifier | Type | Default value | Description | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | `undefined` | - | [packages/drizzle/src/pg-core/db.ts:142](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L142) |
| `_.relations` | `readonly` | `TRelations` | `undefined` | - | [packages/drizzle/src/pg-core/db.ts:143](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L143) |
| `_.session` | `readonly` | [`PgUnthrownSession`](#abstract-pgunthrownsession)<`unknown`> | `undefined` | - | [packages/drizzle/src/pg-core/db.ts:144](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L144) |
|  `$with` | `readonly` | `PgUnthrownWithBuilder` | `...` | Creates a subquery that defines a temporary named result set as a CTE. It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query. See docs: <https://orm.drizzle.team/docs/select#with-clause> **Param** **alias** The alias for the subquery. Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries. **Example** `// Create a subquery with alias 'sq' and use it in the select query const sq = db.$with("sq").as(db.select().from(users).where(eq(users.id, 42))); const rows = (await db.with(sq).select().from(sq)).get();` To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them: `// Select an arbitrary SQL value as a field in a CTE and reference it in the main query const sq = db.$with("sq").as( db .select({ name: sql<string>`upper(${users.name})`.as("name"), }) .from(users), ); const rows = (await db.with(sq).select({ name: sq.name }).from(sq)).get();` | [packages/drizzle/src/pg-core/db.ts:254](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L254) |
|  `query` | `readonly` | { \[K in string | number | symbol]: RelationalQueryBuilder\<TRelations, TRelations\[K], PgUnthrownRelationalQueryHKT> } | `undefined` | The relational query API — `db.query.users.findMany(…)`, one entry per table in the relational schema. | [packages/drizzle/src/pg-core/db.ts:151](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L151) |
|  `tagged` | `readonly` | `boolean` | `false` | - | [packages/drizzle/src/pg-core/db.ts:166](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L166) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownDatabase"` | - | [packages/drizzle/src/pg-core/db.ts:140](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L140) |

#### Methods

##### $count()

```ts
$count(source, filters?): PgUnthrownCountBuilder;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:308](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L308)

Count the rows a table, view or subquery yields, optionally filtered.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `source` | | `PgTable`<`TableConfig`> | `PgViewBase`<`ViewConfig`<`ColumnsSelection`>> | `SQL`<`unknown`> | `SQLWrapper`<`unknown`> |
| `filters?` | `SQL`<`unknown`> |

###### Returns

[`PgUnthrownCountBuilder`](#pgunthrowncountbuilder)

###### Example

```ts
const total = (await db.$count(users, eq(users.active, true))).get();
//    ^? number — a count is a read, so its error channel is `never`.
```

##### delete()

```ts
delete<TTable>(table): PgUnthrownDeleteBase<TTable, TQueryResult>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:715](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L715)

Creates a delete query.

Calling this method without `.where()` clause will delete all rows in a
table. The `.where()` clause specifies which rows should be deleted.

See docs: <https://orm.drizzle.team/docs/delete>

A write carries the full `PgQueryError` union — a delete can still raise
`23505` through an `ON DELETE SET DEFAULT` — so awaiting the builder
resolves to a `Result` you fold with `mapErrCases` or `match`.

###### Type Parameters

| Type Parameter |
| ------ |
|  `TTable` *extends* `PgTable`<`TableConfig`> |

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `table` | `TTable` | The table to delete from. |

###### Returns

[`PgUnthrownDeleteBase`](#pgunthrowndeletebase)<`TTable`, `TQueryResult`>

###### Example

```ts
// Delete all rows in the 'cars' table
const all = await db.delete(cars);
//    ^? Result<DeleteResult<…>, PgQueryError>

// Delete rows with filters and conditions
await db.delete(cars).where(eq(cars.color, "green"));

// Delete with returning clause
const deleted = await db.delete(cars).where(eq(cars.id, 1)).returning();
```

##### execute()

```ts
execute<TRow>(query): PgUnthrownRaw<PgQueryResultKind<TQueryResult, TRow>>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:752](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L752)

Run a statement drizzle does not model — a raw `SQL` fragment or a string.

###### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `TRow` *extends* `Record`<`string`, `unknown`> | `Record`<`string`, `unknown`> |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `query` | `string` | `SQLWrapper`<`unknown`> |

###### Returns

[`PgUnthrownRaw`](#pgunthrownraw)<`PgQueryResultKind`<`TQueryResult`, `TRow`>>

###### Remarks

Unlike every other entry point, this one compiles its argument **eagerly**,
because `PgUnthrownRaw` is defined as holding an already-prepared query
(that is what makes its `getSQL`, `getQuery` and `_prepare` synchronous
accessors, exactly as in drizzle). Compilation therefore happens here rather
than at `await`, and a `SQLWrapper` that cannot compile **throws at this call
site** instead of yielding a defect.

That is a deliberate line, not an oversight: the contract this package makes
is about *running* a query — awaiting a builder, or calling its `execute()` —
and `db.execute(…)` is the factory that produces one, not the run itself. The
builder it returns is fully guarded. Reaching the throw takes handing in a
query builder that is already broken (`db.execute(db.select({ t:
other.col }).from(users))`); a string or a `sql` template — the documented
use — cannot. Closing the gap would mean deferring compilation, which would
cost `PgRaw`'s shape and its synchronous accessors for a case where the
argument, not the statement, is the bug.

###### Example

```ts
const result = await db.execute(sql`select now()`);
```

##### insert()

```ts
insert<TTable>(table): PgInsertBuilder<TTable, TQueryResult, "all", false, PgUnthrownInsertHKT>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:673](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L673)

Creates an insert query.

Calling this method will create new rows in a table. Use `.values()` method
to specify which values to insert.

See docs: <https://orm.drizzle.team/docs/insert>

A write carries the full `PgQueryError` union, so awaiting the builder
resolves to a `Result` you fold with `mapErrCases` or `match` — never a
rejection.

###### Type Parameters

| Type Parameter |
| ------ |
|  `TTable` *extends* `PgTable`<`TableConfig`> |

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `table` | `TTable` | The table to insert into. |

###### Returns

`PgInsertBuilder`<`TTable`, `TQueryResult`, `"all"`, `false`, [`PgUnthrownInsertHKT`](#pgunthrowninserthkt)>

###### Example

```ts
// Insert one row
const one = await db.insert(cars).values({ brand: "BMW" });
//    ^? Result<InsertResult<…>, PgQueryError>

// Insert multiple rows
await db.insert(cars).values([{ brand: "BMW" }, { brand: "Porsche" }]);

// Insert with returning clause
const inserted = await db.insert(cars).values({ brand: "BMW" }).returning();
```

##### refreshMaterializedView()

```ts
refreshMaterializedView<TView>(view): PgUnthrownRefreshMaterializedView<TQueryResult>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:720](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L720)

Rebuild a materialized view's stored rows.

###### Type Parameters

| Type Parameter |
| ------ |
|  `TView` *extends* `PgMaterializedView`<`ViewConfig`<`ColumnsSelection`>> |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `view` | `TView` |

###### Returns

[`PgUnthrownRefreshMaterializedView`](#pgunthrownrefreshmaterializedview)<`TQueryResult`>

##### select()

###### Call Signature

```ts
select(): PgUnthrownSelectBuilder<undefined>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:497](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L497)

Creates a select query.

Calling this method with no arguments will select all columns from the
table. Pass a selection object to specify the columns you want to select.

Use `.from()` method to specify which table to select from.

See docs: <https://orm.drizzle.team/docs/select>

Awaiting the builder resolves to a `Result`, never rows directly — a read
has no modeled failure, so the error channel is `never` and `.get()`
compiles.

###### Returns

[`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`undefined`>

###### Example

```ts
// Select all columns and all rows from the 'cars' table
const allCars = (await db.select().from(cars)).get();

// Select specific columns and all rows from the 'cars' table
const carsIdsAndBrands = (
  await db
    .select({
      id: cars.id,
      brand: cars.brand,
    })
    .from(cars)
).get();
```

###### Call Signature

```ts
select<TSelection>(fields): PgUnthrownSelectBuilder<TSelection>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:498](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L498)

Creates a select query.

Calling this method with no arguments will select all columns from the
table. Pass a selection object to specify the columns you want to select.

Use `.from()` method to specify which table to select from.

See docs: <https://orm.drizzle.team/docs/select>

Awaiting the builder resolves to a `Result`, never rows directly — a read
has no modeled failure, so the error channel is `never` and `.get()`
compiles.

###### Type Parameters

| Type Parameter |
| ------ |
|  `TSelection` *extends* `SelectedFields` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `TSelection` |

###### Returns

[`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`TSelection`>

###### Example

```ts
// Select all columns and all rows from the 'cars' table
const allCars = (await db.select().from(cars)).get();

// Select specific columns and all rows from the 'cars' table
const carsIdsAndBrands = (
  await db
    .select({
      id: cars.id,
      brand: cars.brand,
    })
    .from(cars)
).get();
```

##### selectDistinct()

###### Call Signature

```ts
selectDistinct(): PgUnthrownSelectBuilder<undefined>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:538](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L538)

Adds `distinct` expression to the select query.

Calling this method will return only unique values. When multiple columns
are selected, it returns rows with unique combinations of values in these
columns.

Use `.from()` method to specify which table to select from. Pass a
selection object to specify the columns you want to select.

See docs: <https://orm.drizzle.team/docs/select#distinct>

###### Returns

[`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`undefined`>

###### Example

```ts
// Select all unique rows from the 'cars' table
const unique = (
  await db.selectDistinct().from(cars).orderBy(cars.id, cars.brand, cars.color)
).get();

// Select all unique brands from the 'cars' table
const brands = (
  await db.selectDistinct({ brand: cars.brand }).from(cars).orderBy(cars.brand)
).get();
```

###### Call Signature

```ts
selectDistinct<TSelection>(fields): PgUnthrownSelectBuilder<TSelection>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:539](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L539)

Adds `distinct` expression to the select query.

Calling this method will return only unique values. When multiple columns
are selected, it returns rows with unique combinations of values in these
columns.

Use `.from()` method to specify which table to select from. Pass a
selection object to specify the columns you want to select.

See docs: <https://orm.drizzle.team/docs/select#distinct>

###### Type Parameters

| Type Parameter |
| ------ |
|  `TSelection` *extends* `SelectedFields` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `TSelection` |

###### Returns

[`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`TSelection`>

###### Example

```ts
// Select all unique rows from the 'cars' table
const unique = (
  await db.selectDistinct().from(cars).orderBy(cars.id, cars.brand, cars.color)
).get();

// Select all unique brands from the 'cars' table
const brands = (
  await db.selectDistinct({ brand: cars.brand }).from(cars).orderBy(cars.brand)
).get();
```

##### selectDistinctOn()

###### Call Signature

```ts
selectDistinctOn(on): PgUnthrownSelectBuilder<undefined>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:584](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L584)

Adds `distinct on` expression to the select query.

Calling this method will specify how the unique rows are determined.

Use `.from()` method to specify which table to select from. Pass a
selection object as the second argument to specify the columns you want to
select.

See docs: <https://orm.drizzle.team/docs/select#distinct>

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `on` | ( | `SQLWrapper`<`unknown`> | `PgColumn`<`any`, `PgColumnBaseConfig`<`any`>, { }>)\[] | The expression defining uniqueness. |

###### Returns

[`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`undefined`>

###### Example

```ts
// Select the first row for each unique brand from the 'cars' table
const firstPerBrand = (
  await db.selectDistinctOn([cars.brand]).from(cars).orderBy(cars.brand)
).get();

// The first occurrence of each unique brand, with its color
const brandColors = (
  await db
    .selectDistinctOn([cars.brand], { brand: cars.brand, color: cars.color })
    .from(cars)
    .orderBy(cars.brand, cars.color)
).get();
```

###### Call Signature

```ts
selectDistinctOn<TSelection>(on, fields): PgUnthrownSelectBuilder<TSelection>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:585](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L585)

Adds `distinct on` expression to the select query.

Calling this method will specify how the unique rows are determined.

Use `.from()` method to specify which table to select from. Pass a
selection object as the second argument to specify the columns you want to
select.

See docs: <https://orm.drizzle.team/docs/select#distinct>

###### Type Parameters

| Type Parameter |
| ------ |
|  `TSelection` *extends* `SelectedFields` |

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `on` | ( | `SQLWrapper`<`unknown`> | `PgColumn`<`any`, `PgColumnBaseConfig`<`any`>, { }>)\[] | The expression defining uniqueness. |
| `fields` | `TSelection` | - |

###### Returns

[`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`TSelection`>

###### Example

```ts
// Select the first row for each unique brand from the 'cars' table
const firstPerBrand = (
  await db.selectDistinctOn([cars.brand]).from(cars).orderBy(cars.brand)
).get();

// The first occurrence of each unique brand, with its color
const brandColors = (
  await db
    .selectDistinctOn([cars.brand], { brand: cars.brand, color: cars.color })
    .from(cars)
    .orderBy(cars.brand, cars.color)
).get();
```

##### update()

```ts
update<TTable>(table): PgUpdateBuilder<TTable, TQueryResult, PgUnthrownUpdateHKT>;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:639](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L639)

Creates an update query.

Calling this method without `.where()` clause will update all rows in a
table. The `.where()` clause specifies which rows should be updated.

Use `.set()` method to specify which values to update.

See docs: <https://orm.drizzle.team/docs/update>

A write carries the full `PgQueryError` union, so awaiting the builder
resolves to a `Result` you fold with `mapErrCases` or `match` — never a
rejection.

###### Type Parameters

| Type Parameter |
| ------ |
|  `TTable` *extends* `PgTable`<`TableConfig`> |

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `table` | `TTable` | The table to update. |

###### Returns

`PgUpdateBuilder`<`TTable`, `TQueryResult`, [`PgUnthrownUpdateHKT`](#pgunthrownupdatehkt)>

###### Example

```ts
// Update all rows in the 'cars' table
const all = await db.update(cars).set({ color: "red" });
//    ^? Result<UpdateResult<…>, PgQueryError>

// Update rows with filters and conditions
await db.update(cars).set({ color: "red" }).where(eq(cars.brand, "BMW"));

// Update with returning clause
const updated = await db
  .update(cars)
  .set({ color: "red" })
  .where(eq(cars.id, 1))
  .returning();
```

##### with()

```ts
with<Q>(...queries): object;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:341](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L341)

Incorporates a previously defined CTE (using `$with`) into the main query.

This method allows the main query to reference a temporary named result set.

See docs: <https://orm.drizzle.team/docs/select#with-clause>

###### Type Parameters

| Type Parameter |
| ------ |
|  `Q` *extends* `WithSubquery`<`string`, `Record`<`string`, `unknown`>>\[] |

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| ...`queries` | `Q` | The CTEs to incorporate into the main query. |

###### Returns

`object`

| Name | Type | Defined in |
| ------ | ------ | ------ |
| `delete()` | <`TTable`>(`table`) => [`PgUnthrownDeleteBase`](#pgunthrowndeletebase)<`TTable`, `TQueryResult`> | [packages/drizzle/src/pg-core/db.ts:369](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L369) |
| `insert()` | <`TTable`>(`table`) => `PgInsertBuilder`<`TTable`, `TQueryResult`, `"all"`, `false`, [`PgUnthrownInsertHKT`](#pgunthrowninserthkt)> | [packages/drizzle/src/pg-core/db.ts:366](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L366) |
| `select()` | { (): [`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`undefined`, [`WithListError`](#withlisterror)<`Q`\[`number`]>>; <`TSelection`>(`fields`): [`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`TSelection`, [`WithListError`](#withlisterror)<`Q`\[`number`]>>; } | [packages/drizzle/src/pg-core/db.ts:344](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L344) |
| `selectDistinct()` | { (): [`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`undefined`, [`WithListError`](#withlisterror)<`Q`\[`number`]>>; <`TSelection`>(`fields`): [`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`TSelection`, [`WithListError`](#withlisterror)<`Q`\[`number`]>>; } | [packages/drizzle/src/pg-core/db.ts:350](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L350) |
| `selectDistinctOn()` | { (`on`): [`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`undefined`, [`WithListError`](#withlisterror)<`Q`\[`number`]>>; <`TSelection`>(`on`, `fields`): [`PgUnthrownSelectBuilder`](#pgunthrownselectbuilder)<`TSelection`, [`WithListError`](#withlisterror)<`Q`\[`number`]>>; } | [packages/drizzle/src/pg-core/db.ts:356](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L356) |
| `update()` | <`TTable`>(`table`) => `PgUpdateBuilder`<`TTable`, `TQueryResult`, [`PgUnthrownUpdateHKT`](#pgunthrownupdatehkt)> | [packages/drizzle/src/pg-core/db.ts:363](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L363) |

###### Example

```ts
// Define a subquery 'sq' as a CTE using $with
const sq = db.$with("sq").as(db.select().from(users).where(eq(users.id, 42)));

// Incorporate the CTE 'sq' into the main query and select from it
const rows = (await db.with(sq).select().from(sq)).get();
```

***

### CteError

```ts
type CteError<TError> = object;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:59](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L59)

The modeled error channel a CTE contributes to the select that uses it —
`never` for a CTE that only reads, [PgQueryError](#pgqueryerror) for one that may
write.

#### Remarks

A phantom in drizzle's own `_` type bag, where drizzle keeps its other
compile-time-only fields; nothing sets it at runtime, which is why it is
optional. The runtime half of the same decision is `readOnlyCtes`.

#### Type Parameters

| Type Parameter |
| ------ |
|  `TError` |

#### Properties

| Property | Modifier | Type | Defined in |
| ------ | ------ | ------ | ------ |
|  `_` | `readonly` | `object` | [packages/drizzle/src/pg-core/db.ts:59](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L59) |
| `_.unthrownError?` | `readonly` | `TError` | [packages/drizzle/src/pg-core/db.ts:59](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L59) |

***

### WithListError

```ts
type WithListError<W> = W extends object ? unknown extends E ? PgQueryError : E : PgQueryError;
```

Defined in: [packages/drizzle/src/pg-core/db.ts:79](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/db.ts#L79)

The error channel a `WITH` list adds to its select: the union of what its
CTEs may raise. A CTE this package did not build (a stock drizzle `$with`)
carries no [CteError](#cteerror) and is assumed to write — nothing says it
cannot.

#### Type Parameters

| Type Parameter |
| ------ |
|  `W` |

## Other

### CheckViolation

Defined in: [packages/drizzle/src/errors.ts:59](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L59)

A check constraint was violated (SQLSTATE `23514`).

#### Extends

* `TaggedErrorInstance`<`"CheckViolation"`, `ConstraintFields`>

#### Constructors

##### Constructor

```ts
new CheckViolation(fields): CheckViolation;
```

Defined in: [packages/drizzle/src/errors.ts:62](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L62)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `ConstraintFields` |

###### Returns

[`CheckViolation`](#checkviolation)

###### Overrides

`TaggedError("CheckViolation")<ConstraintFields>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_tag` | `readonly` | `"CheckViolation"` | `undefined` | - | `TaggedError("CheckViolation")._tag` | packages/core/dist/index.d.mts:2363 |
|  `cause` | `public` | `unknown` | `undefined` | - | `TaggedError("CheckViolation").cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
|  `constraint` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("CheckViolation").constraint` | [packages/drizzle/src/errors.ts:11](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L11) |
|  `detail` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("CheckViolation").detail` | [packages/drizzle/src/errors.ts:13](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L13) |
|  `message` | `public` | `string` | `"check constraint violated"` | `TaggedError("CheckViolation").message` | - | [packages/drizzle/src/errors.ts:60](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L60) |
|  `name` | `public` | `string` | `undefined` | - | `TaggedError("CheckViolation").name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
|  `stack?` | `public` | `string` | `undefined` | - | `TaggedError("CheckViolation").stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|  `table` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("CheckViolation").table` | [packages/drizzle/src/errors.ts:12](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L12) |

***

### ExclusionViolation

Defined in: [packages/drizzle/src/errors.ts:69](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L69)

An exclusion constraint was violated (SQLSTATE `23P01`).

#### Extends

* `TaggedErrorInstance`<`"ExclusionViolation"`, `ConstraintFields`>

#### Constructors

##### Constructor

```ts
new ExclusionViolation(fields): ExclusionViolation;
```

Defined in: [packages/drizzle/src/errors.ts:72](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L72)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `ConstraintFields` |

###### Returns

[`ExclusionViolation`](#exclusionviolation)

###### Overrides

`TaggedError("ExclusionViolation")<ConstraintFields>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_tag` | `readonly` | `"ExclusionViolation"` | `undefined` | - | `TaggedError("ExclusionViolation")._tag` | packages/core/dist/index.d.mts:2363 |
|  `cause` | `public` | `unknown` | `undefined` | - | `TaggedError("ExclusionViolation").cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
|  `constraint` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("ExclusionViolation").constraint` | [packages/drizzle/src/errors.ts:11](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L11) |
|  `detail` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("ExclusionViolation").detail` | [packages/drizzle/src/errors.ts:13](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L13) |
|  `message` | `public` | `string` | `"exclusion constraint violated"` | `TaggedError("ExclusionViolation").message` | - | [packages/drizzle/src/errors.ts:70](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L70) |
|  `name` | `public` | `string` | `undefined` | - | `TaggedError("ExclusionViolation").name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
|  `stack?` | `public` | `string` | `undefined` | - | `TaggedError("ExclusionViolation").stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|  `table` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("ExclusionViolation").table` | [packages/drizzle/src/errors.ts:12](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L12) |

***

### ForeignKeyViolation

Defined in: [packages/drizzle/src/errors.ts:49](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L49)

A foreign key constraint was violated (SQLSTATE `23503`).

#### Extends

* `TaggedErrorInstance`<`"ForeignKeyViolation"`, `ConstraintFields`>

#### Constructors

##### Constructor

```ts
new ForeignKeyViolation(fields): ForeignKeyViolation;
```

Defined in: [packages/drizzle/src/errors.ts:52](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L52)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `ConstraintFields` |

###### Returns

[`ForeignKeyViolation`](#foreignkeyviolation)

###### Overrides

`TaggedError("ForeignKeyViolation")<ConstraintFields>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_tag` | `readonly` | `"ForeignKeyViolation"` | `undefined` | - | `TaggedError("ForeignKeyViolation")._tag` | packages/core/dist/index.d.mts:2363 |
|  `cause` | `public` | `unknown` | `undefined` | - | `TaggedError("ForeignKeyViolation").cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
|  `constraint` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("ForeignKeyViolation").constraint` | [packages/drizzle/src/errors.ts:11](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L11) |
|  `detail` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("ForeignKeyViolation").detail` | [packages/drizzle/src/errors.ts:13](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L13) |
|  `message` | `public` | `string` | `"foreign key constraint violated"` | `TaggedError("ForeignKeyViolation").message` | - | [packages/drizzle/src/errors.ts:50](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L50) |
|  `name` | `public` | `string` | `undefined` | - | `TaggedError("ForeignKeyViolation").name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
|  `stack?` | `public` | `string` | `undefined` | - | `TaggedError("ForeignKeyViolation").stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|  `table` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("ForeignKeyViolation").table` | [packages/drizzle/src/errors.ts:12](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L12) |

***

### NotNullViolation

Defined in: [packages/drizzle/src/errors.ts:94](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L94)

A `NOT NULL` constraint was violated (SQLSTATE `23502`).

#### Remarks

Carries `column` rather than `constraint`: `23502` names the offending column
and has no constraint name of its own. `detail` and `cause` are not
enumerable, as on the other four.

#### Extends

* `TaggedErrorInstance`<`"NotNullViolation"`, `NotNullFields`>

#### Constructors

##### Constructor

```ts
new NotNullViolation(fields): NotNullViolation;
```

Defined in: [packages/drizzle/src/errors.ts:97](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L97)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `NotNullFields` |

###### Returns

[`NotNullViolation`](#notnullviolation)

###### Overrides

`TaggedError("NotNullViolation")<NotNullFields>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_tag` | `readonly` | `"NotNullViolation"` | `undefined` | - | `TaggedError("NotNullViolation")._tag` | packages/core/dist/index.d.mts:2363 |
|  `cause` | `public` | `unknown` | `undefined` | - | `TaggedError("NotNullViolation").cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
|  `column` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("NotNullViolation").column` | [packages/drizzle/src/errors.ts:80](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L80) |
|  `detail` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("NotNullViolation").detail` | [packages/drizzle/src/errors.ts:82](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L82) |
|  `message` | `public` | `string` | `"not-null constraint violated"` | `TaggedError("NotNullViolation").message` | - | [packages/drizzle/src/errors.ts:95](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L95) |
|  `name` | `public` | `string` | `undefined` | - | `TaggedError("NotNullViolation").name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
|  `stack?` | `public` | `string` | `undefined` | - | `TaggedError("NotNullViolation").stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|  `table` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError("NotNullViolation").table` | [packages/drizzle/src/errors.ts:81](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L81) |

***

### UniqueConstraintViolation

Defined in: [packages/drizzle/src/errors.ts:37](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L37)

A unique constraint was violated (SQLSTATE `23505`).

#### Extends

* `TaggedErrorInstance`<`"UniqueConstraintViolation"`, `ConstraintFields`>

#### Constructors

##### Constructor

```ts
new UniqueConstraintViolation(fields): UniqueConstraintViolation;
```

Defined in: [packages/drizzle/src/errors.ts:42](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L42)

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fields` | `ConstraintFields` |

###### Returns

[`UniqueConstraintViolation`](#uniqueconstraintviolation)

###### Overrides

`TaggedError( "UniqueConstraintViolation", )<ConstraintFields>.constructor`

#### Properties

| Property | Modifier | Type | Default value | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `_tag` | `readonly` | `"UniqueConstraintViolation"` | `undefined` | - | `TaggedError( "UniqueConstraintViolation", )._tag` | packages/core/dist/index.d.mts:2363 |
|  `cause` | `public` | `unknown` | `undefined` | - | `TaggedError( "UniqueConstraintViolation", ).cause` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 |
|  `constraint` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError( "UniqueConstraintViolation", ).constraint` | [packages/drizzle/src/errors.ts:11](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L11) |
|  `detail` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError( "UniqueConstraintViolation", ).detail` | [packages/drizzle/src/errors.ts:13](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L13) |
|  `message` | `public` | `string` | `"unique constraint violated"` | `TaggedError( "UniqueConstraintViolation", ).message` | - | [packages/drizzle/src/errors.ts:40](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L40) |
|  `name` | `public` | `string` | `undefined` | - | `TaggedError( "UniqueConstraintViolation", ).name` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 |
|  `stack?` | `public` | `string` | `undefined` | - | `TaggedError( "UniqueConstraintViolation", ).stack` | node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 |
|  `table` | `readonly` | `string` | `undefined` | `undefined` | - | `TaggedError( "UniqueConstraintViolation", ).table` | [packages/drizzle/src/errors.ts:12](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L12) |

***

### DeleteResult

```ts
type DeleteResult<TQueryResult, TReturning> = TReturning extends undefined ? PgQueryResultKind<TQueryResult, never> : TReturning[];
```

Defined in: [packages/drizzle/src/pg-core/delete.ts:22](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/delete.ts#L22)

What a `delete` resolves to: the driver's own result object, or the returned
rows once `.returning()` has been called.

#### Type Parameters

| Type Parameter |
| ------ |
|  `TQueryResult` *extends* `PgQueryResultHKT` |
|  `TReturning` |

***

### InsertResult

```ts
type InsertResult<TQueryResult, TReturning> = TReturning extends undefined ? PgQueryResultKind<TQueryResult, never> : TReturning[];
```

Defined in: [packages/drizzle/src/pg-core/insert.ts:21](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/insert.ts#L21)

What an `insert` resolves to: the driver's own result object, or the returned
rows once `.returning()` has been called.

#### Type Parameters

| Type Parameter |
| ------ |
|  `TQueryResult` *extends* `PgQueryResultHKT` |
|  `TReturning` |

***

### PgQueryError

```ts
type PgQueryError = 
  | UniqueConstraintViolation
  | ForeignKeyViolation
  | NotNullViolation
  | CheckViolation
  | ExclusionViolation;
```

Defined in: [packages/drizzle/src/errors.ts:110](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L110)

The full union of domain errors a Postgres query can surface.

#### Remarks

Infrastructure failures are deliberately absent — they are defects, not
values. See [qualifyPgError](#qualifypgerror).

***

### UpdateResult

```ts
type UpdateResult<TQueryResult, TReturning> = TReturning extends undefined ? PgQueryResultKind<TQueryResult, never> : TReturning[];
```

Defined in: [packages/drizzle/src/pg-core/update.ts:26](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/update.ts#L26)

What an `update` resolves to: the driver's own result object, or the returned
rows once `.returning()` has been called.

#### Type Parameters

| Type Parameter |
| ------ |
|  `TQueryResult` *extends* `PgQueryResultHKT` |
|  `TReturning` |

***

### qualifyPgError()

```ts
function qualifyPgError<D>(cause, defect): D | PgQueryError;
```

Defined in: [packages/drizzle/src/errors.ts:165](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/errors.ts#L165)

Triage a Postgres driver failure into the modeled error channel or the defect
channel — a `qualify` in the Thesis-#3 sense, so it drops straight into a
`fromPromise` at a boundary of your own.

#### Type Parameters

| Type Parameter |
| ------ |
|  `D` |

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `cause` | `unknown` | the rejected value from a Postgres query (a node-postgres `DatabaseError`, a `DrizzleQueryError` wrapping one, or anything else). |
| `defect` | (`cause`) => `D` | the defect helper the boundary injects (never import it). |

#### Returns

`D` | [`PgQueryError`](#pgqueryerror)

#### Remarks

Only the five `23xxx` integrity-constraint codes are modeled: they are what a
request handler branches on. Everything else — serialization failure
(`40001`), deadlock (`40P01`), statement timeout (`57014`), connection loss,
syntax errors — is a defect. Retry belongs in one `recoverDefect` wrapper
that inspects the cause, not an arm at every write call site.

Only an error the server reported is triaged — one carrying a `severity` as
well as a SQLSTATE `code`. Anything else with a `code` is a defect.

#### Example

```ts
const rows = fromPromise(pool.query("select 1"), qualifyPgError);
```

## Session

### PgUnthrownPreparedQuery

Defined in: [packages/drizzle/src/pg-core/session.ts:59](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L59)

A prepared query whose execution yields an `AsyncResult`.

#### Remarks

This is the single place in the package where a driver rejection is triaged.
Everything above it — the builder tree, the database facade — is type
plumbing; the container swap happens here, and only here, because drizzle
declares `PgBasePreparedQuery.execute()` as returning `unknown`.

Every failure leaves [execute](#execute-4) as either a modeled [PgQueryError](#pgqueryerror)
or a defect, so the returned `AsyncResult`'s internal promise never rejects
and awaiting it never throws.

#### Extends

* `PgBasePreparedQuery`

#### Extended by

* [`PgUnthrownSafePreparedQuery`](#pgunthrownsafepreparedquery)

#### Type Parameters

| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
|  `T` *extends* `PreparedQueryConfig` | `PreparedQueryConfig` | drizzle's per-query config, whose `execute` member is the value the query resolves to. |

#### Constructors

##### Constructor

```ts
new PgUnthrownPreparedQuery<T>(
   executor, 
   query, 
   mapper, 
   mode, 
   logger
): PgUnthrownPreparedQuery<T>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:73](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L73)

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `executor` | (`params`) => `Promise`<`unknown`> | runs the query against the driver with the given bound parameters. Its rejection is what [execute](#execute-4) triages. |
| `query` | `Query` | the compiled SQL and its parameter list. |
| `mapper` | [`PgRowMapper`](#pgrowmapper) | `undefined` | maps the driver's rows to the query's declared result, or `undefined` to pass the driver's value through untouched. |
| `mode` | [`PgQueryMode`](#pgquerymode) | the row shape the driver was asked for. |
| `logger` | `Logger` | drizzle's query logger. |

###### Returns

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery)<`T`>

###### Overrides

`PgBasePreparedQuery.constructor`

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `mode` | `readonly` | [`PgQueryMode`](#pgquerymode) | `undefined` | the row shape the driver was asked for. | - | [packages/drizzle/src/pg-core/session.ts:77](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L77) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownPreparedQuery"` | - | `PgBasePreparedQuery.[entityKind]` | [packages/drizzle/src/pg-core/session.ts:62](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L62) |

#### Methods

##### execute()

```ts
execute(placeholderValues?): AsyncResult<T["execute"], PgQueryError>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:142](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L142)

Run the query, triaging any driver failure into the error or defect channel.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> | values for the query's named placeholders. |

###### Returns

`AsyncResult`<`T`\[`"execute"`], [`PgQueryError`](#pgqueryerror)>

###### Remarks

The promise is started from a thunk so that a synchronous throw — a missing
placeholder value, a driver that validates its arguments eagerly — is caught
by the same boundary as a rejection. `execute` therefore neither throws nor
rejects: awaiting it always yields a `Result`.

###### Overrides

`PgBasePreparedQuery.execute`

##### getQuery()

```ts
getQuery(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/session.d.ts:14

###### Returns

`Query`

###### Inherited from

`PgBasePreparedQuery.getQuery`

***

### PgUnthrownSafePreparedQuery

Defined in: [packages/drizzle/src/pg-core/session.ts:201](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L201)

A prepared query whose every failure is a defect — the read builders' half of
[PgUnthrownPreparedQuery](#pgunthrownpreparedquery).

#### Remarks

A read has no modeled failure (see `runSafeQuery`), so the four read
builders declare `E = never`. Their `prepare(name)` returns one of these, so
running a *prepared* read reaches the same `fromSafePromise` boundary that
`execute()` and `await` do — all three routes agree, and none of them can put
a value in a channel the type calls empty.

This is a subclass rather than a type parameter on
[PgUnthrownPreparedQuery](#pgunthrownpreparedquery) deliberately. A parameterised `E` would have
to pick its boundary from a constructor-injected function, and the injected
default (`fromPromise` + `qualifyPgError`, typed `PgQueryError`) is not
assignable to an unresolved `E` — so the single-class form needs a cast
exactly where the type and the runtime must not be allowed to drift apart.
Overriding `execute` needs none: `AsyncResult` is covariant in `E`, so
`AsyncResult<T, never>` already satisfies the base's declaration, and the
narrower type is reachable *only* through this class, whose `execute` is the
safe one. The weld is by construction.

#### Extends

* [`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery)<`T`>

#### Type Parameters

| Type Parameter | Default type | Description |
| ------ | ------ | ------ |
|  `T` *extends* `PreparedQueryConfig` | `PreparedQueryConfig` | drizzle's per-query config, whose `execute` member is the value the query resolves to. |

#### Constructors

##### Constructor

```ts
new PgUnthrownSafePreparedQuery<T>(
   executor, 
   query, 
   mapper, 
   mode, 
   logger
): PgUnthrownSafePreparedQuery<T>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:73](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L73)

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `executor` | (`params`) => `Promise`<`unknown`> | runs the query against the driver with the given bound parameters. Its rejection is what [execute](#execute-8) triages. |
| `query` | `Query` | the compiled SQL and its parameter list. |
| `mapper` | [`PgRowMapper`](#pgrowmapper) | `undefined` | maps the driver's rows to the query's declared result, or `undefined` to pass the driver's value through untouched. |
| `mode` | [`PgQueryMode`](#pgquerymode) | the row shape the driver was asked for. |
| `logger` | `Logger` | drizzle's query logger. |

###### Returns

[`PgUnthrownSafePreparedQuery`](#pgunthrownsafepreparedquery)<`T`>

###### Inherited from

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery).[`constructor`](#constructor-8)

#### Properties

| Property | Modifier | Type | Default value | Description | Overrides | Inherited from | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|  `mode` | `readonly` | [`PgQueryMode`](#pgquerymode) | `undefined` | the row shape the driver was asked for. | - | [`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery).[`mode`](#mode) | [packages/drizzle/src/pg-core/session.ts:77](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L77) |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownSafePreparedQuery"` | - | [`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery).[`[entityKind]`](#entitykind-4) | - | [packages/drizzle/src/pg-core/session.ts:204](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L204) |

#### Methods

##### execute()

```ts
execute(placeholderValues?): AsyncResult<T["execute"], never>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:213](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L213)

Run the query. Every failure — a constraint violation raised by a volatile
function the read called included — is a `Defect`; the error channel is
`never`.

###### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `placeholderValues?` | `Record`<`string`, `unknown`> | values for the query's named placeholders. |

###### Returns

`AsyncResult`<`T`\[`"execute"`], `never`>

###### Overrides

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery).[`execute`](#execute-4)

##### getQuery()

```ts
getQuery(): Query;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/session.d.ts:14

###### Returns

`Query`

###### Inherited from

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery).[`getQuery`](#getquery)

***

### `abstract` PgUnthrownSession

Defined in: [packages/drizzle/src/pg-core/session.ts:237](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L237)

The session every unthrown Postgres driver implements.

#### Remarks

The mirror of drizzle's own `PgAsyncSession` / `PgEffectSession`: `PgSession`
declares `execute` / `arrays` / `objects` as returning `unknown`, which is
precisely the seam that lets a fourth execution container — `AsyncResult` —
be plugged in alongside promises and Effects.

#### Extends

* `PgSession`

#### Extended by

* [`NodePgUnthrownSession`](node-postgres.md#nodepgunthrownsession)

#### Type Parameters

| Type Parameter | Description |
| ------ | ------ |
|  `TTransaction` | the transaction handle passed to a [PgUnthrownSession.transaction](#transaction) callback. It is a parameter rather than a concrete type because the transaction class is built on top of the database facade, which in turn is built on this session; the driver that owns both supplies it. |

#### Constructors

##### Constructor

```ts
new PgUnthrownSession<TTransaction>(dialect): PgUnthrownSession<TTransaction>;
```

Defined in: node\_modules/.pnpm/drizzle-orm@1.0.0-rc.5-5935859\_@electric-sql+pglite@0.4.3\_@types+pg@8.23.1\_better-sqlit\_5673ebe1f2b3df7b309939d01388aef3/node\_modules/drizzle-orm/pg-core/session.d.ts:33

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `dialect` | `PgDialect` |

###### Returns

[`PgUnthrownSession`](#abstract-pgunthrownsession)<`TTransaction`>

###### Inherited from

`PgSession.constructor`

#### Properties

| Property | Modifier | Type | Default value | Overrides | Defined in |
| ------ | ------ | ------ | ------ | ------ | ------ |
|  `[entityKind]` | `static readonly` | `string` | `"PgUnthrownSession"` | `PgSession.[entityKind]` | [packages/drizzle/src/pg-core/session.ts:238](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L238) |

#### Methods

##### arrays()

```ts
arrays(query): AsyncResult<unknown, PgQueryError>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:276](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L276)

Run a raw `SQL` fragment, returning each row as an array of column values.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `query` | `SQL` |

###### Returns

`AsyncResult`<`unknown`, [`PgQueryError`](#pgqueryerror)>

###### Overrides

`PgSession.arrays`

##### execute()

```ts
execute(query): AsyncResult<unknown, PgQueryError>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:271](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L271)

Run a raw `SQL` fragment, returning the driver's own result object.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `query` | `SQL` |

###### Returns

`AsyncResult`<`unknown`, [`PgQueryError`](#pgqueryerror)>

###### Remarks

Compilation runs **inside** the failure boundary — see `runQuery`.
`dialect.sqlToQuery` throws for mistakes that are type-legal and reachable,
and a throw escaping here would land on a caller who has no `try`/`catch`,
because this method's contract is a `Result`.

###### Overrides

`PgSession.execute`

##### objects()

```ts
objects(query): AsyncResult<unknown, PgQueryError>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:281](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L281)

Run a raw `SQL` fragment, returning each row as a column-keyed object.

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `query` | `SQL` |

###### Returns

`AsyncResult`<`unknown`, [`PgQueryError`](#pgqueryerror)>

###### Overrides

`PgSession.objects`

##### prepareQuery()

```ts
abstract prepareQuery<T>(
   query, 
   mode, 
   name, 
   mapper?, 
   queryMetadata?, 
   cacheConfig?
): PgUnthrownPreparedQuery<T>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:240](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L240)

###### Type Parameters

| Type Parameter | Default type |
| ------ | ------ |
|  `T` *extends* `PreparedQueryConfig` | `PreparedQueryConfig` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `query` | `Query` |
| `mode` | [`PgQueryMode`](#pgquerymode) |
| `name` | `string` | `boolean` |
| `mapper?` | [`PgRowMapper`](#pgrowmapper) |
| `queryMetadata?` | { `tables`: `string`\[]; `type`: `"insert"` | `"update"` | `"select"` | `"delete"`; } |
| `queryMetadata.tables` | `string`\[] |
| `queryMetadata.type` | `"insert"` | `"update"` | `"select"` | `"delete"` |
| `cacheConfig?` | `WithCacheConfig` |

###### Returns

[`PgUnthrownPreparedQuery`](#pgunthrownpreparedquery)<`T`>

###### Overrides

`PgSession.prepareQuery`

##### transaction()

```ts
abstract transaction<A, E>(fn, config?): AsyncResult<A, PgQueryError | E>;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:257](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L257)

Run `fn` inside a database transaction.

###### Type Parameters

| Type Parameter |
| ------ |
|  `A` |
|  `E` |

###### Parameters

| Parameter | Type |
| ------ | ------ |
| `fn` | (`tx`) => `AsyncResult`<`A`, `E`> |
| `config?` | `PgTransactionConfig` |

###### Returns

`AsyncResult`<`A`, [`PgQueryError`](#pgqueryerror) | `E`>

###### Remarks

An `Err` from `fn` rolls back and re-surfaces typed; a defect rolls back and
stays a defect. The transaction's own control statements can fail too, so
[PgQueryError](#pgqueryerror) joins the callback's error channel.

***

### PgQueryMode

```ts
type PgQueryMode = "arrays" | "objects" | "raw";
```

Defined in: [packages/drizzle/src/pg-core/session.ts:22](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L22)

The row shapes a prepared query can be asked to produce.

***

### PgRowMapper

```ts
type PgRowMapper = (rows) => unknown;
```

Defined in: [packages/drizzle/src/pg-core/session.ts:39](https://github.com/btravstack/unthrown/blob/62d016501fb81e91d4b8a2090643a21cfdab956d/packages/drizzle/src/pg-core/session.ts#L39)

A row mapper, as handed over by a drizzle query builder.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `rows` | `never`\[] |

#### Returns

`unknown`

#### Remarks

The parameter is `never[]` — the bottom array type — deliberately. The
session never inspects rows: it forwards whatever the driver produced to the
mapper the builder supplied, and each builder asks for a different row shape
(`unknown[][]` for a column-array select, `unknown[][] | Record<string,
unknown>[]` for a relational query). Under `strictFunctionTypes` a parameter
is checked contravariantly, so `never[]` is the one parameter type every such
mapper is assignable to. Spelling it `any[]` would accept exactly the same
set while giving up type-checking inside every mapper that reads it.
