Add helper to Database class to call server-side JS easier

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Minor Change
    • None
    • None
    • None
    • None
    • None
    • None

      Currently the best way to add server-side JS functions via PyMongo is:

      db.system.js.save({ '_id': 'add', 'value': Code('function(a,b)

      { return a+b; }')})

      And to call that function via PyMongo:

      db.eval("function(a,b) {return add(a,b);}", var1, var2)

      A simpler API could be provided like:

      # Function creation
      db.js.save('add', 'function(a,b) { return a+b; }

      ')

      1. Function execution
        db.js.add(var1, var2)

      Sample code here:
      http://github.com/schmichael/mongo-python-driver/commit/57e6df4ca14314eb8c0a3a9e4b8c97c0186a0121

            Assignee:
            Michael Dirolf (Inactive)
            Reporter:
            Michael Schurter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: