Currently, I am using m10, The $function operator is supported but external libraries like moment.js are not supported in the aggregation pipeline.
Hell @Sakil_Hossain, Welcome to the MongoDB community forum,
The $function does not support any external libraries!
Why do you need this kind of operation in a query? Make sure you have read the Note in the documentation,
Executing JavaScript inside an aggregation expression may decrease performance. Only use the
$functionoperator if the provided pipeline operators cannot fulfill your application’s needs.
Always try to use this kind of operation on your client-side or server-side instead of a database query.