func (m *TaskMutation) Fields() []string {
	fields := make([]string, 0, 5)
	if m.owner != nil {
		fields = append(fields, task.FieldOwner)
	}
	if m.text != nil {
		fields = append(fields, task.FieldText)
	}
	if m.status != nil {
		fields = append(fields, task.FieldStatus)
	}
	if m.created_at != nil {
		fields = append(fields, task.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, task.FieldUpdatedAt)
	}
	return fields
}
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().
package models
import (
	"context"
	"fmt"
	"sync"
	"time"
	"github.com/adnaan/gomodest-starter/app/gen/models/predicate"
	"github.com/adnaan/gomodest-starter/app/gen/models/task"
	"entgo.io/ent"
)
const (
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne
	TypeTask = "Task"
)
type TaskMutation struct {
	config
	op            Op
	typ           string
	id            *string
	owner         *string
	text          *string
	status        *task.Status
	created_at    *time.Time
	updated_at    *time.Time
	clearedFields map[string]struct{}
	done          bool
	oldValue      func(context.Context) (*Task, error)
	predicates    []predicate.Task
}
var _ ent.Mutation = (*TaskMutation)(nil)
type taskOption func(*TaskMutation)
func newTaskMutation(c config, op Op, opts ...taskOption) *TaskMutation {
	m := &TaskMutation{
		config:        c,
		op:            op,
		typ:           TypeTask,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}
func withTaskID(id string) taskOption {
	return func(m *TaskMutation) {
		var (
			err   error
			once  sync.Once
			value *Task
		)
		m.oldValue = func(ctx context.Context) (*Task, error) {
			once.Do(func() {
				if m.done {
					err = fmt.Errorf("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().Task.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}
func withTask(node *Task) taskOption {
	return func(m *TaskMutation) {
		m.oldValue = func(context.Context) (*Task, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}
func (m TaskMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}
func (m TaskMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, fmt.Errorf("models: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}
func (m *TaskMutation) SetID(id string) {
	m.id = &id
}
func (m *TaskMutation) ID() (id string, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}
func (m *TaskMutation) SetOwner(s string) {
	m.owner = &s
}
func (m *TaskMutation) Owner() (r string, exists bool) {
	v := m.owner
	if v == nil {
		return
	}
	return *v, true
}
func (m *TaskMutation) OldOwner(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldOwner is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldOwner requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldOwner: %w", err)
	}
	return oldValue.Owner, nil
}
func (m *TaskMutation) ResetOwner() {
	m.owner = nil
}
func (m *TaskMutation) SetText(s string) {
	m.text = &s
}
func (m *TaskMutation) Text() (r string, exists bool) {
	v := m.text
	if v == nil {
		return
	}
	return *v, true
}
func (m *TaskMutation) OldText(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, fmt.Errorf("OldText is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, fmt.Errorf("OldText requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldText: %w", err)
	}
	return oldValue.Text, nil
}
func (m *TaskMutation) ResetText() {
	m.text = nil
}
func (m *TaskMutation) SetStatus(t task.Status) {
	m.status = &t
}
func (m *TaskMutation) Status() (r task.Status, exists bool) {
	v := m.status
	if v == nil {
		return
	}
	return *v, true
}
func (m *TaskMutation) OldStatus(ctx context.Context) (v task.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 *TaskMutation) ClearStatus() {
	m.status = nil
	m.clearedFields[task.FieldStatus] = struct{}{}
}
func (m *TaskMutation) StatusCleared() bool {
	_, ok := m.clearedFields[task.FieldStatus]
	return ok
}
func (m *TaskMutation) ResetStatus() {
	m.status = nil
	delete(m.clearedFields, task.FieldStatus)
}
func (m *TaskMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}
func (m *TaskMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}
func (m *TaskMutation) 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 *TaskMutation) ResetCreatedAt() {
	m.created_at = nil
}
func (m *TaskMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}
func (m *TaskMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}
func (m *TaskMutation) 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 *TaskMutation) ResetUpdatedAt() {
	m.updated_at = nil
}
func (m *TaskMutation) Op() Op {
	return m.op
}
func (m *TaskMutation) Type() string {
	return m.typ
}