How to execute custom javascript on mongo server


I have a big js file that needs to be put on mongo server newer mongo version has removed the support by removal of db.eval method now how can i do it

Will the load() method work for what you need?

I think that db.eval() is a function of mongo, the shell. You might be using mongosh command rather than mongo command. The new mongosh is still missing some functionalities.

How were you using the .js script before? Try to connect with the mongo command.

But how to do it using driver load is shell command

I have written for hyper log implementation in mongo db I am using this script in my map reduce function I was doing a poc from the shell where I loaded js file using mongo load command and I succeded in the implementation, now the code of map reduce will be executed though mongo node driver which dont have that load command option