Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: QueryDataSource

require(["esri/layers/QueryDataSource"], function(QueryDataSource) { /* code goes here */ });

Description

(Added at v2.7)
The QueryDataSource class defines and provides information about a layer or table that is defined by a SQL query. The geometry storage format determines the capabilities of the QueryDataSource. If the data source stores the geometry in the database native format the return value is a layer that supports all operations supported by a dynamic layer. If the data source stores geometry in a non-native format the result is a table that can be used to perform query operations.

See also

Samples

Search for samples that use this class.

Class hierarchy

esri/layers/DataSource
|_esri/layers/QueryDataSource

Constructors

NameSummary
new QueryDataSource(json?)Creates a new QueryDataSource object.

Properties

NameTypeSummary
geometryTypeStringThe geometry type of the data source.
oidFieldsString[]An array of field names that define a unique identifier for the feature.
queryStringThe SQL query string that defines the data source output.
spatialReferenceSpatialReferenceThe spatial reference for the data source.
workspaceIdStringThe workspace id for the registered file geodatabase, SDE or Shapefile workspace.

Methods

NameReturn typeSummary
toJson()ObjectConverts object to its ArcGIS Server JSON representation.
Constructor Details

new QueryDataSource(json?)

Creates a new QueryDataSource object.
Parameters:
<Object> json Optional JSON object representing the QueryDataSource.
Sample:
require([
  "esri/layers/QueryDataSource", ... 
], function(QueryDataSource, ... ) {
  var dataSource = new QueryDataSource();
  ...
});
Property Details

<String> geometryType

The geometry type of the data source. Required if the specified data source has a geometry column.
Known values: 'point' | 'multipoint' | 'line' | 'polygon'
Sample:

dataSource.geometryType = "polygon";

<String[]> oidFields

An array of field names that define a unique identifier for the feature. The combiniation of one or more fields will be used to generate a unique identifier for the feature.
Sample:

dataSource.oidFields = ["TaxLotId"];

<String> query

The SQL query string that defines the data source output.
Sample:

dataSource.query = "SELECT * FROM sde.sde.states_geom";

<SpatialReference> spatialReference

The spatial reference for the data source. Required if the specified data source has a geometry column.
Sample:
require([
  "esri/layers/QueryDataSource", "esri/SpatialReference", ... 
], function(QueryDataSource, SpatialReference, ... ) {
  var dataSource = new QueryDataSource( ... );
  dataSource.spatialReference = new SpatialReference({
    wkid: 4269
  });
  ...
});

<String> workspaceId

The workspace id for the registered file geodatabase, SDE or Shapefile workspace.
Sample:

dataSource.workspaceId = "d203_db";

Method Details

toJson()

Converts object to its ArcGIS Server JSON representation.
Return type: Object
Show Modal