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> Iftrue
, theSQLITE_DETERMINISTIC
flag is set on the created function. Default:false
. -
directOnly
<boolean> 如果是true
,则在创建的函数上设置SQLITE_DIRECTONLY
标志。默认值:false
。¥
directOnly
<boolean> Iftrue
, theSQLITE_DIRECTONLY
flag is set on the created function. Default:false
. -
useBigIntArguments
<boolean> 如果true
,则function
的整数参数将转换为BigInt
。如果false
,则整数参数作为 JavaScript 数字传递。默认值:false
。¥
useBigIntArguments
<boolean> Iftrue
, integer arguments tofunction
are converted toBigInt
s. Iffalse
, integer arguments are passed as JavaScript numbers. Default:false
. -
varargs
<boolean> 如果true
,则可以使用任意数量的参数(零到SQLITE_MAX_FUNCTION_ARG
之间)调用function
。如果false
,function
必须使用恰好function.length
个参数调用。默认值:false
。¥
varargs
<boolean> Iftrue
,function
may be invoked with any number of arguments (between zero andSQLITE_MAX_FUNCTION_ARG
). Iffalse
,function
must be invoked with exactlyfunction.length
arguments. Default:false
.
-
-
function
<Function> 调用 SQLite 函数时要调用的 JavaScript 函数。此函数的返回值应为有效的 SQLite 数据类型:见 JavaScript 和 SQLite 之间的类型转换。如果返回值为undefined
,则结果默认为NULL
。¥
function
<Function> The JavaScript function to call when the SQLite function is invoked. The return value of this function should be a valid SQLite data type: see Type conversion between JavaScript and SQLite. The result defaults toNULL
if the return value isundefined
.
此方法用于创建 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()
.