Pular para o conteúdo principal

DELETE

The examples below also work for the execute method.

query(sql)

query(sql: string)

try {
const sql = 'DELETE FROM `users` WHERE `name` = "Page" LIMIT 1';

const [result, fields] = await connection.query(sql);

console.log(result);
console.log(fields);
} catch (err) {
console.log(err);
}
  • result: contains a ResultSetHeader object, which provides details about the operation executed by the server.
  • fields contains extra meta data about the operation, if available
info

The connection used for the query (.query()) can be obtained through the createConnection, createPool or createPoolCluster methods.


query(options)

query(options: QueryOptions)

try {
const sql = 'DELETE FROM `users` WHERE `name` = "Page" LIMIT 1';

const [result, fields] = await connection.query({
sql,
// ... other options
});

console.log(result);
console.log(fields);
} catch (err) {
console.log(err);
}
  • result: contains a ResultSetHeader object, which provides details about the operation executed by the server.
  • fields contains extra meta data about the operation, if available
info

The connection used for the query (.query()) can be obtained through the createConnection, createPool or createPoolCluster methods.


Glossary

ResultSetHeader

ResultSetHeader Specification

QueryOptions

QueryOptions Specification