I have the following node function to INSERT a row into my mysql rds:
var sql = "INSERT INTO items SET item_id = ?, item_name = ?";
connection.query(sql, [event.itemId, event.itemName, function (error, results, fields) {
console.log(results);
connection.release();
if (error) {
context.done(error);
} else {
// continue...
}
});
items also has a date_created column with default value being CURRENT_TIMESTAMP upon creation.
Is there anyway to get the value of date_created without doing another query? Not being that familiar with node/mysql I'm wondering if when a row is created the row values will be returned?
If not, then I have two choices, one is to do another query to get the date_created or just to add the date_created field myself when creating the row. Wondering what is the best practice in this case. Not sure if doing two queries will be costly.
EDIT #1
The results prints out as follows:
{
"fieldCount": 0,
"affectedRows": 1,
"insertId": 0,
"serverStatus": 2,
"warningCount": 0,
"message": "",
"protocol41": true,
"changedRows": 0
}