nodejs mysql getting the number of affected rows

const mysql = require('mysql');

// Create a connection to the MySQL database
const connection = mysql.createConnection({
  host: 'your_host',
  user: 'your_user',
  password: 'your_password',
  database: 'your_database'
});

// Connect to the database
connection.connect();

// Define the SQL query
const sqlQuery = 'UPDATE your_table SET your_column = ? WHERE your_condition';

// Define the values to be inserted into the query
const values = ['new_value'];

// Execute the query with the provided values
connection.query(sqlQuery, values, (error, results) => {
  if (error) throw error;

  // Get the number of affected rows from the results object
  const affectedRows = results.affectedRows;

  // Log the number of affected rows
  console.log(`Number of affected rows: ${affectedRows}`);

  // Close the database connection
  connection.end();
});