本文整理汇总了Golang中github.com/tetrafolium/gae/service/datastore.Key.Parent方法的典型用法代码示例。如果您正苦于以下问题:Golang Key.Parent方法的具体用法?Golang Key.Parent怎么用?Golang Key.Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tetrafolium/gae/service/datastore.Key
的用法示例。
在下文中一共展示了Key.Parent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AllocateIDs
func (d rdsImpl) AllocateIDs(incomplete *ds.Key, n int) (start int64, err error) {
par, err := dsF2R(d.aeCtx, incomplete.Parent())
if err != nil {
return
}
start, _, err = datastore.AllocateIDs(d.aeCtx, incomplete.Kind(), par, n)
return
}
示例2: fixKeyLocked
func (d *dataStoreData) fixKeyLocked(ents *memCollection, key *ds.Key) (*ds.Key, error) {
if key.Incomplete() {
id, err := d.allocateIDsLocked(ents, key, 1)
if err != nil {
return key, err
}
key = ds.NewKey(key.AppID(), key.Namespace(), key.Kind(), "", id, key.Parent())
}
return key, nil
}
示例3: allocateIDsLocked
func (d *dataStoreData) allocateIDsLocked(ents *memCollection, incomplete *ds.Key, n int) (int64, error) {
if d.disableSpecialEntities {
return 0, errors.New("disableSpecialEntities is true so allocateIDs is disabled")
}
idKey := []byte(nil)
if incomplete.Parent() == nil {
idKey = rootIDsKey(incomplete.Kind())
} else {
idKey = groupIDsKey(incomplete)
}
return incrementLocked(ents, idKey, n), nil
}
示例4: PropertyMapPartially
// PropertyMapPartially turns a regular PropertyMap into a SerializedPmap.
// Essentially all the []Property's become SerializedPslice, using cmpbin and
// datastore/serialize's encodings.
func PropertyMapPartially(k *ds.Key, pm ds.PropertyMap) (ret SerializedPmap) {
ret = make(SerializedPmap, len(pm)+2)
if k != nil {
ret["__key__"] = [][]byte{ToBytes(ds.MkProperty(k))}
for k != nil {
ret["__ancestor__"] = append(ret["__ancestor__"], ToBytes(ds.MkProperty(k)))
k = k.Parent()
}
}
for k, vals := range pm {
newVals := PropertySlice(vals)
if len(newVals) > 0 {
ret[k] = newVals
}
}
return
}