Skip to main content

Query

Task for querying features from ArcGIS Feature Services with advanced filtering, spatial queries, and aggregation capabilities.

Constructor

new Query(options: QueryOptions)
ArgumentTypeDescription
optionsQueryOptionsConfiguration options for the query operation

Options

OptionTypeDefaultDescription
urlstringRequired Feature Service or Map Service layer URL
wherestring'1=1'SQL WHERE clause
outFieldsArray<string> | string'*'Fields to return
geometryobjectSpatial filter geometry
geometryTypestringType of geometry filter
spatialRelstring'esriSpatialRelIntersects'Spatial relationship
returnGeometrybooleantrueInclude feature geometry
returnCountOnlybooleanfalseReturn only feature count
returnIdsOnlybooleanfalseReturn only object IDs
orderByFieldsArray<string>Sort order for results
groupByFieldsForStatisticsArray<string>Fields for grouping statistics
outStatisticsArray<object>Statistical operations to perform
resultOffsetnumberOffset for pagination
resultRecordCountnumberMaximum number of features
tokenstringAuthentication token

Chainable Methods

All methods return the task instance for chaining:

query.where("STATE_NAME = 'California'").outFields(['NAME', 'POP2000'])
MethodDescription
where(clause)Set SQL WHERE clause
outFields(fields)Set output fields
geometry(geom)Set spatial filter geometry
spatialRel(relationship)Set spatial relationship
returnGeometry(boolean)Include geometry in results
orderBy(fields)Set sort order
limit(count)Set maximum result count
offset(number)Set result offset for pagination
token(token)Set authentication token

Execution Methods

.run()

Execute the query with current parameters.

Returns: Promise<FeatureCollection>

.count()

Get the count of features matching the query.

Returns: Promise<number>

.ids()

Get only the object IDs of matching features.

Returns: Promise<Array<number>>