如何按 ListProperty* 对查询进行排序?
模型:
class Chapter(ndb.Model):
title = ndb.StringProperty(required=True)
version = ndb.IntegerProperty(repeated=True)
“版本”存储如下值:
1.1 -> [1,1]
1 -> [1]
2.1.1.1.1 -> [2,1,1,1,1]
1.2 -> [1,2]
2.1.2 -> [2,1,2]
我想这样订购:
1
1.1
1.2
2.1.1.1.1
2.1.2
*我正在使用 NDB,ListProperty = ndb.IntegerProperty(repeated=True)
最佳答案
不幸的是,这不是 listproperties 的工作方式。对于升序查询,使用的值将是列表中的最小值。 您必须以不同方式存储这些值(例如,作为字符串)才能执行您的要求。
关于python - 按 ListProperty (NDB) 对查询进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14882833/