Skip to content

Instantly share code, notes, and snippets.

@pjagielski
Created February 11, 2019 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjagielski/67c3ff61933321060bd2e37adc5820b7 to your computer and use it in GitHub Desktop.
Save pjagielski/67c3ff61933321060bd2e37adc5820b7 to your computer and use it in GitHub Desktop.
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