-
Type: New Feature
-
Resolution: Done
-
Priority: 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; }
')
- Function execution
db.js.add(var1, var2)
Sample code here:
http://github.com/schmichael/mongo-python-driver/commit/57e6df4ca14314eb8c0a3a9e4b8c97c0186a0121