私は次のものを持っています:
class Notification(ndb.Model):
targetUser = ndb.KeyProperty()
pointRoot = ndb.KeyProperty()
followReason = ndb.StringProperty()
notificationReason = ndb.StringProperty()
sourceUser = ndb.KeyProperty() # User who caused notification to be raised
raisedDate = ndb.DateTimeProperty(auto_now_add=True)
cleared = ndb.BooleanProperty(default=False)
clearedDate = ndb.DateTimeProperty(default=None)
@classmethod
def getActiveNotificationsForUser(cls, userKey):
q = cls.query(ndb.AND(cls.targetUser == userKey, cls.cleared == False))
q.order(-cls.raisedDate)
notifications = q.fetch(10)
return notifications
これは不等式フィルターを使用せず、等式フィルターのみを使用するため、これは機能するはずだと思いました。うまくいかないときは、次のように index.yaml で定義されたインデックスを追加しました。
- kind: Notification
properties:
- name: targetUser
- name: cleared
- name: raisedDate
direction: desc
ただし、getActiveNotificationsForUser はまだ順不同で通知を返しています。
これを修正するために私ができる理由または何を知っている人はいますか (すべての通知を取得して Python でソートすること以外に)?
前もって感謝します、
- アーロン