maarten ha
03/19/2025, 9:28 AMLuis Arcos
03/19/2025, 10:42 AMsimon.vergauwen
03/19/2025, 10:45 AMmaarten ha
03/19/2025, 11:06 AMobject AuthorsTable : Table("authors") {
val id = integer("id").autoIncrement()
val firstName = varchar("firstName", 128)
val lastName = varchar("lastName", 128)
override val primaryKey = PrimaryKey(id)
}
fun ResultRow.toAuthorsDTO(): AuthorsDTO {
return this.let {
AuthorsDTO(
id = it[AuthorsTable.id],
firstName = it[AuthorsTable.firstName],
lastName = it[AuthorsTable.lastName],
)
}
}
object BooksTable : Table("books") {
val id = integer("id").autoIncrement()
val title = varchar("title", 128)
val publishedDate = date("published_date")
val series = reference("series", SeriesTable.id)
val publishers = reference("publishers", PublishersTable.id)
override val primaryKey = PrimaryKey(id)
}
fun ResultRow.toBooksDTO(): BooksDTO {
return this.let {
BooksDTO(
id = it[BooksTable.id],
title = it[BooksTable.title],
publishedDate = it[BooksTable.publishedDate],
authors = TODO(),
series = TODO(),
publishers = TODO()
// authors = it[BooksTable.authors],
// series = it[BooksTable.series],
// publishers = it[BooksTable.publishers],
)
}
}
object BooksAuthorsTable: Table("books_authors") {
val id = integer("id").autoIncrement()
val bookId = reference("book_id", BooksTable.id, onDelete = ReferenceOption.CASCADE)
val authorId = reference("author_id", AuthorsTable.id, onDelete = ReferenceOption.CASCADE)
override val primaryKey: PrimaryKey = PrimaryKey(id)
}
Luis Arcos
03/19/2025, 11:39 AMmaarten ha
03/19/2025, 1:26 PM