本文整理汇总了Golang中google/golang.org/appengine/datastore.Key.AppID方法的典型用法代码示例。如果您正苦于以下问题:Golang Key.AppID方法的具体用法?Golang Key.AppID怎么用?Golang Key.AppID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google/golang.org/appengine/datastore.Key
的用法示例。
在下文中一共展示了Key.AppID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ktoi
func ktoi(key *datastore.Key) id {
return id{
kind: key.Kind(),
stringID: key.StringID(),
intID: key.IntID(),
appID: key.AppID(),
namespace: key.Namespace(),
}
}
示例2: buildDatastoreKey
func buildDatastoreKey(key *datastore.Key) (map[string]bigquery.JsonValue, error) {
if key == nil {
return map[string]bigquery.JsonValue{
"namespace": "",
"app": "",
"path": "",
"kind": "",
"name": "",
"id": 0,
}, nil
}
var workKey = key
var keys []*datastore.Key
keys = append(keys, key)
for {
if workKey.Parent() == nil {
break
}
keys = append(keys, workKey.Parent())
workKey = workKey.Parent()
}
var buf bytes.Buffer
for i := len(keys) - 1; i >= 0; i-- {
if buf.Len() > 0 {
_, err := buf.WriteString(", ")
if err != nil {
return map[string]bigquery.JsonValue{}, nil
}
}
key := keys[i]
if len(key.StringID()) < 1 {
_, err := buf.WriteString(fmt.Sprintf(`"%s", "%s"`, keys[i].Kind(), keys[i].IntID()))
if err != nil {
return map[string]bigquery.JsonValue{}, nil
}
} else {
_, err := buf.WriteString(fmt.Sprintf(`"%s", "%s"`, keys[i].Kind(), keys[i].StringID()))
if err != nil {
return map[string]bigquery.JsonValue{}, nil
}
}
}
return map[string]bigquery.JsonValue{
"namespace": key.Namespace(),
"app": key.AppID(),
"path": buf.String(),
"kind": key.Kind(),
"name": key.StringID(),
"id": key.IntID(),
}, nil
}
示例3: cmpKey
// cmpKey compares k and other, returning -1, 0 or 1 if k is
// less than, equal or grather than other. The algorithm doesn't
// takes into account any ancestors in the two keys. The order
// of comparision is AppID, Kind, IntID and StringID. Keys with
// integer identifiers are smaller than string identifiers.
func cmpKey(k, other *datastore.Key) int {
if k == other {
return 0
}
if r := cmpStr(k.AppID(), other.AppID()); r != 0 {
return r
}
if r := cmpStr(k.Kind(), other.Kind()); r != 0 {
return r
}
if k.IntID() != 0 {
if other.IntID() == 0 {
return -1
}
return cmpInt(k.IntID(), other.IntID())
}
if other.IntID() != 0 {
return 1
}
return cmpStr(k.StringID(), other.StringID())
}
示例4: dsR2F
// dsR2F (DS real-to-fake) converts an SDK Key to a ds.Key
func dsR2F(k *datastore.Key) *ds.Key {
if k == nil {
return nil
}
aid := k.AppID()
ns := k.Namespace()
count := 0
for nk := k; nk != nil; nk = nk.Parent() {
count++
}
toks := make([]ds.KeyTok, count)
for ; k != nil; k = k.Parent() {
count--
toks[count].Kind = k.Kind()
toks[count].StringID = k.StringID()
toks[count].IntID = k.IntID()
}
return ds.NewKeyToks(aid, ns, toks)
}