2017-06-12 105 views
0

內訪問MongoDB的文檔字段我想從內部訪問某些文件場pymongo find()方法,並傳遞到一個函數在我的Python腳本,我已經試過這樣的事情:pymongo查找()函數

def some_python_function(input): 
    # some calculations 
    return some_int_based_on_input 

cursor = col.find(
    { 
     "$where" : "some_python_function(this.some_field_in_document) > 2000" 
    } 
) 

但沒有運氣。 python腳本是否可以從find()中訪問文檔字段,還是必須先執行查詢並過濾結果?

+0

可能的重複https://stackoverflow.com/questions/10230794/how-can-i-execute-a-js-script-file-from-pymongo – lesingerouge

回答