Spaces:
Sleeping

asd / src /libs /shared /application /BaseRepository.ts
GitHub Actions
deploy: clean snapshot
7f81110
Raw History Blame Contribute Delete
392 Bytes
import { SQL, and, eq } from "drizzle-orm";
export abstract class BaseRepository {
constructor() { }
/**
* Enforces tenant scoping on any condition
*/
protected withTenant(tenantId: string, condition?: SQL): SQL {
const tenantFilter = eq((this as any).table.tenantId, tenantId);
return condition ? and(tenantFilter, condition)! : tenantFilter;
}
}