upsert

inline suspend fun <T : Any> upsert(values: List<T>, request: UpsertRequestBuilder.() -> Unit = {}): PostgrestResult(source)

Perform an UPSERT on the table or view. Depending on the column(s) passed to UpsertRequestBuilder.onConflict, upsert allows you to perform the equivalent of `insert if a row with the corresponding onConflict columns doesn't exist, or if it does exist, perform an alternative action depending on UpsertRequestBuilder.ignoreDuplicates.

By default, upserted rows are not returned. To return it, call [PostgrestRequestBuilder.select].

Parameters

values

The values to insert, will automatically get serialized into json.

request

Additional configurations for the request including filters

Throws

or one of its subclasses if receiving an error response

HttpRequestTimeoutException

if the request timed out

on network related issues


inline suspend fun <T : Any> upsert(value: T, request: UpsertRequestBuilder.() -> Unit = {}): PostgrestResult(source)

Perform an UPSERT on the table or view. Depending on the column(s) passed to UpsertRequestBuilder.onConflict, upsert allows you to perform the equivalent of `insert if a row with the corresponding onConflict columns doesn't exist, or if it does exist, perform an alternative action depending on UpsertRequestBuilder.ignoreDuplicates.

By default, upserted rows are not returned. To return it, call [PostgrestRequestBuilder.select].

Parameters

value

The value to insert, will automatically get serialized into json.

request

Additional filtering to apply to the query

Throws

or one of its subclasses if receiving an error response

HttpRequestTimeoutException

if the request timed out

on network related issues