user513912
user513912

Reputation:

Is it possible to make a REST call from a MongoDB Map/Reduce function and process the results?

I am wondering if it is possible to make a REST request from within a Map-Reduce or system.js function. I would like to be able to call an external service, and from the returned JSON results, take some ids and use them as BSON ObjectIDs for a second Mongo query.

An example for this would be selecting a collection of ObjectIDs from Mongo, and then making a REST call with these ids as a parameter to a graph database. The graph database would then send back a json list of results/new ids, which Mongo would then use to do a second lookup before returning the entire result set to the user.

Thanks!

Upvotes: 0

Views: 346

Answers (2)

Scott Hernandez
Scott Hernandez

Reputation: 7590

It is not possible; It is probably best to do this in your code and not javascript on the server even if it was.

Upvotes: 1

Hamish
Hamish

Reputation: 23354

I don't believe so - purely because of the security implications of such a feature. It would allow a malicious attacker who finds an injection vulnerability to use your database for DDoS attacks, as a proxy for further nefarious activities, etc.

Upvotes: 1

Related Questions