func (clcdc *CheckListCategoryDefinitionCreate) Save(ctx context.Context) (*CheckListCategoryDefinition, error) {
	if _, ok := clcdc.mutation.CreateTime(); !ok {
		v := checklistcategorydefinition.DefaultCreateTime()
		clcdc.mutation.SetCreateTime(v)
	}
	if _, ok := clcdc.mutation.UpdateTime(); !ok {
		v := checklistcategorydefinition.DefaultUpdateTime()
		clcdc.mutation.SetUpdateTime(v)
	}
	if _, ok := clcdc.mutation.Title(); !ok {
		return nil, errors.New("ent: missing required field \"title\"")
	}
	if v, ok := clcdc.mutation.Title(); ok {
		if err := checklistcategorydefinition.TitleValidator(v); err != nil {
			return nil, fmt.Errorf("ent: validator failed for field \"title\": %v", err)
		}
	}
	var (
		err  error
		node *CheckListCategoryDefinition
	)
	if len(clcdc.hooks) == 0 {
		node, err = clcdc.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*CheckListCategoryDefinitionMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			clcdc.mutation = mutation
			node, err = clcdc.sqlSave(ctx)
			mutation.done = true
			return node, err
		})
		for i := len(clcdc.hooks) - 1; i >= 0; i-- {
			mut = clcdc.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, clcdc.mutation); err != nil {
			return nil, err
		}
	}
	return node, err
}
// Save creates the CheckListCategoryDefinition in the database.
Save creates the CheckListCategoryDefinition in the database.
// Save creates the CheckListCategoryDefinition in the database .
func (clcdc *CheckListCategoryDefinitionCreate) Save(ctx context.Context) (*CheckListCategoryDefinition, error) {
	if _, ok := clcdc.mutation.CreateTime(); !ok {
		v := checklistcategorydefinition.DefaultCreateTime()
		clcdc.mutation.SetCreateTime(v)
	}
	if _, ok := clcdc.mutation.UpdateTime(); !ok {
		v := checklistcategorydefinition.DefaultUpdateTime()
		clcdc.mutation.SetUpdateTime(v)
	}
	if _, ok := clcdc.mutation.Title(); !ok {
		return nil, errors.New("ent: missing required field \"title\"")
	}
	if v, ok := clcdc.mutation.Title(); ok {
		if err := checklistcategorydefinition.TitleValidator(v); err != nil {
			return nil, fmt.Errorf("ent: validator failed for field \"title\": %v", err)
		}
	}
	var (
		err  error
		node *CheckListCategoryDefinition
	)
	if len(clcdc.hooks) == 0 {
		node, err = clcdc.sqlSave(ctx)
	} else {
		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
			mutation, ok := m.(*CheckListCategoryDefinitionMutation)
			if !ok {
				return nil, fmt.Errorf("unexpected mutation type %T", m)
			}
			clcdc.mutation = mutation
			node, err = clcdc.sqlSave(ctx)
			mutation.done = true
			return node, err
		})
		for i := len(clcdc.hooks) - 1; i >= 0; i-- {
			mut = clcdc.hooks[i](mut)
		}
		if _, err := mut.Mutate(ctx, clcdc.mutation); err != nil {
			return nil, err
		}
	}
	return node, err
}
func ( clcdc * CheckListCategoryDefinitionCreate ) Save ( ctx context . Context ) ( * CheckListCategoryDefinition , error ) { if _ , ok := clcdc . mutation . CreateTime ( ) ; ! ok { v := checklistcategorydefinition . DefaultCreateTime ( ) clcdc . mutation . SetCreateTime ( v ) } if _ , ok := clcdc . mutation . UpdateTime ( ) ; ! ok { v := checklistcategorydefinition . DefaultUpdateTime ( ) clcdc . mutation . SetUpdateTime ( v ) } if _ , ok := clcdc . mutation . Title ( ) ; ! ok { return nil , errors . New ( " \" \" " ) } if v , ok := clcdc . mutation . Title ( ) ; ok { if err := checklistcategorydefinition . TitleValidator ( v ) ; err != nil { return nil , fmt . Errorf ( " \" \" " , err ) } } var ( err error node * CheckListCategoryDefinition ) if len ( clcdc . hooks ) == 0 { node , err = clcdc . sqlSave ( ctx ) } else { var mut Mutator = MutateFunc ( func ( ctx context . Context , m Mutation ) ( Value , error ) { mutation , ok := m . ( * CheckListCategoryDefinitionMutation ) if ! ok { return nil , fmt . Errorf ( " " , m ) } clcdc . mutation = mutation node , err = clcdc . sqlSave ( ctx ) mutation . done = true return node , err } ) for i := len ( clcdc . hooks ) - 1 ; i >= 0 ; i -- { mut = clcdc . hooks [ i ] ( mut ) } if _ , err := mut . Mutate ( ctx , clcdc . mutation ) ; err != nil { return nil , err } } return node , err }
Save creates the CheckListCategoryDefinition in the database.
Save creates the CheckListCategoryDefinition in the database .