# scopePredicate() function · @imqueue/pg-prisma

Source: https://imqueue.org/api/pg-prisma/latest/pg-prisma.scopepredicate/
Published: 2026-08-28
Author: @imqueue maintainers (https://github.com/imqueue)
Package: @imqueue/pg-prisma 2.0.0 — generated reference, not hand-written

Compose the scope predicate for one table, or null when nothing constrains it.

**Signature:**

```typescript
export declare function scopePredicate(qualifier: string, levels: Record<string, string[]> | undefined, resolvers: Record<string, AccessScopeResolver>): AnyExpression | null;
```

## Parameters


| Parameter | Type | Description |
| --- | --- | --- |
| qualifier | string | Table alias or name to build columns against. |
| levels | Record<string, string\[\]> \| undefined | Scope columns per level for this one table. |
| resolvers | Record<string, [AccessScopeResolver](https://imqueue.org/api/pg-prisma/latest/pg-prisma.accessscoperesolver/)> | One resolver per access level. |


**Returns:**

AnyExpression \| null

The predicate, or null when no level is active.

## Remarks

Each active level contributes an OR across its columns and the levels are AND-ed together. Exported so the composition can be tested without a database — getting it inverted leaks rows rather than raising an error.

A level configured with no columns yields an empty OR, which Postgres reads as `FALSE`: it denies everything. That is the safe direction, and it is what an empty column list should mean.

