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_DETERMINISTICflag is set on the created function. Default:false. -
directOnly<boolean> 如果是true,则在创建的函数上设置SQLITE_DIRECTONLY标志。默认值:false。¥
directOnly<boolean> Iftrue, theSQLITE_DIRECTONLYflag is set on the created function. Default:false. -
useBigIntArguments<boolean> 如果true,则function的整数参数将转换为BigInt。如果false,则整数参数作为 JavaScript 数字传递。默认值:false。¥
useBigIntArguments<boolean> Iftrue, integer arguments tofunctionare converted toBigInts. 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,functionmay be invoked with any number of arguments (between zero andSQLITE_MAX_FUNCTION_ARG). Iffalse,functionmust be invoked with exactlyfunction.lengtharguments. 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 toNULLif 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().