Sha256: 480522a4c3cea89c69c3c2089eeca2b311c14b2d470251e22c548c627b2ef5b3

Contents?: true

Size: 622 Bytes

Versions: 10

Compression:

Stored size: 622 Bytes

Contents

<%-
import 'context'
import 'fmt'
import model.package
import 'google.golang.org/appengine/datastore'
import 'google.golang.org/appengine/log'
-%>

func (s *<%= type.name %>) Create(ctx context.Context, m *<%= model.qualified_name %>) (*datastore.Key, error) {
	if err := m.PrepareToCreate(); err != nil {
		return nil, err
	}
	return s.PutWith(ctx, m, func() error {
		exist, err := s.Exist(ctx, m)
		if err != nil {
			return err
		}
		if exist {
			log.Errorf(ctx, "Failed to create %v because of another entity has same key\n", m)
			return fmt.Errorf("Duplicate ID error: %q of %v\n", m.ID, m)
		}
		return 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/18_Create.go.erb
goon_model_gen-0.3.0 lib/goon_model_gen/templates/store/goon/18_Create.go.erb
goon_model_gen-0.2.5 lib/goon_model_gen/templates/store/goon/18_Create.go.erb
goon_model_gen-0.2.4 lib/goon_model_gen/templates/store/goon/18_Create.go.erb
goon_model_gen-0.2.3 lib/goon_model_gen/templates/store/goon/17_Create.go.erb
goon_model_gen-0.2.2 lib/goon_model_gen/templates/store/goon/17_Create.go.erb
goon_model_gen-0.2.1 lib/goon_model_gen/templates/store/goon/17_Create.go.erb
goon_model_gen-0.2.0 lib/goon_model_gen/templates/store/goon/17_Create.go.erb
goon_model_gen-0.1.3 lib/goon_model_gen/templates/store/goon/17_Create.go.erb
goon_model_gen-0.1.2 lib/goon_model_gen/templates/store/goon/17_Create.go.erb