Class: Query

nyc/soda/Query~ Query


new Query(options)

A class for querying NYC OpenData using the SocrataJson SODA API

Parameters:
Name Type Description
options module:nyc/soda/Query~Query.Options

Constructor options

Source:
See:

Methods


<static> and(where, clause)

Append to a where clause with AND

Parameters:
Name Type Description
where string

The current where clause

clause string

The new clause to append to the current where clause

Source:
Returns:

The modified where clause

Type
string

addFilter(field, filter)

Add a filter to the query

Parameters:
Name Type Description
field string

The field to which the filter will be applied

filter module:nyc/soda/Query~Query.Filter

The filter to apply to the field

Source:

clearAllFilters()

Clear all filters on all fields

Source:

clearFilters(field)

Clear all filters on specified field

Parameters:
Name Type Description
field string

The field to which the filter will be cleared

Source:

execute(options)

Execute the query

Parameters:
Name Type Description
options module:nyc/soda/Query~Query.Options

The execution options

Source:
Returns:

Promise

Type
Promise

getUrlAndQuery()

Get the SODA API call URL that was last requested or will be requested with the current query and filter settings

Source:
Returns:

The SODA API call URL

Type
string

setAppToken(appToken)

Set app token for SODA api request

Parameters:
Name Type Description
appToken string

Authentication token for SODA api

Source:

setFilter(field, filter)

Overwrite a filter for the query

Parameters:
Name Type Description
field string

The field to which the filter will be applied

filter module:nyc/soda/Query~Query.Filter

The filter to apply to the field

Source:

setFilters(filters)

Overwrite all filters for the query

Parameters:
Name Type Description
filters Object.<string, Array.<module:nyc/soda/Query~Query.Filter>>

Filter arrays mapped to field names

Source:

setQuery(q)

Set the base query to which filters can be added

Parameters:
Name Type Description
q module:nyc/soda/Query~Query.Query

the query

Source:

Type Definitions


Filter

Filter object for module:nyc/soda/Query~Query

Type:
  • Object
Properties:
Name Type Description
op string

Filter operator (=, !=, >, <, >=, <=, IN, NOT IN, BETWEEN, NOT BETWEEN)

value string | number | Array.<string> | Array.<number>

Filter value

Source:

Options

Constructor options for module:nyc/soda/Query~Query

Type:
  • Object
Properties:
Name Type Argument Description
url string <optional>

SODA URL

appToken string <optional>

SODA $$app_token parameter

query module:nyc/soda/Query~Query.Query <optional>

Query options

filters Object.<string, Array.<module:nyc/soda/Query~Query.Filter>> <optional>

Filter arrays mapped to field names

Source:

Query

Query object for module:nyc/soda/Query~Query

Type:
  • Object
Properties:
Name Type Argument Description
select string <optional>

SODA $select parameter

where string <optional>

SODA $where parameter

group string <optional>

SODA $group parameter

order string <optional>

SODA $order parameter

limit number <optional>

SODA $limit parameter

Source: