开发者

How can I Create a List of References in Google App Engine Datastore?

开发者 https://www.devze.com 2023-01-11 12:54 出处:网络
I have a Foo type in my Google App Engine datastore. I\'d like it to link to a series of other Foo types, call them prerequ开发者_StackOverflow社区isites.

I have a Foo type in my Google App Engine datastore. I'd like it to link to a series of other Foo types, call them prerequ开发者_StackOverflow社区isites.

I can use the ListProperty type to make a list of simple value types but I'm not sure how to do this with references. What is the recommended approach for doing this?


There's (currently) no db.ReferenceListProperty in the datastore. You can closely approximate it with a db.ListProperty(db.Key); if you need to retrieve all the referenced keys, you can do a batch db.get() on it to retrieve all the referenced entities at once.


References are just keys, which can be represented as strings, so you could use a StringListProperty to store your keys.

0

精彩评论

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