繁体   English   中英

GAE NDB中与ComputedProperty相关的读写操作

[英]Read and Write Operations involved with ComputedProperty in GAE NDB

我使用GAE NDB Python 2.7
我的两个模型代码:

class A(ndb.Model): 
    def X(self, value): 
        :: # some statements to return a value 
        return range 
    def Y(self, value): 
        :: # some statements to return a value 
        return range 
    def Z(self, value): 
        :: # some statements to return a value 
        return range 

    property_1 = ndb.IntegerProperty(default=0, indexed=False) 
    property_2 = ndb.IntegerProperty(default=0, indexed=False) 
    property_3 = ndb.IntegerProperty(default=0, indexed=False) 
    property_4 = ndb.IntegerProperty(indexed=False) 
    # Computed values 
    computed_property_1 = ndb.ComputedProperty(lambda e: e.X(e.property_1)) 
    computed_property_2 = ndb.ComputedProperty(lambda e: e.Y(e.property_2)) 
    computed_property_3 = ndb.ComputedProperty(lambda e: e.Z(e.property_3)) 
    date_added = ndb.DateTimeProperty(auto_now_add=True, indexed=False) 
    date_modified = ndb.DateTimeProperty(auto_now=True, indexed=False) 

class B(ndb.Model): 
    property_5 = ndb.IntegerProperty() 
    property_6 = ndb.StructuredProperty(A) 
    date_added = ndb.DateTimeProperty(auto_now_add=True, indexed=False) 
    date_modified = ndb.DateTimeProperty(auto_now=True, indexed=False) 

我的查询代码:

qry_1 = B.query(B.property_5==input_value) # or B.query(B.property_6.computed_property_2==input_value) 
record_list = qry_1.fetch() 

当我对模型B的实体执行以上查询时,是否将执行任何写操作? (尤其是对于ComputedProperty和DateTimeProperty(带有“ auto_now”)属性)

如果是,将速率限制为每秒写入1次(我认为这是免费应用程序的限制)

如果是,并且如果我有50个与查询匹配的实体,它将先完成写操作(如上所述),然后再完成查询并返回匹配的实体集(查询完成时间的任何估算值)

如果我替换B类中的以下行,则以上答案中的任何区别

property_6 = ndb.StructuredProperty(A)  

property_6 = ndb.StructuredProperty(A, repeated=True)  

没有执行查询的写操作。 同样适用于带有StructuredProperty的两个变体。 同样, auto_now_addauto_now也仅在写操作期间设置。 我不确定100%,但是据我了解的文档,计算属性也在写时更新(我还没有使用过)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM