API reference › @evolu/sqlite-wasm › c-api › sqlite3_create_function

function sqlite3_create_function(
  deps: SqliteWasmDep,
): (
  db: SqliteDbPtr,
  zFunctionName: CStringPtr,
  nArg: number,
  eTextRep: number,
  pApp: 0 | WasmPtr,
  xFunc: 0 | SqliteFunctionPtr,
  xStep: 0 | SqliteFunctionPtr,
  xFinal: 0 | SqliteFunctionPtr,
) => SqliteResultCode;

Defined in: packages/sqlite-wasm/src/CApi.ts:2570

Adds, redefines or, with xFunc, xStep and xFinal all NULL, removes an SQL function of the connection: xFunc implements a scalar function, xStep with xFinal an aggregate. nArg is the argument count or -1 for any, and eTextRep the preferred text encoding, optionally with flags such as SQLITE_DETERMINISTIC and SQLITE_DIRECTONLY.

Wasm type i(iiiiiiii). Signature ["sqlite3_create_function", "int", "sqlite3*", "string", "int", "int", "*", "funcptr:v(pip)", "funcptr:v(pip)", "funcptr:v(p)"] from Evolu's supplement: SQLite binds it by hand to accept JavaScript functions as callbacks.

See https://sqlite.org/c3ref/create_function.html.