mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 11:58:14 +00:00
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:
@@ -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 })));
|
||||
|
||||
Reference in New Issue
Block a user