Created
February 11, 2019 18:09
-
-
Save pjagielski/67c3ff61933321060bd2e37adc5820b7 to your computer and use it in GitHub Desktop.
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
override fun create(article: Article): Article { | |
val savedArticle = ArticleTable.insert { it.from(article) } | |
.getOrThrow(ArticleTable.id) | |
.let { article.copy(id = it) } | |
savedArticle.tags.forEach { tag -> | |
ArticleTagTable.insert { | |
it[ArticleTagTable.tagId] = tag.id | |
it[ArticleTagTable.articleId] = savedArticle.id | |
} | |
} | |
return savedArticle | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment