MCPcopy Create free account
hub / github.com/WebDevSimplified/course-platform / deleteLesson

Function deleteLesson

src/features/lessons/db/lessons.ts:80–107  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

78}
79
80export async function deleteLesson(id: string) {
81 const [deletedLesson, courseId] = await db.transaction(async trx => {
82 const [deletedLesson] = await trx
83 .delete(LessonTable)
84 .where(eq(LessonTable.id, id))
85 .returning()
86 if (deletedLesson == null) {
87 trx.rollback()
88 throw new Error("Failed to delete lesson")
89 }
90
91 const section = await trx.query.CourseSectionTable.findFirst({
92 columns: { courseId: true },
93 where: ({ id }, { eq }) => eq(id, deletedLesson.sectionId),
94 })
95
96 if (section == null) return trx.rollback()
97
98 return [deletedLesson, section.courseId]
99 })
100
101 revalidateLessonCache({
102 id: deletedLesson.id,
103 courseId,
104 })
105
106 return deletedLesson
107}
108
109export async function updateLessonOrders(lessonIds: string[]) {
110 const [lessons, courseId] = await db.transaction(async trx => {

Callers

nothing calls this directly

Calls 1

revalidateLessonCacheFunction · 0.90

Tested by

no test coverage detected