亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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 關注
  • 194 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號