forked from mariadb-developers/nodejs-quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelete.js
More file actions
26 lines (21 loc) · 642 Bytes
/
delete.js
File metadata and controls
26 lines (21 loc) · 642 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const db = require("./db");
async function asyncFunction() {
let conn;
try {
// Acquire a connection from the connection pool
conn = await db.pool.getConnection();
// Parameter value
const contact_id = 1;
// Update contact data
var result = await conn.query("DELETE FROM demo.contacts WHERE id = ?", [contact_id]);
// Print result
console.log(result);
} catch (err) {
// Print error
console.log(err);
} finally {
// Release the connection back into the connection pool
if (conn) await conn.release();
}
}
asyncFunction();