generated from alphane/template
using a kebab options for deck tree node
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import db from "@/db/db-client"
|
||||
import { FlashcardDeck } from "@/models"
|
||||
import BaseService from "@/services/base-service"
|
||||
|
||||
@@ -7,7 +8,13 @@ export class DestroyService extends BaseService {
|
||||
}
|
||||
|
||||
async perform(): Promise<void> {
|
||||
return this.flashcardDeck.destroy()
|
||||
await db.transaction(async (transaction) => {
|
||||
await FlashcardDeck.update(
|
||||
{ parentDeckId: null },
|
||||
{ where: { parentDeckId: this.flashcardDeck.id }, transaction }
|
||||
)
|
||||
await this.flashcardDeck.destroy({ transaction })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user