如何从查询中获取最大模型给定参数?
我想要的是获取 xs 参数,比较 ndb 中的 xs max。
如果 max_ndb(xs) 更高,则返回 max_model,否则返回 204
@MyModel.query_method(requests_fields('xs',),
name='infofest',
path='mymodel',
http_method='GET'
)
def get_model(self,query):
return max(query, key=MyModel.xs)#??
当然查询本身是不可迭代的,我可能不会使用 query_method 来代替,类似的东西。
@MyModel.method(request_fields=('xs',),
path='mymodel/{xs}', http_method='GET', name='mymodel.get') def MyModelGet(self, my_model):
if not my_model.maxXS_from_datastore:
return model_with_maxXS
return 204
或者我们可以在 endpoints-proto-datastore 中使用 GQL 吗?谢谢