DeleteQueryBuilder

Defines the public API for building SQL DELETE queries.

Functions

Link copied to clipboard
abstract fun asStep(): StepBuilderMethods

Converts this builder to a StepBuilder that enables lazy execution within a transaction. Returns a wrapper with terminal methods that create TransactionStep instead of executing the query.

Link copied to clipboard
abstract fun asStream(fetchSize: Int = 100): StreamingTerminalMethods

Switches the builder to streaming mode, optimal for large datasets. Requires using streaming-specific terminal methods like forEachRow(). REQUIRES ACTIVE TRANSACTION. This method must be called inside a DataAccess.transaction { ... } block. Otherwise, PostgreSQL will ignore fetchSize and load everything into RAM.

Link copied to clipboard
abstract fun async(scope: CoroutineScope, ioDispatcher: CoroutineDispatcher = Dispatchers.IO): AsyncTerminalMethods

Switches the builder to asynchronous mode. Requires providing a CoroutineScope in which operations will be launched.

Link copied to clipboard
abstract fun copy(): DeleteQueryBuilder

Creates and returns a deep copy of this builder. Returns the concrete builder type (e.g., SelectQueryBuilder), maintaining API fluency.

Link copied to clipboard
abstract fun execute(params: Map<String, Any?> = emptyMap()): DataResult<Int>

Executes the query and returns the number of rows that were updated

Link copied to clipboard
Link copied to clipboard

Marks the WITH clause as recursive.

Link copied to clipboard
abstract fun returning(vararg columns: String): DeleteQueryBuilder

Adds a RETURNING clause. Requires using methods like .toList(), .toSingle(), etc. instead of .execute().

Link copied to clipboard
abstract fun <T> toColumn(targetType: KType, params: Map<String, Any?> = emptyMap()): DataResult<List<T>>

Fetches a list of values from the first column of all rows. Nullability of elements is determined by the KType: use toColumn<Int>() for non-null or toColumn<Int?>() for nullable elements.

Link copied to clipboard
inline fun <T> TerminalReturningMethods.toColumn(vararg params: Pair<String, Any?>): DataResult<List<T>>
inline fun <T> TerminalReturningMethods.toColumn(params: Map<String, Any?> = emptyMap()): DataResult<List<T>>
Link copied to clipboard
abstract fun <T> toField(targetType: KType, params: Map<String, Any?> = emptyMap()): DataResult<T>

Fetches a single value from the first column of the first row. Nullability is determined by the KType: use toField<Int>() for non-null or toField<Int?>() for nullable results.

Link copied to clipboard
inline fun <T> TerminalReturningMethods.toField(vararg params: Pair<String, Any?>): DataResult<T>
inline fun <T> TerminalReturningMethods.toField(params: Map<String, Any?> = emptyMap()): DataResult<T>
Link copied to clipboard
abstract fun <T> toFieldStrict(targetType: KType, params: Map<String, Any?> = emptyMap()): DataResult<T>

Fetches a single value from the first column of the first row. Always returns Failure if no rows are found, regardless of nullability. Nullability only controls whether a null value in the column is allowed: use toFieldStrict<Int>() to fail on null, or toFieldStrict<Int?>() to allow null values.

Link copied to clipboard
inline fun <T> TerminalReturningMethods.toFieldStrict(params: Map<String, Any?> = emptyMap()): DataResult<T>
Link copied to clipboard
abstract fun toList(params: Map<String, Any?> = emptyMap()): DataResult<List<Map<String, Any?>>>

Fetches a list of rows as List>.

Link copied to clipboard
Link copied to clipboard
abstract fun <T> toListOf(kType: KType, params: Map<String, Any?> = emptyMap()): DataResult<List<T>>

Maps results to a list of objects of the given type. Requires that column names/aliases in SQL (in snake_case convention) match property names in the target class (in camelCase convention) or have a @MapKey annotation with the stored column name.

Link copied to clipboard
inline fun <T : Any> TerminalReturningMethods.toListOf(vararg params: Pair<String, Any?>): DataResult<List<T>>

inline fun <T : Any> TerminalReturningMethods.toListOf(params: Map<String, Any?> = emptyMap()): DataResult<List<T>>

Convenient inline extension function for toListOf. Uses reified to automatically infer the target type.

Link copied to clipboard
abstract fun toSingle(params: Map<String, Any?> = emptyMap()): DataResult<Map<String, Any?>?>

Fetches a single row as Map?. Returns Success(null) if no rows.

Link copied to clipboard
Link copied to clipboard
abstract fun <T> toSingleOf(kType: KType, params: Map<String, Any?> = emptyMap()): DataResult<T>

Maps the result to a single object of the given type. Works on the same mapping principle as toListOf. Nullability is determined by the KType: use toSingleOf<User>() for non-null or toSingleOf<User?>() for nullable results.

Link copied to clipboard
inline fun <T> TerminalReturningMethods.toSingleOf(vararg params: Pair<String, Any?>): DataResult<T>

inline fun <T> TerminalReturningMethods.toSingleOf(params: Map<String, Any?> = emptyMap()): DataResult<T>

Convenient inline extension function for toSingleOf. Uses reified to automatically infer the target type.

Link copied to clipboard
abstract fun toSingleStrict(params: Map<String, Any?> = emptyMap()): DataResult<Map<String, Any?>>

Fetches a single row as Map. Returns Failure if no rows.

Link copied to clipboard
Link copied to clipboard
abstract fun toSql(): String

Returns the SQL string without executing the query.

Link copied to clipboard
abstract fun using(tables: String): DeleteQueryBuilder

Adds a USING clause.

Link copied to clipboard
abstract fun where(condition: String): DeleteQueryBuilder

Defines the WHERE condition. The clause is mandatory for security reasons.

Link copied to clipboard
abstract fun with(name: String, query: String): DeleteQueryBuilder

Adds a Common Table Expression (CTE) to the query.