zvictor
08/06/2021, 8:11 PMIN predicates, you may find this one-liner helpful:
const getBindTokens = (param, ...params) => [param, ...params].flat().map(val => '?').join(', ');
Here's a doc block for it.
/**
* Translate variadic input to anonymous bind-param tokens ?, ?, ... ?
* @param {string|number|boolean|Date|Array} param
* @param {Array} params
* @returns {string}
*/
const getBindTokens = (param, ...params) => [param, ...params].flat().map(val => '?').join(', ');
Can call it with as many primitive values and 1-level arrays as you like. It returns a string of comma-separated question-marks, which you can use for the IN predicate of a dynamically produced SuiteQL query-string. Most of the time one needs an IN predicate in the WHERE clause. IN predicates can also be used in join-criteria (with explicit join syntax) and among column expressions (e.g., a CASE statement). I hope you find this helpful!