# Class ArcGISRelationship

A data/_Relationship!Relationship that works by querying the queryRelatedRecords endpoint of a FeatureLayer, Table, or ArcGIS Sublayer.

#### Hierarchy (view full)

- QueryBasedRelationship<ArcGISRelationshipProperties>
  - ArcGISRelationship

#####
Index

### Constructors

constructor

### Properties

_handles
_id
_itemType
_source
@eventTypes
cardinality
destinationForeignKey
keyField
originForeignKey
queryService
relatedKeyField
relatedSource
relationshipTableId
relationshipType
title

### Accessors

failureMode
id
isAttributed
isDestroyed
isInitialized
itemType
source

### Methods

_getAllRelatedFeatures
_getRelatedFeatures
_getSerializableProperties
_initializableChildCollections
_initializeChildren
_onDestroy
_onInitialize
_postInitialize
_toPropertyDef
assignProperties
assignPropertiesAsync
destroy
finishAssignProperties
getAllRelatedFeatures
getDefault
getDefaults
getRelatedFeatures
getSerializableProperties
initialize
toItemUri
toJSON

##
Constructors

### constructor

- new ArcGISRelationship(properties): ArcGISRelationship

- #### Parameters

  - properties: ArcGISRelationshipProperties

  #### Returns ArcGISRelationship

  Overrides QueryBasedRelationship.constructor

##
Properties

### `Protected` `Readonly`_handles

_handles: Handles<unknown, ResourceHandle>

Inherited from QueryBasedRelationship._handles

### `Protected`_id

_id: string

The unique ID for this entity. Once set, this should never change.

Inherited from QueryBasedRelationship._id

### `Protected` `Readonly`_itemType

_itemType: string = ItemType.RELATIONSHIP

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

Inherited from QueryBasedRelationship._itemType

### `Protected`_source

_source: FeatureSource

#### Inherit Doc

Inherited from QueryBasedRelationship._source

### @eventTypes

@eventTypes: InitializableBaseEvents

#### Deprecated

Do not directly reference this property. Use EventNames and EventTypes helpers from @arcgis/core/Evented.

Inherited from QueryBasedRelationship.@eventTypes

### `Readonly` cardinality

cardinality: Cardinality

The cardinality of the relationship.

Inherited from QueryBasedRelationship.cardinality

### `Readonly` destinationForeignKey

destinationForeignKey: string

In attributed relationships, this is the foreign key in the intermediate table that relates the rows of the intermediate table to the destination layer or table. This property will only be exposed if the relationship is attributed.

### `Readonly` keyField

keyField: string

The key field in the source.

Inherited from QueryBasedRelationship.keyField

### `Readonly` originForeignKey

originForeignKey: string

In an attributed relationship, originForeignKey is the foreign key in the intermediate table, which relates the rows of the intermediate table to the origin layer or table. This property will only be exposed if the relationship is attributed.

### queryService

queryService: QueryService

The tasks/query/QueryService!QueryService to use for fetching related features. The service must be configured with a provider that can handle the related source.

Inherited from QueryBasedRelationship.queryService

### `Readonly` relatedKeyField

relatedKeyField: string

The key field in the related source.

Inherited from QueryBasedRelationship.relatedKeyField

### `Readonly` relatedSource

relatedSource: FeatureSource

The feature source with related data, if available.

Inherited from QueryBasedRelationship.relatedSource

### `Readonly` relationshipTableId

relationshipTableId: number

The ID of the intermediate table in the feature service for attributed relationships. This property will only be exposed if the relationship is attributed.

### `Readonly` relationshipType

relationshipType: string = "ArcGISRelationship"

The type of relationship.

Overrides QueryBasedRelationship.relationshipType

### title

title: string

The human-readable name for the relationship.

Inherited from QueryBasedRelationship.title

##
Accessors

### failureMode

- get failureMode(): FailureMode

- Determines how a parent object should handle initialization failure in this object. The default is "warn".

  - `"error"`: support/InitializeError!InitializeError is thrown.
  - `"warn"`: Message is logged and support/InitializableBase!InitializeWarningEvent is raised.
  - `"ignore"`: support/InitializableBase!InitializeWarningEvent is raised.

  #### Returns FailureMode

  Inherited from QueryBasedRelationship.failureMode

- set failureMode(value): void

- #### Parameters

  - value: FailureMode

  #### Returns void

  Inherited from QueryBasedRelationship.failureMode

### id

- get id(): string

- The unique ID for this entity.

  #### Returns string

  Inherited from QueryBasedRelationship.id

### isAttributed

- get isAttributed(): boolean

- Whether the relationship is attributed.

  #### Returns boolean

### isDestroyed

- get isDestroyed(): boolean

- See support/InitializableBase!Initializable.isDestroyed.

  #### Returns boolean

  Inherited from QueryBasedRelationship.isDestroyed

### isInitialized

- get isInitialized(): boolean

- See support/InitializableBase!Initializable.isInitialized.

  #### Returns boolean

  Inherited from QueryBasedRelationship.isInitialized

### itemType

- get itemType(): string

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

  #### Returns string

  Inherited from QueryBasedRelationship.itemType

### source

- get source(): FeatureSource

- The feature source that owns this relationship.

  #### Returns FeatureSource

  Inherited from QueryBasedRelationship.source

