database.function(name[, options], function)


  • name <string> 要创建的 SQLite 函数的名称。

    ¥name <string> The name of the SQLite function to create.

  • options <Object> 函数的可选配置设置。支持以下属性:

    ¥options <Object> Optional configuration settings for the function. The following properties are supported:

    • deterministic <boolean> 如果是 true,则在创建的函数上设置 SQLITE_DETERMINISTIC 标志。默认值:false

      ¥deterministic <boolean> If true, the SQLITE_DETERMINISTIC flag is set on the created function. Default: false.

    • directOnly <boolean> 如果是 true,则在创建的函数上设置 SQLITE_DIRECTONLY 标志。默认值:false

      ¥directOnly <boolean> If true, the SQLITE_DIRECTONLY flag is set on the created function. Default: false.

    • useBigIntArguments <boolean> 如果 true,则 function 的整数参数将转换为 BigInt。如果 false,则整数参数作为 JavaScript 数字传递。默认值:false

      ¥useBigIntArguments <boolean> If true, integer arguments to function are converted to BigInts. If false, integer arguments are passed as JavaScript numbers. Default: false.

    • varargs <boolean> 如果 truefunction 可以接受可变数量的参数。如果 falsefunction 必须使用恰好 function.length 个参数调用。默认值:false

      ¥varargs <boolean> If true, function can accept a variable number of arguments. If false, function must be invoked with exactly function.length arguments. Default: false.

  • function <Function> 调用 SQLite 函数时要调用的 JavaScript 函数。

    ¥function <Function> The JavaScript function to call when the SQLite function is invoked.

此方法用于创建 SQLite 用户定义函数。此方法是 sqlite3_create_function_v2() 的封装器。

¥This method is used to create SQLite user-defined functions. This method is a wrapper around sqlite3_create_function_v2().