How to use the mssql.UniqueIdentifier 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 DFEAGILEDEVOPS / MTC / admin / services / data-access / sql.service.js View on Github external
// SQL type-mapping adapter.  Add new types as required.
  TYPES: {
    BigInt: mssql.BigInt,
    Bit: mssql.Bit,
    Char: mssql.Char,
    DateTimeOffset: mssql.DateTimeOffset,
    DateTime: mssql.DateTime,
    DateTime2: mssql.DateTime2,
    Decimal: mssql.Decimal,
    Float: mssql.Float,
    Int: mssql.Int,
    Numeric: mssql.Numeric,
    NVarChar: mssql.NVarChar,
    Real: mssql.Real,
    SmallInt: mssql.SmallInt,
    UniqueIdentifier: mssql.UniqueIdentifier
  }
}

// Name of the admin database
sqlService.adminSchema = '[mtc_admin]'

sqlService.initPool = async () => {
  if (pool) {
    logger.warn('The connection pool has already been initialised')
    return
  }
  pool = new mssql.ConnectionPool(poolConfig)
  pool.on('error', err => {
    logger.error('SQL Pool Error:', err)
  })
  return pool.connect()
github DFEAGILEDEVOPS / MTC / design / z_archive / census-import / services / data-access / sql.service.js View on Github external
/** SQL Service **/
const sqlService = {
  // SQL type-mapping adapter.  Add new types as required.
  TYPES: {
    BigInt: mssql.BigInt,
    Bit: mssql.Bit,
    Char: mssql.Char,
    DateTimeOffset: mssql.DateTimeOffset,
    Decimal: mssql.Decimal,
    Float: mssql.Float,
    Int: mssql.Int,
    Numeric: mssql.Numeric,
    NVarChar: mssql.NVarChar,
    Real: mssql.Real,
    SmallInt: mssql.SmallInt,
    UniqueIdentifier: mssql.UniqueIdentifier
  }
}

// Name of the admin database
sqlService.adminSchema = '[mtc_admin]'

sqlService.initPool = async () => {
  if (pool) {
    logger.warn('The connection pool has already been initialised')
    return
  }
  pool = new mssql.ConnectionPool(sqlConfig)
  pool.on('error', err => {
    logger.error('SQL Pool Error:', err)
  })
  return pool.connect()
github DFEAGILEDEVOPS / MTC / deploy / sql / schema-WIP / sql.service.js View on Github external
// SQL type-mapping adapter.  Add new types as required.
  TYPES: {
    BigInt: mssql.BigInt,
    Bit: mssql.Bit,
    Char: mssql.Char,
    DateTimeOffset: mssql.DateTimeOffset,
    DateTime: mssql.DateTime,
    DateTime2: mssql.DateTime2,
    Decimal: mssql.Decimal,
    Float: mssql.Float,
    Int: mssql.Int,
    Numeric: mssql.Numeric,
    NVarChar: mssql.NVarChar,
    Real: mssql.Real,
    SmallInt: mssql.SmallInt,
    UniqueIdentifier: mssql.UniqueIdentifier
  }
}

// Name of the admin database
sqlService.adminSchema = '[mtc_admin]'

sqlService.initPool = async () => {
  if (pool) {
    logger.warn('The connection pool has already been initialised')
    return
  }
  pool = new mssql.ConnectionPool(poolConfig)
  pool.on('error', err => {
    logger.error('SQL Pool Error:', err)
  })
  return pool.connect()
github DFEAGILEDEVOPS / MTC / tslib / src / functions / check-marker / check-form.service.ts View on Github external
async getCheckFormDataByCheckCode (checkCode: string) {
    let pool: mssql.ConnectionPool
    try {
      pool = await this.connection.connect()
      const request = new mssql.Request(pool)
      const sql = `SELECT TOP 1 f.formData
               FROM mtc_admin.[check] chk
               INNER JOIN mtc_admin.[checkForm] f ON chk.checkForm_id = f.id
               WHERE checkCode = @checkCode`
      const params = [
        {
          name: 'checkCode',
          value: checkCode,
          type: mssql.UniqueIdentifier
        }
      ]
      this.addParamsToRequestSimple(params, request)
      const result: mssql.IResult = await request.query(sql)
      if (!R.isNil(result.recordset)) {
        if (!R.isEmpty(result.recordset) && !R.isNil(result.recordset[0].formData)) {
          return result.recordset[0].formData
        }
      }
    } catch (err) {
      console.error(err.message)
      throw err
    } finally {
      await this.connection.close()
    }
  }
github DFEAGILEDEVOPS / MTC / functions / census-import / job.data.service.js View on Github external
jobDataService.sqlUpdateStatus = async (pool, urlSlug, jobStatusCode, jobOutput = undefined, errorOutput = undefined) => {
  const sql = `UPDATE [mtc_admin].[job]
  SET
  jobStatus_id = (
    SELECT id
    FROM [mtc_admin].[jobStatus]
    WHERE jobStatusCode = @jobStatusCode
  ),
  jobOutput=@jobOutput,
  errorOutput=@errorOutput
  OUTPUT Inserted.id
  WHERE urlSlug=@urlSlug`

  const request = new mssql.Request(pool)
  request.input('urlSlug', mssql.UniqueIdentifier, urlSlug)
  request.input('jobStatusCode', mssql.Char(3), jobStatusCode)
  request.input('jobOutput', mssql.NVarChar(mssql.MAX), jobOutput)
  request.input('errorOutput', mssql.NVarChar(mssql.MAX), errorOutput)
  const result = await request.query(sql)
  return R.path(['id'], R.head(R.path(['recordset'], result)))
}
github DFEAGILEDEVOPS / MTC / tslib / src / functions / check-allocator / check-allocation.data.service.ts View on Github external
async getPupilsBySchoolUuid (schoolUUID: string): Promise> {
    const sql = `SELECT p.urlSlug FROM mtc_admin.pupil p
      INNER JOIN mtc_admin.school s ON p.school_id = s.id
      WHERE s.urlSlug=@schoolUUID`
    const params = [
      {
        name: '@schoolUUID',
        type: mssql.UniqueIdentifier,
        value: schoolUUID
      }]
    return this.sqlService.query(sql, params)
  }
}
github DFEAGILEDEVOPS / MTC / tslib / src / functions / check-notifier / check-notifier.data.service.ts View on Github external
updateCheckAsComplete (checkCode: string): Promise {
    const checkCodeParam: ISqlParameter = {
      type: mssql.UniqueIdentifier,
      name: 'checkCode',
      value: checkCode
    }
    const checkRequest: ITransactionRequest = {
      sql: `UPDATE [mtc_admin].[check]
      SET checkStatus_id=(SELECT cs.id
                          FROM
                          [mtc_admin].[checkStatus] cs
                          WHERE cs.code='CMP'),
        complete=1,
        completedAt=GETUTCDATE(),
        processingFailed=0
      WHERE checkCode=@checkCode`,
      params: [
        checkCodeParam
      ]
github totaljs / eshop / node_modules / sqlagent / sqlserver.js View on Github external
if (param.isFN) {
			value = value(params);
			type = typeof(value);
		}

		switch (type) {
			case 'number':
				request.input(param.name, value % 1 === 0 ? database.Int : database.Decimal, value);
				break;
			case 'decimal':
				request.input(param.name, database.Decimal, value);
				break;
			case 'uniqueidentifier':
			case 'guid':
				request.input(param.name, database.UniqueIdentifier, value);
				break;
			case 'money':
				request.input(param.name, database.Money, value);
				break;
			case 'float':
				request.input(param.name, database.Float, value);
				break;
			case 'bigint':
				request.input(param.name, database.BigInt, value);
				break;
			case 'smallint':
			case 'byte':
				request.input(param.name, database.SmallInt, value);
				break;
			case 'string':
			case 'nvarchar':
github totaljs / node-sqlagent / sqlserver.js View on Github external
if (param.isFN) {
			value = value(params);
			type = typeof(value);
		}

		switch (type) {
			case 'number':
				request.input(param.name, value % 1 === 0 ? database.Int : database.Float, value);
				break;
			case 'decimal':
				request.input(param.name, database.Decimal, value);
				break;
			case 'uniqueidentifier':
			case 'guid':
				request.input(param.name, database.UniqueIdentifier, value);
				break;
			case 'money':
				request.input(param.name, database.Money, value);
				break;
			case 'float':
				request.input(param.name, database.Float, value);
				break;
			case 'bigint':
				request.input(param.name, database.BigInt, value);
				break;
			case 'smallint':
			case 'byte':
				request.input(param.name, database.SmallInt, value);
				break;
			case 'string':
			case 'nvarchar':