Esempio n. 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)
	}
}
Esempio n. 2
0
func (d rdsImpl) PutMulti(keys []ds.Key, vals []ds.PropertyMap, cb ds.PutMultiCB) error {
	rkeys := dsMF2R(keys)
	rvals := make([]datastore.PropertyLoadSaver, len(vals))
	for i, val := range vals {
		rvals[i] = &typeFilter{val}
	}
	rkeys, err := datastore.PutMulti(d, rkeys, rvals)
	return idxCallbacker(err, len(keys), func(idx int, err error) {
		k := ds.Key(nil)
		if err == nil {
			k = dsR2F(rkeys[idx])
		}
		cb(k, err)
	})
}