Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-24089

Add method to allow JS functions to take in parameters when converted to a string.

    • 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.

            Assignee:
            backlog-server-stm Backlog - Server Tooling and Methods (STM) (Inactive)
            Reporter:
            robert.guo@mongodb.com Robert Guo (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: