How to use the tedious.TYPES.Char function in tedious

To help you get started, we’ve selected a few tedious 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 / spike-worker / bulkImport.js View on Github external
const bulkLoad = connection.newBulkLoad(`${config.Sql.Database}.[mtc_admin].[pupil]`, options, function (error, rowCount) {
    if (error) {
      console.error('import failed...')
      console.error(error)
    }
    console.log('inserted %d rows', rowCount)
  })

  // setup your columns - always indicate whether the column is nullable
  // TODO add all fields that are being imported to this list
  bulkLoad.addColumn('school_id', TYPES.Int, {nullable: false})
  bulkLoad.addColumn('upn', TYPES.Char, {length: 13, nullable: false})
  bulkLoad.addColumn('lastName', TYPES.NVarChar, {length: 'max', nullable: false})
  bulkLoad.addColumn('foreName', TYPES.NVarChar, {length: 'max', nullable: false})
  bulkLoad.addColumn('middleNames', TYPES.NVarChar, {length: 'max', nullable: true})
  bulkLoad.addColumn('gender', TYPES.Char, {length: 1, nullable: false})
  bulkLoad.addColumn('dateOfBirth', TYPES.DateTimeOffset, {nullable: false})

  const schools = schoolLookupDisabled ? schoolData : await schoolLookup(csvPayload)
  for (let index = 0; index < csvPayload.length; index++) {
    const csvRow = csvPayload[index]
    const dfeNumber = `${csvRow[0]}${csvRow[1]}`
    const school = schools.find(s => s.dfeNumber === parseInt(dfeNumber))
    const schoolId = school && school.id
    if (!schoolId) {
      console.error(`School id not found for DfeNumber ${dfeNumber}`)
      process.exit(1)
    }
    bulkLoad.addRow({
      school_id: schoolId,
      upn: csvRow[2],
      lastName: csvRow[3],
github DFEAGILEDEVOPS / MTC / admin / services / data-access / attendance-code.data.service.js View on Github external
sqlFindOneAttendanceCodeByCode: async (code) => {
    const sql = `
    SELECT 
      id, 
      reason, 
      [code] 
    FROM ${sqlService.adminSchema}.[attendanceCode] 
    WHERE [code] = @pcode`
    const paramCode = { name: 'pcode', value: code, type: TYPES.Char }
    const res = await sqlService.query(sql, [paramCode])
    return R.head(res)
  }
}