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 |
Methods
-
<static> and(where, clause)
-
Append to a where clause with AND
Parameters:
Name Type Description wherestring The current where clause
clausestring 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 fieldstring The field to which the filter will be applied
filtermodule: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 fieldstring The field to which the filter will be cleared
- Source:
-
execute(options)
-
Execute the query
Parameters:
Name Type Description optionsmodule: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 appTokenstring Authentication token for SODA api
- Source:
-
setFilter(field, filter)
-
Overwrite a filter for the query
Parameters:
Name Type Description fieldstring The field to which the filter will be applied
filtermodule: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 filtersObject.<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 qmodule:nyc/soda/Query~Query.Query the query
- Source:
Type Definitions
-
Filter
-
Filter object for module:nyc/soda/Query~Query
Type:
- Object
- Source:
Properties:
Name Type Description opstring Filter operator (=, !=, >, <, >=, <=, IN, NOT IN, BETWEEN, NOT BETWEEN)
valuestring | number | Array.<string> | Array.<number> Filter value
-
Options
-
Constructor options for module:nyc/soda/Query~Query
Type:
- Object
- Source:
Properties:
Name Type Argument Description urlstring <optional>
SODA URL
appTokenstring <optional>
SODA $$app_token parameter
querymodule:nyc/soda/Query~Query.Query <optional>
Query options
filtersObject.<string, Array.<module:nyc/soda/Query~Query.Filter>> <optional>
Filter arrays mapped to field names
-
Query
-
Query object for module:nyc/soda/Query~Query
Type:
- Object
- Source:
Properties:
Name Type Argument Description selectstring <optional>
SODA $select parameter
wherestring <optional>
SODA $where parameter
groupstring <optional>
SODA $group parameter
orderstring <optional>
SODA $order parameter
limitnumber <optional>
SODA $limit parameter