I have a combination of map-reduce commands that have to be performed in
that order.
Each map/reduce/finalize method is stored in db.system.js
I have another javascript function "doIt" ties all commands together
sets scope arguments etc.
I could save doIt in the db.system.js as well and call
db.eval("doIt()"), but for blocking reasons I don't want to do this.
However, if I just call doIt on the client, it can't resolve the
functions stored in db.system.js.
doIt = function() {
innerfunction = function(arg1, arg2) {
db[arg2+"a"].mapReduce(map1, reduce1, {out:
{reduce:tmpCollection}, scope:{"arg1":arg1}})
db[arg2+"b"].mapReduce(map1, reduce1, {out:
{reduce:tmpCollection}, scope:{"arg1":arg2}})
db.tmpCollection.mapReduce(map2, reduce2, {out:
{reduce:arg2+"outCollection"}})
}
innerfunction(4, "collectionOne");
innerfunction(1, "collectionTwo");
// more complicated logic here...
}
I would like to call doIt() on the mongo shell.
When I call doIt() on the mongo shell I get
> ReferenceError: map is not defined (shell)
Note that just calling the following command on the shell works without
the wrapping.
db.collection.mapReduce(map, reduce, {out: {reduce:"outCollection"}})
Is there a command to say "resolve this using the saved function"?
Alternatively, can I fetch the function from db.system.js?
Thanks,
Laura
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
--You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mongodb-user/-/QsRyXdYqVU0J.