Switch to D1 for event by id endpoint
This commit is contained in:
parent
3629b8a39b
commit
9bdaa4afe9
@ -2,10 +2,11 @@ import { jsonError } from "../../../common.js";
|
|||||||
|
|
||||||
export async function onRequestDelete(context: RequestContext) {
|
export async function onRequestDelete(context: RequestContext) {
|
||||||
const eventId = context.params.id as string;
|
const eventId = context.params.id as string;
|
||||||
const eventData: { [k: string]: any } | null = await context.env.DATA.get(
|
const eventData = await context.env.D1.prepare(
|
||||||
`event_${eventId}`,
|
"SELECT created_by FROM events WHERE id = ?;",
|
||||||
{ type: "json" },
|
)
|
||||||
);
|
.bind(eventId)
|
||||||
|
.first();
|
||||||
|
|
||||||
if (!eventData) return jsonError("No event exists with that ID", 404);
|
if (!eventData) return jsonError("No event exists with that ID", 404);
|
||||||
|
|
||||||
@ -30,10 +31,11 @@ export async function onRequestDelete(context: RequestContext) {
|
|||||||
export async function onRequestPatch(context: RequestContext) {
|
export async function onRequestPatch(context: RequestContext) {
|
||||||
const eventId = context.params.id as string;
|
const eventId = context.params.id as string;
|
||||||
const { body } = context.data;
|
const { body } = context.data;
|
||||||
const eventData: { [k: string]: any } | null = await context.env.DATA.get(
|
const eventData = await context.env.D1.prepare(
|
||||||
`event_${eventId}`,
|
"SELECT answer, created_by, details FROM events WHERE id = ?;",
|
||||||
{ type: "json" },
|
)
|
||||||
);
|
.bind(eventId)
|
||||||
|
.first();
|
||||||
|
|
||||||
if (!eventData) return jsonError("No event exists with that ID", 404);
|
if (!eventData) return jsonError("No event exists with that ID", 404);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user