Even more migrations
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
import { jsonError, jsonResponse } from "../../common.js";
|
||||
import { jsonResponse } from "../../common.js";
|
||||
|
||||
export async function onRequestGet(context: RequestContext) {
|
||||
const {
|
||||
results,
|
||||
success,
|
||||
}: {
|
||||
results: { id: string }[];
|
||||
success: boolean;
|
||||
} = await context.env.D1.prepare(
|
||||
"SELECT created_at, id, open, target_usernames FROM reports WHERE json_extract(user, '$.id') = ? ORDER BY created_at LIMIT 50;",
|
||||
)
|
||||
.bind(context.data.current_user.id)
|
||||
.all();
|
||||
|
||||
if (!success) return jsonError("Failed to retrieve reports", 500);
|
||||
|
||||
return jsonResponse(JSON.stringify(results));
|
||||
return jsonResponse(
|
||||
JSON.stringify(
|
||||
await context.data.prisma.report.findMany({
|
||||
select: {
|
||||
created_at: true,
|
||||
id: true,
|
||||
open: true,
|
||||
target_usernames: true,
|
||||
},
|
||||
where: {
|
||||
user: {
|
||||
path: "id",
|
||||
equals: context.data.current_user.id,
|
||||
},
|
||||
},
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user