File size: 367 Bytes
439093c 598f0d5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import { eq, or, SQL } from "drizzle-orm";
interface VisibilityTable {
isPublic: any;
creatorUserId: any;
}
export function buildVisibilityCondition<T extends VisibilityTable>(
table: T,
userId?: string,
): SQL | undefined {
if (!userId) {
return eq(table.isPublic, true);
}
return or(eq(table.isPublic, true), eq(table.creatorUserId, userId));
}
|