Songs & dates

This commit is contained in:
2025-10-02 08:59:05 -04:00
parent dfe3517ac6
commit 27fcedfcd5
6 changed files with 207 additions and 13 deletions

View File

@@ -11,7 +11,7 @@ export default defineEventHandler(async (event) => {
}
const body = await readBody(event)
const { slug, title, date, bible_references, personal_appliance, pastors_challenge } = body
const { slug, title, date, dates, bible_references, personal_appliance, pastors_challenge, worship_songs } = body
if (!slug || !title || !date || !bible_references || !personal_appliance || !pastors_challenge) {
throw createError({
@@ -25,9 +25,11 @@ export default defineEventHandler(async (event) => {
slug,
title,
date,
dates,
bible_references,
personal_appliance,
pastors_challenge
pastors_challenge,
worship_songs
})
return {

View File

@@ -20,7 +20,7 @@ export default defineEventHandler(async (event) => {
}
const body = await readBody(event)
const { slug, title, date, bible_references, personal_appliance, pastors_challenge } = body
const { slug, title, date, dates, bible_references, personal_appliance, pastors_challenge, worship_songs } = body
if (!slug || !title || !date || !bible_references || !personal_appliance || !pastors_challenge) {
throw createError({
@@ -33,10 +33,10 @@ export default defineEventHandler(async (event) => {
const db = getDatabase()
const result = db.prepare(`
UPDATE sermons
SET slug = ?, title = ?, date = ?, bible_references = ?,
personal_appliance = ?, pastors_challenge = ?
SET slug = ?, title = ?, date = ?, dates = ?, bible_references = ?,
personal_appliance = ?, pastors_challenge = ?, worship_songs = ?
WHERE id = ?
`).run(slug, title, date, bible_references, personal_appliance, pastors_challenge, parseInt(id))
`).run(slug, title, date, dates || null, bible_references, personal_appliance, pastors_challenge, worship_songs || null, parseInt(id))
if (result.changes === 0) {
throw createError({

View File

@@ -8,9 +8,11 @@ export interface Sermon {
slug: string
title: string
date: string
dates?: string
bible_references: string
personal_appliance: string
pastors_challenge: string
worship_songs?: string
created_at?: string
}
@@ -32,9 +34,11 @@ export function getDatabase() {
slug TEXT UNIQUE NOT NULL,
title TEXT NOT NULL,
date TEXT NOT NULL,
dates TEXT,
bible_references TEXT NOT NULL,
personal_appliance TEXT NOT NULL,
pastors_challenge TEXT NOT NULL,
worship_songs TEXT,
archived INTEGER DEFAULT 0,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
)
@@ -87,16 +91,18 @@ export function getSermonBySlug(slug: string) {
export function createSermon(sermon: Sermon) {
const db = getDatabase()
const stmt = db.prepare(`
INSERT INTO sermons (slug, title, date, bible_references, personal_appliance, pastors_challenge)
VALUES (?, ?, ?, ?, ?, ?)
INSERT INTO sermons (slug, title, date, dates, bible_references, personal_appliance, pastors_challenge, worship_songs)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`)
return stmt.run(
sermon.slug,
sermon.title,
sermon.date,
sermon.dates || null,
sermon.bible_references,
sermon.personal_appliance,
sermon.pastors_challenge
sermon.pastors_challenge,
sermon.worship_songs || null
)
}