Return 404 当使用 MongoDB 的 ObjectId 获取资源时?

Return 404 when GET the resource using ObjectId of MongoDB?

我正在使用 python 3.4.2、eve 0.7、flask 0.12 和 MongoDB 作为我的数据库。

这是我的 eve 模式代码:

'item_title': 'abc',                                                                                                                                         
'id_field': 'ObjectId',                                                                                                                                        
'item_lookup_field': 'ObjectId',                                                                                                                               
'item_url': r'regex("[\w]+")',                                                                                                                                 
'query_objectid_as_string': True 

当我尝试使用 Mongo 对象 ID 获取资源时,它 returns 404。

'item_title': 'abc',                                                                                                                                         
'id_field': 'custom_field',                                                                                                                                        
'item_lookup_field': 'custom_field',                                                                                                                               
'item_url': r'regex("[\w]+")',                                                                                                                                 
'query_objectid_as_string': True 

当我使用任何其他自定义字段时它工作正常。 我也试过下面的代码。还有 returns 404.

'item_title': 'abc',                                                                                                                                         
#'id_field': 'ObjectId',                                                                                                                                        
#'item_lookup_field': 'ObjectId',                                                                                                                               
'item_url': r'regex("[\w]+")',                                                                                                                                 
'query_objectid_as_string': True 
'id_field': '_id',  # Name of field                                                                                                                                      
'item_lookup_field': '_id', # Name of object field ex. mongo object id here

'query_objectid_as_string': False

因为 `query_objectid_as_string':True 它将数据库查询为字符串而不是对象。所以它不会找到。所以它 returns 404