【发布时间】:2018-10-14 01:34:12
【问题描述】:
我正在尝试从名为 prob 的 mongo 数据库集合中获取 nr 的最高值,现在看起来像这样:
{
"_id": {
"$oid": "5ae9d062f36d282906c59736"
},
"nr": 1,
"nume": "numeunu",
"enunt": "-",
"datedeintrare": "-",
"datedeiesire": "-"
}
{
"_id": {
"$oid": "5ae9f190f36d282906c5b461"
},
"nr": 2,
"nume": "numedoi",
"enunt": "-",
"datedeintrare": "-",
"datedeiesire": "-"
}
我的测试烧瓶代码是:
@app.route('/test')
def testaree():
prob = mongo.db.prob
return prob.find().sort({"nr":-1}).limit(1)
但它给了我一个错误TypeError: if no direction is specified, key_or_list must be an instance of list
【问题讨论】:
标签: python mongodb flask pymongo flask-pymongo