API Reference
interfaces
Relationoptions

@coasys/ad4m / Exports / RelationOptions

Interface: RelationOptions

Options for relation decorators (@HasMany, @HasOne, @BelongsToOne, @BelongsToMany).

Table of contents

Properties

Properties

filter

Optional filter: boolean

Whether to auto-generate a DB-level conformance filter when target is set. Defaults to true when target is present — the query will only return linked nodes whose shape matches the target model (required properties, flags, etc.). Set to false to opt out of filtering while keeping hydration capability.

Defined in

model/decorators.ts:678 (opens in a new tab)


getter

Optional getter: string

Custom SurrealQL getter to resolve the relation values. Use this for custom graph traversals. The expression can reference 'Base' which will be replaced with the instance's base expression. Example: "(<-link[WHERE predicate = 'flux://has_reply'].out.uri)"

Mutually exclusive with through and target. When getter is provided the relation is read-only (no adder/remover actions are generated).

Defined in

model/decorators.ts:669 (opens in a new tab)


local

Optional local: boolean

Whether the link is stored locally (not shared on the network)

Defined in

model/decorators.ts:671 (opens in a new tab)


target

Optional target: () => Ad4mModelLike

Type declaration

▸ (): Ad4mModelLike

The target model class (use a thunk to avoid circular-dependency issues). Optional for untyped string relations. Cannot be combined with getter.

Returns

Ad4mModelLike

Defined in

model/decorators.ts:660 (opens in a new tab)


through

Optional through: string

The predicate URI used to link the two models. Defaults to 'ad4m://has_child' when omitted. Cannot be combined with getter.

Defined in

model/decorators.ts:657 (opens in a new tab)


where

Optional where: Where

Filter constraints on the linked target nodes, using the same query DSL as Model.query().where(...). Property names reference the target model's properties (resolved via target metadata).

When target is set and where is omitted, conformance conditions are auto-derived from the target shape (flags + required properties). Providing where overrides this auto-derivation.

Mutually exclusive with getter and filter: false.

Example

@HasMany(() => Message, {
  through: "flux://entry_type",
  where: { status: "active", priority: { gte: 3 } }
})
activeMessages: Message[] = []

Defined in

model/decorators.ts:699 (opens in a new tab)