Add items that are related to the deleted meta (#562)

This commit is contained in:
Mitchell Syer
2023-05-27 14:09:47 -04:00
committed by GitHub
parent 1e82c879bf
commit 241abc3956
3 changed files with 29 additions and 12 deletions

View File

@@ -156,26 +156,31 @@ class ChapterMutation {
)
data class DeleteChapterMetaPayload(
val clientMutationId: String?,
val meta: ChapterMetaType?
val meta: ChapterMetaType?,
val chapter: ChapterType
)
fun deleteChapterMeta(
input: DeleteChapterMetaInput
): DeleteChapterMetaPayload {
val (clientMutationId, chapterId, key) = input
val meta = transaction {
val (meta, chapter) = transaction {
val meta = ChapterMetaTable.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
.firstOrNull()
ChapterMetaTable.deleteWhere { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) }
val chapter= transaction {
ChapterType(ChapterTable.select { ChapterTable.id eq chapterId }.first())
}
if (meta != null) {
ChapterMetaType(meta)
} else {
null
}
} to chapter
}
return DeleteChapterMetaPayload(clientMutationId, meta)
return DeleteChapterMetaPayload(clientMutationId, meta, chapter)
}
}