require(["esri/rest/support/RelationshipQuery"], (RelationshipQuery) => { /* code goes here */ });
import RelationshipQuery from "@arcgis/core/rest/support/RelationshipQuery.js";
esri/rest/support/RelationshipQuery
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
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
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 | RelationshipQuery | ||
If | RelationshipQuery | ||
If | 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
cacheHint Boolean
Since: ArcGIS Maps SDK for JavaScript 4.24RelationshipQuery 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
-
gdbVersion
gdbVersion String
-
Specify the geodatabase version to query.
-
geometryPrecision
geometryPrecision Number
-
Specify the number of decimal places for the geometries returned by the query operation.
-
historicMoment
historicMoment Date
-
The historic moment to query. This parameter applies only if the
supportsHistoricMoment
on FeatureLayer property of the layer is set totrue
.
-
maxAllowableOffset
maxAllowableOffset Number
-
The maximum allowable offset used for generalizing geometries returned by the query operation. The offset is in the units of
outSpatialReference
. IfoutSpatialReference
is not defined, the spatialReference of the view is used.
-
num
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 ofnum
is 10. If neithernum
norstart
properties are provided, then the default value ofnum
is equal to themaxRecordCount
of the service, which can be found at the REST endpoint of the FeatureLayer.
-
An array of objectIds for the features in the layer/table being queried.
-
One or more field names used to order the query results. Specify
ASC
(ascending) orDESC
(descending) after the field name to control the order. The default order isASC
.Known Limitations
- If querying a MapImageLayer, then
supportsAdvancedQueries
must betrue
on the service. - For FeatureLayer,
FeatureLayer.capabilities.queryRelated.supportsOrderBy
must betrue
.
- See also
Examplequery.orderByFields = ["STATE_NAME DESC"];
- If querying a MapImageLayer, then
-
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.
Examplequery.outFields = [ "NAME", "STATE_ABBR", "POP04" ];
-
outSpatialReference
outSpatialReference SpatialReferenceautocast
-
The spatial reference for the returned geometry. If
outSpatialReference
is not defined, the spatialReference of the view is used.
-
relationshipId
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
returnGeometry Boolean
-
If
true
, each feature in the FeatureSet includes the geometry. Set tofalse
(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
returnM Boolean
-
If
true
, and returnGeometry istrue
, then m-values are included in the geometry.
-
returnZ
returnZ Boolean
-
If
true
, and returnGeometry istrue
, then z-values are included in the geometry.
Method Overview
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
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor 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();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey 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
clone(){RelationshipQuery}
-
Creates a deep clone of RelationshipQuery object.
ReturnsType Description RelationshipQuery A new instance of a RelationshipQuery object equal to the object used to call .clone()
.
-
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.Parameterjson ObjectA 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.
ReturnsType Description * Returns a new instance of this class.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType 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"); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
toJSON
toJSON(){Object}
-
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
ReturnsType Description Object The ArcGIS portal JSON representation of an instance of this class.