我的域配置中有以下架构:
DOMAIN = {
'adv': {
'schema': {
'_id': {'type': 'string'},
'matchups': {
'type': 'dict',
'schema': {
'name': {'type': 'string'},
'value': {'type': 'double'}
},
},
},
},
}
尽管按 _id
排序是可行的:
http://127.0.0.1:5000/adv/?sort=[("_id",1)]
按字典值或名称排序不起作用:
http://127.0.0.1:5000/adv/?sort=[("matchups.value",1)]
最佳答案
常规端点不支持按子文档字段排序。但是,您可以使用 MongoDB Aggregation endpoint达到类似的结果。
关于python - 使用 eve REST API 在 GET 查询中按值对字典进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42956925/