Sha256: d2cccbf8785b30186660cd6e64da9dcbc50d98ddd12ccf1d7ae7516a47c158b2

Contents?: true

Size: 713 Bytes

Versions: 10

Compression:

Stored size: 713 Bytes

Contents

<%-
import 'context'
import model.package
import 'google.golang.org/appengine/datastore'
import 'google.golang.org/appengine/log'
import 'github.com/mjibson/goon'
-%>

func (s *<%= type.name %>) Exist(ctx context.Context, m *<%= model.qualified_name %>) (bool, error) {
	if m.ID == 0 {
		return false, nil
	}
	g := goon.FromContext(ctx)
	key, err := g.KeyError(m)
	if err != nil {
		log.Errorf(ctx, "Failed to Get Key of %v because of %v\n", m, err)
		return false, err
	}
	_, err = s.ByKey(ctx, key)
	if err == datastore.ErrNoSuchEntity {
		return false, nil
	} else if err != nil {
		log.Errorf(ctx, "Failed to get existance of %v because of %v\n", m, err)
		return false, err
	} else {
		return true, nil
	}
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
goon_model_gen-0.3.1 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.3.0 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.2.5 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.2.4 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.2.3 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.2.2 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.2.1 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.2.0 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.1.3 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb
goon_model_gen-0.1.2 lib/goon_model_gen/templates/store/goon/16_Exist.go.erb