coolify/src/lib/database/logs.ts

21 lines
484 B
TypeScript
Raw Normal View History

2022-04-06 18:16:21 +00:00
import type { BuildLog } from '@prisma/client';
import { prisma, ErrorHandler } from './common';
2022-02-10 14:47:44 +00:00
2022-04-06 18:16:21 +00:00
export async function listLogs({
buildId,
last = 0
}: {
buildId: string;
last: number;
}): Promise<BuildLog[] | { status: number; body: { message: string; error: string } }> {
2022-02-10 14:47:44 +00:00
try {
const body = await prisma.buildLog.findMany({
where: { buildId, time: { gt: last } },
orderBy: { time: 'asc' }
});
return [...body];
} catch (error) {
return ErrorHandler(error);
2022-02-10 14:47:44 +00:00
}
}