Avoid D1 internal error in project lookup (#272)

This commit is contained in:
Ben Senescu 2026-06-16 21:40:23 -04:00 committed by GitHub
parent d339f0c3d9
commit b08cb0c9e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,13 +30,18 @@ async function getProjectForOrganization(
projectId: string, projectId: string,
organizationId: string, organizationId: string,
) { ) {
return db.query.projects.findFirst({ const [project] = await db
where: and( .select()
.from(projects)
.where(
and(
eq(projects.id, projectId), eq(projects.id, projectId),
eq(projects.organizationId, organizationId), eq(projects.organizationId, organizationId),
isNull(projects.archivedAt), isNull(projects.archivedAt),
), ),
}); )
.limit(1);
return project ?? null;
} }
async function createProject( async function createProject(