How to use the format function from mysql2

Find comprehensive JavaScript mysql2.format code examples handpicked from public code repositorys.

103
104
105
106
107
108
109
110
111
112
  // [rows, fields] = values ? await conn.query(sql, values) : await conn.query(sql);
  [rows, fields] = await conn.query(sql, values);
  stop = Date.now();
} finally {
  if (rows && this.logging) {
    let sqlString = mysql.format(typeof sql === 'object' ? sql.sql : sql, values || sql.values).trim().replace(/\n/g, ' ').replace(/\s+/g, ' ').replace(/,\s/g, ',');
    if (sqlString.lastIndexOf(';') !== sqlString.length - 1) {
      sqlString = sqlString + ';';
    }
    const cmd = sqlString.split(' ')[0].toUpperCase();
fork icon0
star icon0
watch icon1