getAll什么都不返回?重新思考数据库

我正在尝试从数据库中读取数据库中消息的不同“线程”,但是每次尝试时,我都会返回一个空数组,这使我认为请求所有线程时出了点问题使用get_all命令。像这样从数据库请求是正确的吗?根本没有错误,所以我很困惑,因为它应该返回消息的线程。


def threads(cls, clinic_id, db={}):

    """Threads


    Returns the unique list of threads in the SMS log


    Arguments:

        clinic_id {uint} -- The unique ID of the clinic

        db {dict} -- Optional DB info


    Returns:

        list

    """


    # Get the info

    dInfo = cls.info(db)


    # Connect to the server

    with connect_with(dInfo['server']) as oCon:


        # Request all threads

        itRes = r \

            .db(dInfo['db']) \

            .table(dInfo['tree']._name) \

            .get_all([clinic_id, r.minval], [clinic_id, r.maxval], index="clinic_number") \

            .pluck(['number']) \

            .default(None) \

            .distinct() \

            .run(oCon)


        # Return the list of numbers

        return [d['number'] for d in itRes]

http://img3.mukewang.com/6087de5e0001e76708990248.jpg

慕的地6264312
浏览 150回答 1
1回答

慕标5832272

假设您有一个clinic_id名为clinic_number的二级索引,则语法可能应该是:.get_all(clinic_id, index="clinic_number")除非您想获得一个范围,否则可能应该使用该范围.between()。也不确定您传递的那个奇怪的数组参数应该是什么意思。请注意,您需要一个辅助索引才能使该查询工作,否则,您需要使用.filter,但是这会强制执行非常不理想的表扫描。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python