43 lines
1.3 KiB
Kotlin
43 lines
1.3 KiB
Kotlin
package com.wyattjmiller.data
|
|
|
|
import org.ktorm.entity.Entity
|
|
import org.ktorm.schema.*
|
|
import java.time.LocalDateTime
|
|
|
|
object DbRecipeTable : Table<Recipes>("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<Authors>("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<Recipes> {
|
|
companion object : Entity.Factory<Recipes>()
|
|
|
|
val id: Int?
|
|
val name: String
|
|
val desc: String
|
|
val ingredients: String
|
|
val author: Authors
|
|
val createdTimestamp: LocalDateTime
|
|
}
|
|
|
|
interface Authors : Entity<Authors> {
|
|
companion object : Entity.Factory<Authors>()
|
|
|
|
val id: Int
|
|
val authorName: String
|
|
val user: Users?
|
|
val createdTimestamp: LocalDateTime
|
|
}
|
|
|