package store import ( "context" "fmt" "git.warky.dev/wdevs/amcs/internal/tenancy" ) func tenantKeyPtr(ctx context.Context) *string { if key, ok := tenancy.KeyFromContext(ctx); ok { return &key } return nil } func tenantKey(ctx context.Context) (string, bool) { return tenancy.KeyFromContext(ctx) } func addTenantCondition(ctx context.Context, args *[]any, conditions *[]string, column string) { if key, ok := tenancy.KeyFromContext(ctx); ok { *args = append(*args, key) *conditions = append(*conditions, fmt.Sprintf("%s = $%d", column, len(*args))) } } func tenantSQL(ctx context.Context, args *[]any, column string) string { if key, ok := tenancy.KeyFromContext(ctx); ok { *args = append(*args, key) return fmt.Sprintf(" and %s = $%d", column, len(*args)) } return "" }