# Class QueryBasedRelationship<TProperties>

A data/_Relationship!Relationship that works by querying the related source for features.

#### Type Parameters

- TProperties extends QueryBasedRelationshipProperties = QueryBasedRelationshipProperties

#### Hierarchy (view full)

- RelationshipBase<TProperties>
  - QueryBasedRelationship

#####
Index

### Constructors

constructor

### Properties

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

### Accessors

failureMode
id
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 QueryBasedRelationship<TProperties>(properties): QueryBasedRelationship<TProperties>

- #### Type Parameters

  - TProperties extends QueryBasedRelationshipProperties = QueryBasedRelationshipProperties

  #### Parameters

  - properties: TProperties

  #### Returns QueryBasedRelationship<TProperties>

  Overrides RelationshipBase.constructor

##
Properties

### `Protected` `Readonly`_handles

_handles: Handles<unknown, ResourceHandle>

Inherited from RelationshipBase._handles

### `Protected`_id

_id: string

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

Inherited from RelationshipBase._id

### `Protected` `Readonly`_itemType

_itemType: string = ItemType.RELATIONSHIP

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

Inherited from RelationshipBase._itemType

### `Protected`_source

_source: FeatureSource

#### Inherit Doc

Inherited from RelationshipBase._source

### @eventTypes

@eventTypes: InitializableBaseEvents

#### Deprecated

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

Inherited from RelationshipBase.@eventTypes

### `Readonly` cardinality

cardinality: Cardinality

The cardinality of the relationship.

Overrides RelationshipBase.cardinality

### `Readonly` keyField

keyField: string

The key field in the source.

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

### `Readonly` relatedKeyField

relatedKeyField: string

The key field in the related source.

### `Readonly` relatedSource

relatedSource: FeatureSource

The feature source with related data, if available.

Overrides RelationshipBase.relatedSource

### `Readonly` relationshipType

relationshipType: string = "QueryBasedRelationship"

The type of relationship.

Overrides RelationshipBase.relationshipType

### title

title: string

The human-readable name for the relationship.

Inherited from RelationshipBase.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 RelationshipBase.failureMode

- set failureMode(value): void

- #### Parameters

  - value: FailureMode

  #### Returns void

  Inherited from RelationshipBase.failureMode

### id

- get id(): string

- The unique ID for this entity.

  #### Returns string

  Inherited from RelationshipBase.id

### isDestroyed

- get isDestroyed(): boolean

- See support/InitializableBase!Initializable.isDestroyed.

  #### Returns boolean

  Inherited from RelationshipBase.isDestroyed

### isInitialized

- get isInitialized(): boolean

- See support/InitializableBase!Initializable.isInitialized.

  #### Returns boolean

  Inherited from RelationshipBase.isInitialized

### itemType

- get itemType(): string

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

  #### Returns string

  Inherited from RelationshipBase.itemType

### source

- get source(): FeatureSource

- The feature source that owns this relationship.

  #### Returns FeatureSource

  Inherited from RelationshipBase.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 RelationshipBase._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 RelationshipBase._getRelatedFeatures

### `Protected`_getSerializableProperties

- _getSerializableProperties(): PropertyDefs<TProperties>

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

  #### Returns PropertyDefs<TProperties>

  Overrides RelationshipBase._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 RelationshipBase._initializableChildCollections

### `Protected`_initializeChildren

- _initializeChildren(): Promise<void>

- Initializes child entities.

  #### Returns Promise<void>

  Inherited from RelationshipBase._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 RelationshipBase._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 RelationshipBase._onInitialize

### `Protected`_postInitialize

- _postInitialize(): Promise<void>

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

  #### Returns Promise<void>

  Inherited from RelationshipBase._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 RelationshipBase._toPropertyDef

### assignProperties

- assignProperties(properties): void

- Sets the properties for this item.

  #### Parameters

  - properties: Partial<TProperties>

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

  #### Returns void

  Inherited from RelationshipBase.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<TProperties>

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

  #### Returns Promise<void>

  Inherited from RelationshipBase.assignPropertiesAsync

### destroy

- destroy(): Promise<void>

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

  #### Returns Promise<void>

  Inherited from RelationshipBase.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 RelationshipBase.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 RelationshipBase.getAllRelatedFeatures

### getDefault

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

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

  #### Type Parameters

  - K extends string | number | symbol

  #### Parameters

  - key: K

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

  #### Returns TProperties[K]

  Inherited from RelationshipBase.getDefault

### getDefaults

- getDefaults(): TProperties

- Gets the object's default property values.

  #### Returns TProperties

  Inherited from RelationshipBase.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 RelationshipBase.getRelatedFeatures

### getSerializableProperties

- getSerializableProperties(serializeMode?): PropertyDefs<TProperties>

- Returns the serializable properties.

  #### Parameters

  - `Optional` serializeMode: SerializeMode

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

  #### Returns PropertyDefs<TProperties>

  Inherited from RelationshipBase.getSerializableProperties

### initialize

- initialize(): Promise<void>

- Initializes the item.

  #### Returns Promise<void>

  Inherited from RelationshipBase.initialize

### toItemUri

- toItemUri(): string

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

  #### Returns string

  Inherited from RelationshipBase.toItemUri

### toJSON

- toJSON(serializeMode?): TProperties

- 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 TProperties

  Inherited from RelationshipBase.toJSON