Example #1
0
func key(kind string, id interface{}, parent ...ds.Key) ds.Key {
	p := ds.Key(nil)
	if len(parent) > 0 {
		p = parent[0]
	}
	switch x := id.(type) {
	case string:
		return dskey.New(globalAppID, "ns", kind, x, 0, p)
	case int:
		return dskey.New(globalAppID, "ns", kind, "", int64(x), p)
	default:
		return dskey.New(globalAppID, "ns", kind, "invalid", 100, p)
	}
}
Example #2
0
func (d *dataStoreData) entsKeyLocked(key ds.Key) (*memCollection, ds.Key) {
	coll := "ents:" + key.Namespace()
	ents := d.head.GetCollection(coll)
	if ents == nil {
		ents = d.head.SetCollection(coll, nil)
	}

	if dskey.Incomplete(key) {
		idKey := []byte(nil)
		if key.Parent() == nil {
			idKey = rootIDsKey(key.Kind())
		} else {
			idKey = groupIDsKey(key)
		}
		id := incrementLocked(ents, idKey)
		key = dskey.New(key.AppID(), key.Namespace(), key.Kind(), "", id, key.Parent())
	}

	return ents, key
}
Example #3
0
func (d *dsImpl) NewKey(kind, stringID string, intID int64, parent ds.Key) ds.Key {
	return dskey.New(globalAppID, d.ns, kind, stringID, intID, parent)
}
Example #4
0
func rootIDsKey(kind string) []byte {
	return keyBytes(dskey.New("", "", "__entity_root_ids__", kind, 0, nil))
}
Example #5
0
func groupIDsKey(key ds.Key) []byte {
	return keyBytes(dskey.New("", "", "__entity_group_ids__", "", 1, dskey.Root(key)))
}
Example #6
0
func (ds) NewKey(kind string, sid string, iid int64, par datastore.Key) datastore.Key {
	return dskey.New("dummy~appid", "", kind, sid, iid, par)
}