Skip to content

Open source alternative to Semrush and Ahrefs

Avoid D1 internal error in project lookup (#272)

Ben Senescub08cb0c9e2d5
diff --git a/src/server/features/projects/repositories/ProjectRepository.ts b/src/server/features/projects/repositories/ProjectRepository.ts
index 01dbbb77..98108385 100644
--- a/src/server/features/projects/repositories/ProjectRepository.ts
+++ b/src/server/features/projects/repositories/ProjectRepository.ts
@@ -30,13 +30,18 @@ async function getProjectForOrganization(
projectId: string,
organizationId: string,
) {
- return db.query.projects.findFirst({
- where: and(
- eq(projects.id, projectId),
- eq(projects.organizationId, organizationId),
- isNull(projects.archivedAt),
- ),
- });
+ const [project] = await db
+ .select()
+ .from(projects)
+ .where(
+ and(
+ eq(projects.id, projectId),
+ eq(projects.organizationId, organizationId),
+ isNull(projects.archivedAt),
+ ),
+ )
+ .limit(1);
+ return project ?? null;
}
async function createProject(