backend: fix seed-inventory strict-null type error

Guard the per-org count lookup so the build (tsc -p) doesn't fail on the
possibly-undefined first row.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Khalid Abdi
2026-06-12 19:22:07 +03:00
parent 321a6298a4
commit 9545fdd360
+2 -2
View File
@@ -43,11 +43,11 @@ async function main() {
const orgs = await db.select({ id: organization.id }).from(organization);
let seeded = 0;
for (const org of orgs) {
const [{ count }] = await db
const [row] = await db
.select({ count: sql<number>`count(*)::int` })
.from(inventory)
.where(eq(inventory.organizationId, org.id));
if (count > 0) continue;
if ((row?.count ?? 0) > 0) continue;
await db
.insert(inventory)
.values(DEMO_STOCK.map((s) => ({ ...s, organizationId: org.id })));