How to use the loopback-connector.SqlConnector.ParameterizedSQL function in loopback-connector

To help you get started, we’ve selected a few loopback-connector 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 strongloop / loopback-connector-mysql / lib / mysql.js View on Github external
// Copyright IBM Corp. 2012,2017. All Rights Reserved.
// Node module: loopback-connector-mysql
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';
var g = require('strong-globalize')();

/*!
 * Module dependencies
 */
var mysql = require('mysql');

var SqlConnector = require('loopback-connector').SqlConnector;
var ParameterizedSQL = SqlConnector.ParameterizedSQL;
var EnumFactory = require('./enumFactory').EnumFactory;

var debug = require('debug')('loopback:connector:mysql');
var setHttpCode = require('./set-http-code');

/**
 * @module loopback-connector-mysql
 *
 * Initialize the MySQL connector against the given data source
 *
 * @param {DataSource} dataSource The loopback-datasource-juggler dataSource
 * @param {Function} [callback] The callback function
 */
exports.initialize = function initializeDataSource(dataSource, callback) {
  dataSource.driver = mysql; // Provide access to the native driver
  dataSource.connector = new MySQL(dataSource.settings);
github strongloop / loopback-connector-mssql / lib / mssql.js View on Github external
// Copyright IBM Corp. 2013,2018. All Rights Reserved.
// Node module: loopback-connector-mssql
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';
const g = require('strong-globalize')();

/*! Module dependencies */
const mssql = require('mssql');
const SqlConnector = require('loopback-connector').SqlConnector;
const ParameterizedSQL = SqlConnector.ParameterizedSQL;
const util = require('util');
const debug = require('debug')('loopback:connector:mssql');

mssql.map.register(Number, mssql.BigInt);

const name = 'mssql';

exports.name = name;
exports.initialize = function initializeSchema(dataSource, callback) {
  const settings = dataSource.settings || {};
  debug('Settings: %j', settings);
  const driver = new MsSQL(settings);
  dataSource.connector = driver;
  dataSource.connector.dataSource = dataSource;
  dataSource.connector.tableNameID = dataSource.settings.tableNameID;
github strongloop / loopback-connector-cassandra / lib / cassandra.js View on Github external
// Copyright IBM Corp. 2015,2019. All Rights Reserved.
// Node module: loopback-connector-cassandra
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';
var g = require('strong-globalize')();

/*!
 * Module dependencies
 */
var cassandra = require('cassandra-driver');

var SqlConnector = require('loopback-connector').SqlConnector;
var ParameterizedSQL = SqlConnector.ParameterizedSQL;
var cassandraMAP = require('cassandra-map');

var debug = require('debug')('loopback:connector:cassandra');
var debugQuery = require('debug')('loopback:connector:cassandra:query');
var debugData = require('debug')('loopback:connector:cassandra:data');
var debugFilter = require('debug')('loopback:connector:cassandra:filter');

function uuidFromString(value) {
  var ret = null;
  if (typeof value === 'string' && value.length === 36) {
    ret = originalFromString(value);
  } else {
    ret = value;
  }
  return ret;
}
github strongloop / loopback-connector-oracle / lib / oracle.js View on Github external
// Copyright IBM Corp. 2013,2016. All Rights Reserved.
// Node module: loopback-connector-oracle
// US Government Users Restricted Rights - Use, duplication or disclosure
// restricted by GSA ADP Schedule Contract with IBM Corp.

'use strict';
var g = require('strong-globalize')();

/*!
 * Oracle connector for LoopBack
 */
var oracle = require('oracledb');
var SqlConnector = require('loopback-connector').SqlConnector;
var ParameterizedSQL = SqlConnector.ParameterizedSQL;
var debug = require('debug')('loopback:connector:oracle');
var stream = require('stream');
var async = require('async');

/*!
 * @module loopback-connector-oracle
 *
 * Initialize the Oracle connector against the given data source
 *
 * @param {DataSource} dataSource The loopback-datasource-juggler dataSource
 * @param {Function} [callback] The callback function
 */
exports.initialize = function initializeDataSource(dataSource, callback) {
  if (!oracle) {
    return;
  }
github harishanchu / workplace / server / boot / sqljoin.js View on Github external
/**
 * sqljoin.js
 *
 * @author: Harish Anchu 
 * @copyright Copyright (c) 2018, Harish Anchu.
 * @license See LICENSE
 */
'use strict';

const MySQL = require('loopback-connector-mysql').MySQL;
const SqlConnector = require('loopback-connector').SqlConnector;
const ParameterizedSQL = SqlConnector.ParameterizedSQL;
const debug = require('debug')('loopback:connector:mysql');
const utilities = require('../../util/utilities');

/**
 * Adds inner join support to loopback-connector-mysql
 *
 * @param server
 */
module.exports = function modifyLoopbackMySQLConnector(server) {
  /**
   * Build a SQL SELECT statement
   * @param {String} model Model name
   * @param {Object} filter Filter object
   * @param {Object} options Options object
   * @returns {ParameterizedSQL} Statement object {sql: ..., params: [...]}
   */