English | 简体中文

api-docs / me.liuwj.ktorm.schema / Table / references

references

inline fun <C : Any, R : Entity<R>> BaseTable.ColumnRegistration<C, E>.references(
    referenceTable: Table<R>,
    selector: (E) -> R?
): BaseTable.ColumnRegistration<C, E>
(source code)

Bind the column to a reference table, equivalent to a foreign key in relational databases.
Entity sequence APIs would automatically left join all references (recursively) by default.

Parameters

referenceTable - the reference table, will be copied by calling its aliased function with
an alias like _refN.

selector - a lambda in which we should return the property used to hold the referenced entities.
For example: val departmentId by int("department_id").references(Departments) { it.department }.

Return
this column registration.

See Also

me.liuwj.ktorm.entity.sequenceOf

createEntity