How to use the tedious.TYPES.DateTimeOffset 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
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],
      foreName: csvRow[4],
github DFEAGILEDEVOPS / MTC / load-test / bin / generate-pupil-load-test-data.js View on Github external
for (let i = 0; i < numSchools; i++) {
      let school = schools[i]
      let totalPupils = pupilsPerSchool
      if (i < pupilsRemainder) {
        totalPupils += 1
      }
      params = [
        {
          name: 'schoolId',
          value: school.id,
          type: TYPES.Int
        },
        {
          name: 'dateOfBirth',
          value: randomDob(),
          type: TYPES.DateTimeOffset
        },
        {
          name: 'pinExpiresAt',
          value: pinExpiryDate,
          type: TYPES.DateTimeOffset
        }
      ]

      const sql = `
      DECLARE @cnt INT = 1;
      DECLARE @baseUpn INT = 80120000 + @schoolId;
      DECLARE @tvp AS ${sqlService.adminSchema}.CheckTableType;
      DECLARE @existingPupils INT = 0;
      BEGIN TRAN

        UPDATE ${sqlService.adminSchema}.[school]
github DFEAGILEDEVOPS / MTC / load-test / bin / generate-pupil-load-test-data.js View on Github external
}
      params = [
        {
          name: 'schoolId',
          value: school.id,
          type: TYPES.Int
        },
        {
          name: 'dateOfBirth',
          value: randomDob(),
          type: TYPES.DateTimeOffset
        },
        {
          name: 'pinExpiresAt',
          value: pinExpiryDate,
          type: TYPES.DateTimeOffset
        }
      ]

      const sql = `
      DECLARE @cnt INT = 1;
      DECLARE @baseUpn INT = 80120000 + @schoolId;
      DECLARE @tvp AS ${sqlService.adminSchema}.CheckTableType;
      DECLARE @existingPupils INT = 0;
      BEGIN TRAN

        UPDATE ${sqlService.adminSchema}.[school]
        SET pin = '${randomPass()}', pinExpiresAt = @pinExpiresAt
        WHERE id = ${school.id} AND pin IS NULL;

        WHILE @cnt <= ${totalPupils}
        BEGIN