因此,我正在尝试使用批量加载程序创建一个带有父级的实体。
我有一个客户实体:
class Client(db.Model):
identifier = db.StringProperty()
www_ip = db.StringProperty()
local_ip = db.StringProperty()
status=db.BooleanProperty()
我想创建一个数据作为客户端的子级。
class Data(db.Model):
songscount = db.IntegerProperty()
nextorder = db.IntegerProperty(default=1)
players = db.ListProperty(str)
previousplayer = db.StringProperty()
客户端实体存在。Data.yaml 是(不带前导码):
transformers:
- kind: Data
connector: csv
connector_options:
# TODO: Add connector options here--these are specific to each connector.
property_map:
- property: __key__
external_name: key
import_transform: transform.create_deep_key(('Client', '__key__'), ('Data', transform.CURRENT_PROPERTY))
export_transform: transform.key_id_or_name_as_string
- property: nextorder
external_name: nextorder
import_transform: transform.none_if_empty(int)
- property: players
external_name: players
import_transform: transform.none_if_empty(users.User) # Assumes email address
- property: previousplayer
external_name: previousplayer
import_transform: transform.none_if_empty(users.User) # Assumes email address
- property: songscount
external_name: songscount
import_transform: transform.none_if_empty(int)
我知道需要使用transform.create_foreign_key或transform.create_deep_key。我不明白的是如何通知我的客户实体(即父实体)。
我发现一个这样的问题讨论了如何在 Google App Engine 上批量加载数据期间为数据实体设置父级 appcfg.py?,但"代码配置"已被弃用。
谢谢
老问题,但供将来参考,答案似乎在这里:
- property: __key__
external_name: key
import_transform: transform.create_deep_key(('clientKey‘, ‘clientKey‘),(’key‘, transform.CURRENT_PROPERTY))
export:
- external_name: clientKey
export_transform: transform.key_id_or_name_as_string_n(0)
- external_name: key
export_transform: transform.key_id_or_name_as_string_n(1)
(改编自 http://longsystemit.com/javablog/?p=23)