break;
case 'products': {
let params = [];
let qs = '';
let s = Number(parameters && parameters.store);
if(Number.isInteger(s)) {
qs += `_store_id => $${params.push(s)},`;
}
let st = Number(parameters && parameters.strain_id);
if(Number.isInteger(st)) {
qs += `_strain_id => $${params.push(st)},`;
}
if(typeof parameters.type === 'string') {
qs += `_type => $${params.push(parameters.type)},`;
}
// try {
ws.send(JSON.stringify({
response_ID: request_ID,
data: (await pool.query(`select * from get_products(${qs.slice(0, -1)})`, params)).rows
}));
// } catch(e) {
// ws.send(JSON.stringify({
// response_ID: request_ID,
// data: e.message//usually "invalid input value for enum product_type: "flo"".
// }));
// }
/*
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
[DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Uncomment when the future finally happens OR if we actually want to handle this. For now, it's harmless / won't happen.
*/