从 pymongo 调用 MongoDB 存储函数
Call MongoDB stored function from pymongo
我在 mongodb 中存储了以下函数:
db.system.js.save({
_id: "testFunc",
value: function() {
return db.clients.find_one({}, {"_id" : False});
}
});
如何使用 pymongo 从 python 调用上面的函数?
我已经试过 db.eval('testFunc')
但它不起作用。该方法已弃用。
eval
、system_js
等are all deprecated.
当你can still create javascript functions on the server时,它带有一个明确的警告:
Do not store application logic in the database. There are performance
limitations to running JavaScript inside of MongoDB. Application code
also is typically most effective when it shares version control with
the application itself.
我在 mongodb 中存储了以下函数:
db.system.js.save({
_id: "testFunc",
value: function() {
return db.clients.find_one({}, {"_id" : False});
}
});
如何使用 pymongo 从 python 调用上面的函数?
我已经试过 db.eval('testFunc')
但它不起作用。该方法已弃用。
eval
、system_js
等are all deprecated.
当你can still create javascript functions on the server时,它带有一个明确的警告:
Do not store application logic in the database. There are performance limitations to running JavaScript inside of MongoDB. Application code also is typically most effective when it shares version control with the application itself.