Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-86

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

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

      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:
            mike Michael Dirolf
            Reporter:
            schmichael Michael Schurter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: