How to use the cartodb.js.SQL function in cartodb

To help you get started, we’ve selected a few cartodb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CartoDB / cartodb / lib / assets / core / javascripts / cartodb3 / editor / layers / layer-content-views / analyses / data-observatory-metadata.js View on Github external
sync: function (method, model, options) {
    var sql = new cdb.SQL({
      user: this._configModel.get('user_name'),
      sql_api_template: this._configModel.get('sql_api_template'),
      api_key: this._configModel.get('api_key')
    });
    sql.execute(getQueryForGeometryType(this._geometryType)).done(function (data) {
      options.success && options.success(data);
    }).error(function (errors) {
      // console.log("errors:" + errors);
    });
  },
github CartoDB / cartodb / lib / assets / javascripts / builder / editor / layers / layer-content-views / analyses / data-observatory-metadata.js View on Github external
sync: function (method, model, options) {
    var sql = new cdb.SQL({
      user: this._configModel.get('user_name'),
      sql_api_template: this._configModel.get('sql_api_template'),
      api_key: this._configModel.get('api_key')
    });
    sql.execute(getQueryForGeometryType(this._geometryType)).done(function (data) {
      options.success && options.success(data);
    }).error(function (errors) {
      // console.log("errors:" + errors);
    });
  },
github CartoDB / cartodb / lib / assets / core / javascripts / cartodb3 / components / modals / add-widgets / tablestats.js View on Github external
_getPgStats: function (table, callback) {
    var userModel = this.userModel;
    var self = this;
    if (this.tables[table]) {
      if (!_.isEmpty(this.tables[table])) {
        callback(this.tables[table]);
      } else {
        this.queue[table].push(callback);
      }
    } else {
      this.tables[table] = {};
      this.queue[table] = [callback];

      var schema = userModel.getSchemaName();
      var sql = new CDB.SQL({
        user: this.configModel.get('user_name'),
        sql_api_template: this.configModel.get('sql_api_template'),
        api_key: this.configModel.get('api_key')
      });

      sql.execute(
        'with a as (select reltuples from pg_class where relname = \'' + table + '\'), b as (select * from pg_stats where tablename = \'' + table + '\' and schemaname = \'' + schema + '\') select * from a,b',
        null,
        {
          rows_per_page: 40,
          page: 0
        }
      ).done(function (data) {
        data = data || {};
        var rows = data.rows.map(function (r) {
          var count = r.reltuples;
github CartoDB / cartodb / lib / assets / core / javascripts / cartodb3 / components / form-components / editors / fill / input-color / input-qualitative-ramps / main-view.js View on Github external
_fetchColumns: function () {
    if (!this.model.get('attribute')) {
      return;
    }

    if (this._query) {
      this._setViewStatus('loading');

      var sql = new cdb.SQL({
        user: this._configModel.get('user_name'),
        sql_api_template: this._configModel.get('sql_api_template'),
        api_key: this._configModel.get('api_key')
      });

      sql.execute(
        queryTemplate({
          sql: this._query,
          column: this.model.get('attribute'),
          max_values: MAX_VALUES + 1
        }),
        null,
        {
          success: this._onQueryDone.bind(this),
          error: function () {
            this._setViewStatus('error');
github CartoDB / cartodb / lib / assets / core / javascripts / cartodb3 / components / form-components / editors / fill / input-color / input-categories / input-color-categories.js View on Github external
_fetchColumns: function () {
    if (!this.model.get('attribute')) {
      return;
    }

    if (this._query) {
      this._setViewStatus('loading');

      var sql = new CDB.SQL({
        user: this._configModel.get('user_name'),
        sql_api_template: this._configModel.get('sql_api_template'),
        api_key: this._configModel.get('api_key')
      });

      sql.execute(
        queryTemplate({
          sql: this._query,
          column: this.model.get('attribute'),
          max_values: MAX_VALUES + 1
        }),
        null,
        {
          success: this._onQueryDone.bind(this),
          error: function () {
            this._setViewStatus('error');
github CartoDB / cartodb / lib / assets / javascripts / cartodb3 / data / data-observatory / measurement-model.js View on Github external
initialize: function (attrs, options) {
    checkAndBuildOpts(options, REQUIRED_OPTS, this);
    this._querySchemaModel = this._nodeDefModel.querySchemaModel;

    var configModel = options.configModel;
    this.SQL = new cdb.SQL({
      user: configModel.get('user_name'),
      sql_api_template: configModel.get('sql_api_template'),
      api_key: configModel.get('api_key')
    });

    BaseModel.prototype.initialize.call(this, attrs, options);
  },
github CartoDB / cartodb / lib / assets / javascripts / cartodb3 / editor / layers / layer-content-views / analyses / analyses-quota / analyses-quota-info.js View on Github external
initialize: function (models, options) {
    if (!options || !options.configModel) throw new Error('configModel is required');

    var configModel = options.configModel;
    this.SQL = new cdb.SQL({
      user: configModel.get('user_name'),
      sql_api_template: configModel.get('sql_api_template'),
      api_key: configModel.get('api_key')
    });

    this._state = 'unfetched';
    this._ready = 'notready';
  },
github CartoDB / cartodb / lib / assets / javascripts / builder / data / data-observatory / measurement-model.js View on Github external
initialize: function (attrs, options) {
    checkAndBuildOpts(options, REQUIRED_OPTS, this);
    this._querySchemaModel = this._nodeDefModel.querySchemaModel;

    var configModel = options.configModel;
    this.SQL = new cdb.SQL({
      user: configModel.get('user_name'),
      sql_api_template: configModel.get('sql_api_template'),
      api_key: configModel.get('api_key')
    });

    BaseModel.prototype.initialize.call(this, attrs, options);
  },
github CartoDB / cartodb / lib / assets / javascripts / builder / editor / layers / layer-content-views / analyses / analyses-quota / analyses-quota-enough.js View on Github external
init: function (configModel) {
    this.SQL = new cdb.SQL({
      user: configModel.get('user_name'),
      sql_api_template: configModel.get('sql_api_template'),
      api_key: configModel.get('api_key')
    });
  },
github CartoDB / cartodb / lib / assets / core / javascripts / cartodb3 / components / form-components / editors / data-observatory / measurements-base-collection.js View on Github external
initialize: function (models, options) {
    checkAndBuildOpts(options, REQUIRED_OPTS, this);
    this._country = options.country || 'NULL';
    this._querySchemaModel = this._layerDefinitionModel.getAnalysisDefinitionNodeModel().querySchemaModel;

    var configModel = options.configModel;
    this.SQL = new cdb.SQL({
      user: configModel.get('user_name'),
      sql_api_template: configModel.get('sql_api_template'),
      api_key: configModel.get('api_key')
    });

    this._state = 'unfetched';
  },

cartodb

CartoDB Node.js library

BSD-3-Clause
Latest version published 8 years ago

Package Health Score

43 / 100
Full package analysis

Popular cartodb functions