import RelationshipQuery from "@arcgis/core/rest/support/RelationshipQuery.js";const RelationshipQuery = await $arcgis.import("@arcgis/core/rest/support/RelationshipQuery.js");- Inheritance:
- RelationshipQuery→
Accessor
- 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.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
declaredClass readonly inherited | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| | ||
| |
cacheHint
- 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.
geometryPrecision
- Type
- number
Specify the number of decimal places for the geometries returned by the query operation.
historicMoment
The historic moment to query. This parameter applies only if the supportsHistoricMoment
on FeatureLayer.capabilities property of the layer is set to true.
maxAllowableOffset
- 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
- 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.
orderByFields
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
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
- 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
- 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
- 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
- Type
- boolean
If true, and returnGeometry is true, then m-values are included in the geometry.
returnTrueCurves
- 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.
returnZ
- Type
- boolean
If true, and returnGeometry is true, then z-values are included in the geometry.
Methods
fromJSON
- Signature
-
fromJSON (json: any): any
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
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | 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
- 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
- Signature
-
toJSON (): any
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.