MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / countTenantRows

Function countTenantRows

apps/cloud/src/db/org-deletion.test.ts:206–219  ·  view source on GitHub ↗
(db: DrizzleDb, tenant: string)

Source from the content-addressed store, hash-verified

204};
205
206const countTenantRows = async (db: DrizzleDb, tenant: string): Promise<number> => {
207 let total = 0;
208 for (const table of TENANT_TABLES) {
209 const rows = await db.select().from(table).where(eq(table.tenant, tenant));
210 total += rows.length;
211 }
212 // Count by the exact namespaces `seedTenant` inserts. Matching on a `%tenant%`
213 // LIKE here would reintroduce the very wildcard hazard under test.
214 const blobs = await db
215 .select()
216 .from(blob)
217 .where(inArray(blob.namespace, [`o:${tenant}/plugin`, `u:${tenant}:subject/plugin`]));
218 return total + blobs.length;
219};
220
221describe("purgeOrganizationData", () => {
222 it("removes all of one org's data and leaves other orgs untouched", async () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected