Use native drizzle count

This commit is contained in:
Owen
2026-03-10 10:03:49 -07:00
parent e98f873f81
commit dec358c4cd

View File

@@ -134,17 +134,16 @@ export async function deleteOrgById(
); );
const domainIdsToDelete: string[] = []; const domainIdsToDelete: string[] = [];
for (const orgDomain of allOrgDomains) { for (const orgDomain of allOrgDomains) {
const domainId = orgDomain.domainId; const domainId = orgDomain.domains.domainId;
const orgCount = await trx const [orgCount] = await trx
.select({ count: count() }) .select({ count: count() })
.from(orgDomains) .from(orgDomains)
.where(eq(orgDomains.domainId, domainId)); .where(eq(orgDomains.domainId, domainId));
if (orgCount[0].count == 1) { if (orgCount.count === 1) {
domainIdsToDelete.push(domainId); domainIdsToDelete.push(domainId);
} }
} }
if (domainIdsToDelete.length > 0) { if (domainIdsToDelete.length > 0) {
// delete the orgDomain
await trx await trx
.delete(domains) .delete(domains)
.where(inArray(domains.domainId, domainIdsToDelete)); .where(inArray(domains.domainId, domainIdsToDelete));