Package-level declarations

Types

Link copied to clipboard
data class And<T : Any>(left: Where<T>, right: Where<T>) : Where<T>

Equivalent to AND in SQL

Link copied to clipboard
data class CaseOrderBy<T : Any> : OrderBy<T>
Link copied to clipboard
data class CaseWhen<T : Any>

A SQL CASE … WHEN … END value expression. Build via case on a sealed parent property or KClass. Use as the LHS of a comparison operator (eq, gt, …) to produce a Where, or pass to OrderBy to drive ordering.

Link copied to clipboard
Link copied to clipboard
class CaseWhere<T : Any> : Where<T>

A SQL CASE WHEN <disc> = ? THEN <pred> [...] [ELSE <pred>] END expression usable as a top-level Where.

Link copied to clipboard
class CaseWhereBranch<T : Any, V : T>

Typed scope inside a whenIs<V> { ... } branch.

Link copied to clipboard
Link copied to clipboard

Builder for predicate-dispatch CASE/WHEN where the discriminator is an arbitrary field (enum, string, etc.). Branches are matched against the value of discriminatorPath for equality.

Link copied to clipboard
data class Entity(val entity_name: String, val entity_key: String, val added_at: Long, val updated_at: Long, val expires_at: Long?, val value_: String, val read_at: Long?, val write_at: Long?)

Row in the entity table. The trailing _ on value_ dodges Kotlin's value contextual keyword; the rest of the codebase references the property by that name.

Link copied to clipboard
Link copied to clipboard
data class Eq<T : Any, V>(builder: JsonPathBuilder<T>, value: V?) : Where<T>

Equivalent to = in SQL

Link copied to clipboard
data class GreaterThan<T : Any, V>(builder: JsonPathBuilder<T>, value: V?) : Where<T>

Equivalent to > in SQL

Link copied to clipboard
data class In<T : Any, V>(builder: JsonPathBuilder<T>, value: Collection<V>) : Where<T>

Equivalent to IN in SQL

Link copied to clipboard

Create a Path builder using one of the many reified methods.

Link copied to clipboard
class JsonPathNode<R, V>

Represents a path in a JSON object, using limited reflection and descriptors to build the path.

Link copied to clipboard
data class JsonPathOrderBy<T : Any> : OrderBy<T>
Link copied to clipboard
open class KeyValueStorage<T : Any>(entityName: String, entityQueries: EntityQueries, metadataQueries: MetadataQueries, scope: CoroutineScope, type: KType, serializer: SqkonSerializer = KotlinSqkonSerializer(), config: KeyValueStorage.Config = Config(), readDispatcher: CoroutineDispatcher, writeDispatcher: CoroutineDispatcher, transacter: SqkonTransacter)

Base interaction to the database.

Link copied to clipboard
data class LessThan<T : Any, V>(builder: JsonPathBuilder<T>, value: V?) : Where<T>

Equivalent to < in SQL

Link copied to clipboard
data class Like<T : Any>(builder: JsonPathBuilder<T>, value: String?) : Where<T>

Equivalent to LIKE in SQL

Link copied to clipboard
data class Metadata(val entity_name: String, val lastReadAt: Instant?, val lastWriteAt: Instant?)

Row in the metadata table. MetadataQueries handles the Long ↔ Instant conversion in its cursor mapper and upsert bind paths.

Link copied to clipboard
Link copied to clipboard
data class Not<T : Any>(where: Where<T>) : Where<T>

Equivalent to NOT ($where) in SQL

Link copied to clipboard
data class NotEq<T : Any, V>(builder: JsonPathBuilder<T>, value: V?) : Where<T>

Equivalent to != in SQL

Link copied to clipboard
data class NotIn<T : Any, V>(builder: JsonPathBuilder<T>, value: Collection<V>) : Where<T>
Link copied to clipboard
data class Or<T : Any>(left: Where<T>, right: Where<T>) : Where<T>

Equivalent to OR in SQL

Link copied to clipboard
sealed class OrderBy<T : Any>
Link copied to clipboard
Link copied to clipboard
data class ResultRow<T : Any>(val addedAt: Instant, val updatedAt: Instant, val expiresAt: Instant?, val readAt: Instant?, val writeAt: Instant, val value: T)
Link copied to clipboard
class Sqkon

Main entry point for Sqkon.

Link copied to clipboard
sealed interface SqkonDatabaseType

Where the database lives. Replaces the eygraber AndroidxSqliteDatabaseType in the public API.

Link copied to clipboard

Read/write coroutine dispatcher bundle for Sqkon.

Link copied to clipboard
class SqkonDriverConfig(val journalMode: SqkonJournalMode = SqkonJournalMode.WAL, val sync: SqkonSync = SqkonSync.NORMAL, val readerConnections: Int = 4, val statementCacheSize: Int = 25, val busyTimeoutMillis: Long)

