RelationshipQuery

AMD: require(["esri/rest/support/RelationshipQuery"], (RelationshipQuery) => { /* code goes here */ });
ESM: import RelationshipQuery from "@arcgis/core/rest/support/RelationshipQuery.js";
Class: esri/rest/support/RelationshipQuery
Inheritance: RelationshipQueryAccessor
Since: ArcGIS Maps SDK for JavaScript 4.20

This class defines parameters for executing queries for related records from a layer. Once a RelationshipQuery object's properties are defined, it can then be passed into the query.executeRelationshipQuery() and FeatureLayer.queryRelatedFeatures() methods, which will return FeatureSets grouped by source layer/table objectIds.

See also

Constructors

RelationshipQuery

Constructor
new RelationshipQuery(properties)
Parameter
properties Object
optional

See the properties for a list of all the properties that may be passed into the constructor.

Property Overview

Any properties can be set, retrieved or listened to. See the Watch for changes topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

Indicates if the service should cache the relationship query results.

RelationshipQuery

The name of the class.

Accessor

Specify the geodatabase version to query.

RelationshipQuery

Specify the number of decimal places for the geometries returned by the query operation.

RelationshipQuery

The historic moment to query.

RelationshipQuery

The maximum allowable offset used for generalizing geometries returned by the query operation.

RelationshipQuery

The number of features to retrieve.

RelationshipQuery

An array of objectIds for the features in the layer/table being queried.

RelationshipQuery

One or more field names used to order the query results.

RelationshipQuery

Attribute fields to include in the FeatureSet.

RelationshipQuery

The spatial reference for the returned geometry.

RelationshipQuery

The ID of the relationship to be queried.

RelationshipQuery

If true, each feature in the FeatureSet includes the geometry.

RelationshipQuery

If true, and returnGeometry is true, then m-values are included in the geometry.

RelationshipQuery

If true, and returnGeometry is true, then z-values are included in the geometry.

RelationshipQuery

The zero-based index indicating where to begin retrieving features.

RelationshipQuery

The definition expression to be applied to the related table or layer.

RelationshipQuery

Property Details

cacheHint

Property
cacheHint Boolean
Since: ArcGIS Maps SDK for JavaScript 4.24 RelationshipQuery since 4.20, cacheHint added at 4.24.

Indicates if the service should cache the relationship query results. It only applies if the layer's capabilities.queryRelated.supportsCacheHint is set to true. Use only for queries that have the same parameters every time the app is used. Some examples of cacheable queries:

  • Queries based on preset input, for example, a drop-down list of US states.
  • Queries based on preset extents, for example bookmarks, in web maps.
Default Value:undefined

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

gdbVersion

Property
gdbVersion String

Specify the geodatabase version to query.

geometryPrecision

Property
geometryPrecision Number

Specify the number of decimal places for the geometries returned by the query operation.

historicMoment

Property
historicMoment Date

The historic moment to query. This parameter applies only if the supportsHistoricMoment on FeatureLayer property of the layer is set to true.

maxAllowableOffset

Property
maxAllowableOffset Number

The maximum allowable offset used for generalizing geometries returned by the query operation. The offset is in the units of outSpatialReference. If outSpatialReference is not defined, the spatialReference of the view is used.

num

Property
num Number

The number of features to retrieve. This option should be used in conjunction with the start property. Use this to implement paging (i.e. to retrieve "pages" of results when querying).

If not provided, but an instance of Query has a start property, then the default value of num is 10. If neither num nor start properties are provided, then the default value of num is equal to the maxRecordCount of the service, which can be found at the REST endpoint of the FeatureLayer.

objectIds

Property
objectIds Array<(number|string)>

An array of objectIds for the features in the layer/table being queried.

orderByFields

Property
orderByFields String[]

One or more field names used to order the query results. Specify ASC (ascending) or DESC (descending) after the field name to control the order. The default order is ASC.

Known Limitations

  • If querying a MapImageLayer, then supportsAdvancedQueries must be true on the service.
  • For FeatureLayer, FeatureLayer.capabilities.queryRelated.supportsOrderBy must be true.
Example
query.orderByFields = ["STATE_NAME DESC"];

outFields

Property
outFields String[]

Attribute fields to include in the FeatureSet. Fields must exist in the map layer. You must list actual field names rather than the alias names. You are, however, able to use the alias names when you display the results.

When specifying the output fields, you should limit the fields to only those you expect to use in the query or the results. The fewer fields you include, the faster the response will be.

Each query must have access to the Shape and ObjectId fields for a layer. However, your list of fields does not need to include these two fields.

Example
query.outFields = [ "NAME", "STATE_ABBR", "POP04" ];

outSpatialReference

Property
outSpatialReference SpatialReferenceautocast

The spatial reference for the returned geometry. If outSpatialReference is not defined, the spatialReference of the view is used.

relationshipId

Property
relationshipId Number

The ID of the relationship to be queried. The ids for the relationships the table or layer participates in are listed in the ArcGIS Services directory. The ID of the relationship to be queried. The relationships that this layer/table participates in are included in the Feature Service Layer resource response. Records in tables/layers corresponding to the related table/layer of the relationship are queried.

returnGeometry

Property
returnGeometry Boolean

If true, each feature in the FeatureSet includes the geometry. Set to false (default) if you do not plan to include highlighted features on a map since the geometry makes up a significant portion of the response.

Default Value:false

returnM

Property
returnM Boolean

If true, and returnGeometry is true, then m-values are included in the geometry.

returnZ

Property
returnZ Boolean

If true, and returnGeometry is true, then z-values are included in the geometry.

start

Property
start Number

The zero-based index indicating where to begin retrieving features. This property should be used in conjunction with num. Use this to implement paging and retrieve "pages" of results when querying. Features are sorted ascending by object ID by default.

where

Property
where String

The definition expression to be applied to the related table or layer. Only records in the list of objectIds that satisfy the definition expression are queried for related records.

Method Overview

Show inherited methods Hide inherited methods
Name Return Type Summary Class

Adds one or more handles which are to be tied to the lifecycle of the object.

Accessor

Creates a deep clone of RelationshipQuery object.

RelationshipQuery
*

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product.

RelationshipQuery

Returns true if a named group of handles exist.

Accessor

Removes a group of handles owned by the object.

Accessor

Converts an instance of this class to its ArcGIS portal JSON representation.

RelationshipQuery

Method Details

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, addHandles added at 4.25.

Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.

// Manually manage handles
const handle = reactiveUtils.when(
  () => !view.updating,
  () => {
    wkidSelect.disabled = false;
  },
  { once: true }
);

this.addHandles(handle);

// Destroy the object
this.destroy();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.

clone

Method
clone(){RelationshipQuery}

Creates a deep clone of RelationshipQuery object.

Returns
Type Description
RelationshipQuery A new instance of a RelationshipQuery object equal to the object used to call .clone().

fromJSON

Method
fromJSON(json){*}static

Creates a new instance of this class and initializes it with values from a JSON object generated from an ArcGIS product. The object passed into the input json parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.

Parameter
json Object

A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.

Returns
Type Description
* Returns a new instance of this class.

hasHandles

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type Description
Boolean Returns true if a named group of handles exist.
Example
// Remove a named group of handles if they exist.
if (obj.hasHandles("watch-view-updates")) {
  obj.removeHandles("watch-view-updates");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

toJSON

Method
toJSON(){Object}

Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.

Returns
Type Description
Object The ArcGIS portal JSON representation of an instance of this class.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.