FRAMES | NO FRAMES
Data Source Object

Overview

This is supported from 10.1 onwards.

This document discusses the JSON representation of a dataSource object. A dataSource is a table, feature class, or raster that resides in a registered workspace (either a folder or geodatabase).

The following dataSource objects are discussed here:

Table data source

Table data source is a table, feature class, or raster that resides in a registered workspace (either a folder or geodatabase). In case of a geodatabase, if versioned use version to switch to an alternate geodatabase version. If version is empty or missing, then the registered geodatabase version will be used.

JSON Syntax

{
   "type": "table",
   "workspaceId": "<registered workspace id>",
   "dataSourceName": "<table name>",
   "gdbVersion": "<version name>"
}

JSON Example

{
   "type": "table",
   "workspaceId": "MAP",
   "dataSourceName": "MAP.user1.Taxlots",
   "gdbVersion": "MAP.Version1"
}

Query table data source

A queryTable is a layer/table that is defined by a SQL query. Query layers allow both spatial and nonspatial information stored in a DBMS to be easily integrated into map service operations. Since queryTable uses SQL to directly query database tables and views, spatial information used by a queryTable is not required to be in a geodatabase.

Note:

JSON Syntax

 {
   "type": "queryTable",
   "workspaceId": "<registered workspace id>",
   "query": "<SQL query>",
   "oidFields": "<field1>,<field2>,<field3>",
   "geometryType": "<esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon>",
   "spatialReference": {<spatial reference>}
 }

JSON Example

 {
   "type": "queryTable",
   "workspaceId": "SqlMAP",
   "query": "SELECT * FROM TaxLots",
   "oidFields": "taxlotid",
   "geometryType": "esriGeometryPolygon",
   "spatialReference": {"wkid": 4326}
 }

Raster data source

Raster data source is a file-based raster that resides in a registered raster workspace.

JSON Syntax

{
   "type": "raster",
   "workspaceId": "<registered workspace id>",
   "dataSourceName": "<raster name>"
}

JSON Example

{
   "type": "raster",
   "workspaceId": "rasterWS",
   "dataSourceName": "NewOrleans.tif"
}

Join Table data source

joinTable data source is the result of a join operation. Nested joins are supported. To use nested joins set either of leftTableSource or rightTableSource to be a joinTable.

Note:

JSON Syntax

{
   "type": "joinTable",
   "leftTableSource": <layerSource>,
   "rightTableSource": <layerSource>,
   "leftTableKey": "<field name from left table>",
   "rightTableKey": "<field name from right table>",
   "joinType": "<esriLeftOuterJoin | esriLeftInnerJoin>"
}

JSON Example

{
   "type": "joinTable",
   "leftTableSource": 
   {
      "type": "mapLayer",
      "mapLayerId": 0
   },
   "rightTableSource":
   {
      "type": "dataLayer",
      "dataSource":
      {
         "type": "table",
         "workspaceId": "MAP",
         "dataSourceName": "MAP.user1.TaxLots",
         "gdbVersion": "MAP.Version1"
      }
   },
   "leftTableKey": "STATE_FIPS",
   "rightTableKey": "FIPS",
   "joinType": "esriLeftOuterJoin"
}