Using the mysql2/promise library, one of my objects partly consists of unresolved promises from previous SELECT statements.
When inserting, I get an incorrect integer value error message because the promises have not been resolved. What would be an elegant way to resolve the contained promises?
let insertObj = {
author: this.authorId // unresolved promise #1
recipient: this.recipientId // unresolved promise #2
// ... more promises here
message: this.messageBody
}
let conn = this.pool.getConnection();
return conn.then((conn) => {
const res = conn.query("INSERT INTO posts SET ?", [insertObj]);
conn.release();
return res
});