tenancy
PostgreSQL RLS + Prisma 멀티테넌시. 행 수준 격리를 즉시 적용할 수 있습니다.
v0.8.0
모든 멀티테넌트 SaaS 백엔드는 동일한 6가지 기능이 필요합니다. 이를 직접 구현하면 수 주가 걸리고 미묘한 버그가 생깁니다. nestarc는 이 문제를 한 번에, 올바르게 해결합니다.
// 50개 이상의 서비스에 흩어져 있고, 빠뜨리기 쉽고, 감사하기 어렵습니다
async updateUser(id: string, dto: UpdateUserDto) {
const before = await this.prisma.user.findUnique({ where: { id } });
await this.prisma.$executeRaw`SELECT set_config('app.current_tenant', ${tenantId}, true)`;
const after = await this.prisma.user.update({ where: { id, deletedAt: null }, data: dto });
await this.auditService.log({ action: 'user.update', before, after });
return { success: true, data: after, timestamp: new Date() };
}// 테넌트 격리, 감사 로그, 소프트 딜리트 필터링, 응답 래핑이
// Prisma 확장과 NestJS 인터셉터에 의해 자동으로 처리됩니다.
async updateUser(id: string, dto: UpdateUserDto) {
return this.prisma.user.update({ where: { id }, data: dto });
}