In a Node.js server application I am trying to select a row through the .get() method filtering the result with a WHERE clause with multiple parameters.
function getRowByID(paramA, paramB, paramC) {
return new Promise(function(resolve, reject) {
const query = 'SELECT * FROM myTable WHERE a=? AND b=? AND c=?'
db.get(query, [paramA, paramB, paramC], (err, row) => {
if (err) reject(err)
else {
// check contents of rows and resolve
}
})
})
}
According to the node-sqlite3 API documentation if the result set is empty, the second parameter (row) of the callback is undefined. This unfortunately doesn't give me any information, how can I understand which parameter was the cause of the result being empty?
Could there be workarounds to the problem I am having, like - for example - splitting the query in different sequential promises?