簡體   English   中英

NDB查詢返回零結果。 數據存儲區顯示結果

[英]NDB query returns zero results. Datastore shows the result

我發現這個特殊問題,運行查詢,確認記錄存在,返回計數為零。

這是我的模特:

class Description(ndb.Model):
    description = ndb.TextProperty()
    time_posted = ndb.DateTimeProperty(auto_now_add=True)
    uuid = ndb.StringProperty()

class Examine(ndb.Model):
    updated = ndb.DateTimeProperty(auto_now=True, auto_now_add=True)
    descriptions = ndb.StructuredProperty(Description, repeated=True)
    active = ndb.KeyProperty(kind=Description)
    slug = ndb.StringProperty(indexed=True)

假設我正在運行以下操作,確認數據存儲區中確實存在特定的UUID:

d_id = 'ef531b70-3486-11e3-9500-ef31d661e6b2'
cnt = Description.query(Description.uuid == d_id).count()

因為cnt,我將收到0。 有人可以向我解釋為什么會這樣嗎?

數據存儲區查詢最終是一致的。 這意味着如果基礎數據發生更改,有時查詢將無法反映此更改。

要解決此問題,您可以構建數據存儲區和查詢以保持一致性: https//developers.google.com/appengine/docs/python/datastore/structuring_for_strong_consistency

如果描述實體保存在檢查的父鍵中,則以下查詢將非常一致:

cnt = Description.query(ancestor=ExamineKey).filter(Description.uuid == d_id).count()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM