src/server/pkg/collection/collection.go
func (c *readWriteCollection) Upsert(key string, val proto.Message, f func() error) error {
	if err := watch.CheckType(c.template, val); err != nil {
		return err
	}
	if err := c.Get(key, val); err != nil && !IsErrNotFound(err) {
		return err
	}
	if err := f(); err != nil {
		return err
	}
	return c.Put(key, val)
}
func (c *readWriteCollection) Upsert(key string, val proto.Message, f func() error) error {
	if err := watch.CheckType(c.template, val); err != nil {
		return err
	}
	if err := c.Get(key, val); err != nil && !IsErrNotFound(err) {
		return err
	}
	if err := f(); err != nil {
		return err
	}
	return c.Put(key, val)
}
func ( c * readWriteCollection ) Upsert ( key string , val proto . Message , f func ( ) error ) error { if err := watch . CheckType ( c . template , val ) ; err != nil { return err } if err := c . Get ( key , val ) ; err != nil && ! IsErrNotFound ( err ) { return err } if err := f ( ) ; err != nil { return err } return c . Put ( key , val ) }
// Upsert is like Update but 'key' is not required to be present
Upsert is like Update but key is not required to be present