Skip to content
import RelationshipQuery from "@arcgis/core/rest/support/RelationshipQuery.js";
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 executeRelationshipQuery() and FeatureLayer.queryRelatedFeatures() methods, which will return FeatureSets grouped by source layer/table objectIds.

See also

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

cacheHint

Property
Type
boolean | null | undefined
Since
ArcGIS Maps SDK for JavaScript 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.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

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

gdbVersion

Property
Type
string | null | undefined

Specify the geodatabase version to query.

geometryPrecision

Property
Type
number

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

historicMoment

autocast Property
Type
Date | null | undefined

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

maxAllowableOffset

Property
Type
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 View.spatialReference of the view is used.

num

Property
Type
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
Type
ObjectId[] | null | undefined

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

orderByFields

Property
Type
string[] | null | undefined

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.

See also
Example
query.orderByFields = ["STATE_NAME DESC"];

outFields

Property
Type
string[] | null | undefined

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

autocast Property
Type
SpatialReference | null | undefined

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

relationshipId

Property
Type
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
Type
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
Type
boolean

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

returnTrueCurves

Property
Type
boolean | null | undefined
Since
ArcGIS Maps SDK for JavaScript 5.0

When true output geometry will include curves. If false, curves (if any) will be converted to densified polylines or polygons.

This option only applies when returnGeometry is set to true and the output geometry is non-quantized polylines or polygons.

See also

returnZ

Property
Type
boolean

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

start

Property
Type
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
Type
string | null | undefined

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.

Methods

MethodSignatureClass
fromJSON
inherited static
fromJSON(json: any): any
clone(): RelationshipQuery
toJSON
inherited
toJSON(): any

fromJSON

inheritedstatic Method
Signature
fromJSON (json: any): any
Inherited from: JSONSupportMixin

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.

Parameters
ParameterTypeDescriptionRequired
json
any

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
any

Returns a new instance of this class.

clone

Method
Signature
clone (): RelationshipQuery

Creates a deep clone of RelationshipQuery object.

Returns
RelationshipQuery

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

toJSON

inherited Method
Signature
toJSON (): any
Inherited from: JSONSupportMixin

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

Returns
any

The ArcGIS portal JSON representation of an instance of this class.