@sms/plugin-orm
Classes
OrmError
Defined in: packages/plugins/orm/src/core.ts:21
Errors the ORM raises on purpose; the REST layer maps kind to a status.
Extends
Error
Constructors
Constructor
new OrmError(kind, message): OrmError;
Defined in: packages/plugins/orm/src/core.ts:23
Parameters
| Parameter | Type |
|---|---|
kind | OrmErrorKind |
message | string |
Returns
Overrides
Error.constructor
Properties
cause?
optional cause?: unknown;
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26
Inherited from
Error.cause
kind
readonly kind: OrmErrorKind;
Defined in: packages/plugins/orm/src/core.ts:22
message
message: string;
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077
Inherited from
Error.message
name
name: string;
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Error.name
stack?
optional stack?: string;
Defined in: node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078
Inherited from
Error.stack
stackTraceLimit
static stackTraceLimit: number;
Defined in: node_modules/.pnpm/@types+node@22.20.1/node_modules/@types/node/globals.d.ts:68
The Error.stackTraceLimit property specifies the number of stack frames
collected by a stack trace (whether generated by new Error().stack or
Error.captureStackTrace(obj)).
The default value is 10 but may be set to any valid JavaScript number. Changes
will affect any stack trace captured after the value has been changed.
If set to a non-number value, or set to a negative number, stack traces will not capture any frames.
Inherited from
Error.stackTraceLimit
Methods
captureStackTrace()
static captureStackTrace(targetObject, constructorOpt?): void;
Defined in: node_modules/.pnpm/@types+node@22.20.1/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`
The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTrace
prepareStackTrace()
static prepareStackTrace(err, stackTraces): any;
Defined in: node_modules/.pnpm/@types+node@22.20.1/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTrace
Interfaces
CallRequest
Defined in: packages/plugins/orm/src/types.ts:172
Properties
args?
optional args?: Values;
Defined in: packages/plugins/orm/src/types.ts:174
ids?
optional ids?: number[];
Defined in: packages/plugins/orm/src/types.ts:173
ComputedField
Defined in: packages/plugins/orm/src/types.ts:75
Computed by the model-method named compute, called with { records } (the scalar values of the ids)
and returning { [id]: value }. Stored by default (queryable); store: false computes on read.
Extends
Properties
compute
compute: string;
Defined in: packages/plugins/orm/src/types.ts:80
default?
optional default?: unknown;
Defined in: packages/plugins/orm/src/types.ts:44
Default value; $uid, $now, $today are substituted from the context.
Inherited from
depends
depends: string[];
Defined in: packages/plugins/orm/src/types.ts:79
Fields (dotted paths allowed, one hop) whose change triggers recompute.
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:40
Inherited from
index?
optional index?: boolean;
Defined in: packages/plugins/orm/src/types.ts:45
Inherited from
kind
kind: "computed";
Defined in: packages/plugins/orm/src/types.ts:76
label?
optional label?: string;
Defined in: packages/plugins/orm/src/types.ts:39
Inherited from
options?
optional options?: {
label?: string;
value: string;
}[];
Defined in: packages/plugins/orm/src/types.ts:82
label?
optional label?: string;
value
value: string;
readonly?
optional readonly?: boolean;
Defined in: packages/plugins/orm/src/types.ts:42
Inherited from
required?
optional required?: boolean;
Defined in: packages/plugins/orm/src/types.ts:41
Inherited from
returns
returns: ComputedReturns;
Defined in: packages/plugins/orm/src/types.ts:77
store?
optional store?: boolean;
Defined in: packages/plugins/orm/src/types.ts:81
target?
optional target?: string;
Defined in: packages/plugins/orm/src/types.ts:83
FieldBase
Defined in: packages/plugins/orm/src/types.ts:38
Extended by
Properties
default?
optional default?: unknown;
Defined in: packages/plugins/orm/src/types.ts:44
Default value; $uid, $now, $today are substituted from the context.
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:40
index?
optional index?: boolean;
Defined in: packages/plugins/orm/src/types.ts:45
label?
optional label?: string;
Defined in: packages/plugins/orm/src/types.ts:39
readonly?
optional readonly?: boolean;
Defined in: packages/plugins/orm/src/types.ts:42
required?
optional required?: boolean;
Defined in: packages/plugins/orm/src/types.ts:41
GroupRow
Defined in: packages/plugins/orm/src/types.ts:163
Extends
Indexable
[key: string]: unknown
Properties
__count
__count: number;
Defined in: packages/plugins/orm/src/types.ts:164
__domain
__domain: Domain;
Defined in: packages/plugins/orm/src/types.ts:166
Domain selecting the group’s records.
HookPayload
Defined in: packages/plugins/orm/src/types.ts:142
Properties
ids
ids: number[];
Defined in: packages/plugins/orm/src/types.ts:143
records
records: Rec[];
Defined in: packages/plugins/orm/src/types.ts:145
values
values: Values;
Defined in: packages/plugins/orm/src/types.ts:144
Many2manyField
Defined in: packages/plugins/orm/src/types.ts:65
Extends
Properties
default?
optional default?: unknown;
Defined in: packages/plugins/orm/src/types.ts:44
Default value; $uid, $now, $today are substituted from the context.
Inherited from
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:40
Inherited from
index?
optional index?: boolean;
Defined in: packages/plugins/orm/src/types.ts:45
Inherited from
kind
kind: "many2many";
Defined in: packages/plugins/orm/src/types.ts:66
label?
optional label?: string;
Defined in: packages/plugins/orm/src/types.ts:39
Inherited from
readonly?
optional readonly?: boolean;
Defined in: packages/plugins/orm/src/types.ts:42
Inherited from
required?
optional required?: boolean;
Defined in: packages/plugins/orm/src/types.ts:41
Inherited from
target
target: string;
Defined in: packages/plugins/orm/src/types.ts:67
through?
optional through?: string;
Defined in: packages/plugins/orm/src/types.ts:69
Junction table; default m_<model>__<target>__<field>. Share it between both sides for symmetry.
Many2oneField
Defined in: packages/plugins/orm/src/types.ts:54
Extends
Properties
default?
optional default?: unknown;
Defined in: packages/plugins/orm/src/types.ts:44
Default value; $uid, $now, $today are substituted from the context.
Inherited from
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:40
Inherited from
index?
optional index?: boolean;
Defined in: packages/plugins/orm/src/types.ts:45
Inherited from
kind
kind: "many2one";
Defined in: packages/plugins/orm/src/types.ts:55
label?
optional label?: string;
Defined in: packages/plugins/orm/src/types.ts:39
Inherited from
onDelete?
optional onDelete?: "set-null" | "cascade" | "restrict";
Defined in: packages/plugins/orm/src/types.ts:57
readonly?
optional readonly?: boolean;
Defined in: packages/plugins/orm/src/types.ts:42
Inherited from
required?
optional required?: boolean;
Defined in: packages/plugins/orm/src/types.ts:41
Inherited from
target
target: string;
Defined in: packages/plugins/orm/src/types.ts:56
MethodEnv
Defined in: packages/plugins/orm/src/types.ts:121
What a method / hook / onchange handler receives. orm is absent for handlers running in an executor.
Properties
ctx
ctx: OpContext;
Defined in: packages/plugins/orm/src/types.ts:123
model
model: string;
Defined in: packages/plugins/orm/src/types.ts:122
orm?
optional orm?: OrmService;
Defined in: packages/plugins/orm/src/types.ts:124
ModelFieldContribution
Defined in: packages/plugins/orm/src/types.ts:115
Point model-field: add a field to a model declared by someone else (now or later).
Properties
model
model: string;
Defined in: packages/plugins/orm/src/types.ts:116
name
name: string;
Defined in: packages/plugins/orm/src/types.ts:117
spec
spec: FieldSpec;
Defined in: packages/plugins/orm/src/types.ts:118
ModelHook
Defined in: packages/plugins/orm/src/types.ts:136
Point model-hook: before handlers may mutate values; after handlers see the saved records.
Properties
handler
handler: (env, payload) => unknown;
Defined in: packages/plugins/orm/src/types.ts:140
Parameters
| Parameter | Type |
|---|---|
env | MethodEnv |
payload | HookPayload |
Returns
unknown
model
model: string;
Defined in: packages/plugins/orm/src/types.ts:137
on
on: "create" | "write" | "unlink";
Defined in: packages/plugins/orm/src/types.ts:138
when
when: "before" | "after";
Defined in: packages/plugins/orm/src/types.ts:139
ModelMethod
Defined in: packages/plugins/orm/src/types.ts:127
Point model-method: handler(env, ids, args). For computes args = { records } and the result is { [id]: value }.
Properties
access?
optional access?: Op;
Defined in: packages/plugins/orm/src/types.ts:133
Access needed to call it. Default write.
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:130
handler
handler: (env, ids, args) => unknown;
Defined in: packages/plugins/orm/src/types.ts:131
Parameters
Returns
unknown
model
model: string;
Defined in: packages/plugins/orm/src/types.ts:128
name
name: string;
Defined in: packages/plugins/orm/src/types.ts:129
ModelOnchange
Defined in: packages/plugins/orm/src/types.ts:148
Point model-onchange: when field changes in a form, handler(env, values) returns a patch.
Properties
field
field: string;
Defined in: packages/plugins/orm/src/types.ts:150
handler
handler: (env, values) => Values | Promise<Values>;
Defined in: packages/plugins/orm/src/types.ts:151
Parameters
Returns
model
model: string;
Defined in: packages/plugins/orm/src/types.ts:149
ModelSpec
Defined in: packages/plugins/orm/src/types.ts:105
Point model. Every model also gets id, display, created_at, updated_at, created_by, updated_by.
Properties
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:107
displayField?
optional displayField?: string;
Defined in: packages/plugins/orm/src/types.ts:110
Which field feeds display. Default name when present, else id.
fields
fields: Record<string, FieldSpec>;
Defined in: packages/plugins/orm/src/types.ts:108
name
name: string;
Defined in: packages/plugins/orm/src/types.ts:106
order?
optional order?: string;
Defined in: packages/plugins/orm/src/types.ts:112
Default order. Default id desc.
One2manyField
Defined in: packages/plugins/orm/src/types.ts:59
Extends
Properties
default?
optional default?: unknown;
Defined in: packages/plugins/orm/src/types.ts:44
Default value; $uid, $now, $today are substituted from the context.
Inherited from
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:40
Inherited from
index?
optional index?: boolean;
Defined in: packages/plugins/orm/src/types.ts:45
Inherited from
inverse
inverse: string;
Defined in: packages/plugins/orm/src/types.ts:63
The many2one on target pointing back.
kind
kind: "one2many";
Defined in: packages/plugins/orm/src/types.ts:60
label?
optional label?: string;
Defined in: packages/plugins/orm/src/types.ts:39
Inherited from
readonly?
optional readonly?: boolean;
Defined in: packages/plugins/orm/src/types.ts:42
Inherited from
required?
optional required?: boolean;
Defined in: packages/plugins/orm/src/types.ts:41
Inherited from
target
target: string;
Defined in: packages/plugins/orm/src/types.ts:61
OpContext
Defined in: packages/plugins/orm/src/types.ts:28
Who is operating. sudo bypasses the guard (system code only).
Properties
isAdmin?
optional isAdmin?: boolean;
Defined in: packages/plugins/orm/src/types.ts:30
sudo?
optional sudo?: boolean;
Defined in: packages/plugins/orm/src/types.ts:31
userId?
optional userId?: number;
Defined in: packages/plugins/orm/src/types.ts:29
OrmEventPayload
Defined in: packages/plugins/orm/src/types.ts:187
Properties
ctx
ctx: OpContext;
Defined in: packages/plugins/orm/src/types.ts:191
ids
ids: number[];
Defined in: packages/plugins/orm/src/types.ts:189
model
model: string;
Defined in: packages/plugins/orm/src/types.ts:188
values
values: Values;
Defined in: packages/plugins/orm/src/types.ts:190
OrmGuard
Defined in: packages/plugins/orm/src/types.ts:181
Row-level access seam (an RBAC plugin calls orm.setGuard). can gates the operation; domain is AND-ed
into every search/read/write/unlink. Absent → everything allowed.
Methods
can()
can(q): boolean | Promise<boolean>;
Defined in: packages/plugins/orm/src/types.ts:182
Parameters
Returns
boolean | Promise<boolean>
domain()
domain(q): Domain | Promise<Domain>;
Defined in: packages/plugins/orm/src/types.ts:183
Parameters
Returns
OrmOptions
Defined in: packages/plugins/orm/src/index.ts:28
Properties
contextOf?
optional contextOf?: (req) => OpContext | Promise<OpContext>;
Defined in: packages/plugins/orm/src/index.ts:30
Who is calling a REST route. Default: an anonymous context {} (everything the guard allows anonymous users).
Parameters
| Parameter | Type |
|---|---|
req | RouteRequest |
Returns
OpContext | Promise<OpContext>
prefix?
optional prefix?: string;
Defined in: packages/plugins/orm/src/index.ts:32
Route prefix. Default /api/orm.
OrmService
Defined in: packages/plugins/orm/src/types.ts:196
The orm key. Every call is guard-checked unless ctx.sudo.
Methods
call()
call(
model,
method,
req,
ctx
): Promise<unknown>;
Defined in: packages/plugins/orm/src/types.ts:215
Parameters
| Parameter | Type |
|---|---|
model | string |
method | string |
req | CallRequest |
ctx | OpContext |
Returns
Promise<unknown>
count()
count(
model,
domain,
ctx
): Promise<number>;
Defined in: packages/plugins/orm/src/types.ts:201
Parameters
Returns
Promise<number>
create()
create(
model,
values,
ctx
): Promise<number>;
Defined in: packages/plugins/orm/src/types.ts:208
Parameters
Returns
Promise<number>
defaults()
defaults(model, ctx): Values;
Defined in: packages/plugins/orm/src/types.ts:214
Parameters
| Parameter | Type |
|---|---|
model | string |
ctx | OpContext |
Returns
models()
models(): string[];
Defined in: packages/plugins/orm/src/types.ts:197
Returns
string[]
on()
on(event, listener): () => void;
Defined in: packages/plugins/orm/src/types.ts:216
Parameters
| Parameter | Type |
|---|---|
event | OrmEvent |
listener | OrmListener |
Returns
() => void
onchange()
onchange(
model,
values,
changed,
ctx
): Promise<Values>;
Defined in: packages/plugins/orm/src/types.ts:213
Run the onchange handlers of changed fields and recompute non-stored fields of a saved record.
Parameters
Returns
Promise<Values>
read()
read(
model,
ids,
fields,
ctx
): Promise<Rec[]>;
Defined in: packages/plugins/orm/src/types.ts:202
Parameters
Returns
Promise<Rec[]>
readGroup()
readGroup(
model,
req,
ctx
): Promise<GroupRow[]>;
Defined in: packages/plugins/orm/src/types.ts:211
Parameters
| Parameter | Type |
|---|---|
model | string |
req | ReadGroupRequest |
ctx | OpContext |
Returns
Promise<GroupRow[]>
search()
search(
model,
domain,
ctx,
opts?
): Promise<number[]>;
Defined in: packages/plugins/orm/src/types.ts:200
Parameters
| Parameter | Type |
|---|---|
model | string |
domain | Domain |
ctx | OpContext |
opts? | SearchOptions |
Returns
Promise<number[]>
searchRead()
searchRead(
model,
req,
ctx
): Promise<{
length: number;
records: Rec[];
}>;
Defined in: packages/plugins/orm/src/types.ts:203
Parameters
| Parameter | Type |
|---|---|
model | string |
req | SearchReadRequest |
ctx | OpContext |
Returns
Promise<{
length: number;
records: Rec[];
}>
setGuard()
setGuard(guard): void;
Defined in: packages/plugins/orm/src/types.ts:217
Parameters
| Parameter | Type |
|---|---|
guard | OrmGuard | undefined |
Returns
void
spec()
spec(model): ModelSpec | undefined;
Defined in: packages/plugins/orm/src/types.ts:199
Resolved spec: fields include the implicit ones and model-field extensions.
Parameters
| Parameter | Type |
|---|---|
model | string |
Returns
ModelSpec | undefined
unlink()
unlink(
model,
ids,
ctx
): Promise<void>;
Defined in: packages/plugins/orm/src/types.ts:210
Parameters
| Parameter | Type |
|---|---|
model | string |
ids | number[] |
ctx | OpContext |
Returns
Promise<void>
write()
write(
model,
ids,
values,
ctx
): Promise<void>;
Defined in: packages/plugins/orm/src/types.ts:209
Parameters
Returns
Promise<void>
ReadGroupRequest
Defined in: packages/plugins/orm/src/types.ts:154
Properties
aggregates?
optional aggregates?: Record<string, string>;
Defined in: packages/plugins/orm/src/types.ts:159
{ total: 'sum:amount', n: 'count' } — sum/avg/min/max/count.
domain
domain: Domain;
Defined in: packages/plugins/orm/src/types.ts:155
groupBy
groupBy: string[];
Defined in: packages/plugins/orm/src/types.ts:157
Field names; dates accept :month / :day.
limit?
optional limit?: number;
Defined in: packages/plugins/orm/src/types.ts:160
order?
optional order?: string;
Defined in: packages/plugins/orm/src/types.ts:161
Rec
Defined in: packages/plugins/orm/src/types.ts:13
A record as returned by read: id + display + requested fields; many2one → { id, display, … } | null.
Extends
Indexable
[key: string]: unknown
Properties
display
display: string;
Defined in: packages/plugins/orm/src/types.ts:15
id
id: number;
Defined in: packages/plugins/orm/src/types.ts:14
RelatedField
Defined in: packages/plugins/orm/src/types.ts:86
Read-through of a dotted path (partner.email). Never stored.
Extends
Properties
default?
optional default?: unknown;
Defined in: packages/plugins/orm/src/types.ts:44
Default value; $uid, $now, $today are substituted from the context.
Inherited from
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:40
Inherited from
index?
optional index?: boolean;
Defined in: packages/plugins/orm/src/types.ts:45
Inherited from
kind
kind: "related";
Defined in: packages/plugins/orm/src/types.ts:87
label?
optional label?: string;
Defined in: packages/plugins/orm/src/types.ts:39
Inherited from
options?
optional options?: {
label?: string;
value: string;
}[];
Defined in: packages/plugins/orm/src/types.ts:92
label?
optional label?: string;
value
value: string;
path
path: string;
Defined in: packages/plugins/orm/src/types.ts:88
readonly?
optional readonly?: boolean;
Defined in: packages/plugins/orm/src/types.ts:42
Inherited from
required?
optional required?: boolean;
Defined in: packages/plugins/orm/src/types.ts:41
Inherited from
returns?
optional returns?: ComputedReturns;
Defined in: packages/plugins/orm/src/types.ts:90
Filled by the ORM when the path resolves.
target?
optional target?: string;
Defined in: packages/plugins/orm/src/types.ts:91
ScalarField
Defined in: packages/plugins/orm/src/types.ts:47
Extends
Properties
default?
optional default?: unknown;
Defined in: packages/plugins/orm/src/types.ts:44
Default value; $uid, $now, $today are substituted from the context.
Inherited from
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:40
Inherited from
index?
optional index?: boolean;
Defined in: packages/plugins/orm/src/types.ts:45
Inherited from
kind
kind: ScalarKind;
Defined in: packages/plugins/orm/src/types.ts:48
label?
optional label?: string;
Defined in: packages/plugins/orm/src/types.ts:39
Inherited from
readonly?
optional readonly?: boolean;
Defined in: packages/plugins/orm/src/types.ts:42
Inherited from
required?
optional required?: boolean;
Defined in: packages/plugins/orm/src/types.ts:41
Inherited from
SearchOptions
Defined in: packages/plugins/orm/src/types.ts:20
Extended by
Properties
limit?
optional limit?: number;
Defined in: packages/plugins/orm/src/types.ts:21
offset?
optional offset?: number;
Defined in: packages/plugins/orm/src/types.ts:22
order?
optional order?: string;
Defined in: packages/plugins/orm/src/types.ts:24
'name asc, id desc'
SearchReadRequest
Defined in: packages/plugins/orm/src/types.ts:168
Extends
Properties
domain
domain: Domain;
Defined in: packages/plugins/orm/src/types.ts:169
fields
fields: ReadSpec;
Defined in: packages/plugins/orm/src/types.ts:170
limit?
optional limit?: number;
Defined in: packages/plugins/orm/src/types.ts:21
Inherited from
offset?
optional offset?: number;
Defined in: packages/plugins/orm/src/types.ts:22
Inherited from
order?
optional order?: string;
Defined in: packages/plugins/orm/src/types.ts:24
'name asc, id desc'
Inherited from
SelectionField
Defined in: packages/plugins/orm/src/types.ts:50
Extends
Properties
default?
optional default?: unknown;
Defined in: packages/plugins/orm/src/types.ts:44
Default value; $uid, $now, $today are substituted from the context.
Inherited from
description?
optional description?: string;
Defined in: packages/plugins/orm/src/types.ts:40
Inherited from
index?
optional index?: boolean;
Defined in: packages/plugins/orm/src/types.ts:45
Inherited from
kind
kind: "selection";
Defined in: packages/plugins/orm/src/types.ts:51
label?
optional label?: string;
Defined in: packages/plugins/orm/src/types.ts:39
Inherited from
options
options: {
label?: string;
value: string;
}[];
Defined in: packages/plugins/orm/src/types.ts:52
label?
optional label?: string;
value
value: string;
readonly?
optional readonly?: boolean;
Defined in: packages/plugins/orm/src/types.ts:42
Inherited from
required?
optional required?: boolean;
Defined in: packages/plugins/orm/src/types.ts:41
Inherited from
Type Aliases
Command
type Command =
| {
op: "create";
values: Values;
}
| {
id: number;
op: "update";
values: Values;
}
| {
id: number;
op: "delete";
}
| {
id: number;
op: "link";
}
| {
id: number;
op: "unlink";
}
| {
ids: number[];
op: "set";
};
Defined in: packages/plugins/orm/src/x2many.ts:5
ComputedReturns
type ComputedReturns = ScalarKind | "selection" | "many2one";
Defined in: packages/plugins/orm/src/types.ts:36
Domain
type Domain = (DomainLeaf | "&" | "|" | "!")[];
Defined in: packages/plugins/orm/src/types.ts:9
DomainLeaf
type DomainLeaf = [string, DomainOp, unknown];
Defined in: packages/plugins/orm/src/types.ts:8
DomainOp
type DomainOp = "=" | "!=" | "<" | "<=" | ">" | ">=" | "in" | "not in" | "like" | "ilike";
Defined in: packages/plugins/orm/src/types.ts:7
Filter in prefix notation: leaves [field, op, value], operators & (implicit between leaves), |, !.
FieldKind
type FieldKind = FieldSpec["kind"];
Defined in: packages/plugins/orm/src/types.ts:102
FieldSpec
type FieldSpec =
| ScalarField
| SelectionField
| Many2oneField
| One2manyField
| Many2manyField
| ComputedField
| RelatedField;
Defined in: packages/plugins/orm/src/types.ts:94
Op
type Op = "read" | "write" | "create" | "unlink";
Defined in: packages/plugins/orm/src/types.ts:33
OrmErrorKind
type OrmErrorKind = "not_found" | "forbidden" | "validation";
Defined in: packages/plugins/orm/src/core.ts:18
OrmEvent
type OrmEvent = "create" | "write" | "unlink";
Defined in: packages/plugins/orm/src/types.ts:186
OrmListener
type OrmListener = (payload) => unknown | Promise<unknown>;
Defined in: packages/plugins/orm/src/types.ts:193
Parameters
| Parameter | Type |
|---|---|
payload | OrmEventPayload |
Returns
unknown | Promise<unknown>
ReadSpec
type ReadSpec = {
[field: string]: ReadSpec;
};
Defined in: packages/plugins/orm/src/types.ts:18
Which fields to read; for relational fields, which sub-fields ({} = id + display / ids only).
Index Signature
[field: string]: ReadSpec
ScalarKind
type ScalarKind = "char" | "text" | "int" | "float" | "bool" | "date" | "datetime" | "json";
Defined in: packages/plugins/orm/src/types.ts:35
Values
type Values = Record<string, unknown>;
Defined in: packages/plugins/orm/src/types.ts:11
Variables
DSL_PROMPT
const DSL_PROMPT: "Models (point \"model\"): { name, description?, fields: { <field>: spec }, displayField?, order? }.\nField spec: { kind, label?, required?, readonly?, default?, index? } with kind one of char text int float bool date datetime json,\nselection { options: [{ value, label? }] }, many2one { target, onDelete? }, one2many { target, inverse }, many2many { target },\ncomputed { returns, depends: [fields], compute: <model-method name>, store? }, related { path: \"a.b\" }.\nEvery model also has id, display, created_at, updated_at. Add a field to an existing model with point \"model-field\":\n{ model, name, spec }. Add behaviour with point \"model-method\": { model, name, handler(env, ids, args) } — a compute\nmethod receives args.records (the rows' scalar values) and returns { [id]: value }.\nDomains filter records in prefix notation: [[\"state\",\"=\",\"open\"], \"|\", [\"name\",\"ilike\",\"a\"], [\"email\",\"ilike\",\"a\"]].";
Defined in: packages/plugins/orm/src/contract.ts:18
HOOK_POINT
const HOOK_POINT: "model-hook" = 'model-hook';
Defined in: packages/plugins/orm/src/methods.ts:17
METHOD_POINT
const METHOD_POINT: "model-method" = 'model-method';
Defined in: packages/plugins/orm/src/methods.ts:16
MODEL_FIELD_POINT
const MODEL_FIELD_POINT: "model-field" = 'model-field';
Defined in: packages/plugins/orm/src/contract.ts:16
MODEL_POINT
const MODEL_POINT: "model" = 'model';
Defined in: packages/plugins/orm/src/contract.ts:15
ONCHANGE_POINT
const ONCHANGE_POINT: "model-onchange" = 'model-onchange';
Defined in: packages/plugins/orm/src/methods.ts:18
ORM_KEY
const ORM_KEY: "orm" = 'orm';
Defined in: packages/plugins/orm/src/contract.ts:14
Key under which the orm plugin provides OrmService (system-only).
ormPlugin
const ormPlugin: SystemPlugin;
Defined in: packages/plugins/orm/src/index.ts:143
Functions
createOrmPlugin()
function createOrmPlugin(opts?): SystemPlugin;
Defined in: packages/plugins/orm/src/index.ts:63
Parameters
| Parameter | Type |
|---|---|
opts | OrmOptions |
Returns
httpErrorOf()
function httpErrorOf(err): unknown;
Defined in: packages/plugins/orm/src/routes.ts:15
An OrmError as the HttpError a route should throw; anything else comes back unchanged (a 500).
Parameters
| Parameter | Type |
|---|---|
err | unknown |
Returns
unknown
sudo()
function sudo(ctx): OpContext;
Defined in: packages/plugins/orm/src/core.ts:42
Parameters
| Parameter | Type |
|---|---|
ctx | OpContext |
Returns
validateField()
function validateField(rawName, f): asserts f is FieldSpec;
Defined in: packages/plugins/orm/src/registry.ts:95
Parameters
| Parameter | Type |
|---|---|
rawName | unknown |
f | unknown |
Returns
asserts f is FieldSpec
validateModel()
function validateModel(m): asserts m is ModelSpec;
Defined in: packages/plugins/orm/src/registry.ts:139
Parameters
| Parameter | Type |
|---|---|
m | unknown |
Returns
asserts m is ModelSpec
validateModelField()
function validateModelField(item): asserts item is ModelFieldContribution;
Defined in: packages/plugins/orm/src/registry.ts:150
Parameters
| Parameter | Type |
|---|---|
item | unknown |
Returns
asserts item is ModelFieldContribution