postgrelize / Scopes
Function: Scopes() ​
Scopes(
scopes):ModelClassDecorator
Defined in: src/decorators/table-decorators.ts:52
Defines the named scopes of a model (scopes of Model.init).
Parameters ​
scopes ​
Readonly<Record<string, ScopeDefinition>> | (() => ScopesInput)
Scopes by name (options or functions returning options), or a function returning them.
Returns ​
A class decorator.
Example ​
ts
@Scopes({ recent: { order: [['createdAt', 'DESC']] }, named: (name: string) => ({ where: { name } }) })
class User extends Model {}