Home > @i2analyze/i2connect > Result > addLink
Result.addLink() method
Adds a new link record to the result, whose identifier is a string that you provide.
Signature:
addLink<TLinkType extends schema.ILinkType, TFromEnd extends records.ISeededResultEntityRecord | records.IResultEntityRecord<schema.IEntityType, records.ResultRecordId> | records.IResultEntityRecord<schema.IEntityType, records.ISourceIdentifier>, TToEnd extends records.ISeededResultEntityRecord | records.IResultEntityRecord<schema.IEntityType, records.ResultRecordId> | records.IResultEntityRecord<schema.IEntityType, records.ISourceIdentifier>>(type: TLinkType, id: records.ResultRecordId, fromEnd: TFromEnd, toEnd: TToEnd, direction?: data.LinkDirection): records.IResultLinkRecord<TLinkType, TFromEnd, TToEnd, records.ResultRecordId>;
Introduced: API version 1.0
Type Parameters
Parameter | Type | Description |
---|---|---|
TLinkType | extends schema.ILinkType | The type of the new link record. |
TFromEnd | extends records.ISeededResultEntityRecord | records.IResultEntityRecord<schema.IEntityType, records.ResultRecordId> | records.IResultEntityRecord<schema.IEntityType, records.ISourceIdentifier> | The type of the entity record at the "from" end of the link. |
TToEnd | extends records.ISeededResultEntityRecord | records.IResultEntityRecord<schema.IEntityType, records.ResultRecordId> | records.IResultEntityRecord<schema.IEntityType, records.ISourceIdentifier> | The type of the entity record at the "to" end of the link. |
Parameters
Parameter | Type | Description |
---|---|---|
type | TLinkType | The link type of the new record. |
id | records.ResultRecordId | An identifier for the new record. |
fromEnd | TFromEnd | The entity record for the "from" end of the link, which was previously returned from Result.addEntity() or Result.addEntityFromSeed(). |
toEnd | TToEnd | The entity record for the "to" end of the link, which was previously returned from Result.addEntity() or Result.addEntityFromSeed(). |
direction | data.LinkDirection | The direction of the new link record, which defaults to "none" . |
Returns:
records.IResultLinkRecord<TLinkType, TFromEnd, TToEnd, records.ResultRecordId>
The link record that was added to the result.
Remarks
The identifier that you provide 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.