← Back to Stormify Documentation

db

class db<T>(defaultValue: T) : ReadWriteProperty<Any?, T>

Property delegate that triggers auto-hydration from the database on first access. Use with AutoTable entities: properties delegated to db will lazily load the entity's data when read or written for the first time.

class User : AutoTable() {
var name: String by db("")
}

Constructors

Link copied to clipboard
constructor(defaultValue: T)

Functions

Link copied to clipboard
open operator override fun getValue(thisRef: Any?, property: KProperty<*>): T

Delegate read: on a library-constructed shadow reference, triggers AutoTable.hydrate to load the row before returning the in-memory value. On a user-constructed entity (or one already hydrated), returns the in-memory value directly with no DB access.

Link copied to clipboard
open operator override fun setValue(thisRef: Any?, property: KProperty<*>, value: T)

Delegate write: on a library-constructed shadow reference, runs AutoTable.hydrate first so that all other fields keep their database values, then stores the new value (so the just-written field wins). On a user-constructed entity (or one already hydrated), stores the value directly with no DB access.