Schema fixes
All checks were successful
Docker Deploy / build-and-push (push) Successful in 3m59s

This commit is contained in:
2026-01-20 12:08:06 -07:00
parent 55eb03165e
commit 815c08dd50
17 changed files with 1381 additions and 307 deletions

View File

@@ -1,15 +1,15 @@
import { db } from "../db";
import { clients, tags as tagsTable } from "../db/schema";
import { eq, and, inArray } from "drizzle-orm";
import { eq, and } from "drizzle-orm";
export async function validateTimeEntryResources({
organizationId,
clientId,
tagIds,
tagId,
}: {
organizationId: string;
clientId: string;
tagIds?: string[];
tagId?: string | null;
}) {
const client = await db
.select()
@@ -23,20 +23,20 @@ export async function validateTimeEntryResources({
return { valid: false, error: "Invalid client" };
}
if (tagIds && tagIds.length > 0) {
const validTags = await db
if (tagId) {
const validTag = await db
.select()
.from(tagsTable)
.where(
and(
inArray(tagsTable.id, tagIds),
eq(tagsTable.id, tagId),
eq(tagsTable.organizationId, organizationId),
),
)
.all();
.get();
if (validTags.length !== tagIds.length) {
return { valid: false, error: "Invalid tags" };
if (!validTag) {
return { valid: false, error: "Invalid tag" };
}
}