-
Type: Improvement
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.3.5
-
Component/s: JavaScript, Testing Infrastructure
-
Server Tooling & Methods
When passing code to parallel shells through StartMongoProgramNoConnect or StartParallelShell, the easiest way to know about variables in the caller's scope is to construct the code from a string. e.g. startParallelShell(coll + '.find()')
This is unwieldy for any code longer than a one liner. We should consider adding a method to the Function object, something along the lines of toStringWithArgs(argsObj), that will construct the variables for you. e.g.
var f = function(coll) {return coll.find()} var s = f.toStringWithArgs({coll:coll}) // s will be "var coll = 'test.test'; var f = function(coll) {return coll.find()}" startParallelShell(s)
This solution is not perfect. Ideally we'd want to replace things the variables when Function.toString() is called, but it doesn't look like that is possible in JS at the moment.