it fixes the issue You can use following code snippet from laravel to execute your mongoDB function. $cursor = DB::connection('mongodb')->command(array('eval' => 'echoFunction("4")')); $data = $cursor->toArray(); dd($data);
How to call a stored function whose name is returned by another stored function in Oracle plsql?
may help you . Stored Procedures and UDFs are aspects of the native SQL (DocumentDB) API and associated SDKs. MongoDB SDKs (or frameworks tailored to work with MongoDB, such as Mongoose that you're using) know nothing about Cosmos DB's stored procs or UDFs. You would need to use the Cosmos DB SDKs for your specific language to take advantage of these. However, I doubt they will work properly against a database set up using the MongoDB API.