[英]The best way to store data or query data on google app engine
我希望能夠在App Engine中存儲一些數據,並且我正在尋找有關存儲數據或通過查詢檢索數據的最佳方法的幫助。 我有一個用戶列表,希望他們能夠添加他們要出售的汽車,並輸入可接受的下限和上限。 當用戶搜索汽車並輸入價格時,如果此價格介於上限和下限之間,則會退回汽車:
class User(ndb.Model):
username = ndb.StringProperty()
cars = ndb.StructuredProperty(Car, repeated = True)
datecreated = ndb.DateTimeProperty(auto_now_add = True)
date_last_modified = ndb.DateTimeProperty(auto_now = True)
class Car(ndb.Model):
lowerprice = ndb.IntegerProperty()
maxprice = ndb.IntegerProperty()
make = ndb.StringProperty()
model = ndb.StringProperty()
datecreated = ndb.DateTimeProperty(auto_now_add = True)
date_last_modified = ndb.DateTimeProperty(auto_now = True)
我無法過濾:
c = User.query(User.car.lowerprice >= int(self.carprice), User.car.maxprice < int(self.carprice)).get())
返回BadRequestError時:每個查詢僅支持一個不等式過濾器。
我是否應該以不同的方式構造或存儲數據以允許對一個不等式進行過濾,還是應該嘗試使用和和/或查詢?
您還有其他建議嗎?
嘗試這樣的事情:
持有人= User.query(User.car.lowerprice> = int(self.carprice))。get())
結果=過濾器(lambda x:x.car.maxprice <int(self.carprice),持有人)
歸結為必須以可編程方式處理第二個過濾器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.