map() 的 Google AppEngine NDB 文档指出:
"All query options keyword arguments are supported."
但是,我已尝试在 map()
上使用 produces_cursors=True
,但我没有取回光标。
map(callback, pass_batch_into_callback=None, merge_future=None, **q_options)
我想使用 map()
,因为我可以将回调设置为 tasklet。
https://developers.google.com/appengine/docs/python/ndb/queryclass#kwdargs_options
编辑 - 提供代码示例:
@ndb.tasklet
def callback(user):
statistics = yield ndb.Key(Statistics, user.key.id()).get_async()
raise ndb.Return(user, statistics)
result = User.query().map(callback, produces_cursors=True)
最佳答案
该示例似乎有错字——正确的标志是 produce_cursors
,而不是 produces_cursors
。
但是只有在使用迭代器时才能使用游标,而不能使用 map()
。查看异步迭代器示例;这需要一些工作,但您绝对可以使用它为每个结果手动创建一个 tasklet。
关于python - NDB map (回调,produces_cursors=True),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14125243/