mirror of
https://github.com/temetro/temetro.git
synced 2026-08-28 03:17:05 +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);
|
const orgs = await db.select({ id: organization.id }).from(organization);
|
||||||
let seeded = 0;
|
let seeded = 0;
|
||||||
for (const org of orgs) {
|
for (const org of orgs) {
|
||||||
const [{ count }] = await db
|
const [row] = await db
|
||||||
.select({ count: sql<number>`count(*)::int` })
|
.select({ count: sql<number>`count(*)::int` })
|
||||||
.from(inventory)
|
.from(inventory)
|
||||||
.where(eq(inventory.organizationId, org.id));
|
.where(eq(inventory.organizationId, org.id));
|
||||||
if (count > 0) continue;
|
if ((row?.count ?? 0) > 0) continue;
|
||||||
await db
|
await db
|
||||||
.insert(inventory)
|
.insert(inventory)
|
||||||
.values(DEMO_STOCK.map((s) => ({ ...s, organizationId: org.id })));
|
.values(DEMO_STOCK.map((s) => ({ ...s, organizationId: org.id })));
|
||||||
|
|||||||
Reference in New Issue
Block a user