pistacchio
pistacchio

Reputation: 58903

Pymongo and stored javascript

I have a stored javascript function in db.system.js, call it my_func and it accepts 2 arrays of strings as arguments.

How can I call it from pymongo? For example calling

my_func(['a', 'b'], ['c', 'd'])

Thanks

Upvotes: 0

Views: 861

Answers (1)

Fernando Jorge Mota
Fernando Jorge Mota

Reputation: 1554

You can use something as

...
database_connection = conn.my_database
# Here is the magic:
print database_connection.system_js.my_func(['a', 'b'], ['c', 'd'])

And it just works!

Here is the documentation of the system_js attribute: http://api.mongodb.org/python/current/api/pymongo/database.html#pymongo.database.Database.system_js

Upvotes: 1

Related Questions