Home > @i2analyze/i2connect > services > IResult > addLink
services.IResult.addLink() method
Adds a new link record to the result, whose identifier is a string that you provide or a source identifier that you create.
Signature:
addLink<TLinkType extends schema.ILinkType, TFromEnd extends records.ISeededResultEntityRecord | records.IResultEntityRecord, TToEnd extends records.ISeededResultEntityRecord | records.IResultEntityRecord, TIdType extends records.ResultRecordIdType>(type: TLinkType, id: TIdType, fromEnd: TFromEnd, toEnd: TToEnd, direction?: data.LinkDirection): records.IResultLinkRecord<TLinkType, TFromEnd, TToEnd, TIdType>;
Introduced: API version 2.0
Type Parameters
Parameter | Type | Description |
---|---|---|
TLinkType | extends schema.ILinkType | The type of the new link record. |
TFromEnd | extends records.ISeededResultEntityRecord | records.IResultEntityRecord | The type of the entity record at the "from" end of the link. |
TToEnd | extends records.ISeededResultEntityRecord | records.IResultEntityRecord | The type of the entity record at the "to" end of the link. |
TIdType | extends records.ResultRecordIdType | The type of the identifier of the new link record. |
Parameters
Parameter | Type | Description |
---|---|---|
type | TLinkType | The link type of the new record. |
id | TIdType | A source identifier or identifier for the new record. |
fromEnd | TFromEnd | The entity record for the "from" end of the link, which was previously returned from services.IResult.addEntity() or services.IResult.addEntityFromSeed(). |
toEnd | TToEnd | The entity record for the "to" end of the link, which was previously returned from services.IResult.addEntity() or services.IResult.addEntityFromSeed(). |
direction | data.LinkDirection | (Optional) The direction of the new link record, which defaults to "none" . |
Returns:
records.IResultLinkRecord<TLinkType, TFromEnd, TToEnd, TIdType>
The link record that was added to the result.
Remarks
If you provide a string identifier, it needs to be unique only for links of the specified type, from the connector that owns the service.
If there is no suitable identifier for the link in the data source, you can often construct one from the identifiers of the "from" and "to" ends. If there might be more than one link between the same two entities, you will need to add extra identifying information. For example, for a link that represents a financial transaction, you might include a timestamp and perhaps also the amount.