Created
October 4, 2017 17:45
-
-
Save Wonicon/814dfa5a664231a3fd632117dd5ff14f to your computer and use it in GitHub Desktop.
My Table Definition for Exposed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object <table-plural> : ... { | |
val <column> = ... | |
val <column> = reference(..., <another-table>) | |
... | |
} | |
=> | |
class User(id: EntityID<Int>) : IntEntity(id) { | |
companion object : IntEntityClass<User>(Users) | |
var name by Users.name | |
var city by City referencedOn Users.city | |
var age by Users.age | |
} | |
class <table-single> : IntEntity(id) { | |
companion object : IntEntityClass<table-singal)(<table-plural>) | |
var <column> by <table-plural>.<column> | |
var <foreign-key> by <another-table-single> referencedOn <table-plural>.<foreign-key> | |
val <back-link> by <another-table-single> referredOn <table-plural>.<foreign-key> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Categories : IntIdTable() { | |
val name = varchar("name", 50) | |
val parent = reference("parent", Categories) | |
} | |
object Subjects : IntIdTable() { | |
val name = varchar("name", 256) | |
val description = text("description") | |
val coverURL = varchar("coverURL", 256) | |
val category = reference("category", Categories) | |
} | |
object Posts : IntIdTable() { | |
val title = varchar("title", 256) | |
val content = text("content") | |
val subject = reference("subject", Subjects) | |
} | |
object Journals : IntIdTable() { | |
val date = date("date") | |
val content = text("content") | |
val subject = reference("subject", Subjects) | |
} | |
object Tasks : IntIdTable() { | |
val createDate = date("createDate") | |
val title = varchar("title", 256) | |
val content = text("content") | |
val subject = reference("subject", Subjects) | |
} | |
object TaskItems : IntIdTable() { | |
val finishDate = date("finishDate") | |
val content = text("content") | |
val task = reference("task", Tasks) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment