Ejemplo n.º 1
0
func encode(kind, appID, namespace, stringID, intIDStr, parentKeyString string) (*datastore.Key, error) {
	var parent *datastore.Key = nil
	if parentKeyString != "" {
		var err error
		parent, err = datastore.DecodeKey(parentKeyString)
		if err != nil {
			return nil, err
		}
	}
	return datastorekey.CreateKey(nil, appID, namespace, kind, stringID, intID64(intIDStr), parent)
}
Ejemplo n.º 2
0
func translate(sourceKey *datastore.Key, translateAppId bool, targetAppId string, translateNamespace bool, targetNamespace string) (*datastore.Key, error) {
	if !translateAppId {
		targetAppId = sourceKey.AppID()
	}
	if !translateNamespace {
		targetNamespace = sourceKey.Namespace()
	}
	var translatedParent *datastore.Key = nil
	if sourceKey.Parent() != nil {
		var err error
		translatedParent, err = translate(sourceKey.Parent(), translateAppId, targetAppId, translateNamespace, targetNamespace)
		if err != nil {
			return nil, err
		}
	}
	return datastorekey.CreateKey(nil, targetAppId, targetNamespace, sourceKey.Kind(), sourceKey.StringID(), sourceKey.IntID(), translatedParent)
}