1

I'm using Java driver for MongoDB (mongo-java-driver-2.13.0).
I need to store a function, called my_function, on server. From MongoDB shell I used the following code:

> db.system.js.save( { _id : "function1", value : my_function } );

I need this function to use it in a map-reduce.
How can I store the function using Java driver?

1 Answer 1

0

I answer all to myself, maybe it can be useful for someone.
You don't need to save your function on server. Suppose I have to use a javascript function foo in map-reduce. You can follow this example:

    String map = "function(){" 
                  + "foo = function(parameters) {...here you have to write foo code...}
                  + ".....now you can use foo function in your map reduce......."

So, just define in map function your function foo and then you will be able to you it inside your map reduce code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.