Migrate the rest of the easy stuff
This commit is contained in:
@@ -14,13 +14,27 @@ export async function onRequestGet(context: RequestContext) {
|
||||
if (currentYear < year || (currentYear === year && currentMonth < month))
|
||||
return jsonError("Cannot get events for a time in the future", 400);
|
||||
|
||||
const eventRecords = await context.env.D1.prepare(
|
||||
"SELECT answer, approved, created_by, day, details, month, pending, performed_at, type, year FROM events WHERE month = ? AND year = ? ORDER BY day ASC;",
|
||||
)
|
||||
.bind(month, year)
|
||||
.all();
|
||||
const eventRecords = await context.data.prisma.event.findMany({
|
||||
select: {
|
||||
answer: true,
|
||||
approved: true,
|
||||
created_by: true,
|
||||
day: true,
|
||||
details: true,
|
||||
month: true,
|
||||
pending: true,
|
||||
performed_at: true,
|
||||
type: true,
|
||||
year: true,
|
||||
},
|
||||
where: {
|
||||
month: month,
|
||||
year: year,
|
||||
},
|
||||
orderBy: {
|
||||
day: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
if (!eventRecords.success) return jsonError("Failed to retrieve events", 400);
|
||||
|
||||
return jsonResponse(JSON.stringify(eventRecords.results));
|
||||
return jsonResponse(JSON.stringify(eventRecords));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user