tencent cloud

Last updated: 2025-03-11 20:05:05
Result
Last updated: 2025-03-11 20:05:05
Result is the result returned by Database.exec.

Field

Field
Type
Description
lastInsertId?
number
Return an integer generated by the database in response to the command; this will typically come from the "Auto-Increment" column when inserting a new row.
rowsAffected?
number
Return the number of rows affected by the update, insert, or delete operation.

Samples

Use exec to execute a database query, and Result is returned:
import sql from 'pts/sql';

// Create a database instance using new.
const db = new sql.Database(sql.MySQL, "user:passwd@tcp(ip:port)/database")

export default function () {
let result = db.exec("UPDATE user SET age=? WHERE name='zhangsan'", Math.floor(Math.random() * 100));
console.log(JSON.stringify(result)); // {"lastInsertId":0,"rowsAffected":1}
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback