require(["esri/core/sql"], function(sql) { /* code goes here */ });
Object: esri/core/sql
Since: ArcGIS API for JavaScript 4.14

Creates a WhereClause expression that adheres to standardized SQL expressions. SQL expression is a combination of one or more values, operators and SQL functions that results in to a value.

Method Overview

NameReturn TypeSummaryObject
Promise<WhereClause>

Parses the given where clause string and returns an instance of WhereClause when resolved.

more details
more detailssql

Method Details

parseWhereClause(clause, fieldsIndex){Promise<WhereClause>}

Parses the given where clause string and returns an instance of WhereClause when resolved. The WhereClause object can be used repeatedly against different features, to test if they individually meet the condition. The parser does not parse a whole SQL statement (ie. SELECT X… WHERE…). It only parses the expression after the where token.

Parameters:
clause String

The SQL where clause expression.

fieldsIndex FieldsIndex

The fields index of the layer. The fields index is used to match the fields found in the where clause against the service, to fix casing for example.

Returns:
TypeDescription
Promise<WhereClause>Parses a string where clause and returns a promise that resolves to an object with the WhereClause specification.
Example:
sql.parseWhereClause("POPULATION > 100000", layer.fieldsIndex)
.then(function(clause){
  var testResult = clause.testFeature(new Graphic({
    attributes: {
      POPULATION: 300000
   }
 });
 console.log(testResult); // prints true
});

API Reference search results

NameTypeModule
Loading...