PgwasmTransaction
Defined in: packages/pgwasm/src/drizzle/session.ts:100
Extends
Section titled “Extends”PgAsyncTransaction<PgwasmQueryResultHKT,TRelations>
Type Parameters
Section titled “Type Parameters”TRelations
Section titled “TRelations”TRelations extends AnyRelations
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PgwasmTransaction<
TRelations>(dialect,session,relations,nestedIndex,parseRqbJson):PgwasmTransaction<TRelations>
Defined in: packages/pgwasm/src/drizzle/session.ts:108
Parameters
Section titled “Parameters”dialect
Section titled “dialect”PgDialect
session
Section titled “session”PgwasmSession<TRelations>
relations
Section titled “relations”TRelations
nestedIndex
Section titled “nestedIndex”number | undefined
parseRqbJson
Section titled “parseRqbJson”boolean | undefined
Returns
Section titled “Returns”PgwasmTransaction<TRelations>
Overrides
Section titled “Overrides”PgAsyncTransaction<PgwasmQueryResultHKT, TRelations>.constructor
Properties
Section titled “Properties”
readonly_:object
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:353
relations
Section titled “relations”
readonlyrelations:TRelations
session
Section titled “session”
readonlysession:PgAsyncSession<PgwasmQueryResultHKT,TRelations>
Inherited from
Section titled “Inherited from”PgAsyncTransaction._
$cache
Section titled “$cache”$cache:
object
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:78
invalidate
Section titled “invalidate”invalidate: (
params) =>Promise<void>
Invoked if insert, update, delete was invoked
Parameters
Section titled “Parameters”params
Section titled “params”MutationOption
Returns
Section titled “Returns”Promise<void>
Inherited from
Section titled “Inherited from”PgAsyncTransaction.$cache
$with:
WithBuilder
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:76
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
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
Section titled “Example”// Create a subquery with alias 'sq' and use it in the select queryconst sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
const result = await db.with(sq).select().from(sq);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 queryconst sq = db.$with('sq').as(db.select({ name: sql<string>`upper(${users.name})`.as('name'),}).from(users));
const result = await db.with(sq).select({ name: sq.name }).from(sq);Inherited from
Section titled “Inherited from”PgAsyncTransaction.$with
query: { [K in string | number | symbol]: RelationalQueryBuilder<TRelations, TRelations[K], PgAsyncRelationalQueryHKT> }
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:38
Inherited from
Section titled “Inherited from”PgAsyncTransaction.query
tagged
Section titled “tagged”
readonlytagged:boolean
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:31
Inherited from
Section titled “Inherited from”PgAsyncTransaction.tagged
[entityKind]
Section titled “[entityKind]”
readonlystatic[entityKind]:string="PgwasmTransaction"
Defined in: packages/pgwasm/src/drizzle/session.ts:104
Overrides
Section titled “Overrides”PgAsyncTransaction.[entityKind]
Methods
Section titled “Methods”$count()
Section titled “$count()”$count(
source,filters?):PgAsyncCountBuilder
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:77
Parameters
Section titled “Parameters”source
Section titled “source”SQLWrapper<unknown> | PgTable<TableConfig> | SQL<unknown> | PgViewBase<ViewConfig<ColumnsSelection>>
filters?
Section titled “filters?”SQL<unknown>
Returns
Section titled “Returns”PgAsyncCountBuilder
Inherited from
Section titled “Inherited from”PgAsyncTransaction.$count
delete()
Section titled “delete()”delete<
TTable>(table):PgAsyncDeleteBase<TTable,PgwasmQueryResultHKT>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:292
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
Type Parameters
Section titled “Type Parameters”TTable
Section titled “TTable”TTable extends PgTable<TableConfig>
Parameters
Section titled “Parameters”TTable
The table to delete from.
Returns
Section titled “Returns”PgAsyncDeleteBase<TTable, PgwasmQueryResultHKT>
Example
Section titled “Example”// Delete all rows in the 'cars' tableawait db.delete(cars);
// Delete rows with filters and conditionsawait db.delete(cars).where(eq(cars.color, 'green'));
// Delete with returning clauseconst deletedCar: Car[] = await db.delete(cars) .where(eq(cars.id, 1)) .returning();Inherited from
Section titled “Inherited from”PgAsyncTransaction.delete
execute()
Section titled “execute()”Call Signature
Section titled “Call Signature”execute<
TRow>(query,mode):PgAsyncRaw<TRow[]>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:308
Executes raw SQL query, responding with rows as arrays of values
Types assume single statement is executed per query
Type Parameters
Section titled “Type Parameters”TRow extends unknown[] = unknown[]
Parameters
Section titled “Parameters”string | SQLWrapper<unknown>
SQL query to execute
"arrays"
'arrays'
Returns
Section titled “Returns”PgAsyncRaw<TRow[]>
Example
Section titled “Example”// [number, string][]const rows = await db.execute<[number, string]>(sql`select ${users.id}, ${users.name} from ${users}`, 'arrays');Inherited from
Section titled “Inherited from”PgAsyncTransaction.execute
Call Signature
Section titled “Call Signature”execute<
TRow>(query,mode):PgAsyncRaw<TRow[]>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:323
Executes raw SQL query, responding with rows as objects
Types assume single statement is executed per query
Type Parameters
Section titled “Type Parameters”TRow extends Record<string, any> = Record<string, unknown>
Parameters
Section titled “Parameters”string | SQLWrapper<unknown>
SQL query to execute
"objects"
'objects'
Returns
Section titled “Returns”PgAsyncRaw<TRow[]>
Example
Section titled “Example”// { id: number; name: string }[]const rows = await db.execute<{ id: number; name: string }>(sql`select ${users.id}, ${users.name} from ${users}`, 'objects');Inherited from
Section titled “Inherited from”PgAsyncTransaction.execute
Call Signature
Section titled “Call Signature”execute<
TRow>(query,mode?):PgAsyncRaw<Results<Assume<TRow,Row>>>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:349
Executes raw SQL query, returning driver’s raw response
Row type argument defines the type of the response:
'unknown'(default) - any response of the drivernever- response of a statement that returns no rows- object shape - response with rows of given shape
Typed call assumes single statement is executed per query
Type Parameters
Section titled “Type Parameters”TRow extends Record<string, any> | "unknown" = "unknown"
Parameters
Section titled “Parameters”string | SQLWrapper<unknown>
SQL query to execute
"raw"
'raw' (default)
Returns
Section titled “Returns”PgAsyncRaw<Results<Assume<TRow, Row>>>
Example
Section titled “Example”// Any response of the driverconst response = await db.execute(sql`select * from ${users}`);
// Response of a statement that returns no rowsconst updated = await db.execute<never>(sql`update ${users} set ${users.name} = ${'John'}`);
// Response with rows of given shapeconst selected = await db.execute<{ id: number; name: string }>(sql`select ${users.id}, ${users.name} from ${users}`);Inherited from
Section titled “Inherited from”PgAsyncTransaction.execute
insert()
Section titled “insert()”insert<
TTable,TColumnList,TRequiredKeys>(table, …columns):PgInsertBuilder<TTable,PgwasmQueryResultHKT,TColumnListextends [] ?"all":TColumnList,false,PgAsyncInsertHKT>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:265
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
Type Parameters
Section titled “Type Parameters”TTable
Section titled “TTable”TTable extends PgTable<TableConfig>
TColumnList
Section titled “TColumnList”TColumnList extends (keyof { [Key in string as RequiredKeyOnly<Key, TTable[“_”][“columns”][Key]>]: TTable[“_”][“columns”][Key][“_”][“notNull”] extends true ? TTable[“_”][“columns”][Key][“_”][“data”] : (…)[(…)][“columns”][Key][“_”][“data”] | null } | keyof { [Key in string as OptionalKeyOnly<Key, TTable[“_”][“columns”][Key], true>]?: (…)[(…)][“columns”][Key][“_”][“notNull”] extends true ? (…)[(…)][“columns”][Key][“_”][“data”] : (…)[(…)][Key][“_”][“data”] | null })[] = []
TRequiredKeys
Section titled “TRequiredKeys”TRequiredKeys extends string = RequiredInsertKeys<TTable>
Parameters
Section titled “Parameters”TTable
The table to insert into.
columns
Section titled “columns”…TColumnList extends [] ? [] : IsNever<TRequiredKeys> extends true ? TColumnList & NoDuplicateColumns<TColumnList, never> : [TRequiredKeys] extends [TColumnList[number]] ? TColumnList & NoDuplicateColumns<TColumnList, never> : DrizzleTypeError<`Column selection is missing following required columns: ${JoinTuple<UnionToTuple<`"${Exclude<TRequiredKeys, (...)[(...)]>}"`, LastInUnion<`"${Exclude<(...), (...)>}"`>>, ", ">}`>[]
Returns
Section titled “Returns”PgInsertBuilder<TTable, PgwasmQueryResultHKT, TColumnList extends [] ? "all" : TColumnList, false, PgAsyncInsertHKT>
Example
Section titled “Example”// Insert one rowawait db.insert(cars).values({ brand: 'BMW' });
// Insert multiple rowsawait db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
// Insert only selected columnsawait db.insert(cars, 'brand', 'productionYear').values([{ brand: 'BMW', productionYear: 1995 }, { brand: 'Porsche', productionYear: 1989 }]);
// Insert with returning clauseconst insertedCar: Car[] = await db.insert(cars) .values({ brand: 'BMW' }) .returning();Inherited from
Section titled “Inherited from”PgAsyncTransaction.insert
refreshMaterializedView()
Section titled “refreshMaterializedView()”refreshMaterializedView<
TView>(view):PgAsyncRefreshMaterializedView<PgwasmQueryResultHKT>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:293
Type Parameters
Section titled “Type Parameters”TView extends PgMaterializedView<ViewConfig<ColumnsSelection>>
Parameters
Section titled “Parameters”TView
Returns
Section titled “Returns”PgAsyncRefreshMaterializedView<PgwasmQueryResultHKT>
Inherited from
Section titled “Inherited from”PgAsyncTransaction.refreshMaterializedView
rollback()
Section titled “rollback()”rollback():
never
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/session.d.ts:40
Returns
Section titled “Returns”never
Inherited from
Section titled “Inherited from”PgAsyncTransaction.rollback
select()
Section titled “select()”Call Signature
Section titled “Call Signature”select():
PgAsyncSelectBuilder<undefined>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:155
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
Returns
Section titled “Returns”PgAsyncSelectBuilder<undefined>
Example
Section titled “Example”// Select all columns and all rows from the 'cars' tableconst allCars: Car[] = await db.select().from(cars);
// Select specific columns and all rows from the 'cars' tableconst carsIdsAndBrands: { id: number; brand: string }[] = await db.select({ id: cars.id, brand: cars.brand}) .from(cars);Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:
// Select specific columns along with expression and all rows from the 'cars' tableconst carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({ id: cars.id, lowerBrand: sql<string>`lower(${cars.brand})`,}) .from(cars);Inherited from
Section titled “Inherited from”PgAsyncTransaction.select
Call Signature
Section titled “Call Signature”select<
TSelection>(fields):PgAsyncSelectBuilder<TSelection>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:156
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
Type Parameters
Section titled “Type Parameters”TSelection
Section titled “TSelection”TSelection extends SelectedFields
Parameters
Section titled “Parameters”fields
Section titled “fields”TSelection
The selection object.
Returns
Section titled “Returns”PgAsyncSelectBuilder<TSelection>
Example
Section titled “Example”// Select all columns and all rows from the 'cars' tableconst allCars: Car[] = await db.select().from(cars);
// Select specific columns and all rows from the 'cars' tableconst carsIdsAndBrands: { id: number; brand: string }[] = await db.select({ id: cars.id, brand: cars.brand}) .from(cars);Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:
// Select specific columns along with expression and all rows from the 'cars' tableconst carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({ id: cars.id, lowerBrand: sql<string>`lower(${cars.brand})`,}) .from(cars);Inherited from
Section titled “Inherited from”PgAsyncTransaction.select
selectDistinct()
Section titled “selectDistinct()”Call Signature
Section titled “Call Signature”selectDistinct():
PgAsyncSelectBuilder<undefined>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:181
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.
See docs: https://orm.drizzle.team/docs/select#distinct
Returns
Section titled “Returns”PgAsyncSelectBuilder<undefined>
Example
Section titled “Example”// Select all unique rows from the 'cars' tableawait db.selectDistinct() .from(cars) .orderBy(cars.id, cars.brand, cars.color);
// Select all unique brands from the 'cars' tableawait db.selectDistinct({ brand: cars.brand }) .from(cars) .orderBy(cars.brand);Inherited from
Section titled “Inherited from”PgAsyncTransaction.selectDistinct
Call Signature
Section titled “Call Signature”selectDistinct<
TSelection>(fields):PgAsyncSelectBuilder<TSelection>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:182
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.
See docs: https://orm.drizzle.team/docs/select#distinct
Type Parameters
Section titled “Type Parameters”TSelection
Section titled “TSelection”TSelection extends SelectedFields
Parameters
Section titled “Parameters”fields
Section titled “fields”TSelection
The selection object.
Returns
Section titled “Returns”PgAsyncSelectBuilder<TSelection>
Example
Section titled “Example”// Select all unique rows from the 'cars' tableawait db.selectDistinct() .from(cars) .orderBy(cars.id, cars.brand, cars.color);
// Select all unique brands from the 'cars' tableawait db.selectDistinct({ brand: cars.brand }) .from(cars) .orderBy(cars.brand);Inherited from
Section titled “Inherited from”PgAsyncTransaction.selectDistinct
selectDistinctOn()
Section titled “selectDistinctOn()”Call Signature
Section titled “Call Signature”selectDistinctOn(
on):PgAsyncSelectBuilder<undefined>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:208
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.
See docs: https://orm.drizzle.team/docs/select#distinct
Parameters
Section titled “Parameters”(SQLWrapper<unknown> | PgColumn<any, PgColumnBaseConfig<any>, { }>)[]
The expression defining uniqueness.
Returns
Section titled “Returns”PgAsyncSelectBuilder<undefined>
Example
Section titled “Example”// Select the first row for each unique brand from the 'cars' tableawait db.selectDistinctOn([cars.brand]) .from(cars) .orderBy(cars.brand);
// Selects the first occurrence of each unique car brand along with its color from the 'cars' tableawait db.selectDistinctOn([cars.brand], { brand: cars.brand, color: cars.color }) .from(cars) .orderBy(cars.brand, cars.color);Inherited from
Section titled “Inherited from”PgAsyncTransaction.selectDistinctOn
Call Signature
Section titled “Call Signature”selectDistinctOn<
TSelection>(on,fields):PgAsyncSelectBuilder<TSelection>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:209
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.
See docs: https://orm.drizzle.team/docs/select#distinct
Type Parameters
Section titled “Type Parameters”TSelection
Section titled “TSelection”TSelection extends SelectedFields
Parameters
Section titled “Parameters”(SQLWrapper<unknown> | PgColumn<any, PgColumnBaseConfig<any>, { }>)[]
The expression defining uniqueness.
fields
Section titled “fields”TSelection
The selection object.
Returns
Section titled “Returns”PgAsyncSelectBuilder<TSelection>
Example
Section titled “Example”// Select the first row for each unique brand from the 'cars' tableawait db.selectDistinctOn([cars.brand]) .from(cars) .orderBy(cars.brand);
// Selects the first occurrence of each unique car brand along with its color from the 'cars' tableawait db.selectDistinctOn([cars.brand], { brand: cars.brand, color: cars.color }) .from(cars) .orderBy(cars.brand, cars.color);Inherited from
Section titled “Inherited from”PgAsyncTransaction.selectDistinctOn
setTransaction()
Section titled “setTransaction()”setTransaction(
config):Promise<unknown>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/session.d.ts:41
Parameters
Section titled “Parameters”config
Section titled “config”PgTransactionConfig
Returns
Section titled “Returns”Promise<unknown>
Inherited from
Section titled “Inherited from”PgAsyncTransaction.setTransaction
transaction()
Section titled “transaction()”transaction<
T>(transaction):Promise<T>
Defined in: packages/pgwasm/src/drizzle/session.ts:120
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”transaction
Section titled “transaction”(tx) => Promise<T>
Returns
Section titled “Returns”Promise<T>
Overrides
Section titled “Overrides”PgAsyncTransaction.transaction
update()
Section titled “update()”update<
TTable>(table):PgUpdateBuilder<TTable,PgwasmQueryResultHKT,PgAsyncUpdateHKT>
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:237
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
Type Parameters
Section titled “Type Parameters”TTable
Section titled “TTable”TTable extends PgTable<TableConfig>
Parameters
Section titled “Parameters”TTable
The table to update.
Returns
Section titled “Returns”PgUpdateBuilder<TTable, PgwasmQueryResultHKT, PgAsyncUpdateHKT>
Example
Section titled “Example”// Update all rows in the 'cars' tableawait db.update(cars).set({ color: 'red' });
// Update rows with filters and conditionsawait db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
// Update with returning clauseconst updatedCar: Car[] = await db.update(cars) .set({ color: 'red' }) .where(eq(cars.id, 1)) .returning();Inherited from
Section titled “Inherited from”PgAsyncTransaction.update
with()
Section titled “with()”with(…
queries):object
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:100
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
Parameters
Section titled “Parameters”queries
Section titled “queries”…WithSubquery<string, Record<string, unknown>>[]
The CTEs to incorporate into the main query.
Returns
Section titled “Returns”object
delete
Section titled “delete”delete: <
TTable>(table) =>PgAsyncDeleteBase<TTable,PgwasmQueryResultHKT>
Type Parameters
Section titled “Type Parameters”TTable
Section titled “TTable”TTable extends PgTable<TableConfig>
Parameters
Section titled “Parameters”TTable
Returns
Section titled “Returns”PgAsyncDeleteBase<TTable, PgwasmQueryResultHKT>
insert
Section titled “insert”insert: <
TTable,TColumnList,TRequiredKeys>(table, …columns) =>PgInsertBuilder<TTable,PgwasmQueryResultHKT,TColumnListextends [] ?"all":TColumnList,false,PgAsyncInsertHKT>
Type Parameters
Section titled “Type Parameters”TTable
Section titled “TTable”TTable extends PgTable<TableConfig>
TColumnList
Section titled “TColumnList”TColumnList extends (keyof { [Key in string as RequiredKeyOnly<Key, TTable[“_”][“columns”][Key]>]: (…)[(…)][Key][“_”][“notNull”] extends true ? (…)[(…)][Key][“_”][“data”] : (…)[(…)][“_”][“data”] | null } | keyof { [Key in string as OptionalKeyOnly<Key, TTable[“_”][“columns”][Key], true>]?: (…)[(…)][“_”][“notNull”] extends true ? (…)[(…)][“_”][“data”] : (…)[(…)][“data”] | null })[] = []
TRequiredKeys
Section titled “TRequiredKeys”TRequiredKeys extends string = RequiredInsertKeys<TTable>
Parameters
Section titled “Parameters”TTable
columns
Section titled “columns”…TColumnList extends [] ? [] : IsNever<TRequiredKeys> extends true ? TColumnList & NoDuplicateColumns<TColumnList, never> : [TRequiredKeys] extends [TColumnList[number]] ? TColumnList & NoDuplicateColumns<TColumnList, never> : DrizzleTypeError<`Column selection is missing following required columns: ${JoinTuple<UnionToTuple<`"${(...)}"`, LastInUnion<(...)>>, ", ">}`>[]
Returns
Section titled “Returns”PgInsertBuilder<TTable, PgwasmQueryResultHKT, TColumnList extends [] ? "all" : TColumnList, false, PgAsyncInsertHKT>
select
Section titled “select”select: {():
PgAsyncSelectBuilder<undefined>; <TSelection>(fields):PgAsyncSelectBuilder<TSelection>; }
Call Signature
Section titled “Call Signature”():
PgAsyncSelectBuilder<undefined>
Returns
Section titled “Returns”PgAsyncSelectBuilder<undefined>
Call Signature
Section titled “Call Signature”<
TSelection>(fields):PgAsyncSelectBuilder<TSelection>
Type Parameters
Section titled “Type Parameters”TSelection
Section titled “TSelection”TSelection extends SelectedFields
Parameters
Section titled “Parameters”fields
Section titled “fields”TSelection
Returns
Section titled “Returns”PgAsyncSelectBuilder<TSelection>
selectDistinct
Section titled “selectDistinct”selectDistinct: {():
PgAsyncSelectBuilder<undefined>; <TSelection>(fields):PgAsyncSelectBuilder<TSelection>; }
Call Signature
Section titled “Call Signature”():
PgAsyncSelectBuilder<undefined>
Returns
Section titled “Returns”PgAsyncSelectBuilder<undefined>
Call Signature
Section titled “Call Signature”<
TSelection>(fields):PgAsyncSelectBuilder<TSelection>
Type Parameters
Section titled “Type Parameters”TSelection
Section titled “TSelection”TSelection extends SelectedFields
Parameters
Section titled “Parameters”fields
Section titled “fields”TSelection
Returns
Section titled “Returns”PgAsyncSelectBuilder<TSelection>
selectDistinctOn
Section titled “selectDistinctOn”selectDistinctOn: {(
on):PgAsyncSelectBuilder<undefined>; <TSelection>(on,fields):PgAsyncSelectBuilder<TSelection>; }
Call Signature
Section titled “Call Signature”(
on):PgAsyncSelectBuilder<undefined>
Parameters
Section titled “Parameters”(SQLWrapper<unknown> | PgColumn<any, PgColumnBaseConfig<any>, { }>)[]
Returns
Section titled “Returns”PgAsyncSelectBuilder<undefined>
Call Signature
Section titled “Call Signature”<
TSelection>(on,fields):PgAsyncSelectBuilder<TSelection>
Type Parameters
Section titled “Type Parameters”TSelection
Section titled “TSelection”TSelection extends SelectedFields
Parameters
Section titled “Parameters”(SQLWrapper<unknown> | PgColumn<any, PgColumnBaseConfig<any>, { }>)[]
fields
Section titled “fields”TSelection
Returns
Section titled “Returns”PgAsyncSelectBuilder<TSelection>
update
Section titled “update”update: <
TTable>(table) =>PgUpdateBuilder<TTable,PgwasmQueryResultHKT,PgAsyncUpdateHKT>
Type Parameters
Section titled “Type Parameters”TTable
Section titled “TTable”TTable extends PgTable<TableConfig>
Parameters
Section titled “Parameters”TTable
Returns
Section titled “Returns”PgUpdateBuilder<TTable, PgwasmQueryResultHKT, PgAsyncUpdateHKT>
Example
Section titled “Example”// Define a subquery 'sq' as a CTE using $withconst 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 itconst result = await db.with(sq).select().from(sq);Inherited from
Section titled “Inherited from”PgAsyncTransaction.with
[hasInstance]()
Section titled “[hasInstance]()”
static[hasInstance](value):boolean
Defined in: node_modules/.bun/drizzle-orm@1.0.0-rc.5+94d79d82a35f7da4/node_modules/drizzle-orm/pg-core/async/db.d.ts:33
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”PgAsyncTransaction.[hasInstance]