if(!functionName||!returnType||!language||!body)thrownewError('createFunction missing some parameters. Did you pass functionName, returnType, language and body?');
return`CREATE FUNCTION ${functionName}(${paramList}) RETURNS ${returnType} AS $func$ BEGIN ${body} END; $func$ language '${language}'${expandedOptions};`;
conststatement=options&&options.force?'CREATE OR REPLACE FUNCTION':'CREATE FUNCTION';
return`${statement}${functionName}(${paramList}) RETURNS ${returnType} AS $func$ BEGIN ${body} END; $func$ language '${language}'${expandedOptionsArray};`;
* @param {Array} optionsArray Extra-options for creation
* @param {Object} [options] query options
* @param {boolean} options.force If force is true, any existing functions with the same parameters will be replaced. For postgres, this means using `CREATE OR REPLACE FUNCTION` instead of `CREATE FUNCTION`. Default is false