使用python,我有一个像这样的谷歌数据存储区域模型。
class Persona(ndb.Model):
name = ndb.StringProperty(repeated=True)
names= ndb.StringProperty(default="")
address = ndb.StringProperty(indexed=False)
city = ndb.StringProperty()
count = ndb.IntegerProperty(default=0)
当我创建实体时,我为每个实体使用了自己的ID(sting),因此我可以像这样查询(使用remote_api):
data_person.Person.query(data_person.Person.name=="Adam").fetch(10,keys_only=True)
结果是:
[Key('Person', '16.240.886'), Key('Person', '17.722.453'), Key('Person', '13.627.225'), Key('Person', '18.223.406'), Key('Person', '18.460.819'), Key('Persona', '17.047.133'), Key('Person', '12.875.781'), Key('Person', '13.182.078'), Key('Person', '14.186.000'), Key('Person', '14.424.659')]
如何查询ID(或键)以使vales比特定Id(或Key)更低(或更高)
例如:
query(Person.id()<'16.240.886') #I know this is wrong, is just understand the idea order to get all the keys lower then the specific id
答案 0 :(得分:1)
你可以这样做:
Person.query().filter(Person.key < ndb.Key(Person, '16.240.886'))