package com.wyattjmiller.data import org.ktorm.entity.Entity import org.ktorm.schema.* import java.time.LocalDateTime object DbRecipeTable : Table("recipe") { val id = int("id").primaryKey().bindTo { it.id } val name = varchar("name").bindTo { it.name } val desc = varchar("description").bindTo { it.desc } val ingredients = varchar("ingredients").bindTo { it.ingredients } val author = int("author_id").references(DbAuthorTable) { it.author } val createdTimestamp = datetime("created_timestamp").bindTo { it.createdTimestamp } } object DbAuthorTable : Table("author") { val id = int("id").primaryKey().bindTo { it.id } val authorName = varchar("author_name").bindTo { it.authorName } val user = int("user_id").references(DbUserTable) { it.user } val createdTimestamp = datetime("created_timestamp").bindTo { it.createdTimestamp } } interface Recipes : Entity { companion object : Entity.Factory() val id: Int? val name: String val desc: String val ingredients: String val author: Authors val createdTimestamp: LocalDateTime } interface Authors : Entity { companion object : Entity.Factory() val id: Int val authorName: String val user: Users? val createdTimestamp: LocalDateTime }