I have created a UDF function to process some content based on dates in Azure cosmos database. The function looks like below
function userDefinedFunction(array,dateString){
var moment = require('moment');
const startDate = moment(dateString);
const endDate = moment(dateString).add(1,'days');
// filter the array by the dates and return a value
}
When the above UDF is used inside a query the following error message is thrown.
Encountered exception while executing Javascript. Exception = ReferenceError: 'require' is not defined
This error is seemed to be an error orginating from incorrect import of the moment node module .
i have already tried checking on the microsoft offcial docs about the UDFs and using of node module inside UDF.
I tried surfing through the inte.net about this issue, but both the methods did not provide me with satisfactory answer.
so i would like to know how to import a node module and use it inside an UDF function. Thanks a lot in advance.
Importing modules is not supported for any of the service-side features including stored procedures, triggers and user-defined functions.
This is not currently documented. Will ask for this to be updated.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.