所以,我正在尝试使用bulkloader创建一个父实体。
我有一个客户实体:
class Client(db.Model):
identifier = db.StringProperty()
www_ip = db.StringProperty()
local_ip = db.StringProperty()
status=db.BooleanProperty()
我想创建一个Data entiy作为Client的孩子。
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。我不明白的是如何通知我的客户实体(父母)。
我发现有一个问题已经讨论How to set parent for datastrore entity during bulkloading data by appcfg.py on Google App Engine?,但“代码配置”已被弃用。
由于
答案 0 :(得分:2)
老问题,但为了将来的参考,似乎答案就在这里:
- 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)