Tunables for the native androidx.sqlite-backed driver. Defaults match the pre-3.0 behavior (WAL, NORMAL, 4 reader connections), with two intentional differences: every connection now opens with SQLITE_OPEN_FULLMUTEX on JVM too (previously implicit only on Android), and a non-zero busy_timeout (3000 ms) is applied for WAL-contention hardening (was SQLite's fail-immediately default of 0).

Link copied to clipboard

SQLite journal mode. WAL is the default and required for the reader/writer pool.

Link copied to clipboard

Thrown out of transactionWithResult when SqkonTransactionScope.rollback is called: a result-returning transaction has no value to hand back on rollback, so it aborts by throwing.

Link copied to clipboard

SQLite synchronous setting. NORMAL is safe + fast under WAL.

Link copied to clipboard
sealed interface SqkonTransactionScope

Sqkon-owned transaction scope, the receiver of transaction / transactionWithResult.

Link copied to clipboard
data class SqlQuery(val from: String? = null, val where: String? = null, val parameters: Int = 0, val bindArgs: AutoIncrementSqlPreparedStatement.() -> Unit = {}, val orderBy: String? = null)
Link copied to clipboard
data class SqlValueFragment(val sql: String, val parameters: Int, val bindArgs: AutoIncrementSqlPreparedStatement.() -> Unit)
Link copied to clipboard
abstract class Where<T : Any>

Functions

Link copied to clipboard
infix fun <T : Any> Where<T>.and(other: Where<T>): Where<T>

Equivalent to AND in SQL

Link copied to clipboard
inline fun <R : Any, V> KProperty1<R, V>.builder(serialName: String? = null, block: JsonPathNode<R, V>.() -> Unit = {}): JsonPathBuilder<R>
Link copied to clipboard
inline fun <R : Any, V> KProperty1<R, Collection<V>>.builderFromList(block: JsonPathNode<out R, V>.() -> Unit = {}): JsonPathBuilder<R>
Link copied to clipboard
inline fun <R : Any> KClass<R>.case(block: CaseWhenBuilder<R>.() -> Unit): CaseWhen<R>

CASE WHEN expression rooted at the entity itself when it is a sealed type (e.g. KeyValueStorage<BaseSealed>). Discriminator path is $[0], payload is under $[1].

inline fun <T : Any, S : Any> KProperty1<T, S>.case(block: CaseWhenBuilder<T>.() -> Unit): CaseWhen<T>

CASE WHEN expression rooted at a sealed parent property (e.g. MyEntity::status). The variant discriminator is read from <parentPath>[0]; payload paths sit under [1].

Link copied to clipboard
inline fun <T : Any, K> caseWhere(discriminator: KProperty1<T, K>, block: CaseWhereOnBuilder<T, K>.() -> Unit): Where<T>

Predicate-dispatch CASE/WHEN where the discriminator is an arbitrary field (enum, string, etc.). Compile safety: the whenEq value must match the discriminator field's type.

Link copied to clipboard
inline fun <R : Any> KClass<R>.caseWhere(block: CaseWhereBuilder<R>.() -> Unit): Where<R>

Predicate-dispatch CASE/WHEN rooted at the entity itself when it is a sealed type. Discriminator at $[0], payload under $[1].

Link copied to clipboard
infix fun <T : Any, V> CaseWhen<T>.eq(value: V?): Where<T>

infix fun <T : Any, V> JsonPathBuilder<T>.eq(value: V?): Eq<T, V>

Equivalent to = in SQL

infix inline fun <T : Any, V, VALUE> KProperty1<T, V>.eq(value: VALUE?): Eq<T, VALUE>

Equivalent to = in SQL.

Link copied to clipboard
infix fun <T : Any, V> CaseWhen<T>.gt(value: V?): Where<T>

infix fun <T : Any, V> JsonPathBuilder<T>.gt(value: V?): GreaterThan<T, V>
infix inline fun <T : Any, V, VALUE> KProperty1<T, V>.gt(value: VALUE?): GreaterThan<T, VALUE>

Equivalent to > in SQL

Link copied to clipboard
infix fun <T : Any, V> JsonPathBuilder<T>.inList(value: Collection<V>): In<T, V>
infix inline fun <T : Any, V, C> KProperty1<T, V>.inList(value: Collection<C>): In<T, C>

Equivalent to IN in SQL

Link copied to clipboard
fun <T : Any> CaseWhen<T>.isNotNull(): Where<T>
Link copied to clipboard
fun <T : Any> CaseWhen<T>.isNull(): Where<T>
Link copied to clipboard
inline fun <T : Any> keyValueStorage(entityName: String, entityQueries: EntityQueries, metadataQueries: MetadataQueries, scope: CoroutineScope, serializer: SqkonSerializer = KotlinSqkonSerializer(), config: KeyValueStorage.Config = KeyValueStorage.Config(), readDispatcher: CoroutineDispatcher = defaultSqkonDispatchers.read, writeDispatcher: CoroutineDispatcher = defaultSqkonDispatchers.write, transactor: SqkonTransacter = entityQueries): KeyValueStorage<T>
Link copied to clipboard
infix fun <T : Any> JsonPathBuilder<T>.like(value: String?): Like<T>
infix inline fun <T : Any, V> KProperty1<T, V>.like(value: String?): Like<T>

Equivalent to LIKE in SQL

Link copied to clipboard
infix fun <T : Any, V> CaseWhen<T>.lt(value: V?): Where<T>

infix fun <T : Any, V> JsonPathBuilder<T>.lt(value: V?): LessThan<T, V>
infix inline fun <T : Any, V, VALUE> KProperty1<T, V>.lt(value: VALUE?): LessThan<T, VALUE>

Equivalent to < in SQL

Link copied to clipboard
infix fun <T : Any, V> CaseWhen<T>.neq(value: V?): Where<T>

infix fun <T : Any, V> JsonPathBuilder<T>.neq(value: V?): NotEq<T, V>
infix inline fun <T : Any, V, VALUE> KProperty1<T, V>.neq(value: VALUE?): NotEq<T, VALUE>

Equivalent to != in SQL

Link copied to clipboard
fun <T : Any> not(where: Where<T>): Not<T>

Equivalent to NOT ($where) in SQL

Link copied to clipboard
infix fun <T : Any, V> JsonPathBuilder<T>.notInList(value: Collection<V>): NotIn<T, V>
inline fun <T : Any, V, C> KProperty1<T, V>.notInList(value: Collection<C>): NotIn<T, C>

Equivalent to NOT IN in SQL

Link copied to clipboard
infix fun <T : Any> Where<T>.or(other: Where<T>): Where<T>

Equivalent to OR in SQL

Link copied to clipboard
fun <T : Any> OrderBy(case: CaseWhen<T>, direction: OrderDirection? = null): OrderBy<T>
fun <T : Any> OrderBy(builder: JsonPathBuilder<T>, direction: OrderDirection? = null): OrderBy<T>
inline fun <T : Any, V> OrderBy(property: KProperty1<T, V>, direction: OrderDirection? = null): OrderBy<T>
Link copied to clipboard
fun Sqkon(context: Context, scope: CoroutineScope, json: Json = SqkonJson { }, inMemory: Boolean = false, config: KeyValueStorage.Config = KeyValueStorage.Config()): Sqkon

fun Sqkon(context: Context, scope: CoroutineScope, json: Json = SqkonJson { }, dbFileName: String? = "sqkon.db", config: KeyValueStorage.Config = KeyValueStorage.Config(), driverConfig: SqkonDriverConfig = SqkonDriverConfig(), dispatchers: SqkonDispatchers = defaultSqkonDispatchers): Sqkon

Main entry point for Sqkon on Android.

fun Sqkon(scope: CoroutineScope, json: Json = SqkonJson { }, type: SqkonDatabaseType = SqkonDatabaseType.Memory, config: KeyValueStorage.Config = KeyValueStorage.Config(), driverConfig: SqkonDriverConfig = SqkonDriverConfig(), dispatchers: SqkonDispatchers = defaultSqkonDispatchers): Sqkon
Link copied to clipboard
@JvmName(name = "thenList")
inline fun <R : Any, V, V2> KProperty1<R, V>.then(property: KProperty1<out V, Collection<V2>>, block: JsonPathNode<out V, V2>.() -> Unit = {}): JsonPathBuilder<R>
inline fun <R : Any, V, V1 : V, V2> KProperty1<R, V>.then(property: KProperty1<V1, V2>, fromSerialName: String? = null, thenSerialName: String? = null, block: JsonPathNode<V1, V2>.() -> Unit = {}): JsonPathBuilder<R>
@JvmName(name = "thenFromList")
inline fun <R : Any, V, V1 : V, V2> KProperty1<R, Collection<V>>.then(property: KProperty1<V1, V2>, fromSerialName: String? = null, thenSerialName: String? = null, block: JsonPathNode<V1, V2>.() -> Unit = {}): JsonPathBuilder<R>
Link copied to clipboard
Link copied to clipboard

Run body in a database transaction. Calling SqkonTransactionScope.rollback discards the work and returns silently.

Link copied to clipboard

Run body in a database transaction and return its value. Calling SqkonTransactionScope.rollback aborts the transaction and throws SqkonRollbackException (there is no value to return).

Link copied to clipboard
inline fun <T : Any, V : T, X> CaseWhereBranch<T, V>.with(prop: KProperty1<V, X>): JsonPathBuilder<T>

Reach into a property of the variant V from inside a whenIs<V> { ... } scope, producing a JsonPathBuilder rooted at the variant payload (e.g. $[1].dueAt for a sealed-root entity).

inline fun <T : Any, V : T, X> CaseWhereBranch<T, V>.with(prop: KProperty1<V, X>, noinline block: JsonPathNode<T, X>.() -> Unit): JsonPathBuilder<T>

Nested-path variant — chains then onto the variant property path.

inline fun <R : Any, R1 : R, V> KClass<R>.with(property: KProperty1<R1, V>, serialName: String? = null, block: JsonPathNode<R, V>.() -> Unit = {}): JsonPathBuilder<R>
Link copied to clipboard
inline fun <R : Any, V> KClass<R>.withList(property: KProperty1<R, Collection<V>>, serialName: String? = null, block: JsonPathNode<R, V>.() -> Unit = {}): JsonPathBuilder<R>