func (ec *EquipmentCreate) Save(ctx context.Context) (*Equipment, error) {
	if ec.create_time == nil {
		v := equipment.DefaultCreateTime()
		ec.create_time = &v
	}
	if ec.update_time == nil {
		v := equipment.DefaultUpdateTime()
		ec.update_time = &v
	}
	if ec.name == nil {
		return nil, errors.New("ent: missing required field \"name\"")
	}
	if err := equipment.NameValidator(*ec.name); err != nil {
		return nil, fmt.Errorf("ent: validator failed for field \"name\": %v", err)
	}
	if len(ec._type) > 1 {
		return nil, errors.New("ent: multiple assignments on a unique edge \"type\"")
	}
	if ec._type == nil {
		return nil, errors.New("ent: missing required edge \"type\"")
	}
	if len(ec.location) > 1 {
		return nil, errors.New("ent: multiple assignments on a unique edge \"location\"")
	}
	if len(ec.parent_position) > 1 {
		return nil, errors.New("ent: multiple assignments on a unique edge \"parent_position\"")
	}
	if len(ec.work_order) > 1 {
		return nil, errors.New("ent: multiple assignments on a unique edge \"work_order\"")
	}
	return ec.sqlSave(ctx)
}
// Save creates the Equipment in the database.
Save creates the Equipment in the database.
// Save creates the Equipment in the database .
func (ec *EquipmentCreate) Save(ctx context.Context) (*Equipment, error) {
	if ec.create_time == nil {
		v := equipment.DefaultCreateTime()
		ec.create_time = &v
	}
	if ec.update_time == nil {
		v := equipment.DefaultUpdateTime()
		ec.update_time = &v
	}
	if ec.name == nil {
		return nil, errors.New("ent: missing required field \"name\"")
	}
	if err := equipment.NameValidator(*ec.name); err != nil {
		return nil, fmt.Errorf("ent: validator failed for field \"name\": %v", err)
	}
	if len(ec._type) > 1 {
		return nil, errors.New("ent: multiple assignments on a unique edge \"type\"")
	}
	if ec._type == nil {
		return nil, errors.New("ent: missing required edge \"type\"")
	}
	if len(ec.location) > 1 {
		return nil, errors.New("ent: multiple assignments on a unique edge \"location\"")
	}
	if len(ec.parent_position) > 1 {
		return nil, errors.New("ent: multiple assignments on a unique edge \"parent_position\"")
	}
	if len(ec.work_order) > 1 {
		return nil, errors.New("ent: multiple assignments on a unique edge \"work_order\"")
	}
	return ec.sqlSave(ctx)
}
func ( ec * EquipmentCreate ) Save ( ctx context . Context ) ( * Equipment , error ) { if ec . create_time == nil { v := equipment . DefaultCreateTime ( ) ec . create_time = & v } if ec . update_time == nil { v := equipment . DefaultUpdateTime ( ) ec . update_time = & v } if ec . name == nil { return nil , errors . New ( " \" \" " ) } if err := equipment . NameValidator ( * ec . name ) ; err != nil { return nil , fmt . Errorf ( " \" \" " , err ) } if len ( ec . _type ) > 1 { return nil , errors . New ( " \" \" " ) } if ec . _type == nil { return nil , errors . New ( " \" \" " ) } if len ( ec . location ) > 1 { return nil , errors . New ( " \" \" " ) } if len ( ec . parent_position ) > 1 { return nil , errors . New ( " \" \" " ) } if len ( ec . work_order ) > 1 { return nil , errors . New ( " \" \" " ) } return ec . sqlSave ( ctx ) }
Save creates the Equipment in the database.
Save creates the Equipment in the database .