Skip to content

WriteManyRelationInstance

Defined in: runtime/relation.ts:134

A relation instance where the cardinality is ”*”.

TItem extends WriteItem

readonly type: "many"

Defined in: runtime/relation.ts:128

Indicates that an abstract relation instance is cardinality ”*”.

ReadManyRelationInstance.type

add(target): Promise<boolean>

Defined in: runtime/relation.ts:145

Adds this target item to the relation instance. Calling select below would now include that item. The supplied target item must match the templates specified in the relationship. For example, if the relation is TemplateA -> TemplateB, you could not supply an item of TemplateC.

TItem

Promise<boolean>

true if there was an actual addition, false otherwise (i.e. the relation already exists)

add(targets): Promise<boolean[]>

Defined in: runtime/relation.ts:146

TItem[]

Promise<boolean[]>


addIfNotExists(target, condition?): Promise<boolean>

Defined in: runtime/relation.ts:162

Conditionally adds this relation, but only if that specific to-from relation does not already exists (that is, it’s unique only for the from AND to members of the relation).

Conditions include specifying a max age for any existing relations. With this approach existing relations can be “expired” after a given duration.

This operation is atomic.

TItem

IfNotExistCondition

Promise<boolean>

true if the addIfNotExists operation succeeded, false if there is already a value set that satisifes the supplied condition.


clear(): Promise<void>

Defined in: runtime/relation.ts:167

Removes all targets from the relation instance.

Promise<void>


isType(item): item is TItem

Defined in: runtime/relation.ts:48

True if the supplied item is of the correct type for this side of the relation.

BaseReadItem

item is TItem

ReadManyRelationInstance.isType


remove(target): Promise<boolean>

Defined in: runtime/relation.ts:177

Removes the supplied target from the relation instance. If the supplied target is not in the instance this method returns with no effect.

This operation is atomic.

TItem

Promise<boolean>

true if there was an actual removal, false otherwise.

remove(targets): Promise<boolean[]>

Defined in: runtime/relation.ts:178

TItem[]

Promise<boolean[]>


select(): TemplateItemCursorSelector<RelatedItem<TItem>>

Defined in: runtime/relation.ts:123

Returns a selector builder to return the targets of this relation instance. This is a standard ItemSelector, so rules on includeArchived can be used in the same manner.

TemplateItemCursorSelector<RelatedItem<TItem>>

ReadManyRelationInstance.select