为了账号安全,请及时绑定邮箱和手机立即绑定

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

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

慕的地6264312 2021-03-29 12:44:48
我正在尝试从数据库中读取数据库中消息的不同“线程”,但是每次尝试时,我都会返回一个空数组,这使我认为请求所有线程时出了点问题使用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]
查看完整描述

1 回答

?
慕标5832272

TA贡献1966条经验 获得超4个赞

假设您有一个clinic_id名为clinic_number的二级索引,则语法可能应该是:

.get_all(clinic_id, index="clinic_number")

除非您想获得一个范围,否则可能应该使用该范围.between()

也不确定您传递的那个奇怪的数组参数应该是什么意思。

请注意,您需要一个辅助索引才能使该查询工作,否则,您需要使用.filter,但是这会强制执行非常不理想的表扫描。


查看完整回答
反对 回复 2021-04-27
  • 1 回答
  • 0 关注
  • 149 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号