How to use the mssql.Table function in mssql

To help you get started, we’ve selected a few mssql 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 DefinitelyTyped / DefinitelyTyped / types / mssql / mssql-tests.ts View on Github external
function test_table() {
    var table = new sql.Table('#temp_table');

    table.create = true;

    table.columns.add('name', sql.VarChar(sql.MAX), { nullable: false });
    table.columns.add('type', sql.Int, { nullable: false });
    table.columns.add('amount', sql.Decimal(7, 2), { nullable: false });

    table.rows.add('name', 42, 3.50);
    table.rows.add('name2', 7, 3.14);
}
github instana / nodejs-sensor / test / tracing / database / mssql / app.js View on Github external
app.get('/bulk', function(req, res) {
  var table = new sql.Table('AnotherUserTable');
  table.create = true;
  table.columns.add('name', sql.NVarChar(40), { nullable: true });
  table.columns.add('email', sql.NVarChar(40), { nullable: true });
  table.rows.add('Domitian', 'domitian@flavius.com');
  table.rows.add('Nerva', 'nerva@nerva.com');
  table.rows.add('Trajan ', 'trajan@nerva.com');
  new sql.Request().bulk(table, function(err, results) {
    if (err) {
      log('Failed to execute bulk operation.', err);
      return res.status(500).json(err);
    }
    res.json(results);
  });
});
github LeanKit-Labs / seriate / src / sqlContextUtils.js View on Github external
function bulkLoadTable( state, name, options ) {
	var table = new sql.Table( options.bulkLoadTable.name );
	table.create = true;

	_.forEach( options.bulkLoadTable.columns, function( column, columnName ) {
		table.columns.add( columnName, column.type, { nullable: column.nullable === undefined ? true : column.nullable } );
	} );

	var columnNames = Object.keys( options.bulkLoadTable.columns );

	options.bulkLoadTable.rows.forEach( function( row ) {
		var values = columnNames.map( function( columnName ) {
			return row[ columnName ];
		} );

		table.rows.add.apply( table.rows, values );
	} );
github DFEAGILEDEVOPS / MTC / functions / census-import / census-import.data.service.js View on Github external
module.exports.sqlLoadStagingTable = async (context, pool, censusTable, blobContent) => {
  if (!pool) {
    await this.initPool(context)
  }
  const table = new mssql.Table(censusTable)
  table.create = true
  table.columns.add('id', mssql.Int, { nullable: false, primary: true, identity: true })
  table.columns.add('lea', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('estab', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('upn', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('surname', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('forename', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('middlenames', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('gender', mssql.NVarChar(mssql.MAX), { nullable: false })
  table.columns.add('dob', mssql.NVarChar(mssql.MAX), { nullable: false })
  for (let i = 1; i < blobContent.length; i++) {
    const row = blobContent[i]
    table.rows.add(i, row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8])
  }

  const request = new mssql.Request(pool)
github alice-si / etheroscope / db / db.js View on Github external
function getNewVariablesTable () {
  var variablesTable = new mssql.Table('variables')
  variablesTable.create = true
  variablesTable.columns.add('contractHash', mssql.VarChar(40), {nullable: false, primary: true})
  variablesTable.columns.add('variableName', mssql.VarChar(50), {nullable: false, primary: true})
  variablesTable.columns.add('cachedFrom', mssql.BigInt, {nullable: true})
  variablesTable.columns.add('cachedUpTo', mssql.BigInt, {nullable: true})
  return variablesTable
}
github dymajo / waka / server-worker / db / gtfs-import.js View on Github external
getTable(name) {
    const table = new sql.Table(name)
    if (name === 'agency') {
      table.columns.add('agency_id', sql.VarChar(50), {nullable: false})
      table.columns.add('agency_name', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_url', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_timezone', sql.VarChar(100), {nullable: false})
      table.columns.add('agency_lang', sql.VarChar(50), {nullable: true})
      table.columns.add('agency_phone', sql.VarChar(50), {nullable: true})
      table.columns.add('agency_fare_url', sql.VarChar(100), {nullable: true})
      table.columns.add('agency_email', sql.VarChar(50), {nullable: true})
    } else if (name === 'stops') {
      table.columns.add('stop_id', sql.VarChar(100), {nullable: false})
      table.columns.add('stop_code', sql.VarChar(50), {nullable: true})
      table.columns.add('stop_name', sql.VarChar(100), {nullable: false})
      table.columns.add('stop_desc', sql.VarChar(150), {nullable: true})
      table.columns.add('stop_lat', sql.Decimal(10,6), {nullable: false})
      table.columns.add('stop_lon', sql.Decimal(10,6), {nullable: false})
github yinfxs / ibird / lib / model / mssql.js View on Github external
app.schema = function (mdl, schema, models, create) {
    const name = schema.table || mdl.code + '_' + schema.code;
    const table = new sql.Table(name);
    table.create = true;
    Object.keys(schema.fields).forEach(function (code) {
        const value = schema.fields[code];
        const mssql = value.mssql || {};
        const column = mssql.column || code;
        let type = mssql.type, options = mssql.options;
        if (!type) {
            const jstype = _.keys(value) && _.keys(value).length > 0 ? value.type : value;
            switch (jstype) {
                case String:
                    type = sql.NVarChar(255);
                    break;
                case Number:
                    type = sql.NVarChar(255);
                    break;
                case Date: