Class: Dao maps.nyc.gov

nyc.carto.Dao

new Dao(cartoSql, sqlTemplate, filters)

CartoDB data access class
Parameters:
Name Type Description
cartoSql cartodb.SQL The object used to query CartoDB data
sqlTemplate string The template with optional replacement tokens for generating queries for cartoSql
filters Object.<string, string> The filters used with the sqlTemplate for generating queries for cartoSql
Source:

Extends

Methods

data(filterValues, callback)

Parameters:
Name Type Description
filterValues Object.<string, Object.<string, string>> The values object used along with the views filters and sqlTemlate to modify the query for this view
callback function The callback function to receive data from CartoDB
Source:

replace(str, values) → {string}

Replace tokens in a string with values from a provided object
Parameters:
Name Type Description
str string String with tokens to be replaced
values Object.<string, string> Values token for replacement
Inherited From:
Source:
Returns:
String with replacement value substitution
Type
string

sql(template, values, filtersopt) → {string}

Parameters:
Name Type Attributes Description
template string The SQL template with optional replacement tokens
values Object.<string, Object.<string, string>> The replacement values
filters Object.<string, string> <optional>
The filters to append to the WHERE clause (i.e. )
Inherited From:
Source:
Returns:
The SQL statement
Type
string
Example
var template = "SELECT * FROM bike WHERE ${where}";
var values =  {
  color: {value: "red"},
  gear: {low: 10, high: 18}
};
var filters = {
  color: "color = '${value}'",
  gear: "gear BETWEEN ${low} AND ${high}"
};
var sqlTmpl = nyc.carto.SqlTemplate();
sqlTmpl.sql(template, values, filters);
//Returns "SELECT * FROM bike WHERE color = 'red' AND gear BETWEEN 10 AND 18"