# Interface Relationship

Describes a relationship between a data/FeatureSource!FeatureSource and another source.

interface Relationship {
cardinality: Cardinality;
id: string;
itemType: string;
relatedSource: FeatureSource;
relationshipType: string;
source: FeatureSource;
title: string;
assignProperties(properties: Partial<RelationshipProperties>): void;
assignPropertiesAsync(properties: Partial<RelationshipProperties>): Promise<void>;
finishAssignProperties(): Promise<void>;
getAllRelatedFeatures(features: FeatureSet | FeatureStream | Feature[]): Promise<Map<Feature, FeatureSet>>;
getDefault<K>(key: K): RelationshipProperties[K];
getDefaults(): Partial<RelationshipProperties>;
getRelatedFeatures(feature: Feature, options?: FetchRelatedFeaturesOptions): Promise<FeatureSet>;
getSerializableProperties(serializeMode?: SerializeMode): PropertyDefs<RelationshipProperties>;
toItemUri(): string;
toJSON(serializeMode?: SerializeMode): Partial<RelationshipProperties>;
}

#### Hierarchy (view full)

- Entity
- Serializable<RelationshipProperties>
  - Relationship

#### Implemented by

- RelationshipBase

#####
Index

### Properties

cardinality
id
itemType
relatedSource
relationshipType
source
title

### Methods

assignProperties
assignPropertiesAsync
finishAssignProperties
getAllRelatedFeatures
getDefault
getDefaults
getRelatedFeatures
getSerializableProperties
toItemUri
toJSON

##
Properties

### `Readonly` cardinality

cardinality: Cardinality

The cardinality of the relationship.

### `Readonly` id

id: string

The unique ID for this entity.

Inherited from Entity.id

### `Readonly` itemType

itemType: string

The item type for this entity when it participates in an App.

Inherited from Entity.itemType

### `Readonly` relatedSource

relatedSource: FeatureSource

The feature source with related data, if available.

### `Readonly` relationshipType

relationshipType: string

The type of relationship.

### `Readonly` source

source: FeatureSource

The feature source that owns this relationship.

### title

title: string

The human-readable name for the relationship.

##
Methods

### assignProperties

- assignProperties(properties): void

- Sets the properties for this item.

  #### Parameters

  - properties: Partial<RelationshipProperties>

    A plain object containing property values to set, keyed by property name.

  #### Returns void

  Inherited from Serializable.assignProperties

### assignPropertiesAsync

- assignPropertiesAsync(properties): Promise<void>

- Sets the properties for this item.

  This version will also await any asynchronous logic that is needed to set the properties.

  #### Parameters

  - properties: Partial<RelationshipProperties>

    A plain object containing property values to set, keyed by property name.

  #### Returns Promise<void>

  Inherited from Serializable.assignPropertiesAsync

### finishAssignProperties

- finishAssignProperties(): Promise<void>

- Waits for all deserialization logic initiated thus far to finish, whether invoked by passing properties into the constructor, or by invoking `assignProperties()` or `assignPropertiesAsync()`.

  #### Returns Promise<void>

  Inherited from Serializable.finishAssignProperties

### getAllRelatedFeatures

- getAllRelatedFeatures(features): Promise<Map<Feature, FeatureSet>>

- Gets features that are related to the each of the given features.

  #### Parameters

  - features: FeatureSet | FeatureStream | Feature[]

  #### Returns Promise<Map<Feature, FeatureSet>>

### getDefault

- getDefault<K>(key): RelationshipProperties[K]

- Gets the default value of an object's property.

  #### Type Parameters

  - K extends keyof RelationshipProperties

  #### Parameters

  - key: K

    The property of the object for which to get the default value.

  #### Returns RelationshipProperties[K]

  Inherited from Serializable.getDefault

### getDefaults

- getDefaults(): Partial<RelationshipProperties>

- Gets the object's default property values.

  #### Returns Partial<RelationshipProperties>

  Inherited from Serializable.getDefaults

### getRelatedFeatures

- getRelatedFeatures(feature, options?): Promise<FeatureSet>

- Gets features that are related to the given feature.

  #### Parameters

  - feature: Feature
  - `Optional` options: FetchRelatedFeaturesOptions

  #### Returns Promise<FeatureSet>

### getSerializableProperties

- getSerializableProperties(serializeMode?): PropertyDefs<RelationshipProperties>

- Returns the serializable properties.

  #### Parameters

  - `Optional` serializeMode: SerializeMode

    Optional. If specified, only properties that support the given serialization mode will be returned.

  #### Returns PropertyDefs<RelationshipProperties>

  Inherited from Serializable.getSerializableProperties

### toItemUri

- toItemUri(): string

- Creates an item:// URI reference to this entity.

  #### Returns string

  Inherited from Entity.toItemUri

### toJSON

- toJSON(serializeMode?): Partial<RelationshipProperties>

- Returns a serializable representation of the item.

  #### Parameters

  - `Optional` serializeMode: SerializeMode

    If specified, only properties that are appropriate for the given mode are returned. Otherwise, all properties will be serialized.

  #### Returns Partial<RelationshipProperties>

  Inherited from Serializable.toJSON