package ent

import (
	"context"
	"fmt"
	"refernet/internal/ent/company"
	"refernet/internal/ent/job"
	"refernet/internal/ent/predicate"
	"refernet/internal/ent/skill"
	"refernet/internal/ent/user"
	"refernet/internal/ent/workexperience"
	"sync"
	"time"

	"entgo.io/ent"
)

const (

	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	TypeCompany        = "Company"
	TypeJob            = "Job"
	TypeSkill          = "Skill"
	TypeUser           = "User"
	TypeWorkExperience = "WorkExperience"
)

type CompanyMutation struct {
	config
	op            Op
	typ           string
	id            *int
	created_at    *time.Time
	updated_at    *time.Time
	name          *string
	overview      *string
	website       *string
	logo_url      *string
	size          *company.Size
	founded_at    *int
	addfounded_at *int
	clearedFields map[string]struct{}
	staffs        map[int]struct{}
	removedstaffs map[int]struct{}
	clearedstaffs bool
	done          bool
	oldValue      func(context.Context) (*Company, error)
	predicates    []predicate.Company
}

var _ ent.Mutation = (*CompanyMutation)(nil)

type companyOption func(*CompanyMutation)

func newCompanyMutation(c config, op Op, opts ...companyOption) *CompanyMutation {
	m := &CompanyMutation{
		config:        c,
		op:            op,
		typ:           TypeCompany,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

func withCompanyID(id int) companyOption {
	return func(m *CompanyMutation) {
		var (
			err   error
			once  sync.Once
			value *Company
		)
		m.oldValue = func(ctx context.Context) (*Company, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Company.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

func withCompany(node *Company) companyOption {
	return func(m *CompanyMutation) {
		m.oldValue = func(context.Context) (*Company, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

func (m CompanyMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

func (m CompanyMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

func (m *CompanyMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

func (m *CompanyMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

func (m *CompanyMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

func (m *CompanyMutation) ResetCreatedAt() {
	m.created_at = nil
}

func (m *CompanyMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

func (m *CompanyMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

func (m *CompanyMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

func (m *CompanyMutation) SetName(s string) {
	m.name = &s
}

func (m *CompanyMutation) Name() (r string, exists bool) {
	v := m.name
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) OldName(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldName requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldName: %w", err)
	}
	return oldValue.Name, nil
}

func (m *CompanyMutation) ResetName() {
	m.name = nil
}

func (m *CompanyMutation) SetOverview(s string) {
	m.overview = &s
}

func (m *CompanyMutation) Overview() (r string, exists bool) {
	v := m.overview
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) OldOverview(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldOverview is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldOverview requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldOverview: %w", err)
	}
	return oldValue.Overview, nil
}

func (m *CompanyMutation) ResetOverview() {
	m.overview = nil
}

func (m *CompanyMutation) SetWebsite(s string) {
	m.website = &s
}

func (m *CompanyMutation) Website() (r string, exists bool) {
	v := m.website
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) OldWebsite(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldWebsite is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldWebsite requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldWebsite: %w", err)
	}
	return oldValue.Website, nil
}

func (m *CompanyMutation) ResetWebsite() {
	m.website = nil
}

func (m *CompanyMutation) SetLogoURL(s string) {
	m.logo_url = &s
}

func (m *CompanyMutation) LogoURL() (r string, exists bool) {
	v := m.logo_url
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) OldLogoURL(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldLogoURL is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldLogoURL requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLogoURL: %w", err)
	}
	return oldValue.LogoURL, nil
}

func (m *CompanyMutation) ResetLogoURL() {
	m.logo_url = nil
}

func (m *CompanyMutation) SetSize(c company.Size) {
	m.size = &c
}

func (m *CompanyMutation) Size() (r company.Size, exists bool) {
	v := m.size
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) OldSize(ctx context.Context) (v company.Size, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldSize is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldSize requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSize: %w", err)
	}
	return oldValue.Size, nil
}

func (m *CompanyMutation) ResetSize() {
	m.size = nil
}

func (m *CompanyMutation) SetFoundedAt(i int) {
	m.founded_at = &i
	m.addfounded_at = nil
}

func (m *CompanyMutation) FoundedAt() (r int, exists bool) {
	v := m.founded_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) OldFoundedAt(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldFoundedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldFoundedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldFoundedAt: %w", err)
	}
	return oldValue.FoundedAt, nil
}

func (m *CompanyMutation) AddFoundedAt(i int) {
	if m.addfounded_at != nil {
		*m.addfounded_at += i
	} else {
		m.addfounded_at = &i
	}
}

func (m *CompanyMutation) AddedFoundedAt() (r int, exists bool) {
	v := m.addfounded_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *CompanyMutation) ResetFoundedAt() {
	m.founded_at = nil
	m.addfounded_at = nil
}

func (m *CompanyMutation) AddStaffIDs(ids ...int) {
	if m.staffs == nil {
		m.staffs = make(map[int]struct{})
	}
	for i := range ids {
		m.staffs[ids[i]] = struct{}{}
	}
}

func (m *CompanyMutation) ClearStaffs() {
	m.clearedstaffs = true
}

func (m *CompanyMutation) StaffsCleared() bool {
	return m.clearedstaffs
}

func (m *CompanyMutation) RemoveStaffIDs(ids ...int) {
	if m.removedstaffs == nil {
		m.removedstaffs = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.staffs, ids[i])
		m.removedstaffs[ids[i]] = struct{}{}
	}
}

func (m *CompanyMutation) RemovedStaffsIDs() (ids []int) {
	for id := range m.removedstaffs {
		ids = append(ids, id)
	}
	return
}

func (m *CompanyMutation) StaffsIDs() (ids []int) {
	for id := range m.staffs {
		ids = append(ids, id)
	}
	return
}

func (m *CompanyMutation) ResetStaffs() {
	m.staffs = nil
	m.clearedstaffs = false
	m.removedstaffs = nil
}

func (m *CompanyMutation) Where(ps ...predicate.Company) {
	m.predicates = append(m.predicates, ps...)
}

func (m *CompanyMutation) Op() Op {
	return m.op
}

func (m *CompanyMutation) Type() string {
	return m.typ
}

func (m *CompanyMutation) Fields() []string {
	fields := make([]string, 0, 8)
	if m.created_at != nil {
		fields = append(fields, company.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, company.FieldUpdatedAt)
	}
	if m.name != nil {
		fields = append(fields, company.FieldName)
	}
	if m.overview != nil {
		fields = append(fields, company.FieldOverview)
	}
	if m.website != nil {
		fields = append(fields, company.FieldWebsite)
	}
	if m.logo_url != nil {
		fields = append(fields, company.FieldLogoURL)
	}
	if m.size != nil {
		fields = append(fields, company.FieldSize)
	}
	if m.founded_at != nil {
		fields = append(fields, company.FieldFoundedAt)
	}
	return fields
}

func (m *CompanyMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case company.FieldCreatedAt:
		return m.CreatedAt()
	case company.FieldUpdatedAt:
		return m.UpdatedAt()
	case company.FieldName:
		return m.Name()
	case company.FieldOverview:
		return m.Overview()
	case company.FieldWebsite:
		return m.Website()
	case company.FieldLogoURL:
		return m.LogoURL()
	case company.FieldSize:
		return m.Size()
	case company.FieldFoundedAt:
		return m.FoundedAt()
	}
	return nil, false
}

func (m *CompanyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case company.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case company.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case company.FieldName:
		return m.OldName(ctx)
	case company.FieldOverview:
		return m.OldOverview(ctx)
	case company.FieldWebsite:
		return m.OldWebsite(ctx)
	case company.FieldLogoURL:
		return m.OldLogoURL(ctx)
	case company.FieldSize:
		return m.OldSize(ctx)
	case company.FieldFoundedAt:
		return m.OldFoundedAt(ctx)
	}
	return nil, fmt.Errorf("unknown Company field %s", name)
}

func (m *CompanyMutation) SetField(name string, value ent.Value) error {
	switch name {
	case company.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case company.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case company.FieldName:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetName(v)
		return nil
	case company.FieldOverview:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetOverview(v)
		return nil
	case company.FieldWebsite:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetWebsite(v)
		return nil
	case company.FieldLogoURL:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLogoURL(v)
		return nil
	case company.FieldSize:
		v, ok := value.(company.Size)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSize(v)
		return nil
	case company.FieldFoundedAt:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetFoundedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Company field %s", name)
}

func (m *CompanyMutation) AddedFields() []string {
	var fields []string
	if m.addfounded_at != nil {
		fields = append(fields, company.FieldFoundedAt)
	}
	return fields
}

func (m *CompanyMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case company.FieldFoundedAt:
		return m.AddedFoundedAt()
	}
	return nil, false
}

func (m *CompanyMutation) AddField(name string, value ent.Value) error {
	switch name {
	case company.FieldFoundedAt:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddFoundedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Company numeric field %s", name)
}

func (m *CompanyMutation) ClearedFields() []string {
	return nil
}

func (m *CompanyMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

func (m *CompanyMutation) ClearField(name string) error {
	return fmt.Errorf("unknown Company nullable field %s", name)
}

func (m *CompanyMutation) ResetField(name string) error {
	switch name {
	case company.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case company.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case company.FieldName:
		m.ResetName()
		return nil
	case company.FieldOverview:
		m.ResetOverview()
		return nil
	case company.FieldWebsite:
		m.ResetWebsite()
		return nil
	case company.FieldLogoURL:
		m.ResetLogoURL()
		return nil
	case company.FieldSize:
		m.ResetSize()
		return nil
	case company.FieldFoundedAt:
		m.ResetFoundedAt()
		return nil
	}
	return fmt.Errorf("unknown Company field %s", name)
}

func (m *CompanyMutation) AddedEdges() []string {
	edges := make([]string, 0, 1)
	if m.staffs != nil {
		edges = append(edges, company.EdgeStaffs)
	}
	return edges
}

func (m *CompanyMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case company.EdgeStaffs:
		ids := make([]ent.Value, 0, len(m.staffs))
		for id := range m.staffs {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *CompanyMutation) RemovedEdges() []string {
	edges := make([]string, 0, 1)
	if m.removedstaffs != nil {
		edges = append(edges, company.EdgeStaffs)
	}
	return edges
}

func (m *CompanyMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case company.EdgeStaffs:
		ids := make([]ent.Value, 0, len(m.removedstaffs))
		for id := range m.removedstaffs {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *CompanyMutation) ClearedEdges() []string {
	edges := make([]string, 0, 1)
	if m.clearedstaffs {
		edges = append(edges, company.EdgeStaffs)
	}
	return edges
}

func (m *CompanyMutation) EdgeCleared(name string) bool {
	switch name {
	case company.EdgeStaffs:
		return m.clearedstaffs
	}
	return false
}

func (m *CompanyMutation) ClearEdge(name string) error {
	switch name {
	}
	return fmt.Errorf("unknown Company unique edge %s", name)
}

func (m *CompanyMutation) ResetEdge(name string) error {
	switch name {
	case company.EdgeStaffs:
		m.ResetStaffs()
		return nil
	}
	return fmt.Errorf("unknown Company edge %s", name)
}

type JobMutation struct {
	config
	op               Op
	typ              string
	id               *int
	created_at       *time.Time
	updated_at       *time.Time
	title            *string
	min_salary       *uint64
	addmin_salary    *uint64
	max_salary       *uint64
	addmax_salary    *uint64
	salary_unit      *job.SalaryUnit
	employment_type  *job.EmploymentType
	requirements     *string
	responsibilities *string
	benefits         *string
	clearedFields    map[string]struct{}
	owner            *int
	clearedowner     bool
	skills           map[int]struct{}
	removedskills    map[int]struct{}
	clearedskills    bool
	done             bool
	oldValue         func(context.Context) (*Job, error)
	predicates       []predicate.Job
}

var _ ent.Mutation = (*JobMutation)(nil)

type jobOption func(*JobMutation)

func newJobMutation(c config, op Op, opts ...jobOption) *JobMutation {
	m := &JobMutation{
		config:        c,
		op:            op,
		typ:           TypeJob,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

func withJobID(id int) jobOption {
	return func(m *JobMutation) {
		var (
			err   error
			once  sync.Once
			value *Job
		)
		m.oldValue = func(ctx context.Context) (*Job, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Job.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

func withJob(node *Job) jobOption {
	return func(m *JobMutation) {
		m.oldValue = func(context.Context) (*Job, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

func (m JobMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

func (m JobMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

func (m *JobMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

func (m *JobMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

func (m *JobMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

func (m *JobMutation) ResetCreatedAt() {
	m.created_at = nil
}

func (m *JobMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

func (m *JobMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

func (m *JobMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

func (m *JobMutation) SetTitle(s string) {
	m.title = &s
}

func (m *JobMutation) Title() (r string, exists bool) {
	v := m.title
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldTitle(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldTitle is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldTitle requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldTitle: %w", err)
	}
	return oldValue.Title, nil
}

func (m *JobMutation) ResetTitle() {
	m.title = nil
}

func (m *JobMutation) SetMinSalary(u uint64) {
	m.min_salary = &u
	m.addmin_salary = nil
}

func (m *JobMutation) MinSalary() (r uint64, exists bool) {
	v := m.min_salary
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldMinSalary(ctx context.Context) (v uint64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldMinSalary is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldMinSalary requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldMinSalary: %w", err)
	}
	return oldValue.MinSalary, nil
}

func (m *JobMutation) AddMinSalary(u uint64) {
	if m.addmin_salary != nil {
		*m.addmin_salary += u
	} else {
		m.addmin_salary = &u
	}
}

func (m *JobMutation) AddedMinSalary() (r uint64, exists bool) {
	v := m.addmin_salary
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) ResetMinSalary() {
	m.min_salary = nil
	m.addmin_salary = nil
}

func (m *JobMutation) SetMaxSalary(u uint64) {
	m.max_salary = &u
	m.addmax_salary = nil
}

func (m *JobMutation) MaxSalary() (r uint64, exists bool) {
	v := m.max_salary
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldMaxSalary(ctx context.Context) (v uint64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldMaxSalary is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldMaxSalary requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldMaxSalary: %w", err)
	}
	return oldValue.MaxSalary, nil
}

func (m *JobMutation) AddMaxSalary(u uint64) {
	if m.addmax_salary != nil {
		*m.addmax_salary += u
	} else {
		m.addmax_salary = &u
	}
}

func (m *JobMutation) AddedMaxSalary() (r uint64, exists bool) {
	v := m.addmax_salary
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) ResetMaxSalary() {
	m.max_salary = nil
	m.addmax_salary = nil
}

func (m *JobMutation) SetSalaryUnit(ju job.SalaryUnit) {
	m.salary_unit = &ju
}

func (m *JobMutation) SalaryUnit() (r job.SalaryUnit, exists bool) {
	v := m.salary_unit
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldSalaryUnit(ctx context.Context) (v job.SalaryUnit, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldSalaryUnit is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldSalaryUnit requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSalaryUnit: %w", err)
	}
	return oldValue.SalaryUnit, nil
}

func (m *JobMutation) ResetSalaryUnit() {
	m.salary_unit = nil
}

func (m *JobMutation) SetEmploymentType(jt job.EmploymentType) {
	m.employment_type = &jt
}

func (m *JobMutation) EmploymentType() (r job.EmploymentType, exists bool) {
	v := m.employment_type
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldEmploymentType(ctx context.Context) (v job.EmploymentType, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldEmploymentType is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldEmploymentType requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEmploymentType: %w", err)
	}
	return oldValue.EmploymentType, nil
}

func (m *JobMutation) ResetEmploymentType() {
	m.employment_type = nil
}

func (m *JobMutation) SetRequirements(s string) {
	m.requirements = &s
}

func (m *JobMutation) Requirements() (r string, exists bool) {
	v := m.requirements
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldRequirements(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldRequirements is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldRequirements requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRequirements: %w", err)
	}
	return oldValue.Requirements, nil
}

func (m *JobMutation) ResetRequirements() {
	m.requirements = nil
}

func (m *JobMutation) SetResponsibilities(s string) {
	m.responsibilities = &s
}

func (m *JobMutation) Responsibilities() (r string, exists bool) {
	v := m.responsibilities
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldResponsibilities(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldResponsibilities is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldResponsibilities requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldResponsibilities: %w", err)
	}
	return oldValue.Responsibilities, nil
}

func (m *JobMutation) ResetResponsibilities() {
	m.responsibilities = nil
}

func (m *JobMutation) SetBenefits(s string) {
	m.benefits = &s
}

func (m *JobMutation) Benefits() (r string, exists bool) {
	v := m.benefits
	if v == nil {
		return
	}
	return *v, true
}

func (m *JobMutation) OldBenefits(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldBenefits is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldBenefits requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldBenefits: %w", err)
	}
	return oldValue.Benefits, nil
}

func (m *JobMutation) ResetBenefits() {
	m.benefits = nil
}

func (m *JobMutation) SetOwnerID(id int) {
	m.owner = &id
}

func (m *JobMutation) ClearOwner() {
	m.clearedowner = true
}

func (m *JobMutation) OwnerCleared() bool {
	return m.clearedowner
}

func (m *JobMutation) OwnerID() (id int, exists bool) {
	if m.owner != nil {
		return *m.owner, true
	}
	return
}

func (m *JobMutation) OwnerIDs() (ids []int) {
	if id := m.owner; id != nil {
		ids = append(ids, *id)
	}
	return
}

func (m *JobMutation) ResetOwner() {
	m.owner = nil
	m.clearedowner = false
}

func (m *JobMutation) AddSkillIDs(ids ...int) {
	if m.skills == nil {
		m.skills = make(map[int]struct{})
	}
	for i := range ids {
		m.skills[ids[i]] = struct{}{}
	}
}

func (m *JobMutation) ClearSkills() {
	m.clearedskills = true
}

func (m *JobMutation) SkillsCleared() bool {
	return m.clearedskills
}

func (m *JobMutation) RemoveSkillIDs(ids ...int) {
	if m.removedskills == nil {
		m.removedskills = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.skills, ids[i])
		m.removedskills[ids[i]] = struct{}{}
	}
}

func (m *JobMutation) RemovedSkillsIDs() (ids []int) {
	for id := range m.removedskills {
		ids = append(ids, id)
	}
	return
}

func (m *JobMutation) SkillsIDs() (ids []int) {
	for id := range m.skills {
		ids = append(ids, id)
	}
	return
}

func (m *JobMutation) ResetSkills() {
	m.skills = nil
	m.clearedskills = false
	m.removedskills = nil
}

func (m *JobMutation) Where(ps ...predicate.Job) {
	m.predicates = append(m.predicates, ps...)
}

func (m *JobMutation) Op() Op {
	return m.op
}

func (m *JobMutation) Type() string {
	return m.typ
}

func (m *JobMutation) Fields() []string {
	fields := make([]string, 0, 10)
	if m.created_at != nil {
		fields = append(fields, job.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, job.FieldUpdatedAt)
	}
	if m.title != nil {
		fields = append(fields, job.FieldTitle)
	}
	if m.min_salary != nil {
		fields = append(fields, job.FieldMinSalary)
	}
	if m.max_salary != nil {
		fields = append(fields, job.FieldMaxSalary)
	}
	if m.salary_unit != nil {
		fields = append(fields, job.FieldSalaryUnit)
	}
	if m.employment_type != nil {
		fields = append(fields, job.FieldEmploymentType)
	}
	if m.requirements != nil {
		fields = append(fields, job.FieldRequirements)
	}
	if m.responsibilities != nil {
		fields = append(fields, job.FieldResponsibilities)
	}
	if m.benefits != nil {
		fields = append(fields, job.FieldBenefits)
	}
	return fields
}

func (m *JobMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case job.FieldCreatedAt:
		return m.CreatedAt()
	case job.FieldUpdatedAt:
		return m.UpdatedAt()
	case job.FieldTitle:
		return m.Title()
	case job.FieldMinSalary:
		return m.MinSalary()
	case job.FieldMaxSalary:
		return m.MaxSalary()
	case job.FieldSalaryUnit:
		return m.SalaryUnit()
	case job.FieldEmploymentType:
		return m.EmploymentType()
	case job.FieldRequirements:
		return m.Requirements()
	case job.FieldResponsibilities:
		return m.Responsibilities()
	case job.FieldBenefits:
		return m.Benefits()
	}
	return nil, false
}

func (m *JobMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case job.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case job.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case job.FieldTitle:
		return m.OldTitle(ctx)
	case job.FieldMinSalary:
		return m.OldMinSalary(ctx)
	case job.FieldMaxSalary:
		return m.OldMaxSalary(ctx)
	case job.FieldSalaryUnit:
		return m.OldSalaryUnit(ctx)
	case job.FieldEmploymentType:
		return m.OldEmploymentType(ctx)
	case job.FieldRequirements:
		return m.OldRequirements(ctx)
	case job.FieldResponsibilities:
		return m.OldResponsibilities(ctx)
	case job.FieldBenefits:
		return m.OldBenefits(ctx)
	}
	return nil, fmt.Errorf("unknown Job field %s", name)
}

func (m *JobMutation) SetField(name string, value ent.Value) error {
	switch name {
	case job.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case job.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case job.FieldTitle:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetTitle(v)
		return nil
	case job.FieldMinSalary:
		v, ok := value.(uint64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetMinSalary(v)
		return nil
	case job.FieldMaxSalary:
		v, ok := value.(uint64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetMaxSalary(v)
		return nil
	case job.FieldSalaryUnit:
		v, ok := value.(job.SalaryUnit)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSalaryUnit(v)
		return nil
	case job.FieldEmploymentType:
		v, ok := value.(job.EmploymentType)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEmploymentType(v)
		return nil
	case job.FieldRequirements:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRequirements(v)
		return nil
	case job.FieldResponsibilities:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetResponsibilities(v)
		return nil
	case job.FieldBenefits:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetBenefits(v)
		return nil
	}
	return fmt.Errorf("unknown Job field %s", name)
}

func (m *JobMutation) AddedFields() []string {
	var fields []string
	if m.addmin_salary != nil {
		fields = append(fields, job.FieldMinSalary)
	}
	if m.addmax_salary != nil {
		fields = append(fields, job.FieldMaxSalary)
	}
	return fields
}

func (m *JobMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case job.FieldMinSalary:
		return m.AddedMinSalary()
	case job.FieldMaxSalary:
		return m.AddedMaxSalary()
	}
	return nil, false
}

func (m *JobMutation) AddField(name string, value ent.Value) error {
	switch name {
	case job.FieldMinSalary:
		v, ok := value.(uint64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddMinSalary(v)
		return nil
	case job.FieldMaxSalary:
		v, ok := value.(uint64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddMaxSalary(v)
		return nil
	}
	return fmt.Errorf("unknown Job numeric field %s", name)
}

func (m *JobMutation) ClearedFields() []string {
	return nil
}

func (m *JobMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

func (m *JobMutation) ClearField(name string) error {
	return fmt.Errorf("unknown Job nullable field %s", name)
}

func (m *JobMutation) ResetField(name string) error {
	switch name {
	case job.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case job.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case job.FieldTitle:
		m.ResetTitle()
		return nil
	case job.FieldMinSalary:
		m.ResetMinSalary()
		return nil
	case job.FieldMaxSalary:
		m.ResetMaxSalary()
		return nil
	case job.FieldSalaryUnit:
		m.ResetSalaryUnit()
		return nil
	case job.FieldEmploymentType:
		m.ResetEmploymentType()
		return nil
	case job.FieldRequirements:
		m.ResetRequirements()
		return nil
	case job.FieldResponsibilities:
		m.ResetResponsibilities()
		return nil
	case job.FieldBenefits:
		m.ResetBenefits()
		return nil
	}
	return fmt.Errorf("unknown Job field %s", name)
}

func (m *JobMutation) AddedEdges() []string {
	edges := make([]string, 0, 2)
	if m.owner != nil {
		edges = append(edges, job.EdgeOwner)
	}
	if m.skills != nil {
		edges = append(edges, job.EdgeSkills)
	}
	return edges
}

func (m *JobMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case job.EdgeOwner:
		if id := m.owner; id != nil {
			return []ent.Value{*id}
		}
	case job.EdgeSkills:
		ids := make([]ent.Value, 0, len(m.skills))
		for id := range m.skills {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *JobMutation) RemovedEdges() []string {
	edges := make([]string, 0, 2)
	if m.removedskills != nil {
		edges = append(edges, job.EdgeSkills)
	}
	return edges
}

func (m *JobMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case job.EdgeSkills:
		ids := make([]ent.Value, 0, len(m.removedskills))
		for id := range m.removedskills {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *JobMutation) ClearedEdges() []string {
	edges := make([]string, 0, 2)
	if m.clearedowner {
		edges = append(edges, job.EdgeOwner)
	}
	if m.clearedskills {
		edges = append(edges, job.EdgeSkills)
	}
	return edges
}

func (m *JobMutation) EdgeCleared(name string) bool {
	switch name {
	case job.EdgeOwner:
		return m.clearedowner
	case job.EdgeSkills:
		return m.clearedskills
	}
	return false
}

func (m *JobMutation) ClearEdge(name string) error {
	switch name {
	case job.EdgeOwner:
		m.ClearOwner()
		return nil
	}
	return fmt.Errorf("unknown Job unique edge %s", name)
}

func (m *JobMutation) ResetEdge(name string) error {
	switch name {
	case job.EdgeOwner:
		m.ResetOwner()
		return nil
	case job.EdgeSkills:
		m.ResetSkills()
		return nil
	}
	return fmt.Errorf("unknown Job edge %s", name)
}

type SkillMutation struct {
	config
	op                 Op
	typ                string
	id                 *int
	created_at         *time.Time
	updated_at         *time.Time
	name               *string
	logo_url           *string
	clearedFields      map[string]struct{}
	experiences        map[int]struct{}
	removedexperiences map[int]struct{}
	clearedexperiences bool
	jobs               map[int]struct{}
	removedjobs        map[int]struct{}
	clearedjobs        bool
	done               bool
	oldValue           func(context.Context) (*Skill, error)
	predicates         []predicate.Skill
}

var _ ent.Mutation = (*SkillMutation)(nil)

type skillOption func(*SkillMutation)

func newSkillMutation(c config, op Op, opts ...skillOption) *SkillMutation {
	m := &SkillMutation{
		config:        c,
		op:            op,
		typ:           TypeSkill,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

func withSkillID(id int) skillOption {
	return func(m *SkillMutation) {
		var (
			err   error
			once  sync.Once
			value *Skill
		)
		m.oldValue = func(ctx context.Context) (*Skill, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Skill.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

func withSkill(node *Skill) skillOption {
	return func(m *SkillMutation) {
		m.oldValue = func(context.Context) (*Skill, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

func (m SkillMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

func (m SkillMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

func (m *SkillMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

func (m *SkillMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

func (m *SkillMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *SkillMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

func (m *SkillMutation) ResetCreatedAt() {
	m.created_at = nil
}

func (m *SkillMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

func (m *SkillMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *SkillMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

func (m *SkillMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

func (m *SkillMutation) SetName(s string) {
	m.name = &s
}

func (m *SkillMutation) Name() (r string, exists bool) {
	v := m.name
	if v == nil {
		return
	}
	return *v, true
}

func (m *SkillMutation) OldName(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldName requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldName: %w", err)
	}
	return oldValue.Name, nil
}

func (m *SkillMutation) ResetName() {
	m.name = nil
}

func (m *SkillMutation) SetLogoURL(s string) {
	m.logo_url = &s
}

func (m *SkillMutation) LogoURL() (r string, exists bool) {
	v := m.logo_url
	if v == nil {
		return
	}
	return *v, true
}

func (m *SkillMutation) OldLogoURL(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldLogoURL is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldLogoURL requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLogoURL: %w", err)
	}
	return oldValue.LogoURL, nil
}

func (m *SkillMutation) ResetLogoURL() {
	m.logo_url = nil
}

func (m *SkillMutation) AddExperienceIDs(ids ...int) {
	if m.experiences == nil {
		m.experiences = make(map[int]struct{})
	}
	for i := range ids {
		m.experiences[ids[i]] = struct{}{}
	}
}

func (m *SkillMutation) ClearExperiences() {
	m.clearedexperiences = true
}

func (m *SkillMutation) ExperiencesCleared() bool {
	return m.clearedexperiences
}

func (m *SkillMutation) RemoveExperienceIDs(ids ...int) {
	if m.removedexperiences == nil {
		m.removedexperiences = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.experiences, ids[i])
		m.removedexperiences[ids[i]] = struct{}{}
	}
}

func (m *SkillMutation) RemovedExperiencesIDs() (ids []int) {
	for id := range m.removedexperiences {
		ids = append(ids, id)
	}
	return
}

func (m *SkillMutation) ExperiencesIDs() (ids []int) {
	for id := range m.experiences {
		ids = append(ids, id)
	}
	return
}

func (m *SkillMutation) ResetExperiences() {
	m.experiences = nil
	m.clearedexperiences = false
	m.removedexperiences = nil
}

func (m *SkillMutation) AddJobIDs(ids ...int) {
	if m.jobs == nil {
		m.jobs = make(map[int]struct{})
	}
	for i := range ids {
		m.jobs[ids[i]] = struct{}{}
	}
}

func (m *SkillMutation) ClearJobs() {
	m.clearedjobs = true
}

func (m *SkillMutation) JobsCleared() bool {
	return m.clearedjobs
}

func (m *SkillMutation) RemoveJobIDs(ids ...int) {
	if m.removedjobs == nil {
		m.removedjobs = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.jobs, ids[i])
		m.removedjobs[ids[i]] = struct{}{}
	}
}

func (m *SkillMutation) RemovedJobsIDs() (ids []int) {
	for id := range m.removedjobs {
		ids = append(ids, id)
	}
	return
}

func (m *SkillMutation) JobsIDs() (ids []int) {
	for id := range m.jobs {
		ids = append(ids, id)
	}
	return
}

func (m *SkillMutation) ResetJobs() {
	m.jobs = nil
	m.clearedjobs = false
	m.removedjobs = nil
}

func (m *SkillMutation) Where(ps ...predicate.Skill) {
	m.predicates = append(m.predicates, ps...)
}

func (m *SkillMutation) Op() Op {
	return m.op
}

func (m *SkillMutation) Type() string {
	return m.typ
}

func (m *SkillMutation) Fields() []string {
	fields := make([]string, 0, 4)
	if m.created_at != nil {
		fields = append(fields, skill.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, skill.FieldUpdatedAt)
	}
	if m.name != nil {
		fields = append(fields, skill.FieldName)
	}
	if m.logo_url != nil {
		fields = append(fields, skill.FieldLogoURL)
	}
	return fields
}

func (m *SkillMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case skill.FieldCreatedAt:
		return m.CreatedAt()
	case skill.FieldUpdatedAt:
		return m.UpdatedAt()
	case skill.FieldName:
		return m.Name()
	case skill.FieldLogoURL:
		return m.LogoURL()
	}
	return nil, false
}

func (m *SkillMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case skill.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case skill.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case skill.FieldName:
		return m.OldName(ctx)
	case skill.FieldLogoURL:
		return m.OldLogoURL(ctx)
	}
	return nil, fmt.Errorf("unknown Skill field %s", name)
}

func (m *SkillMutation) SetField(name string, value ent.Value) error {
	switch name {
	case skill.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case skill.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case skill.FieldName:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetName(v)
		return nil
	case skill.FieldLogoURL:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLogoURL(v)
		return nil
	}
	return fmt.Errorf("unknown Skill field %s", name)
}

func (m *SkillMutation) AddedFields() []string {
	return nil
}

func (m *SkillMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

func (m *SkillMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown Skill numeric field %s", name)
}

func (m *SkillMutation) ClearedFields() []string {
	return nil
}

func (m *SkillMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

func (m *SkillMutation) ClearField(name string) error {
	return fmt.Errorf("unknown Skill nullable field %s", name)
}

func (m *SkillMutation) ResetField(name string) error {
	switch name {
	case skill.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case skill.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case skill.FieldName:
		m.ResetName()
		return nil
	case skill.FieldLogoURL:
		m.ResetLogoURL()
		return nil
	}
	return fmt.Errorf("unknown Skill field %s", name)
}

func (m *SkillMutation) AddedEdges() []string {
	edges := make([]string, 0, 2)
	if m.experiences != nil {
		edges = append(edges, skill.EdgeExperiences)
	}
	if m.jobs != nil {
		edges = append(edges, skill.EdgeJobs)
	}
	return edges
}

func (m *SkillMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case skill.EdgeExperiences:
		ids := make([]ent.Value, 0, len(m.experiences))
		for id := range m.experiences {
			ids = append(ids, id)
		}
		return ids
	case skill.EdgeJobs:
		ids := make([]ent.Value, 0, len(m.jobs))
		for id := range m.jobs {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *SkillMutation) RemovedEdges() []string {
	edges := make([]string, 0, 2)
	if m.removedexperiences != nil {
		edges = append(edges, skill.EdgeExperiences)
	}
	if m.removedjobs != nil {
		edges = append(edges, skill.EdgeJobs)
	}
	return edges
}

func (m *SkillMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case skill.EdgeExperiences:
		ids := make([]ent.Value, 0, len(m.removedexperiences))
		for id := range m.removedexperiences {
			ids = append(ids, id)
		}
		return ids
	case skill.EdgeJobs:
		ids := make([]ent.Value, 0, len(m.removedjobs))
		for id := range m.removedjobs {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *SkillMutation) ClearedEdges() []string {
	edges := make([]string, 0, 2)
	if m.clearedexperiences {
		edges = append(edges, skill.EdgeExperiences)
	}
	if m.clearedjobs {
		edges = append(edges, skill.EdgeJobs)
	}
	return edges
}

func (m *SkillMutation) EdgeCleared(name string) bool {
	switch name {
	case skill.EdgeExperiences:
		return m.clearedexperiences
	case skill.EdgeJobs:
		return m.clearedjobs
	}
	return false
}

func (m *SkillMutation) ClearEdge(name string) error {
	switch name {
	}
	return fmt.Errorf("unknown Skill unique edge %s", name)
}

func (m *SkillMutation) ResetEdge(name string) error {
	switch name {
	case skill.EdgeExperiences:
		m.ResetExperiences()
		return nil
	case skill.EdgeJobs:
		m.ResetJobs()
		return nil
	}
	return fmt.Errorf("unknown Skill edge %s", name)
}

type UserMutation struct {
	config
	op                  Op
	typ                 string
	id                  *int
	created_at          *time.Time
	updated_at          *time.Time
	username            *string
	fullname            *string
	password            *string
	email               *string
	phone               *string
	bio                 *string
	intro               *string
	github_profile      *string
	profile_picture_url *string
	status              *user.Status
	clearedFields       map[string]struct{}
	jobs                map[int]struct{}
	removedjobs         map[int]struct{}
	clearedjobs         bool
	experiences         map[int]struct{}
	removedexperiences  map[int]struct{}
	clearedexperiences  bool
	done                bool
	oldValue            func(context.Context) (*User, error)
	predicates          []predicate.User
}

var _ ent.Mutation = (*UserMutation)(nil)

type userOption func(*UserMutation)

func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
	m := &UserMutation{
		config:        c,
		op:            op,
		typ:           TypeUser,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

func withUserID(id int) userOption {
	return func(m *UserMutation) {
		var (
			err   error
			once  sync.Once
			value *User
		)
		m.oldValue = func(ctx context.Context) (*User, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().User.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

func withUser(node *User) userOption {
	return func(m *UserMutation) {
		m.oldValue = func(context.Context) (*User, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

func (m UserMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

func (m UserMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

func (m *UserMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

func (m *UserMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

func (m *UserMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

func (m *UserMutation) ResetCreatedAt() {
	m.created_at = nil
}

func (m *UserMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

func (m *UserMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

func (m *UserMutation) SetUsername(s string) {
	m.username = &s
}

func (m *UserMutation) Username() (r string, exists bool) {
	v := m.username
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUsername is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUsername requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUsername: %w", err)
	}
	return oldValue.Username, nil
}

func (m *UserMutation) ResetUsername() {
	m.username = nil
}

func (m *UserMutation) SetFullname(s string) {
	m.fullname = &s
}

func (m *UserMutation) Fullname() (r string, exists bool) {
	v := m.fullname
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldFullname(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldFullname is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldFullname requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldFullname: %w", err)
	}
	return oldValue.Fullname, nil
}

func (m *UserMutation) ResetFullname() {
	m.fullname = nil
}

func (m *UserMutation) SetPassword(s string) {
	m.password = &s
}

func (m *UserMutation) Password() (r string, exists bool) {
	v := m.password
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldPassword is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldPassword requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPassword: %w", err)
	}
	return oldValue.Password, nil
}

func (m *UserMutation) ResetPassword() {
	m.password = nil
}

func (m *UserMutation) SetEmail(s string) {
	m.email = &s
}

func (m *UserMutation) Email() (r string, exists bool) {
	v := m.email
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldEmail is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldEmail requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEmail: %w", err)
	}
	return oldValue.Email, nil
}

func (m *UserMutation) ResetEmail() {
	m.email = nil
}

func (m *UserMutation) SetPhone(s string) {
	m.phone = &s
}

func (m *UserMutation) Phone() (r string, exists bool) {
	v := m.phone
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldPhone(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldPhone is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldPhone requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPhone: %w", err)
	}
	return oldValue.Phone, nil
}

func (m *UserMutation) ResetPhone() {
	m.phone = nil
}

func (m *UserMutation) SetBio(s string) {
	m.bio = &s
}

func (m *UserMutation) Bio() (r string, exists bool) {
	v := m.bio
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldBio(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldBio is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldBio requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldBio: %w", err)
	}
	return oldValue.Bio, nil
}

func (m *UserMutation) ResetBio() {
	m.bio = nil
}

func (m *UserMutation) SetIntro(s string) {
	m.intro = &s
}

func (m *UserMutation) Intro() (r string, exists bool) {
	v := m.intro
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldIntro(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldIntro is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldIntro requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldIntro: %w", err)
	}
	return oldValue.Intro, nil
}

func (m *UserMutation) ResetIntro() {
	m.intro = nil
}

func (m *UserMutation) SetGithubProfile(s string) {
	m.github_profile = &s
}

func (m *UserMutation) GithubProfile() (r string, exists bool) {
	v := m.github_profile
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldGithubProfile(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldGithubProfile is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldGithubProfile requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldGithubProfile: %w", err)
	}
	return oldValue.GithubProfile, nil
}

func (m *UserMutation) ResetGithubProfile() {
	m.github_profile = nil
}

func (m *UserMutation) SetProfilePictureURL(s string) {
	m.profile_picture_url = &s
}

func (m *UserMutation) ProfilePictureURL() (r string, exists bool) {
	v := m.profile_picture_url
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldProfilePictureURL(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldProfilePictureURL is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldProfilePictureURL requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldProfilePictureURL: %w", err)
	}
	return oldValue.ProfilePictureURL, nil
}

func (m *UserMutation) ResetProfilePictureURL() {
	m.profile_picture_url = nil
}

func (m *UserMutation) SetStatus(u user.Status) {
	m.status = &u
}

func (m *UserMutation) Status() (r user.Status, exists bool) {
	v := m.status
	if v == nil {
		return
	}
	return *v, true
}

func (m *UserMutation) OldStatus(ctx context.Context) (v user.Status, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldStatus is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldStatus requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
	}
	return oldValue.Status, nil
}

func (m *UserMutation) ResetStatus() {
	m.status = nil
}

func (m *UserMutation) AddJobIDs(ids ...int) {
	if m.jobs == nil {
		m.jobs = make(map[int]struct{})
	}
	for i := range ids {
		m.jobs[ids[i]] = struct{}{}
	}
}

func (m *UserMutation) ClearJobs() {
	m.clearedjobs = true
}

func (m *UserMutation) JobsCleared() bool {
	return m.clearedjobs
}

func (m *UserMutation) RemoveJobIDs(ids ...int) {
	if m.removedjobs == nil {
		m.removedjobs = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.jobs, ids[i])
		m.removedjobs[ids[i]] = struct{}{}
	}
}

func (m *UserMutation) RemovedJobsIDs() (ids []int) {
	for id := range m.removedjobs {
		ids = append(ids, id)
	}
	return
}

func (m *UserMutation) JobsIDs() (ids []int) {
	for id := range m.jobs {
		ids = append(ids, id)
	}
	return
}

func (m *UserMutation) ResetJobs() {
	m.jobs = nil
	m.clearedjobs = false
	m.removedjobs = nil
}

func (m *UserMutation) AddExperienceIDs(ids ...int) {
	if m.experiences == nil {
		m.experiences = make(map[int]struct{})
	}
	for i := range ids {
		m.experiences[ids[i]] = struct{}{}
	}
}

func (m *UserMutation) ClearExperiences() {
	m.clearedexperiences = true
}

func (m *UserMutation) ExperiencesCleared() bool {
	return m.clearedexperiences
}

func (m *UserMutation) RemoveExperienceIDs(ids ...int) {
	if m.removedexperiences == nil {
		m.removedexperiences = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.experiences, ids[i])
		m.removedexperiences[ids[i]] = struct{}{}
	}
}

func (m *UserMutation) RemovedExperiencesIDs() (ids []int) {
	for id := range m.removedexperiences {
		ids = append(ids, id)
	}
	return
}

func (m *UserMutation) ExperiencesIDs() (ids []int) {
	for id := range m.experiences {
		ids = append(ids, id)
	}
	return
}

func (m *UserMutation) ResetExperiences() {
	m.experiences = nil
	m.clearedexperiences = false
	m.removedexperiences = nil
}

func (m *UserMutation) Where(ps ...predicate.User) {
	m.predicates = append(m.predicates, ps...)
}

func (m *UserMutation) Op() Op {
	return m.op
}

func (m *UserMutation) Type() string {
	return m.typ
}

func (m *UserMutation) Fields() []string {
	fields := make([]string, 0, 12)
	if m.created_at != nil {
		fields = append(fields, user.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, user.FieldUpdatedAt)
	}
	if m.username != nil {
		fields = append(fields, user.FieldUsername)
	}
	if m.fullname != nil {
		fields = append(fields, user.FieldFullname)
	}
	if m.password != nil {
		fields = append(fields, user.FieldPassword)
	}
	if m.email != nil {
		fields = append(fields, user.FieldEmail)
	}
	if m.phone != nil {
		fields = append(fields, user.FieldPhone)
	}
	if m.bio != nil {
		fields = append(fields, user.FieldBio)
	}
	if m.intro != nil {
		fields = append(fields, user.FieldIntro)
	}
	if m.github_profile != nil {
		fields = append(fields, user.FieldGithubProfile)
	}
	if m.profile_picture_url != nil {
		fields = append(fields, user.FieldProfilePictureURL)
	}
	if m.status != nil {
		fields = append(fields, user.FieldStatus)
	}
	return fields
}

func (m *UserMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case user.FieldCreatedAt:
		return m.CreatedAt()
	case user.FieldUpdatedAt:
		return m.UpdatedAt()
	case user.FieldUsername:
		return m.Username()
	case user.FieldFullname:
		return m.Fullname()
	case user.FieldPassword:
		return m.Password()
	case user.FieldEmail:
		return m.Email()
	case user.FieldPhone:
		return m.Phone()
	case user.FieldBio:
		return m.Bio()
	case user.FieldIntro:
		return m.Intro()
	case user.FieldGithubProfile:
		return m.GithubProfile()
	case user.FieldProfilePictureURL:
		return m.ProfilePictureURL()
	case user.FieldStatus:
		return m.Status()
	}
	return nil, false
}

func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case user.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case user.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case user.FieldUsername:
		return m.OldUsername(ctx)
	case user.FieldFullname:
		return m.OldFullname(ctx)
	case user.FieldPassword:
		return m.OldPassword(ctx)
	case user.FieldEmail:
		return m.OldEmail(ctx)
	case user.FieldPhone:
		return m.OldPhone(ctx)
	case user.FieldBio:
		return m.OldBio(ctx)
	case user.FieldIntro:
		return m.OldIntro(ctx)
	case user.FieldGithubProfile:
		return m.OldGithubProfile(ctx)
	case user.FieldProfilePictureURL:
		return m.OldProfilePictureURL(ctx)
	case user.FieldStatus:
		return m.OldStatus(ctx)
	}
	return nil, fmt.Errorf("unknown User field %s", name)
}

func (m *UserMutation) SetField(name string, value ent.Value) error {
	switch name {
	case user.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case user.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case user.FieldUsername:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUsername(v)
		return nil
	case user.FieldFullname:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetFullname(v)
		return nil
	case user.FieldPassword:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPassword(v)
		return nil
	case user.FieldEmail:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEmail(v)
		return nil
	case user.FieldPhone:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPhone(v)
		return nil
	case user.FieldBio:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetBio(v)
		return nil
	case user.FieldIntro:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetIntro(v)
		return nil
	case user.FieldGithubProfile:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetGithubProfile(v)
		return nil
	case user.FieldProfilePictureURL:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetProfilePictureURL(v)
		return nil
	case user.FieldStatus:
		v, ok := value.(user.Status)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStatus(v)
		return nil
	}
	return fmt.Errorf("unknown User field %s", name)
}

func (m *UserMutation) AddedFields() []string {
	return nil
}

func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

func (m *UserMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown User numeric field %s", name)
}

func (m *UserMutation) ClearedFields() []string {
	return nil
}

func (m *UserMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

func (m *UserMutation) ClearField(name string) error {
	return fmt.Errorf("unknown User nullable field %s", name)
}

func (m *UserMutation) ResetField(name string) error {
	switch name {
	case user.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case user.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case user.FieldUsername:
		m.ResetUsername()
		return nil
	case user.FieldFullname:
		m.ResetFullname()
		return nil
	case user.FieldPassword:
		m.ResetPassword()
		return nil
	case user.FieldEmail:
		m.ResetEmail()
		return nil
	case user.FieldPhone:
		m.ResetPhone()
		return nil
	case user.FieldBio:
		m.ResetBio()
		return nil
	case user.FieldIntro:
		m.ResetIntro()
		return nil
	case user.FieldGithubProfile:
		m.ResetGithubProfile()
		return nil
	case user.FieldProfilePictureURL:
		m.ResetProfilePictureURL()
		return nil
	case user.FieldStatus:
		m.ResetStatus()
		return nil
	}
	return fmt.Errorf("unknown User field %s", name)
}

func (m *UserMutation) AddedEdges() []string {
	edges := make([]string, 0, 2)
	if m.jobs != nil {
		edges = append(edges, user.EdgeJobs)
	}
	if m.experiences != nil {
		edges = append(edges, user.EdgeExperiences)
	}
	return edges
}

func (m *UserMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case user.EdgeJobs:
		ids := make([]ent.Value, 0, len(m.jobs))
		for id := range m.jobs {
			ids = append(ids, id)
		}
		return ids
	case user.EdgeExperiences:
		ids := make([]ent.Value, 0, len(m.experiences))
		for id := range m.experiences {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *UserMutation) RemovedEdges() []string {
	edges := make([]string, 0, 2)
	if m.removedjobs != nil {
		edges = append(edges, user.EdgeJobs)
	}
	if m.removedexperiences != nil {
		edges = append(edges, user.EdgeExperiences)
	}
	return edges
}

func (m *UserMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case user.EdgeJobs:
		ids := make([]ent.Value, 0, len(m.removedjobs))
		for id := range m.removedjobs {
			ids = append(ids, id)
		}
		return ids
	case user.EdgeExperiences:
		ids := make([]ent.Value, 0, len(m.removedexperiences))
		for id := range m.removedexperiences {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *UserMutation) ClearedEdges() []string {
	edges := make([]string, 0, 2)
	if m.clearedjobs {
		edges = append(edges, user.EdgeJobs)
	}
	if m.clearedexperiences {
		edges = append(edges, user.EdgeExperiences)
	}
	return edges
}

func (m *UserMutation) EdgeCleared(name string) bool {
	switch name {
	case user.EdgeJobs:
		return m.clearedjobs
	case user.EdgeExperiences:
		return m.clearedexperiences
	}
	return false
}

func (m *UserMutation) ClearEdge(name string) error {
	switch name {
	}
	return fmt.Errorf("unknown User unique edge %s", name)
}

func (m *UserMutation) ResetEdge(name string) error {
	switch name {
	case user.EdgeJobs:
		m.ResetJobs()
		return nil
	case user.EdgeExperiences:
		m.ResetExperiences()
		return nil
	}
	return fmt.Errorf("unknown User edge %s", name)
}

type WorkExperienceMutation struct {
	config
	op                Op
	typ               string
	id                *int
	created_at        *time.Time
	updated_at        *time.Time
	title             *string
	location          *string
	start_date        *time.Time
	end_date          *time.Time
	description       *string
	clearedFields     map[string]struct{}
	owner             *int
	clearedowner      bool
	in_company        *int
	clearedin_company bool
	skills            map[int]struct{}
	removedskills     map[int]struct{}
	clearedskills     bool
	done              bool
	oldValue          func(context.Context) (*WorkExperience, error)
	predicates        []predicate.WorkExperience
}

var _ ent.Mutation = (*WorkExperienceMutation)(nil)

type workexperienceOption func(*WorkExperienceMutation)

func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
	m := &WorkExperienceMutation{
		config:        c,
		op:            op,
		typ:           TypeWorkExperience,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

func withWorkExperienceID(id int) workexperienceOption {
	return func(m *WorkExperienceMutation) {
		var (
			err   error
			once  sync.Once
			value *WorkExperience
		)
		m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().WorkExperience.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

func withWorkExperience(node *WorkExperience) workexperienceOption {
	return func(m *WorkExperienceMutation) {
		m.oldValue = func(context.Context) (*WorkExperience, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

func (m WorkExperienceMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

func (m WorkExperienceMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

func (m *WorkExperienceMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

func (m *WorkExperienceMutation) ResetCreatedAt() {
	m.created_at = nil
}

func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

func (m *WorkExperienceMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

func (m *WorkExperienceMutation) SetTitle(s string) {
	m.title = &s
}

func (m *WorkExperienceMutation) Title() (r string, exists bool) {
	v := m.title
	if v == nil {
		return
	}
	return *v, true
}

func (m *WorkExperienceMutation) OldTitle(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldTitle is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldTitle requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldTitle: %w", err)
	}
	return oldValue.Title, nil
}

func (m *WorkExperienceMutation) ResetTitle() {
	m.title = nil
}

func (m *WorkExperienceMutation) SetLocation(s string) {
	m.location = &s
}

func (m *WorkExperienceMutation) Location() (r string, exists bool) {
	v := m.location
	if v == nil {
		return
	}
	return *v, true
}

func (m *WorkExperienceMutation) OldLocation(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldLocation is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldLocation requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLocation: %w", err)
	}
	return oldValue.Location, nil
}

func (m *WorkExperienceMutation) ResetLocation() {
	m.location = nil
}

func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
	m.start_date = &t
}

func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
	v := m.start_date
	if v == nil {
		return
	}
	return *v, true
}

func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldStartDate is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldStartDate requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
	}
	return oldValue.StartDate, nil
}

func (m *WorkExperienceMutation) ResetStartDate() {
	m.start_date = nil
}

func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
	m.end_date = &t
}

func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
	v := m.end_date
	if v == nil {
		return
	}
	return *v, true
}

func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldEndDate is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldEndDate requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
	}
	return oldValue.EndDate, nil
}

func (m *WorkExperienceMutation) ClearEndDate() {
	m.end_date = nil
	m.clearedFields[workexperience.FieldEndDate] = struct{}{}
}

func (m *WorkExperienceMutation) EndDateCleared() bool {
	_, ok := m.clearedFields[workexperience.FieldEndDate]
	return ok
}

func (m *WorkExperienceMutation) ResetEndDate() {
	m.end_date = nil
	delete(m.clearedFields, workexperience.FieldEndDate)
}

func (m *WorkExperienceMutation) SetDescription(s string) {
	m.description = &s
}

func (m *WorkExperienceMutation) Description() (r string, exists bool) {
	v := m.description
	if v == nil {
		return
	}
	return *v, true
}

func (m *WorkExperienceMutation) OldDescription(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldDescription is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldDescription requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDescription: %w", err)
	}
	return oldValue.Description, nil
}

func (m *WorkExperienceMutation) ResetDescription() {
	m.description = nil
}

func (m *WorkExperienceMutation) SetOwnerID(id int) {
	m.owner = &id
}

func (m *WorkExperienceMutation) ClearOwner() {
	m.clearedowner = true
}

func (m *WorkExperienceMutation) OwnerCleared() bool {
	return m.clearedowner
}

func (m *WorkExperienceMutation) OwnerID() (id int, exists bool) {
	if m.owner != nil {
		return *m.owner, true
	}
	return
}

func (m *WorkExperienceMutation) OwnerIDs() (ids []int) {
	if id := m.owner; id != nil {
		ids = append(ids, *id)
	}
	return
}

func (m *WorkExperienceMutation) ResetOwner() {
	m.owner = nil
	m.clearedowner = false
}

func (m *WorkExperienceMutation) SetInCompanyID(id int) {
	m.in_company = &id
}

func (m *WorkExperienceMutation) ClearInCompany() {
	m.clearedin_company = true
}

func (m *WorkExperienceMutation) InCompanyCleared() bool {
	return m.clearedin_company
}

func (m *WorkExperienceMutation) InCompanyID() (id int, exists bool) {
	if m.in_company != nil {
		return *m.in_company, true
	}
	return
}

func (m *WorkExperienceMutation) InCompanyIDs() (ids []int) {
	if id := m.in_company; id != nil {
		ids = append(ids, *id)
	}
	return
}

func (m *WorkExperienceMutation) ResetInCompany() {
	m.in_company = nil
	m.clearedin_company = false
}

func (m *WorkExperienceMutation) AddSkillIDs(ids ...int) {
	if m.skills == nil {
		m.skills = make(map[int]struct{})
	}
	for i := range ids {
		m.skills[ids[i]] = struct{}{}
	}
}

func (m *WorkExperienceMutation) ClearSkills() {
	m.clearedskills = true
}

func (m *WorkExperienceMutation) SkillsCleared() bool {
	return m.clearedskills
}

func (m *WorkExperienceMutation) RemoveSkillIDs(ids ...int) {
	if m.removedskills == nil {
		m.removedskills = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.skills, ids[i])
		m.removedskills[ids[i]] = struct{}{}
	}
}

func (m *WorkExperienceMutation) RemovedSkillsIDs() (ids []int) {
	for id := range m.removedskills {
		ids = append(ids, id)
	}
	return
}

func (m *WorkExperienceMutation) SkillsIDs() (ids []int) {
	for id := range m.skills {
		ids = append(ids, id)
	}
	return
}

func (m *WorkExperienceMutation) ResetSkills() {
	m.skills = nil
	m.clearedskills = false
	m.removedskills = nil
}

func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
	m.predicates = append(m.predicates, ps...)
}

func (m *WorkExperienceMutation) Op() Op {
	return m.op
}

func (m *WorkExperienceMutation) Type() string {
	return m.typ
}

func (m *WorkExperienceMutation) Fields() []string {
	fields := make([]string, 0, 7)
	if m.created_at != nil {
		fields = append(fields, workexperience.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, workexperience.FieldUpdatedAt)
	}
	if m.title != nil {
		fields = append(fields, workexperience.FieldTitle)
	}
	if m.location != nil {
		fields = append(fields, workexperience.FieldLocation)
	}
	if m.start_date != nil {
		fields = append(fields, workexperience.FieldStartDate)
	}
	if m.end_date != nil {
		fields = append(fields, workexperience.FieldEndDate)
	}
	if m.description != nil {
		fields = append(fields, workexperience.FieldDescription)
	}
	return fields
}

func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case workexperience.FieldCreatedAt:
		return m.CreatedAt()
	case workexperience.FieldUpdatedAt:
		return m.UpdatedAt()
	case workexperience.FieldTitle:
		return m.Title()
	case workexperience.FieldLocation:
		return m.Location()
	case workexperience.FieldStartDate:
		return m.StartDate()
	case workexperience.FieldEndDate:
		return m.EndDate()
	case workexperience.FieldDescription:
		return m.Description()
	}
	return nil, false
}

func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case workexperience.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case workexperience.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case workexperience.FieldTitle:
		return m.OldTitle(ctx)
	case workexperience.FieldLocation:
		return m.OldLocation(ctx)
	case workexperience.FieldStartDate:
		return m.OldStartDate(ctx)
	case workexperience.FieldEndDate:
		return m.OldEndDate(ctx)
	case workexperience.FieldDescription:
		return m.OldDescription(ctx)
	}
	return nil, fmt.Errorf("unknown WorkExperience field %s", name)
}

func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
	switch name {
	case workexperience.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case workexperience.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case workexperience.FieldTitle:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetTitle(v)
		return nil
	case workexperience.FieldLocation:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLocation(v)
		return nil
	case workexperience.FieldStartDate:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStartDate(v)
		return nil
	case workexperience.FieldEndDate:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEndDate(v)
		return nil
	case workexperience.FieldDescription:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDescription(v)
		return nil
	}
	return fmt.Errorf("unknown WorkExperience field %s", name)
}

func (m *WorkExperienceMutation) AddedFields() []string {
	return nil
}

func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown WorkExperience numeric field %s", name)
}

func (m *WorkExperienceMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(workexperience.FieldEndDate) {
		fields = append(fields, workexperience.FieldEndDate)
	}
	return fields
}

func (m *WorkExperienceMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

func (m *WorkExperienceMutation) ClearField(name string) error {
	switch name {
	case workexperience.FieldEndDate:
		m.ClearEndDate()
		return nil
	}
	return fmt.Errorf("unknown WorkExperience nullable field %s", name)
}

func (m *WorkExperienceMutation) ResetField(name string) error {
	switch name {
	case workexperience.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case workexperience.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case workexperience.FieldTitle:
		m.ResetTitle()
		return nil
	case workexperience.FieldLocation:
		m.ResetLocation()
		return nil
	case workexperience.FieldStartDate:
		m.ResetStartDate()
		return nil
	case workexperience.FieldEndDate:
		m.ResetEndDate()
		return nil
	case workexperience.FieldDescription:
		m.ResetDescription()
		return nil
	}
	return fmt.Errorf("unknown WorkExperience field %s", name)
}

func (m *WorkExperienceMutation) AddedEdges() []string {
	edges := make([]string, 0, 3)
	if m.owner != nil {
		edges = append(edges, workexperience.EdgeOwner)
	}
	if m.in_company != nil {
		edges = append(edges, workexperience.EdgeInCompany)
	}
	if m.skills != nil {
		edges = append(edges, workexperience.EdgeSkills)
	}
	return edges
}

func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case workexperience.EdgeOwner:
		if id := m.owner; id != nil {
			return []ent.Value{*id}
		}
	case workexperience.EdgeInCompany:
		if id := m.in_company; id != nil {
			return []ent.Value{*id}
		}
	case workexperience.EdgeSkills:
		ids := make([]ent.Value, 0, len(m.skills))
		for id := range m.skills {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *WorkExperienceMutation) RemovedEdges() []string {
	edges := make([]string, 0, 3)
	if m.removedskills != nil {
		edges = append(edges, workexperience.EdgeSkills)
	}
	return edges
}

func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case workexperience.EdgeSkills:
		ids := make([]ent.Value, 0, len(m.removedskills))
		for id := range m.removedskills {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

func (m *WorkExperienceMutation) ClearedEdges() []string {
	edges := make([]string, 0, 3)
	if m.clearedowner {
		edges = append(edges, workexperience.EdgeOwner)
	}
	if m.clearedin_company {
		edges = append(edges, workexperience.EdgeInCompany)
	}
	if m.clearedskills {
		edges = append(edges, workexperience.EdgeSkills)
	}
	return edges
}

func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
	switch name {
	case workexperience.EdgeOwner:
		return m.clearedowner
	case workexperience.EdgeInCompany:
		return m.clearedin_company
	case workexperience.EdgeSkills:
		return m.clearedskills
	}
	return false
}

func (m *WorkExperienceMutation) ClearEdge(name string) error {
	switch name {
	case workexperience.EdgeOwner:
		m.ClearOwner()
		return nil
	case workexperience.EdgeInCompany:
		m.ClearInCompany()
		return nil
	}
	return fmt.Errorf("unknown WorkExperience unique edge %s", name)
}

func (m *WorkExperienceMutation) ResetEdge(name string) error {
	switch name {
	case workexperience.EdgeOwner:
		m.ResetOwner()
		return nil
	case workexperience.EdgeInCompany:
		m.ResetInCompany()
		return nil
	case workexperience.EdgeSkills:
		m.ResetSkills()
		return nil
	}
	return fmt.Errorf("unknown WorkExperience edge %s", name)
}
// Code generated by entc, DO NOT EDIT.

package ent

import (
	"context"
	"fmt"
	"refernet/internal/ent/company"
	"refernet/internal/ent/job"
	"refernet/internal/ent/predicate"
	"refernet/internal/ent/skill"
	"refernet/internal/ent/user"
	"refernet/internal/ent/workexperience"
	"sync"
	"time"

	"entgo.io/ent"
)

const (
	// Operation types.
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	// Node types.
	TypeCompany        = "Company"
	TypeJob            = "Job"
	TypeSkill          = "Skill"
	TypeUser           = "User"
	TypeWorkExperience = "WorkExperience"
)

// CompanyMutation represents an operation that mutates the Company nodes in the graph.
type CompanyMutation struct {
	config
	op            Op
	typ           string
	id            *int
	created_at    *time.Time
	updated_at    *time.Time
	name          *string
	overview      *string
	website       *string
	logo_url      *string
	size          *company.Size
	founded_at    *int
	addfounded_at *int
	clearedFields map[string]struct{}
	staffs        map[int]struct{}
	removedstaffs map[int]struct{}
	clearedstaffs bool
	done          bool
	oldValue      func(context.Context) (*Company, error)
	predicates    []predicate.Company
}

var _ ent.Mutation = (*CompanyMutation)(nil)

// companyOption allows management of the mutation configuration using functional options.
type companyOption func(*CompanyMutation)

// newCompanyMutation creates new mutation for the Company entity.
func newCompanyMutation(c config, op Op, opts ...companyOption) *CompanyMutation {
	m := &CompanyMutation{
		config:        c,
		op:            op,
		typ:           TypeCompany,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withCompanyID sets the ID field of the mutation.
func withCompanyID(id int) companyOption {
	return func(m *CompanyMutation) {
		var (
			err   error
			once  sync.Once
			value *Company
		)
		m.oldValue = func(ctx context.Context) (*Company, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Company.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withCompany sets the old Company of the mutation.
func withCompany(node *Company) companyOption {
	return func(m *CompanyMutation) {
		m.oldValue = func(context.Context) (*Company, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m CompanyMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m CompanyMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *CompanyMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// SetCreatedAt sets the "created_at" field.
func (m *CompanyMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *CompanyMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the Company entity.
// If the Company object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CompanyMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *CompanyMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *CompanyMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *CompanyMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the Company entity.
// If the Company object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CompanyMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *CompanyMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// SetName sets the "name" field.
func (m *CompanyMutation) SetName(s string) {
	m.name = &s
}

// Name returns the value of the "name" field in the mutation.
func (m *CompanyMutation) Name() (r string, exists bool) {
	v := m.name
	if v == nil {
		return
	}
	return *v, true
}

// OldName returns the old "name" field's value of the Company entity.
// If the Company object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CompanyMutation) OldName(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldName requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldName: %w", err)
	}
	return oldValue.Name, nil
}

// ResetName resets all changes to the "name" field.
func (m *CompanyMutation) ResetName() {
	m.name = nil
}

// SetOverview sets the "overview" field.
func (m *CompanyMutation) SetOverview(s string) {
	m.overview = &s
}

// Overview returns the value of the "overview" field in the mutation.
func (m *CompanyMutation) Overview() (r string, exists bool) {
	v := m.overview
	if v == nil {
		return
	}
	return *v, true
}

// OldOverview returns the old "overview" field's value of the Company entity.
// If the Company object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CompanyMutation) OldOverview(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldOverview is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldOverview requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldOverview: %w", err)
	}
	return oldValue.Overview, nil
}

// ResetOverview resets all changes to the "overview" field.
func (m *CompanyMutation) ResetOverview() {
	m.overview = nil
}

// SetWebsite sets the "website" field.
func (m *CompanyMutation) SetWebsite(s string) {
	m.website = &s
}

// Website returns the value of the "website" field in the mutation.
func (m *CompanyMutation) Website() (r string, exists bool) {
	v := m.website
	if v == nil {
		return
	}
	return *v, true
}

// OldWebsite returns the old "website" field's value of the Company entity.
// If the Company object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CompanyMutation) OldWebsite(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldWebsite is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldWebsite requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldWebsite: %w", err)
	}
	return oldValue.Website, nil
}

// ResetWebsite resets all changes to the "website" field.
func (m *CompanyMutation) ResetWebsite() {
	m.website = nil
}

// SetLogoURL sets the "logo_url" field.
func (m *CompanyMutation) SetLogoURL(s string) {
	m.logo_url = &s
}

// LogoURL returns the value of the "logo_url" field in the mutation.
func (m *CompanyMutation) LogoURL() (r string, exists bool) {
	v := m.logo_url
	if v == nil {
		return
	}
	return *v, true
}

// OldLogoURL returns the old "logo_url" field's value of the Company entity.
// If the Company object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CompanyMutation) OldLogoURL(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldLogoURL is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldLogoURL requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLogoURL: %w", err)
	}
	return oldValue.LogoURL, nil
}

// ResetLogoURL resets all changes to the "logo_url" field.
func (m *CompanyMutation) ResetLogoURL() {
	m.logo_url = nil
}

// SetSize sets the "size" field.
func (m *CompanyMutation) SetSize(c company.Size) {
	m.size = &c
}

// Size returns the value of the "size" field in the mutation.
func (m *CompanyMutation) Size() (r company.Size, exists bool) {
	v := m.size
	if v == nil {
		return
	}
	return *v, true
}

// OldSize returns the old "size" field's value of the Company entity.
// If the Company object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CompanyMutation) OldSize(ctx context.Context) (v company.Size, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldSize is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldSize requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSize: %w", err)
	}
	return oldValue.Size, nil
}

// ResetSize resets all changes to the "size" field.
func (m *CompanyMutation) ResetSize() {
	m.size = nil
}

// SetFoundedAt sets the "founded_at" field.
func (m *CompanyMutation) SetFoundedAt(i int) {
	m.founded_at = &i
	m.addfounded_at = nil
}

// FoundedAt returns the value of the "founded_at" field in the mutation.
func (m *CompanyMutation) FoundedAt() (r int, exists bool) {
	v := m.founded_at
	if v == nil {
		return
	}
	return *v, true
}

// OldFoundedAt returns the old "founded_at" field's value of the Company entity.
// If the Company object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *CompanyMutation) OldFoundedAt(ctx context.Context) (v int, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldFoundedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldFoundedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldFoundedAt: %w", err)
	}
	return oldValue.FoundedAt, nil
}

// AddFoundedAt adds i to the "founded_at" field.
func (m *CompanyMutation) AddFoundedAt(i int) {
	if m.addfounded_at != nil {
		*m.addfounded_at += i
	} else {
		m.addfounded_at = &i
	}
}

// AddedFoundedAt returns the value that was added to the "founded_at" field in this mutation.
func (m *CompanyMutation) AddedFoundedAt() (r int, exists bool) {
	v := m.addfounded_at
	if v == nil {
		return
	}
	return *v, true
}

// ResetFoundedAt resets all changes to the "founded_at" field.
func (m *CompanyMutation) ResetFoundedAt() {
	m.founded_at = nil
	m.addfounded_at = nil
}

// AddStaffIDs adds the "staffs" edge to the WorkExperience entity by ids.
func (m *CompanyMutation) AddStaffIDs(ids ...int) {
	if m.staffs == nil {
		m.staffs = make(map[int]struct{})
	}
	for i := range ids {
		m.staffs[ids[i]] = struct{}{}
	}
}

// ClearStaffs clears the "staffs" edge to the WorkExperience entity.
func (m *CompanyMutation) ClearStaffs() {
	m.clearedstaffs = true
}

// StaffsCleared reports if the "staffs" edge to the WorkExperience entity was cleared.
func (m *CompanyMutation) StaffsCleared() bool {
	return m.clearedstaffs
}

// RemoveStaffIDs removes the "staffs" edge to the WorkExperience entity by IDs.
func (m *CompanyMutation) RemoveStaffIDs(ids ...int) {
	if m.removedstaffs == nil {
		m.removedstaffs = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.staffs, ids[i])
		m.removedstaffs[ids[i]] = struct{}{}
	}
}

// RemovedStaffs returns the removed IDs of the "staffs" edge to the WorkExperience entity.
func (m *CompanyMutation) RemovedStaffsIDs() (ids []int) {
	for id := range m.removedstaffs {
		ids = append(ids, id)
	}
	return
}

// StaffsIDs returns the "staffs" edge IDs in the mutation.
func (m *CompanyMutation) StaffsIDs() (ids []int) {
	for id := range m.staffs {
		ids = append(ids, id)
	}
	return
}

// ResetStaffs resets all changes to the "staffs" edge.
func (m *CompanyMutation) ResetStaffs() {
	m.staffs = nil
	m.clearedstaffs = false
	m.removedstaffs = nil
}

// Where appends a list predicates to the CompanyMutation builder.
func (m *CompanyMutation) Where(ps ...predicate.Company) {
	m.predicates = append(m.predicates, ps...)
}

// Op returns the operation name.
func (m *CompanyMutation) Op() Op {
	return m.op
}

// Type returns the node type of this mutation (Company).
func (m *CompanyMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *CompanyMutation) Fields() []string {
	fields := make([]string, 0, 8)
	if m.created_at != nil {
		fields = append(fields, company.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, company.FieldUpdatedAt)
	}
	if m.name != nil {
		fields = append(fields, company.FieldName)
	}
	if m.overview != nil {
		fields = append(fields, company.FieldOverview)
	}
	if m.website != nil {
		fields = append(fields, company.FieldWebsite)
	}
	if m.logo_url != nil {
		fields = append(fields, company.FieldLogoURL)
	}
	if m.size != nil {
		fields = append(fields, company.FieldSize)
	}
	if m.founded_at != nil {
		fields = append(fields, company.FieldFoundedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *CompanyMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case company.FieldCreatedAt:
		return m.CreatedAt()
	case company.FieldUpdatedAt:
		return m.UpdatedAt()
	case company.FieldName:
		return m.Name()
	case company.FieldOverview:
		return m.Overview()
	case company.FieldWebsite:
		return m.Website()
	case company.FieldLogoURL:
		return m.LogoURL()
	case company.FieldSize:
		return m.Size()
	case company.FieldFoundedAt:
		return m.FoundedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *CompanyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case company.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case company.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case company.FieldName:
		return m.OldName(ctx)
	case company.FieldOverview:
		return m.OldOverview(ctx)
	case company.FieldWebsite:
		return m.OldWebsite(ctx)
	case company.FieldLogoURL:
		return m.OldLogoURL(ctx)
	case company.FieldSize:
		return m.OldSize(ctx)
	case company.FieldFoundedAt:
		return m.OldFoundedAt(ctx)
	}
	return nil, fmt.Errorf("unknown Company field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *CompanyMutation) SetField(name string, value ent.Value) error {
	switch name {
	case company.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case company.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case company.FieldName:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetName(v)
		return nil
	case company.FieldOverview:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetOverview(v)
		return nil
	case company.FieldWebsite:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetWebsite(v)
		return nil
	case company.FieldLogoURL:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLogoURL(v)
		return nil
	case company.FieldSize:
		v, ok := value.(company.Size)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSize(v)
		return nil
	case company.FieldFoundedAt:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetFoundedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Company field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *CompanyMutation) AddedFields() []string {
	var fields []string
	if m.addfounded_at != nil {
		fields = append(fields, company.FieldFoundedAt)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *CompanyMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case company.FieldFoundedAt:
		return m.AddedFoundedAt()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *CompanyMutation) AddField(name string, value ent.Value) error {
	switch name {
	case company.FieldFoundedAt:
		v, ok := value.(int)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddFoundedAt(v)
		return nil
	}
	return fmt.Errorf("unknown Company numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *CompanyMutation) ClearedFields() []string {
	return nil
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *CompanyMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *CompanyMutation) ClearField(name string) error {
	return fmt.Errorf("unknown Company nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *CompanyMutation) ResetField(name string) error {
	switch name {
	case company.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case company.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case company.FieldName:
		m.ResetName()
		return nil
	case company.FieldOverview:
		m.ResetOverview()
		return nil
	case company.FieldWebsite:
		m.ResetWebsite()
		return nil
	case company.FieldLogoURL:
		m.ResetLogoURL()
		return nil
	case company.FieldSize:
		m.ResetSize()
		return nil
	case company.FieldFoundedAt:
		m.ResetFoundedAt()
		return nil
	}
	return fmt.Errorf("unknown Company field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *CompanyMutation) AddedEdges() []string {
	edges := make([]string, 0, 1)
	if m.staffs != nil {
		edges = append(edges, company.EdgeStaffs)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *CompanyMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case company.EdgeStaffs:
		ids := make([]ent.Value, 0, len(m.staffs))
		for id := range m.staffs {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *CompanyMutation) RemovedEdges() []string {
	edges := make([]string, 0, 1)
	if m.removedstaffs != nil {
		edges = append(edges, company.EdgeStaffs)
	}
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *CompanyMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case company.EdgeStaffs:
		ids := make([]ent.Value, 0, len(m.removedstaffs))
		for id := range m.removedstaffs {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *CompanyMutation) ClearedEdges() []string {
	edges := make([]string, 0, 1)
	if m.clearedstaffs {
		edges = append(edges, company.EdgeStaffs)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *CompanyMutation) EdgeCleared(name string) bool {
	switch name {
	case company.EdgeStaffs:
		return m.clearedstaffs
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *CompanyMutation) ClearEdge(name string) error {
	switch name {
	}
	return fmt.Errorf("unknown Company unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *CompanyMutation) ResetEdge(name string) error {
	switch name {
	case company.EdgeStaffs:
		m.ResetStaffs()
		return nil
	}
	return fmt.Errorf("unknown Company edge %s", name)
}

// JobMutation represents an operation that mutates the Job nodes in the graph.
type JobMutation struct {
	config
	op               Op
	typ              string
	id               *int
	created_at       *time.Time
	updated_at       *time.Time
	title            *string
	min_salary       *uint64
	addmin_salary    *uint64
	max_salary       *uint64
	addmax_salary    *uint64
	salary_unit      *job.SalaryUnit
	employment_type  *job.EmploymentType
	requirements     *string
	responsibilities *string
	benefits         *string
	clearedFields    map[string]struct{}
	owner            *int
	clearedowner     bool
	skills           map[int]struct{}
	removedskills    map[int]struct{}
	clearedskills    bool
	done             bool
	oldValue         func(context.Context) (*Job, error)
	predicates       []predicate.Job
}

var _ ent.Mutation = (*JobMutation)(nil)

// jobOption allows management of the mutation configuration using functional options.
type jobOption func(*JobMutation)

// newJobMutation creates new mutation for the Job entity.
func newJobMutation(c config, op Op, opts ...jobOption) *JobMutation {
	m := &JobMutation{
		config:        c,
		op:            op,
		typ:           TypeJob,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withJobID sets the ID field of the mutation.
func withJobID(id int) jobOption {
	return func(m *JobMutation) {
		var (
			err   error
			once  sync.Once
			value *Job
		)
		m.oldValue = func(ctx context.Context) (*Job, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Job.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withJob sets the old Job of the mutation.
func withJob(node *Job) jobOption {
	return func(m *JobMutation) {
		m.oldValue = func(context.Context) (*Job, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m JobMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m JobMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *JobMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// SetCreatedAt sets the "created_at" field.
func (m *JobMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *JobMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *JobMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *JobMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *JobMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *JobMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// SetTitle sets the "title" field.
func (m *JobMutation) SetTitle(s string) {
	m.title = &s
}

// Title returns the value of the "title" field in the mutation.
func (m *JobMutation) Title() (r string, exists bool) {
	v := m.title
	if v == nil {
		return
	}
	return *v, true
}

// OldTitle returns the old "title" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldTitle(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldTitle is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldTitle requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldTitle: %w", err)
	}
	return oldValue.Title, nil
}

// ResetTitle resets all changes to the "title" field.
func (m *JobMutation) ResetTitle() {
	m.title = nil
}

// SetMinSalary sets the "min_salary" field.
func (m *JobMutation) SetMinSalary(u uint64) {
	m.min_salary = &u
	m.addmin_salary = nil
}

// MinSalary returns the value of the "min_salary" field in the mutation.
func (m *JobMutation) MinSalary() (r uint64, exists bool) {
	v := m.min_salary
	if v == nil {
		return
	}
	return *v, true
}

// OldMinSalary returns the old "min_salary" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldMinSalary(ctx context.Context) (v uint64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldMinSalary is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldMinSalary requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldMinSalary: %w", err)
	}
	return oldValue.MinSalary, nil
}

// AddMinSalary adds u to the "min_salary" field.
func (m *JobMutation) AddMinSalary(u uint64) {
	if m.addmin_salary != nil {
		*m.addmin_salary += u
	} else {
		m.addmin_salary = &u
	}
}

// AddedMinSalary returns the value that was added to the "min_salary" field in this mutation.
func (m *JobMutation) AddedMinSalary() (r uint64, exists bool) {
	v := m.addmin_salary
	if v == nil {
		return
	}
	return *v, true
}

// ResetMinSalary resets all changes to the "min_salary" field.
func (m *JobMutation) ResetMinSalary() {
	m.min_salary = nil
	m.addmin_salary = nil
}

// SetMaxSalary sets the "max_salary" field.
func (m *JobMutation) SetMaxSalary(u uint64) {
	m.max_salary = &u
	m.addmax_salary = nil
}

// MaxSalary returns the value of the "max_salary" field in the mutation.
func (m *JobMutation) MaxSalary() (r uint64, exists bool) {
	v := m.max_salary
	if v == nil {
		return
	}
	return *v, true
}

// OldMaxSalary returns the old "max_salary" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldMaxSalary(ctx context.Context) (v uint64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldMaxSalary is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldMaxSalary requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldMaxSalary: %w", err)
	}
	return oldValue.MaxSalary, nil
}

// AddMaxSalary adds u to the "max_salary" field.
func (m *JobMutation) AddMaxSalary(u uint64) {
	if m.addmax_salary != nil {
		*m.addmax_salary += u
	} else {
		m.addmax_salary = &u
	}
}

// AddedMaxSalary returns the value that was added to the "max_salary" field in this mutation.
func (m *JobMutation) AddedMaxSalary() (r uint64, exists bool) {
	v := m.addmax_salary
	if v == nil {
		return
	}
	return *v, true
}

// ResetMaxSalary resets all changes to the "max_salary" field.
func (m *JobMutation) ResetMaxSalary() {
	m.max_salary = nil
	m.addmax_salary = nil
}

// SetSalaryUnit sets the "salary_unit" field.
func (m *JobMutation) SetSalaryUnit(ju job.SalaryUnit) {
	m.salary_unit = &ju
}

// SalaryUnit returns the value of the "salary_unit" field in the mutation.
func (m *JobMutation) SalaryUnit() (r job.SalaryUnit, exists bool) {
	v := m.salary_unit
	if v == nil {
		return
	}
	return *v, true
}

// OldSalaryUnit returns the old "salary_unit" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldSalaryUnit(ctx context.Context) (v job.SalaryUnit, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldSalaryUnit is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldSalaryUnit requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldSalaryUnit: %w", err)
	}
	return oldValue.SalaryUnit, nil
}

// ResetSalaryUnit resets all changes to the "salary_unit" field.
func (m *JobMutation) ResetSalaryUnit() {
	m.salary_unit = nil
}

// SetEmploymentType sets the "employment_type" field.
func (m *JobMutation) SetEmploymentType(jt job.EmploymentType) {
	m.employment_type = &jt
}

// EmploymentType returns the value of the "employment_type" field in the mutation.
func (m *JobMutation) EmploymentType() (r job.EmploymentType, exists bool) {
	v := m.employment_type
	if v == nil {
		return
	}
	return *v, true
}

// OldEmploymentType returns the old "employment_type" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldEmploymentType(ctx context.Context) (v job.EmploymentType, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldEmploymentType is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldEmploymentType requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEmploymentType: %w", err)
	}
	return oldValue.EmploymentType, nil
}

// ResetEmploymentType resets all changes to the "employment_type" field.
func (m *JobMutation) ResetEmploymentType() {
	m.employment_type = nil
}

// SetRequirements sets the "requirements" field.
func (m *JobMutation) SetRequirements(s string) {
	m.requirements = &s
}

// Requirements returns the value of the "requirements" field in the mutation.
func (m *JobMutation) Requirements() (r string, exists bool) {
	v := m.requirements
	if v == nil {
		return
	}
	return *v, true
}

// OldRequirements returns the old "requirements" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldRequirements(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldRequirements is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldRequirements requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRequirements: %w", err)
	}
	return oldValue.Requirements, nil
}

// ResetRequirements resets all changes to the "requirements" field.
func (m *JobMutation) ResetRequirements() {
	m.requirements = nil
}

// SetResponsibilities sets the "responsibilities" field.
func (m *JobMutation) SetResponsibilities(s string) {
	m.responsibilities = &s
}

// Responsibilities returns the value of the "responsibilities" field in the mutation.
func (m *JobMutation) Responsibilities() (r string, exists bool) {
	v := m.responsibilities
	if v == nil {
		return
	}
	return *v, true
}

// OldResponsibilities returns the old "responsibilities" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldResponsibilities(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldResponsibilities is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldResponsibilities requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldResponsibilities: %w", err)
	}
	return oldValue.Responsibilities, nil
}

// ResetResponsibilities resets all changes to the "responsibilities" field.
func (m *JobMutation) ResetResponsibilities() {
	m.responsibilities = nil
}

// SetBenefits sets the "benefits" field.
func (m *JobMutation) SetBenefits(s string) {
	m.benefits = &s
}

// Benefits returns the value of the "benefits" field in the mutation.
func (m *JobMutation) Benefits() (r string, exists bool) {
	v := m.benefits
	if v == nil {
		return
	}
	return *v, true
}

// OldBenefits returns the old "benefits" field's value of the Job entity.
// If the Job object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *JobMutation) OldBenefits(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldBenefits is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldBenefits requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldBenefits: %w", err)
	}
	return oldValue.Benefits, nil
}

// ResetBenefits resets all changes to the "benefits" field.
func (m *JobMutation) ResetBenefits() {
	m.benefits = nil
}

// SetOwnerID sets the "owner" edge to the User entity by id.
func (m *JobMutation) SetOwnerID(id int) {
	m.owner = &id
}

// ClearOwner clears the "owner" edge to the User entity.
func (m *JobMutation) ClearOwner() {
	m.clearedowner = true
}

// OwnerCleared reports if the "owner" edge to the User entity was cleared.
func (m *JobMutation) OwnerCleared() bool {
	return m.clearedowner
}

// OwnerID returns the "owner" edge ID in the mutation.
func (m *JobMutation) OwnerID() (id int, exists bool) {
	if m.owner != nil {
		return *m.owner, true
	}
	return
}

// OwnerIDs returns the "owner" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// OwnerID instead. It exists only for internal usage by the builders.
func (m *JobMutation) OwnerIDs() (ids []int) {
	if id := m.owner; id != nil {
		ids = append(ids, *id)
	}
	return
}

// ResetOwner resets all changes to the "owner" edge.
func (m *JobMutation) ResetOwner() {
	m.owner = nil
	m.clearedowner = false
}

// AddSkillIDs adds the "skills" edge to the Skill entity by ids.
func (m *JobMutation) AddSkillIDs(ids ...int) {
	if m.skills == nil {
		m.skills = make(map[int]struct{})
	}
	for i := range ids {
		m.skills[ids[i]] = struct{}{}
	}
}

// ClearSkills clears the "skills" edge to the Skill entity.
func (m *JobMutation) ClearSkills() {
	m.clearedskills = true
}

// SkillsCleared reports if the "skills" edge to the Skill entity was cleared.
func (m *JobMutation) SkillsCleared() bool {
	return m.clearedskills
}

// RemoveSkillIDs removes the "skills" edge to the Skill entity by IDs.
func (m *JobMutation) RemoveSkillIDs(ids ...int) {
	if m.removedskills == nil {
		m.removedskills = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.skills, ids[i])
		m.removedskills[ids[i]] = struct{}{}
	}
}

// RemovedSkills returns the removed IDs of the "skills" edge to the Skill entity.
func (m *JobMutation) RemovedSkillsIDs() (ids []int) {
	for id := range m.removedskills {
		ids = append(ids, id)
	}
	return
}

// SkillsIDs returns the "skills" edge IDs in the mutation.
func (m *JobMutation) SkillsIDs() (ids []int) {
	for id := range m.skills {
		ids = append(ids, id)
	}
	return
}

// ResetSkills resets all changes to the "skills" edge.
func (m *JobMutation) ResetSkills() {
	m.skills = nil
	m.clearedskills = false
	m.removedskills = nil
}

// Where appends a list predicates to the JobMutation builder.
func (m *JobMutation) Where(ps ...predicate.Job) {
	m.predicates = append(m.predicates, ps...)
}

// Op returns the operation name.
func (m *JobMutation) Op() Op {
	return m.op
}

// Type returns the node type of this mutation (Job).
func (m *JobMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *JobMutation) Fields() []string {
	fields := make([]string, 0, 10)
	if m.created_at != nil {
		fields = append(fields, job.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, job.FieldUpdatedAt)
	}
	if m.title != nil {
		fields = append(fields, job.FieldTitle)
	}
	if m.min_salary != nil {
		fields = append(fields, job.FieldMinSalary)
	}
	if m.max_salary != nil {
		fields = append(fields, job.FieldMaxSalary)
	}
	if m.salary_unit != nil {
		fields = append(fields, job.FieldSalaryUnit)
	}
	if m.employment_type != nil {
		fields = append(fields, job.FieldEmploymentType)
	}
	if m.requirements != nil {
		fields = append(fields, job.FieldRequirements)
	}
	if m.responsibilities != nil {
		fields = append(fields, job.FieldResponsibilities)
	}
	if m.benefits != nil {
		fields = append(fields, job.FieldBenefits)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *JobMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case job.FieldCreatedAt:
		return m.CreatedAt()
	case job.FieldUpdatedAt:
		return m.UpdatedAt()
	case job.FieldTitle:
		return m.Title()
	case job.FieldMinSalary:
		return m.MinSalary()
	case job.FieldMaxSalary:
		return m.MaxSalary()
	case job.FieldSalaryUnit:
		return m.SalaryUnit()
	case job.FieldEmploymentType:
		return m.EmploymentType()
	case job.FieldRequirements:
		return m.Requirements()
	case job.FieldResponsibilities:
		return m.Responsibilities()
	case job.FieldBenefits:
		return m.Benefits()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *JobMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case job.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case job.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case job.FieldTitle:
		return m.OldTitle(ctx)
	case job.FieldMinSalary:
		return m.OldMinSalary(ctx)
	case job.FieldMaxSalary:
		return m.OldMaxSalary(ctx)
	case job.FieldSalaryUnit:
		return m.OldSalaryUnit(ctx)
	case job.FieldEmploymentType:
		return m.OldEmploymentType(ctx)
	case job.FieldRequirements:
		return m.OldRequirements(ctx)
	case job.FieldResponsibilities:
		return m.OldResponsibilities(ctx)
	case job.FieldBenefits:
		return m.OldBenefits(ctx)
	}
	return nil, fmt.Errorf("unknown Job field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *JobMutation) SetField(name string, value ent.Value) error {
	switch name {
	case job.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case job.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case job.FieldTitle:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetTitle(v)
		return nil
	case job.FieldMinSalary:
		v, ok := value.(uint64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetMinSalary(v)
		return nil
	case job.FieldMaxSalary:
		v, ok := value.(uint64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetMaxSalary(v)
		return nil
	case job.FieldSalaryUnit:
		v, ok := value.(job.SalaryUnit)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetSalaryUnit(v)
		return nil
	case job.FieldEmploymentType:
		v, ok := value.(job.EmploymentType)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEmploymentType(v)
		return nil
	case job.FieldRequirements:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRequirements(v)
		return nil
	case job.FieldResponsibilities:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetResponsibilities(v)
		return nil
	case job.FieldBenefits:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetBenefits(v)
		return nil
	}
	return fmt.Errorf("unknown Job field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *JobMutation) AddedFields() []string {
	var fields []string
	if m.addmin_salary != nil {
		fields = append(fields, job.FieldMinSalary)
	}
	if m.addmax_salary != nil {
		fields = append(fields, job.FieldMaxSalary)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *JobMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case job.FieldMinSalary:
		return m.AddedMinSalary()
	case job.FieldMaxSalary:
		return m.AddedMaxSalary()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *JobMutation) AddField(name string, value ent.Value) error {
	switch name {
	case job.FieldMinSalary:
		v, ok := value.(uint64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddMinSalary(v)
		return nil
	case job.FieldMaxSalary:
		v, ok := value.(uint64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddMaxSalary(v)
		return nil
	}
	return fmt.Errorf("unknown Job numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *JobMutation) ClearedFields() []string {
	return nil
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *JobMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *JobMutation) ClearField(name string) error {
	return fmt.Errorf("unknown Job nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *JobMutation) ResetField(name string) error {
	switch name {
	case job.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case job.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case job.FieldTitle:
		m.ResetTitle()
		return nil
	case job.FieldMinSalary:
		m.ResetMinSalary()
		return nil
	case job.FieldMaxSalary:
		m.ResetMaxSalary()
		return nil
	case job.FieldSalaryUnit:
		m.ResetSalaryUnit()
		return nil
	case job.FieldEmploymentType:
		m.ResetEmploymentType()
		return nil
	case job.FieldRequirements:
		m.ResetRequirements()
		return nil
	case job.FieldResponsibilities:
		m.ResetResponsibilities()
		return nil
	case job.FieldBenefits:
		m.ResetBenefits()
		return nil
	}
	return fmt.Errorf("unknown Job field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *JobMutation) AddedEdges() []string {
	edges := make([]string, 0, 2)
	if m.owner != nil {
		edges = append(edges, job.EdgeOwner)
	}
	if m.skills != nil {
		edges = append(edges, job.EdgeSkills)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *JobMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case job.EdgeOwner:
		if id := m.owner; id != nil {
			return []ent.Value{*id}
		}
	case job.EdgeSkills:
		ids := make([]ent.Value, 0, len(m.skills))
		for id := range m.skills {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *JobMutation) RemovedEdges() []string {
	edges := make([]string, 0, 2)
	if m.removedskills != nil {
		edges = append(edges, job.EdgeSkills)
	}
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *JobMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case job.EdgeSkills:
		ids := make([]ent.Value, 0, len(m.removedskills))
		for id := range m.removedskills {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *JobMutation) ClearedEdges() []string {
	edges := make([]string, 0, 2)
	if m.clearedowner {
		edges = append(edges, job.EdgeOwner)
	}
	if m.clearedskills {
		edges = append(edges, job.EdgeSkills)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *JobMutation) EdgeCleared(name string) bool {
	switch name {
	case job.EdgeOwner:
		return m.clearedowner
	case job.EdgeSkills:
		return m.clearedskills
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *JobMutation) ClearEdge(name string) error {
	switch name {
	case job.EdgeOwner:
		m.ClearOwner()
		return nil
	}
	return fmt.Errorf("unknown Job unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *JobMutation) ResetEdge(name string) error {
	switch name {
	case job.EdgeOwner:
		m.ResetOwner()
		return nil
	case job.EdgeSkills:
		m.ResetSkills()
		return nil
	}
	return fmt.Errorf("unknown Job edge %s", name)
}

// SkillMutation represents an operation that mutates the Skill nodes in the graph.
type SkillMutation struct {
	config
	op                 Op
	typ                string
	id                 *int
	created_at         *time.Time
	updated_at         *time.Time
	name               *string
	logo_url           *string
	clearedFields      map[string]struct{}
	experiences        map[int]struct{}
	removedexperiences map[int]struct{}
	clearedexperiences bool
	jobs               map[int]struct{}
	removedjobs        map[int]struct{}
	clearedjobs        bool
	done               bool
	oldValue           func(context.Context) (*Skill, error)
	predicates         []predicate.Skill
}

var _ ent.Mutation = (*SkillMutation)(nil)

// skillOption allows management of the mutation configuration using functional options.
type skillOption func(*SkillMutation)

// newSkillMutation creates new mutation for the Skill entity.
func newSkillMutation(c config, op Op, opts ...skillOption) *SkillMutation {
	m := &SkillMutation{
		config:        c,
		op:            op,
		typ:           TypeSkill,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withSkillID sets the ID field of the mutation.
func withSkillID(id int) skillOption {
	return func(m *SkillMutation) {
		var (
			err   error
			once  sync.Once
			value *Skill
		)
		m.oldValue = func(ctx context.Context) (*Skill, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Skill.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withSkill sets the old Skill of the mutation.
func withSkill(node *Skill) skillOption {
	return func(m *SkillMutation) {
		m.oldValue = func(context.Context) (*Skill, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m SkillMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m SkillMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *SkillMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// SetCreatedAt sets the "created_at" field.
func (m *SkillMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *SkillMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the Skill entity.
// If the Skill object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SkillMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *SkillMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *SkillMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *SkillMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the Skill entity.
// If the Skill object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SkillMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *SkillMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// SetName sets the "name" field.
func (m *SkillMutation) SetName(s string) {
	m.name = &s
}

// Name returns the value of the "name" field in the mutation.
func (m *SkillMutation) Name() (r string, exists bool) {
	v := m.name
	if v == nil {
		return
	}
	return *v, true
}

// OldName returns the old "name" field's value of the Skill entity.
// If the Skill object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SkillMutation) OldName(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldName requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldName: %w", err)
	}
	return oldValue.Name, nil
}

// ResetName resets all changes to the "name" field.
func (m *SkillMutation) ResetName() {
	m.name = nil
}

// SetLogoURL sets the "logo_url" field.
func (m *SkillMutation) SetLogoURL(s string) {
	m.logo_url = &s
}

// LogoURL returns the value of the "logo_url" field in the mutation.
func (m *SkillMutation) LogoURL() (r string, exists bool) {
	v := m.logo_url
	if v == nil {
		return
	}
	return *v, true
}

// OldLogoURL returns the old "logo_url" field's value of the Skill entity.
// If the Skill object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SkillMutation) OldLogoURL(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldLogoURL is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldLogoURL requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLogoURL: %w", err)
	}
	return oldValue.LogoURL, nil
}

// ResetLogoURL resets all changes to the "logo_url" field.
func (m *SkillMutation) ResetLogoURL() {
	m.logo_url = nil
}

// AddExperienceIDs adds the "experiences" edge to the WorkExperience entity by ids.
func (m *SkillMutation) AddExperienceIDs(ids ...int) {
	if m.experiences == nil {
		m.experiences = make(map[int]struct{})
	}
	for i := range ids {
		m.experiences[ids[i]] = struct{}{}
	}
}

// ClearExperiences clears the "experiences" edge to the WorkExperience entity.
func (m *SkillMutation) ClearExperiences() {
	m.clearedexperiences = true
}

// ExperiencesCleared reports if the "experiences" edge to the WorkExperience entity was cleared.
func (m *SkillMutation) ExperiencesCleared() bool {
	return m.clearedexperiences
}

// RemoveExperienceIDs removes the "experiences" edge to the WorkExperience entity by IDs.
func (m *SkillMutation) RemoveExperienceIDs(ids ...int) {
	if m.removedexperiences == nil {
		m.removedexperiences = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.experiences, ids[i])
		m.removedexperiences[ids[i]] = struct{}{}
	}
}

// RemovedExperiences returns the removed IDs of the "experiences" edge to the WorkExperience entity.
func (m *SkillMutation) RemovedExperiencesIDs() (ids []int) {
	for id := range m.removedexperiences {
		ids = append(ids, id)
	}
	return
}

// ExperiencesIDs returns the "experiences" edge IDs in the mutation.
func (m *SkillMutation) ExperiencesIDs() (ids []int) {
	for id := range m.experiences {
		ids = append(ids, id)
	}
	return
}

// ResetExperiences resets all changes to the "experiences" edge.
func (m *SkillMutation) ResetExperiences() {
	m.experiences = nil
	m.clearedexperiences = false
	m.removedexperiences = nil
}

// AddJobIDs adds the "jobs" edge to the Job entity by ids.
func (m *SkillMutation) AddJobIDs(ids ...int) {
	if m.jobs == nil {
		m.jobs = make(map[int]struct{})
	}
	for i := range ids {
		m.jobs[ids[i]] = struct{}{}
	}
}

// ClearJobs clears the "jobs" edge to the Job entity.
func (m *SkillMutation) ClearJobs() {
	m.clearedjobs = true
}

// JobsCleared reports if the "jobs" edge to the Job entity was cleared.
func (m *SkillMutation) JobsCleared() bool {
	return m.clearedjobs
}

// RemoveJobIDs removes the "jobs" edge to the Job entity by IDs.
func (m *SkillMutation) RemoveJobIDs(ids ...int) {
	if m.removedjobs == nil {
		m.removedjobs = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.jobs, ids[i])
		m.removedjobs[ids[i]] = struct{}{}
	}
}

// RemovedJobs returns the removed IDs of the "jobs" edge to the Job entity.
func (m *SkillMutation) RemovedJobsIDs() (ids []int) {
	for id := range m.removedjobs {
		ids = append(ids, id)
	}
	return
}

// JobsIDs returns the "jobs" edge IDs in the mutation.
func (m *SkillMutation) JobsIDs() (ids []int) {
	for id := range m.jobs {
		ids = append(ids, id)
	}
	return
}

// ResetJobs resets all changes to the "jobs" edge.
func (m *SkillMutation) ResetJobs() {
	m.jobs = nil
	m.clearedjobs = false
	m.removedjobs = nil
}

// Where appends a list predicates to the SkillMutation builder.
func (m *SkillMutation) Where(ps ...predicate.Skill) {
	m.predicates = append(m.predicates, ps...)
}

// Op returns the operation name.
func (m *SkillMutation) Op() Op {
	return m.op
}

// Type returns the node type of this mutation (Skill).
func (m *SkillMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *SkillMutation) Fields() []string {
	fields := make([]string, 0, 4)
	if m.created_at != nil {
		fields = append(fields, skill.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, skill.FieldUpdatedAt)
	}
	if m.name != nil {
		fields = append(fields, skill.FieldName)
	}
	if m.logo_url != nil {
		fields = append(fields, skill.FieldLogoURL)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *SkillMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case skill.FieldCreatedAt:
		return m.CreatedAt()
	case skill.FieldUpdatedAt:
		return m.UpdatedAt()
	case skill.FieldName:
		return m.Name()
	case skill.FieldLogoURL:
		return m.LogoURL()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *SkillMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case skill.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case skill.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case skill.FieldName:
		return m.OldName(ctx)
	case skill.FieldLogoURL:
		return m.OldLogoURL(ctx)
	}
	return nil, fmt.Errorf("unknown Skill field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *SkillMutation) SetField(name string, value ent.Value) error {
	switch name {
	case skill.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case skill.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case skill.FieldName:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetName(v)
		return nil
	case skill.FieldLogoURL:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLogoURL(v)
		return nil
	}
	return fmt.Errorf("unknown Skill field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *SkillMutation) AddedFields() []string {
	return nil
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *SkillMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *SkillMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown Skill numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *SkillMutation) ClearedFields() []string {
	return nil
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *SkillMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *SkillMutation) ClearField(name string) error {
	return fmt.Errorf("unknown Skill nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *SkillMutation) ResetField(name string) error {
	switch name {
	case skill.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case skill.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case skill.FieldName:
		m.ResetName()
		return nil
	case skill.FieldLogoURL:
		m.ResetLogoURL()
		return nil
	}
	return fmt.Errorf("unknown Skill field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *SkillMutation) AddedEdges() []string {
	edges := make([]string, 0, 2)
	if m.experiences != nil {
		edges = append(edges, skill.EdgeExperiences)
	}
	if m.jobs != nil {
		edges = append(edges, skill.EdgeJobs)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *SkillMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case skill.EdgeExperiences:
		ids := make([]ent.Value, 0, len(m.experiences))
		for id := range m.experiences {
			ids = append(ids, id)
		}
		return ids
	case skill.EdgeJobs:
		ids := make([]ent.Value, 0, len(m.jobs))
		for id := range m.jobs {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *SkillMutation) RemovedEdges() []string {
	edges := make([]string, 0, 2)
	if m.removedexperiences != nil {
		edges = append(edges, skill.EdgeExperiences)
	}
	if m.removedjobs != nil {
		edges = append(edges, skill.EdgeJobs)
	}
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *SkillMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case skill.EdgeExperiences:
		ids := make([]ent.Value, 0, len(m.removedexperiences))
		for id := range m.removedexperiences {
			ids = append(ids, id)
		}
		return ids
	case skill.EdgeJobs:
		ids := make([]ent.Value, 0, len(m.removedjobs))
		for id := range m.removedjobs {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *SkillMutation) ClearedEdges() []string {
	edges := make([]string, 0, 2)
	if m.clearedexperiences {
		edges = append(edges, skill.EdgeExperiences)
	}
	if m.clearedjobs {
		edges = append(edges, skill.EdgeJobs)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *SkillMutation) EdgeCleared(name string) bool {
	switch name {
	case skill.EdgeExperiences:
		return m.clearedexperiences
	case skill.EdgeJobs:
		return m.clearedjobs
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *SkillMutation) ClearEdge(name string) error {
	switch name {
	}
	return fmt.Errorf("unknown Skill unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *SkillMutation) ResetEdge(name string) error {
	switch name {
	case skill.EdgeExperiences:
		m.ResetExperiences()
		return nil
	case skill.EdgeJobs:
		m.ResetJobs()
		return nil
	}
	return fmt.Errorf("unknown Skill edge %s", name)
}

// UserMutation represents an operation that mutates the User nodes in the graph.
type UserMutation struct {
	config
	op                  Op
	typ                 string
	id                  *int
	created_at          *time.Time
	updated_at          *time.Time
	username            *string
	fullname            *string
	password            *string
	email               *string
	phone               *string
	bio                 *string
	intro               *string
	github_profile      *string
	profile_picture_url *string
	status              *user.Status
	clearedFields       map[string]struct{}
	jobs                map[int]struct{}
	removedjobs         map[int]struct{}
	clearedjobs         bool
	experiences         map[int]struct{}
	removedexperiences  map[int]struct{}
	clearedexperiences  bool
	done                bool
	oldValue            func(context.Context) (*User, error)
	predicates          []predicate.User
}

var _ ent.Mutation = (*UserMutation)(nil)

// userOption allows management of the mutation configuration using functional options.
type userOption func(*UserMutation)

// newUserMutation creates new mutation for the User entity.
func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
	m := &UserMutation{
		config:        c,
		op:            op,
		typ:           TypeUser,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withUserID sets the ID field of the mutation.
func withUserID(id int) userOption {
	return func(m *UserMutation) {
		var (
			err   error
			once  sync.Once
			value *User
		)
		m.oldValue = func(ctx context.Context) (*User, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().User.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withUser sets the old User of the mutation.
func withUser(node *User) userOption {
	return func(m *UserMutation) {
		m.oldValue = func(context.Context) (*User, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m UserMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m UserMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *UserMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// SetCreatedAt sets the "created_at" field.
func (m *UserMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *UserMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *UserMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *UserMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *UserMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// SetUsername sets the "username" field.
func (m *UserMutation) SetUsername(s string) {
	m.username = &s
}

// Username returns the value of the "username" field in the mutation.
func (m *UserMutation) Username() (r string, exists bool) {
	v := m.username
	if v == nil {
		return
	}
	return *v, true
}

// OldUsername returns the old "username" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUsername is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUsername requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUsername: %w", err)
	}
	return oldValue.Username, nil
}

// ResetUsername resets all changes to the "username" field.
func (m *UserMutation) ResetUsername() {
	m.username = nil
}

// SetFullname sets the "fullname" field.
func (m *UserMutation) SetFullname(s string) {
	m.fullname = &s
}

// Fullname returns the value of the "fullname" field in the mutation.
func (m *UserMutation) Fullname() (r string, exists bool) {
	v := m.fullname
	if v == nil {
		return
	}
	return *v, true
}

// OldFullname returns the old "fullname" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldFullname(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldFullname is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldFullname requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldFullname: %w", err)
	}
	return oldValue.Fullname, nil
}

// ResetFullname resets all changes to the "fullname" field.
func (m *UserMutation) ResetFullname() {
	m.fullname = nil
}

// SetPassword sets the "password" field.
func (m *UserMutation) SetPassword(s string) {
	m.password = &s
}

// Password returns the value of the "password" field in the mutation.
func (m *UserMutation) Password() (r string, exists bool) {
	v := m.password
	if v == nil {
		return
	}
	return *v, true
}

// OldPassword returns the old "password" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldPassword is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldPassword requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPassword: %w", err)
	}
	return oldValue.Password, nil
}

// ResetPassword resets all changes to the "password" field.
func (m *UserMutation) ResetPassword() {
	m.password = nil
}

// SetEmail sets the "email" field.
func (m *UserMutation) SetEmail(s string) {
	m.email = &s
}

// Email returns the value of the "email" field in the mutation.
func (m *UserMutation) Email() (r string, exists bool) {
	v := m.email
	if v == nil {
		return
	}
	return *v, true
}

// OldEmail returns the old "email" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldEmail is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldEmail requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEmail: %w", err)
	}
	return oldValue.Email, nil
}

// ResetEmail resets all changes to the "email" field.
func (m *UserMutation) ResetEmail() {
	m.email = nil
}

// SetPhone sets the "phone" field.
func (m *UserMutation) SetPhone(s string) {
	m.phone = &s
}

// Phone returns the value of the "phone" field in the mutation.
func (m *UserMutation) Phone() (r string, exists bool) {
	v := m.phone
	if v == nil {
		return
	}
	return *v, true
}

// OldPhone returns the old "phone" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldPhone(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldPhone is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldPhone requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldPhone: %w", err)
	}
	return oldValue.Phone, nil
}

// ResetPhone resets all changes to the "phone" field.
func (m *UserMutation) ResetPhone() {
	m.phone = nil
}

// SetBio sets the "bio" field.
func (m *UserMutation) SetBio(s string) {
	m.bio = &s
}

// Bio returns the value of the "bio" field in the mutation.
func (m *UserMutation) Bio() (r string, exists bool) {
	v := m.bio
	if v == nil {
		return
	}
	return *v, true
}

// OldBio returns the old "bio" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldBio(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldBio is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldBio requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldBio: %w", err)
	}
	return oldValue.Bio, nil
}

// ResetBio resets all changes to the "bio" field.
func (m *UserMutation) ResetBio() {
	m.bio = nil
}

// SetIntro sets the "intro" field.
func (m *UserMutation) SetIntro(s string) {
	m.intro = &s
}

// Intro returns the value of the "intro" field in the mutation.
func (m *UserMutation) Intro() (r string, exists bool) {
	v := m.intro
	if v == nil {
		return
	}
	return *v, true
}

// OldIntro returns the old "intro" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldIntro(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldIntro is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldIntro requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldIntro: %w", err)
	}
	return oldValue.Intro, nil
}

// ResetIntro resets all changes to the "intro" field.
func (m *UserMutation) ResetIntro() {
	m.intro = nil
}

// SetGithubProfile sets the "github_profile" field.
func (m *UserMutation) SetGithubProfile(s string) {
	m.github_profile = &s
}

// GithubProfile returns the value of the "github_profile" field in the mutation.
func (m *UserMutation) GithubProfile() (r string, exists bool) {
	v := m.github_profile
	if v == nil {
		return
	}
	return *v, true
}

// OldGithubProfile returns the old "github_profile" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldGithubProfile(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldGithubProfile is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldGithubProfile requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldGithubProfile: %w", err)
	}
	return oldValue.GithubProfile, nil
}

// ResetGithubProfile resets all changes to the "github_profile" field.
func (m *UserMutation) ResetGithubProfile() {
	m.github_profile = nil
}

// SetProfilePictureURL sets the "profile_picture_url" field.
func (m *UserMutation) SetProfilePictureURL(s string) {
	m.profile_picture_url = &s
}

// ProfilePictureURL returns the value of the "profile_picture_url" field in the mutation.
func (m *UserMutation) ProfilePictureURL() (r string, exists bool) {
	v := m.profile_picture_url
	if v == nil {
		return
	}
	return *v, true
}

// OldProfilePictureURL returns the old "profile_picture_url" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldProfilePictureURL(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldProfilePictureURL is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldProfilePictureURL requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldProfilePictureURL: %w", err)
	}
	return oldValue.ProfilePictureURL, nil
}

// ResetProfilePictureURL resets all changes to the "profile_picture_url" field.
func (m *UserMutation) ResetProfilePictureURL() {
	m.profile_picture_url = nil
}

// SetStatus sets the "status" field.
func (m *UserMutation) SetStatus(u user.Status) {
	m.status = &u
}

// Status returns the value of the "status" field in the mutation.
func (m *UserMutation) Status() (r user.Status, exists bool) {
	v := m.status
	if v == nil {
		return
	}
	return *v, true
}

// OldStatus returns the old "status" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldStatus(ctx context.Context) (v user.Status, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldStatus is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldStatus requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
	}
	return oldValue.Status, nil
}

// ResetStatus resets all changes to the "status" field.
func (m *UserMutation) ResetStatus() {
	m.status = nil
}

// AddJobIDs adds the "jobs" edge to the Job entity by ids.
func (m *UserMutation) AddJobIDs(ids ...int) {
	if m.jobs == nil {
		m.jobs = make(map[int]struct{})
	}
	for i := range ids {
		m.jobs[ids[i]] = struct{}{}
	}
}

// ClearJobs clears the "jobs" edge to the Job entity.
func (m *UserMutation) ClearJobs() {
	m.clearedjobs = true
}

// JobsCleared reports if the "jobs" edge to the Job entity was cleared.
func (m *UserMutation) JobsCleared() bool {
	return m.clearedjobs
}

// RemoveJobIDs removes the "jobs" edge to the Job entity by IDs.
func (m *UserMutation) RemoveJobIDs(ids ...int) {
	if m.removedjobs == nil {
		m.removedjobs = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.jobs, ids[i])
		m.removedjobs[ids[i]] = struct{}{}
	}
}

// RemovedJobs returns the removed IDs of the "jobs" edge to the Job entity.
func (m *UserMutation) RemovedJobsIDs() (ids []int) {
	for id := range m.removedjobs {
		ids = append(ids, id)
	}
	return
}

// JobsIDs returns the "jobs" edge IDs in the mutation.
func (m *UserMutation) JobsIDs() (ids []int) {
	for id := range m.jobs {
		ids = append(ids, id)
	}
	return
}

// ResetJobs resets all changes to the "jobs" edge.
func (m *UserMutation) ResetJobs() {
	m.jobs = nil
	m.clearedjobs = false
	m.removedjobs = nil
}

// AddExperienceIDs adds the "experiences" edge to the WorkExperience entity by ids.
func (m *UserMutation) AddExperienceIDs(ids ...int) {
	if m.experiences == nil {
		m.experiences = make(map[int]struct{})
	}
	for i := range ids {
		m.experiences[ids[i]] = struct{}{}
	}
}

// ClearExperiences clears the "experiences" edge to the WorkExperience entity.
func (m *UserMutation) ClearExperiences() {
	m.clearedexperiences = true
}

// ExperiencesCleared reports if the "experiences" edge to the WorkExperience entity was cleared.
func (m *UserMutation) ExperiencesCleared() bool {
	return m.clearedexperiences
}

// RemoveExperienceIDs removes the "experiences" edge to the WorkExperience entity by IDs.
func (m *UserMutation) RemoveExperienceIDs(ids ...int) {
	if m.removedexperiences == nil {
		m.removedexperiences = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.experiences, ids[i])
		m.removedexperiences[ids[i]] = struct{}{}
	}
}

// RemovedExperiences returns the removed IDs of the "experiences" edge to the WorkExperience entity.
func (m *UserMutation) RemovedExperiencesIDs() (ids []int) {
	for id := range m.removedexperiences {
		ids = append(ids, id)
	}
	return
}

// ExperiencesIDs returns the "experiences" edge IDs in the mutation.
func (m *UserMutation) ExperiencesIDs() (ids []int) {
	for id := range m.experiences {
		ids = append(ids, id)
	}
	return
}

// ResetExperiences resets all changes to the "experiences" edge.
func (m *UserMutation) ResetExperiences() {
	m.experiences = nil
	m.clearedexperiences = false
	m.removedexperiences = nil
}

// Where appends a list predicates to the UserMutation builder.
func (m *UserMutation) Where(ps ...predicate.User) {
	m.predicates = append(m.predicates, ps...)
}

// Op returns the operation name.
func (m *UserMutation) Op() Op {
	return m.op
}

// Type returns the node type of this mutation (User).
func (m *UserMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *UserMutation) Fields() []string {
	fields := make([]string, 0, 12)
	if m.created_at != nil {
		fields = append(fields, user.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, user.FieldUpdatedAt)
	}
	if m.username != nil {
		fields = append(fields, user.FieldUsername)
	}
	if m.fullname != nil {
		fields = append(fields, user.FieldFullname)
	}
	if m.password != nil {
		fields = append(fields, user.FieldPassword)
	}
	if m.email != nil {
		fields = append(fields, user.FieldEmail)
	}
	if m.phone != nil {
		fields = append(fields, user.FieldPhone)
	}
	if m.bio != nil {
		fields = append(fields, user.FieldBio)
	}
	if m.intro != nil {
		fields = append(fields, user.FieldIntro)
	}
	if m.github_profile != nil {
		fields = append(fields, user.FieldGithubProfile)
	}
	if m.profile_picture_url != nil {
		fields = append(fields, user.FieldProfilePictureURL)
	}
	if m.status != nil {
		fields = append(fields, user.FieldStatus)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *UserMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case user.FieldCreatedAt:
		return m.CreatedAt()
	case user.FieldUpdatedAt:
		return m.UpdatedAt()
	case user.FieldUsername:
		return m.Username()
	case user.FieldFullname:
		return m.Fullname()
	case user.FieldPassword:
		return m.Password()
	case user.FieldEmail:
		return m.Email()
	case user.FieldPhone:
		return m.Phone()
	case user.FieldBio:
		return m.Bio()
	case user.FieldIntro:
		return m.Intro()
	case user.FieldGithubProfile:
		return m.GithubProfile()
	case user.FieldProfilePictureURL:
		return m.ProfilePictureURL()
	case user.FieldStatus:
		return m.Status()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case user.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case user.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case user.FieldUsername:
		return m.OldUsername(ctx)
	case user.FieldFullname:
		return m.OldFullname(ctx)
	case user.FieldPassword:
		return m.OldPassword(ctx)
	case user.FieldEmail:
		return m.OldEmail(ctx)
	case user.FieldPhone:
		return m.OldPhone(ctx)
	case user.FieldBio:
		return m.OldBio(ctx)
	case user.FieldIntro:
		return m.OldIntro(ctx)
	case user.FieldGithubProfile:
		return m.OldGithubProfile(ctx)
	case user.FieldProfilePictureURL:
		return m.OldProfilePictureURL(ctx)
	case user.FieldStatus:
		return m.OldStatus(ctx)
	}
	return nil, fmt.Errorf("unknown User field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *UserMutation) SetField(name string, value ent.Value) error {
	switch name {
	case user.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case user.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case user.FieldUsername:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUsername(v)
		return nil
	case user.FieldFullname:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetFullname(v)
		return nil
	case user.FieldPassword:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPassword(v)
		return nil
	case user.FieldEmail:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEmail(v)
		return nil
	case user.FieldPhone:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetPhone(v)
		return nil
	case user.FieldBio:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetBio(v)
		return nil
	case user.FieldIntro:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetIntro(v)
		return nil
	case user.FieldGithubProfile:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetGithubProfile(v)
		return nil
	case user.FieldProfilePictureURL:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetProfilePictureURL(v)
		return nil
	case user.FieldStatus:
		v, ok := value.(user.Status)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStatus(v)
		return nil
	}
	return fmt.Errorf("unknown User field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *UserMutation) AddedFields() []string {
	return nil
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *UserMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown User numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *UserMutation) ClearedFields() []string {
	return nil
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *UserMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *UserMutation) ClearField(name string) error {
	return fmt.Errorf("unknown User nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *UserMutation) ResetField(name string) error {
	switch name {
	case user.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case user.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case user.FieldUsername:
		m.ResetUsername()
		return nil
	case user.FieldFullname:
		m.ResetFullname()
		return nil
	case user.FieldPassword:
		m.ResetPassword()
		return nil
	case user.FieldEmail:
		m.ResetEmail()
		return nil
	case user.FieldPhone:
		m.ResetPhone()
		return nil
	case user.FieldBio:
		m.ResetBio()
		return nil
	case user.FieldIntro:
		m.ResetIntro()
		return nil
	case user.FieldGithubProfile:
		m.ResetGithubProfile()
		return nil
	case user.FieldProfilePictureURL:
		m.ResetProfilePictureURL()
		return nil
	case user.FieldStatus:
		m.ResetStatus()
		return nil
	}
	return fmt.Errorf("unknown User field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *UserMutation) AddedEdges() []string {
	edges := make([]string, 0, 2)
	if m.jobs != nil {
		edges = append(edges, user.EdgeJobs)
	}
	if m.experiences != nil {
		edges = append(edges, user.EdgeExperiences)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *UserMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case user.EdgeJobs:
		ids := make([]ent.Value, 0, len(m.jobs))
		for id := range m.jobs {
			ids = append(ids, id)
		}
		return ids
	case user.EdgeExperiences:
		ids := make([]ent.Value, 0, len(m.experiences))
		for id := range m.experiences {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *UserMutation) RemovedEdges() []string {
	edges := make([]string, 0, 2)
	if m.removedjobs != nil {
		edges = append(edges, user.EdgeJobs)
	}
	if m.removedexperiences != nil {
		edges = append(edges, user.EdgeExperiences)
	}
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *UserMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case user.EdgeJobs:
		ids := make([]ent.Value, 0, len(m.removedjobs))
		for id := range m.removedjobs {
			ids = append(ids, id)
		}
		return ids
	case user.EdgeExperiences:
		ids := make([]ent.Value, 0, len(m.removedexperiences))
		for id := range m.removedexperiences {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *UserMutation) ClearedEdges() []string {
	edges := make([]string, 0, 2)
	if m.clearedjobs {
		edges = append(edges, user.EdgeJobs)
	}
	if m.clearedexperiences {
		edges = append(edges, user.EdgeExperiences)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *UserMutation) EdgeCleared(name string) bool {
	switch name {
	case user.EdgeJobs:
		return m.clearedjobs
	case user.EdgeExperiences:
		return m.clearedexperiences
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *UserMutation) ClearEdge(name string) error {
	switch name {
	}
	return fmt.Errorf("unknown User unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *UserMutation) ResetEdge(name string) error {
	switch name {
	case user.EdgeJobs:
		m.ResetJobs()
		return nil
	case user.EdgeExperiences:
		m.ResetExperiences()
		return nil
	}
	return fmt.Errorf("unknown User edge %s", name)
}

// WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
type WorkExperienceMutation struct {
	config
	op                Op
	typ               string
	id                *int
	created_at        *time.Time
	updated_at        *time.Time
	title             *string
	location          *string
	start_date        *time.Time
	end_date          *time.Time
	description       *string
	clearedFields     map[string]struct{}
	owner             *int
	clearedowner      bool
	in_company        *int
	clearedin_company bool
	skills            map[int]struct{}
	removedskills     map[int]struct{}
	clearedskills     bool
	done              bool
	oldValue          func(context.Context) (*WorkExperience, error)
	predicates        []predicate.WorkExperience
}

var _ ent.Mutation = (*WorkExperienceMutation)(nil)

// workexperienceOption allows management of the mutation configuration using functional options.
type workexperienceOption func(*WorkExperienceMutation)

// newWorkExperienceMutation creates new mutation for the WorkExperience entity.
func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
	m := &WorkExperienceMutation{
		config:        c,
		op:            op,
		typ:           TypeWorkExperience,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withWorkExperienceID sets the ID field of the mutation.
func withWorkExperienceID(id int) workexperienceOption {
	return func(m *WorkExperienceMutation) {
		var (
			err   error
			once  sync.Once
			value *WorkExperience
		)
		m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().WorkExperience.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withWorkExperience sets the old WorkExperience of the mutation.
func withWorkExperience(node *WorkExperience) workexperienceOption {
	return func(m *WorkExperienceMutation) {
		m.oldValue = func(context.Context) (*WorkExperience, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m WorkExperienceMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m WorkExperienceMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("ent: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *WorkExperienceMutation) ID() (id int, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// SetCreatedAt sets the "created_at" field.
func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
// If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *WorkExperienceMutation) ResetCreatedAt() {
	m.created_at = nil
}

// SetUpdatedAt sets the "updated_at" field.
func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
// If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *WorkExperienceMutation) ResetUpdatedAt() {
	m.updated_at = nil
}

// SetTitle sets the "title" field.
func (m *WorkExperienceMutation) SetTitle(s string) {
	m.title = &s
}

// Title returns the value of the "title" field in the mutation.
func (m *WorkExperienceMutation) Title() (r string, exists bool) {
	v := m.title
	if v == nil {
		return
	}
	return *v, true
}

// OldTitle returns the old "title" field's value of the WorkExperience entity.
// If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WorkExperienceMutation) OldTitle(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldTitle is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldTitle requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldTitle: %w", err)
	}
	return oldValue.Title, nil
}

// ResetTitle resets all changes to the "title" field.
func (m *WorkExperienceMutation) ResetTitle() {
	m.title = nil
}

// SetLocation sets the "location" field.
func (m *WorkExperienceMutation) SetLocation(s string) {
	m.location = &s
}

// Location returns the value of the "location" field in the mutation.
func (m *WorkExperienceMutation) Location() (r string, exists bool) {
	v := m.location
	if v == nil {
		return
	}
	return *v, true
}

// OldLocation returns the old "location" field's value of the WorkExperience entity.
// If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WorkExperienceMutation) OldLocation(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldLocation is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldLocation requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldLocation: %w", err)
	}
	return oldValue.Location, nil
}

// ResetLocation resets all changes to the "location" field.
func (m *WorkExperienceMutation) ResetLocation() {
	m.location = nil
}

// SetStartDate sets the "start_date" field.
func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
	m.start_date = &t
}

// StartDate returns the value of the "start_date" field in the mutation.
func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
	v := m.start_date
	if v == nil {
		return
	}
	return *v, true
}

// OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
// If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldStartDate is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldStartDate requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
	}
	return oldValue.StartDate, nil
}

// ResetStartDate resets all changes to the "start_date" field.
func (m *WorkExperienceMutation) ResetStartDate() {
	m.start_date = nil
}

// SetEndDate sets the "end_date" field.
func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
	m.end_date = &t
}

// EndDate returns the value of the "end_date" field in the mutation.
func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
	v := m.end_date
	if v == nil {
		return
	}
	return *v, true
}

// OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
// If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldEndDate is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldEndDate requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
	}
	return oldValue.EndDate, nil
}

// ClearEndDate clears the value of the "end_date" field.
func (m *WorkExperienceMutation) ClearEndDate() {
	m.end_date = nil
	m.clearedFields[workexperience.FieldEndDate] = struct{}{}
}

// EndDateCleared returns if the "end_date" field was cleared in this mutation.
func (m *WorkExperienceMutation) EndDateCleared() bool {
	_, ok := m.clearedFields[workexperience.FieldEndDate]
	return ok
}

// ResetEndDate resets all changes to the "end_date" field.
func (m *WorkExperienceMutation) ResetEndDate() {
	m.end_date = nil
	delete(m.clearedFields, workexperience.FieldEndDate)
}

// SetDescription sets the "description" field.
func (m *WorkExperienceMutation) SetDescription(s string) {
	m.description = &s
}

// Description returns the value of the "description" field in the mutation.
func (m *WorkExperienceMutation) Description() (r string, exists bool) {
	v := m.description
	if v == nil {
		return
	}
	return *v, true
}

// OldDescription returns the old "description" field's value of the WorkExperience entity.
// If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *WorkExperienceMutation) OldDescription(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldDescription is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldDescription requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldDescription: %w", err)
	}
	return oldValue.Description, nil
}

// ResetDescription resets all changes to the "description" field.
func (m *WorkExperienceMutation) ResetDescription() {
	m.description = nil
}

// SetOwnerID sets the "owner" edge to the User entity by id.
func (m *WorkExperienceMutation) SetOwnerID(id int) {
	m.owner = &id
}

// ClearOwner clears the "owner" edge to the User entity.
func (m *WorkExperienceMutation) ClearOwner() {
	m.clearedowner = true
}

// OwnerCleared reports if the "owner" edge to the User entity was cleared.
func (m *WorkExperienceMutation) OwnerCleared() bool {
	return m.clearedowner
}

// OwnerID returns the "owner" edge ID in the mutation.
func (m *WorkExperienceMutation) OwnerID() (id int, exists bool) {
	if m.owner != nil {
		return *m.owner, true
	}
	return
}

// OwnerIDs returns the "owner" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// OwnerID instead. It exists only for internal usage by the builders.
func (m *WorkExperienceMutation) OwnerIDs() (ids []int) {
	if id := m.owner; id != nil {
		ids = append(ids, *id)
	}
	return
}

// ResetOwner resets all changes to the "owner" edge.
func (m *WorkExperienceMutation) ResetOwner() {
	m.owner = nil
	m.clearedowner = false
}

// SetInCompanyID sets the "in_company" edge to the Company entity by id.
func (m *WorkExperienceMutation) SetInCompanyID(id int) {
	m.in_company = &id
}

// ClearInCompany clears the "in_company" edge to the Company entity.
func (m *WorkExperienceMutation) ClearInCompany() {
	m.clearedin_company = true
}

// InCompanyCleared reports if the "in_company" edge to the Company entity was cleared.
func (m *WorkExperienceMutation) InCompanyCleared() bool {
	return m.clearedin_company
}

// InCompanyID returns the "in_company" edge ID in the mutation.
func (m *WorkExperienceMutation) InCompanyID() (id int, exists bool) {
	if m.in_company != nil {
		return *m.in_company, true
	}
	return
}

// InCompanyIDs returns the "in_company" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// InCompanyID instead. It exists only for internal usage by the builders.
func (m *WorkExperienceMutation) InCompanyIDs() (ids []int) {
	if id := m.in_company; id != nil {
		ids = append(ids, *id)
	}
	return
}

// ResetInCompany resets all changes to the "in_company" edge.
func (m *WorkExperienceMutation) ResetInCompany() {
	m.in_company = nil
	m.clearedin_company = false
}

// AddSkillIDs adds the "skills" edge to the Skill entity by ids.
func (m *WorkExperienceMutation) AddSkillIDs(ids ...int) {
	if m.skills == nil {
		m.skills = make(map[int]struct{})
	}
	for i := range ids {
		m.skills[ids[i]] = struct{}{}
	}
}

// ClearSkills clears the "skills" edge to the Skill entity.
func (m *WorkExperienceMutation) ClearSkills() {
	m.clearedskills = true
}

// SkillsCleared reports if the "skills" edge to the Skill entity was cleared.
func (m *WorkExperienceMutation) SkillsCleared() bool {
	return m.clearedskills
}

// RemoveSkillIDs removes the "skills" edge to the Skill entity by IDs.
func (m *WorkExperienceMutation) RemoveSkillIDs(ids ...int) {
	if m.removedskills == nil {
		m.removedskills = make(map[int]struct{})
	}
	for i := range ids {
		delete(m.skills, ids[i])
		m.removedskills[ids[i]] = struct{}{}
	}
}

// RemovedSkills returns the removed IDs of the "skills" edge to the Skill entity.
func (m *WorkExperienceMutation) RemovedSkillsIDs() (ids []int) {
	for id := range m.removedskills {
		ids = append(ids, id)
	}
	return
}

// SkillsIDs returns the "skills" edge IDs in the mutation.
func (m *WorkExperienceMutation) SkillsIDs() (ids []int) {
	for id := range m.skills {
		ids = append(ids, id)
	}
	return
}

// ResetSkills resets all changes to the "skills" edge.
func (m *WorkExperienceMutation) ResetSkills() {
	m.skills = nil
	m.clearedskills = false
	m.removedskills = nil
}

// Where appends a list predicates to the WorkExperienceMutation builder.
func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
	m.predicates = append(m.predicates, ps...)
}

// Op returns the operation name.
func (m *WorkExperienceMutation) Op() Op {
	return m.op
}

// Type returns the node type of this mutation (WorkExperience).
func (m *WorkExperienceMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *WorkExperienceMutation) Fields() []string {
	fields := make([]string, 0, 7)
	if m.created_at != nil {
		fields = append(fields, workexperience.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, workexperience.FieldUpdatedAt)
	}
	if m.title != nil {
		fields = append(fields, workexperience.FieldTitle)
	}
	if m.location != nil {
		fields = append(fields, workexperience.FieldLocation)
	}
	if m.start_date != nil {
		fields = append(fields, workexperience.FieldStartDate)
	}
	if m.end_date != nil {
		fields = append(fields, workexperience.FieldEndDate)
	}
	if m.description != nil {
		fields = append(fields, workexperience.FieldDescription)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case workexperience.FieldCreatedAt:
		return m.CreatedAt()
	case workexperience.FieldUpdatedAt:
		return m.UpdatedAt()
	case workexperience.FieldTitle:
		return m.Title()
	case workexperience.FieldLocation:
		return m.Location()
	case workexperience.FieldStartDate:
		return m.StartDate()
	case workexperience.FieldEndDate:
		return m.EndDate()
	case workexperience.FieldDescription:
		return m.Description()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case workexperience.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case workexperience.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	case workexperience.FieldTitle:
		return m.OldTitle(ctx)
	case workexperience.FieldLocation:
		return m.OldLocation(ctx)
	case workexperience.FieldStartDate:
		return m.OldStartDate(ctx)
	case workexperience.FieldEndDate:
		return m.OldEndDate(ctx)
	case workexperience.FieldDescription:
		return m.OldDescription(ctx)
	}
	return nil, fmt.Errorf("unknown WorkExperience field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
	switch name {
	case workexperience.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case workexperience.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	case workexperience.FieldTitle:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetTitle(v)
		return nil
	case workexperience.FieldLocation:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetLocation(v)
		return nil
	case workexperience.FieldStartDate:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStartDate(v)
		return nil
	case workexperience.FieldEndDate:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetEndDate(v)
		return nil
	case workexperience.FieldDescription:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetDescription(v)
		return nil
	}
	return fmt.Errorf("unknown WorkExperience field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *WorkExperienceMutation) AddedFields() []string {
	return nil
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
	switch name {
	}
	return fmt.Errorf("unknown WorkExperience numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *WorkExperienceMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(workexperience.FieldEndDate) {
		fields = append(fields, workexperience.FieldEndDate)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *WorkExperienceMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *WorkExperienceMutation) ClearField(name string) error {
	switch name {
	case workexperience.FieldEndDate:
		m.ClearEndDate()
		return nil
	}
	return fmt.Errorf("unknown WorkExperience nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *WorkExperienceMutation) ResetField(name string) error {
	switch name {
	case workexperience.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case workexperience.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	case workexperience.FieldTitle:
		m.ResetTitle()
		return nil
	case workexperience.FieldLocation:
		m.ResetLocation()
		return nil
	case workexperience.FieldStartDate:
		m.ResetStartDate()
		return nil
	case workexperience.FieldEndDate:
		m.ResetEndDate()
		return nil
	case workexperience.FieldDescription:
		m.ResetDescription()
		return nil
	}
	return fmt.Errorf("unknown WorkExperience field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *WorkExperienceMutation) AddedEdges() []string {
	edges := make([]string, 0, 3)
	if m.owner != nil {
		edges = append(edges, workexperience.EdgeOwner)
	}
	if m.in_company != nil {
		edges = append(edges, workexperience.EdgeInCompany)
	}
	if m.skills != nil {
		edges = append(edges, workexperience.EdgeSkills)
	}
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
	switch name {
	case workexperience.EdgeOwner:
		if id := m.owner; id != nil {
			return []ent.Value{*id}
		}
	case workexperience.EdgeInCompany:
		if id := m.in_company; id != nil {
			return []ent.Value{*id}
		}
	case workexperience.EdgeSkills:
		ids := make([]ent.Value, 0, len(m.skills))
		for id := range m.skills {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *WorkExperienceMutation) RemovedEdges() []string {
	edges := make([]string, 0, 3)
	if m.removedskills != nil {
		edges = append(edges, workexperience.EdgeSkills)
	}
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
	switch name {
	case workexperience.EdgeSkills:
		ids := make([]ent.Value, 0, len(m.removedskills))
		for id := range m.removedskills {
			ids = append(ids, id)
		}
		return ids
	}
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *WorkExperienceMutation) ClearedEdges() []string {
	edges := make([]string, 0, 3)
	if m.clearedowner {
		edges = append(edges, workexperience.EdgeOwner)
	}
	if m.clearedin_company {
		edges = append(edges, workexperience.EdgeInCompany)
	}
	if m.clearedskills {
		edges = append(edges, workexperience.EdgeSkills)
	}
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
	switch name {
	case workexperience.EdgeOwner:
		return m.clearedowner
	case workexperience.EdgeInCompany:
		return m.clearedin_company
	case workexperience.EdgeSkills:
		return m.clearedskills
	}
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *WorkExperienceMutation) ClearEdge(name string) error {
	switch name {
	case workexperience.EdgeOwner:
		m.ClearOwner()
		return nil
	case workexperience.EdgeInCompany:
		m.ClearInCompany()
		return nil
	}
	return fmt.Errorf("unknown WorkExperience unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *WorkExperienceMutation) ResetEdge(name string) error {
	switch name {
	case workexperience.EdgeOwner:
		m.ResetOwner()
		return nil
	case workexperience.EdgeInCompany:
		m.ResetInCompany()
		return nil
	case workexperience.EdgeSkills:
		m.ResetSkills()
		return nil
	}
	return fmt.Errorf("unknown WorkExperience edge %s", name)
}