##
Methods

### `Protected`_getAllRelatedFeatures

- _getAllRelatedFeatures(features, options?): Promise<Map<Feature, FeatureSet>>

- Called to get related features. Subclasses must override this.

  #### Parameters

  - features: Feature[]
  - `Optional` options: FetchRelatedFeaturesOptions

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

  Overrides QueryBasedRelationship._getAllRelatedFeatures

### `Protected`_getRelatedFeatures

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

- Called to get related features. Subclasses must override this.

  #### Parameters

  - feature: Feature
  - `Optional` options: FetchRelatedFeaturesOptions

  #### Returns Promise<FeatureSet>

  Overrides QueryBasedRelationship._getRelatedFeatures

### `Protected`_getSerializableProperties

- _getSerializableProperties(): PropertyDefs<ArcGISRelationshipProperties>

- The property keys and their metadata that are used to implement serializing and deserializing the class instance.

  #### Returns PropertyDefs<ArcGISRelationshipProperties>

  Overrides QueryBasedRelationship._getSerializableProperties

### `Protected`_initializableChildCollections

- _initializableChildCollections(): IterableIterator<Collection<InitializableBase<InitializableBaseProperties>>, any, any>

- Collections of child items to initialize. Items that fail to initialize are removed from the collection.

  #### Returns IterableIterator<Collection<InitializableBase<InitializableBaseProperties>>, any, any>

  Inherited from QueryBasedRelationship._initializableChildCollections

### `Protected`_initializeChildren

- _initializeChildren(): Promise<void>

- Initializes child entities.

  #### Returns Promise<void>

  Inherited from QueryBasedRelationship._initializeChildren

### `Protected`_onDestroy

- _onDestroy(): Promise<void>

- Called to perform cleanup. Subclasses should override this method rather than destroy() to perform custom cleanup.

  #### Returns Promise<void>

  Inherited from QueryBasedRelationship._onDestroy

### `Protected`_onInitialize

- _onInitialize(): Promise<void>

- Called to perform initialization of the support/InitializableBase!InitializableBase. Subclasses should override this method rather than initialize() to perform custom initialization.

  #### Returns Promise<void>

  Inherited from QueryBasedRelationship._onInitialize

### `Protected`_postInitialize

- _postInitialize(): Promise<void>

- Called after normal initialization. Note: Child items are initialized before this is called.

  #### Returns Promise<void>

  Inherited from QueryBasedRelationship._postInitialize

### `Protected`_toPropertyDef

- _toPropertyDef<T>(def): PropertyDef<T>

- Converts the value to a PropertyDef object.

  #### Type Parameters

  - T

  #### Parameters

  - def: PropertyDefSerializeMode | PropertyDefSerializeMode[] | PropertyDef<T>

    The value to convert.

  #### Returns PropertyDef<T>

  Inherited from QueryBasedRelationship._toPropertyDef

### assignProperties

- assignProperties(properties): void

- Sets the properties for this item.

  #### Parameters

  - properties: Partial<ArcGISRelationshipProperties>

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

  #### Returns void

  Inherited from QueryBasedRelationship.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<ArcGISRelationshipProperties>

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

  #### Returns Promise<void>

  Inherited from QueryBasedRelationship.assignPropertiesAsync

### destroy

- destroy(): Promise<void>

- A clean-up function that should get called whenever the item is disposed of.

  #### Returns Promise<void>

  Inherited from QueryBasedRelationship.destroy

### 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 QueryBasedRelationship.finishAssignProperties

### getAllRelatedFeatures

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

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

  #### Parameters

  - features: FeatureSet | FeatureStream | Feature[]
  - `Optional` options: FetchRelatedFeaturesOptions

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

  Inherited from QueryBasedRelationship.getAllRelatedFeatures

### getDefault

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

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

  #### Type Parameters

  - K extends keyof ArcGISRelationshipProperties

  #### Parameters

  - key: K

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

  #### Returns ArcGISRelationshipProperties[K]

  Inherited from QueryBasedRelationship.getDefault

### getDefaults

- getDefaults(): ArcGISRelationshipProperties

- Gets the object's default property values.

  #### Returns ArcGISRelationshipProperties

  Inherited from QueryBasedRelationship.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>

  Inherited from QueryBasedRelationship.getRelatedFeatures

### getSerializableProperties

- getSerializableProperties(serializeMode?): PropertyDefs<ArcGISRelationshipProperties>

- Returns the serializable properties.

  #### Parameters

  - `Optional` serializeMode: SerializeMode

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

  #### Returns PropertyDefs<ArcGISRelationshipProperties>

  Inherited from QueryBasedRelationship.getSerializableProperties

### initialize

- initialize(): Promise<void>

- Initializes the item.

  #### Returns Promise<void>

  Inherited from QueryBasedRelationship.initialize

### toItemUri

- toItemUri(): string

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

  #### Returns string

  Inherited from QueryBasedRelationship.toItemUri

### toJSON

- toJSON(serializeMode?): ArcGISRelationshipProperties

- Returns a serializable representation of the item.

  #### Parameters

  - serializeMode: SerializeMode = "all"

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

  #### Returns ArcGISRelationshipProperties

  Inherited from QueryBasedRelationship.toJSON