开发者

What is dbReferenceProperty?

In the python app engine docs, I see something called dbReferenceProperty. I can't understand what it is, or how it's used. I'm using the java interface to app engine, so I'm not sure if there's an equivalent.

I'm interested in 开发者_StackOverflowit because it sounds like some sort of pseudo-join, where we can point a property of a class to some other object's value - something like if we had:

class User {
    private String mPhotoUrl;
    private String mPhone;
    private String mState;
    private String mCountry;
    .. etc ..
}

class UserLite {
    @ReferenceProperty User.mPhotoUrl;
    private String mPhotoUrl;
}

then if we had to update a User object's mPhotoUrl value, the change would somehow propagate out to all UserLite instances referencing it, rather than having to update every UserLite object instance manually,

Thanks


A db.ReferenceProperty simply holds the key of another datastore entity, which is automatically fetched from the datastore when the property is used.

There's some additional magic where the entity that is referenced has access to a query for entities of type Foo that reference it in the special attribute foo_set.

The Java datastore API instead has owned relationships, which serve the same purpose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