Home > database >  4.2 how to perform a custom function
4.2 how to perform a custom function

Time:10-31

How to perform a custom function in directing,
Before I see blog, for example, a custom function:
//define a Sum function
Db. The system. Js. Save ({_id: "Sum",
Value: the function (key, values)
{
Var total=0;
for(var i=0; i Total +=values [I];
Return the total;
}});
How to call this function
The version 4.2 db. The eval deleted
I call: db loadServerScripts ();
The Sum (1,,2,3,4,5,6,7,8,9 [1])
Error:


So now do not know how to call the custom of the sum function, strives for the bosses to solve

CodePudding user response:

A custom function has been abandoned is not recommended, anyway, now the better tools have affairs

CodePudding user response:

Tested in 4.2 no problem
  • Related