是否可以判断NDB光标是否已反转?

2024-03-29 14:44:50 发布

您现在位置:Python中文网/ 问答频道 /正文

从GAE文档中,可以通过以下方式创建反向光标:

rev_cursor = cursor.reversed()

我正在寻找类似cursor.is_reversed()的东西,它将返回光标是否已反转。你知道吗

存在吗?你知道吗


Tags: 文档is方式revcursorgae光标reversed
1条回答
网友
1楼 · 发布于 2024-03-29 14:44:50

不,不保留此类信息。.reversed()调用只返回一个位置相反的新游标:

def reversed(self):
    """Creates a cursor for use in a query with a reversed sort order."""
    for pos in self.__compiled_cursor.position_list():
        if pos.has_start_key():
            raise datastore_errors.BadRequestError('Cursor cannot be reversed.')

    rev_pb = datastore_pb.CompiledCursor()
    rev_pb.CopyFrom(self.__compiled_cursor)
    for pos in rev_pb.position_list():
        pos.set_start_inclusive(not pos.start_inclusive())
    return Cursor(_cursor_pb=rev_pb)

(为了可读性,源代码缩进为4个空格)。你知道吗

相关问题 更多 >