WriteManyRelationInstance
Defined in: runtime/relation.ts:134
A relation instance where the cardinality is ”*”.
Extends
Section titled “Extends”ReadManyRelationInstance<TItem>
Type Parameters
Section titled “Type Parameters”TItem extends WriteItem
Properties
Section titled “Properties”
readonlytype:"many"
Defined in: runtime/relation.ts:128
Indicates that an abstract relation instance is cardinality ”*”.
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”target
Section titled “target”TItem
Returns
Section titled “Returns”Promise<boolean>
true if there was an actual addition, false otherwise (i.e. the relation already exists)
Call Signature
Section titled “Call Signature”add(
targets):Promise<boolean[]>
Defined in: runtime/relation.ts:146
Parameters
Section titled “Parameters”targets
Section titled “targets”TItem[]
Returns
Section titled “Returns”Promise<boolean[]>
addIfNotExists()
Section titled “addIfNotExists()”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.
Parameters
Section titled “Parameters”target
Section titled “target”TItem
condition?
Section titled “condition?”Returns
Section titled “Returns”Promise<boolean>
true if the addIfNotExists operation succeeded, false if there is already a value set that satisifes the supplied condition.
clear()
Section titled “clear()”clear():
Promise<void>
Defined in: runtime/relation.ts:167
Removes all targets from the relation instance.
Returns
Section titled “Returns”Promise<void>
isType()
Section titled “isType()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”item is TItem
Inherited from
Section titled “Inherited from”ReadManyRelationInstance.isType
remove()
Section titled “remove()”Call Signature
Section titled “Call Signature”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.
Parameters
Section titled “Parameters”target
Section titled “target”TItem
Returns
Section titled “Returns”Promise<boolean>
true if there was an actual removal, false otherwise.
Call Signature
Section titled “Call Signature”remove(
targets):Promise<boolean[]>
Defined in: runtime/relation.ts:178
Parameters
Section titled “Parameters”targets
Section titled “targets”TItem[]
Returns
Section titled “Returns”Promise<boolean[]>
select()
Section titled “select()”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.
Returns
Section titled “Returns”TemplateItemCursorSelector<RelatedItem<TItem>>