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

Function countTenantRows

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

Source from the content-addressed store, hash-verified

208};
209
210const countTenantRows = async (db: DrizzleDb, tenant: string): Promise<number> => {
211 let total = 0;
212 for (const table of TENANT_TABLES) {
213 const rows = await db.select().from(table).where(eq(table.tenant, tenant));
214 total += rows.length;
215 }
216 // Count by the exact namespaces `seedTenant` inserts. Matching on a `%tenant%`
217 // LIKE here would reintroduce the very wildcard hazard under test.
218 const blobs = await db
219 .select()
220 .from(blob)
221 .where(inArray(blob.namespace, [`o:${tenant}/plugin`, `u:${tenant}:subject/plugin`]));
222 return total + blobs.length;
223};
224
225describe("purgeOrganizationData", () => {
226 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