lazy Details
Property delegate that lazy-loads child (detail) records on first access.
When omitted, propertyName is resolved automatically by scanning the child type (T) for exactly one field whose type matches the declaring parent class. When the child type has multiple foreign keys pointing to the same parent type, supply the Kotlin property name on the child class (not the database column name) that should be used for the lookup — i.e. the name of the var/val in the child source, even if it has been remapped with @DbField(name = "…") to a different column. The value must be a single field identifier, not a dotted traversal path.
class Order : AutoTable() {
var items: List<OrderItem> by lazyDetails()
}
class User : AutoTable() {
// AuditEntry has both `createdBy: User` and `modifiedBy: User`,
// so we disambiguate by the child-side Kotlin property name:
var createdEntries: List<AuditEntry> by lazyDetails("createdBy")
var modifiedEntries: List<AuditEntry> by lazyDetails("modifiedBy")
}Type-safe variant of lazyDetails that accepts an annotation-processor-generated reference path (e.g. Paths.AuditEntry_.modifiedBy) instead of a magic string. The compiler guarantees that the referenced property actually exists on the child type, so typos and renames are caught at build time instead of first query execution.
The runtime value passed to the underlying lookup is identical to the plain-string form — lazyDetails(Paths.AuditEntry_.modifiedBy) resolves to the same field lookup as lazyDetails("modifiedBy"). Only direct reference fields on the child class are accepted; chained paths (e.g. Paths.AuditEntry_.modifiedBy.somethingElse) produce a onl.ycode.stormify.biglist.ScalarPath which the overload resolution rejects at compile time, and any lingering trailing . from the path builder is stripped before the lookup runs.
class User : AutoTable() {
@DbField(primaryKey = true)
var id: Int? = null
var createdEntries: List<AuditEntry> by lazyDetails(Paths.AuditEntry_.createdBy)
var modifiedEntries: List<AuditEntry> by lazyDetails(Paths.AuditEntry_.modifiedBy)
}