I need to run some havy read & write operations on mongodb. I thought of doing this using a js script on a remote mongodb server, something similar to what's asked in here: How to run mongo db script on remote server?
where the answer says:
mongo -u user -p password mongodb01d.mydomain.com:27017/mydb yourFile.js
but instead, I need to run this from nodejs code, because I am using Azure Functions and I don't have an environment for running mongo client binary.
So I would like to now if doing something like this it is somehow possible:
MongoClient.connect(someUrl, function (err, client) {
client.load("some script") // <-- Of course client.load doesn't exist.
});
I tried db.eval, which is similar, but it is blocking. I want to run the task in background and don't block my nodejs script, as "load(...)" does when it is run in shell.
Thanks!