本文整理汇总了Golang中github.com/soundtrackyourbrand/utils/key.Key.Parent方法的典型用法代码示例。如果您正苦于以下问题:Golang Key.Parent方法的具体用法?Golang Key.Parent怎么用?Golang Key.Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/soundtrackyourbrand/utils/key.Key
的用法示例。
在下文中一共展示了Key.Parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: cacheKeys
// cacheKeys will append to oldKeys, and also return as newKeys, all cache keys this finder may use to find the provided model.
// the reason there may be multiple keys is that we don't know which ancestor will be used when finding the model.
func (self finder) cacheKeys(c PersistenceContext, model interface{}, oldKeys *[]string) (newKeys []string, err error) {
var id key.Key
if _, id, err = getTypeAndId(model); err != nil {
return
}
values := make([]interface{}, len(self.fields))
val := reflect.ValueOf(model).Elem()
for index, field := range self.fields {
values[index] = val.FieldByName(field.Name).Interface()
}
if oldKeys == nil {
oldKeys = &[]string{}
}
for id != "" {
*oldKeys = append(*oldKeys, self.keyForValues(id.Parent(), values))
id = id.Parent()
}
newKeys = *oldKeys
return
}