If you generate S[uite]QL with variable numbers of...
# suiteql
z
If you generate S[uite]QL with variable numbers of anonymous bind parameters for
IN
predicates, you may find this one-liner helpful:
Copy code
const getBindTokens = (param, ...params) => [param, ...params].flat().map(val => '?').join(', ');
Here's a doc block for it.
Copy code
/**
   * 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!
👍 1