gomanager/ent/mutation.go

1309 lines
38 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"sync"
"time"
"code.icod.de/dalu/gomanager/ent/logentry"
"code.icod.de/dalu/gomanager/ent/predicate"
"code.icod.de/dalu/gomanager/ent/project"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
const (
// Operation types.
OpCreate = ent.OpCreate
OpDelete = ent.OpDelete
OpDeleteOne = ent.OpDeleteOne
OpUpdate = ent.OpUpdate
OpUpdateOne = ent.OpUpdateOne
// Node types.
TypeLogentry = "Logentry"
TypeProject = "Project"
)
// LogentryMutation represents an operation that mutates the Logentry nodes in the graph.
type LogentryMutation struct {
config
op Op
typ string
id *int
date *time.Time
content *string
clearedFields map[string]struct{}
project *int
clearedproject bool
done bool
oldValue func(context.Context) (*Logentry, error)
predicates []predicate.Logentry
}
var _ ent.Mutation = (*LogentryMutation)(nil)
// logentryOption allows management of the mutation configuration using functional options.
type logentryOption func(*LogentryMutation)
// newLogentryMutation creates new mutation for the Logentry entity.
func newLogentryMutation(c config, op Op, opts ...logentryOption) *LogentryMutation {
m := &LogentryMutation{
config: c,
op: op,
typ: TypeLogentry,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withLogentryID sets the ID field of the mutation.
func withLogentryID(id int) logentryOption {
return func(m *LogentryMutation) {
var (
err error
once sync.Once
value *Logentry
)
m.oldValue = func(ctx context.Context) (*Logentry, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Logentry.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withLogentry sets the old Logentry of the mutation.
func withLogentry(node *Logentry) logentryOption {
return func(m *LogentryMutation) {
m.oldValue = func(context.Context) (*Logentry, 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 LogentryMutation) 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 LogentryMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Logentry entities.
func (m *LogentryMutation) SetID(id int) {
m.id = &id
}
// 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 *LogentryMutation) ID() (id int, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *LogentryMutation) IDs(ctx context.Context) ([]int, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []int{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Logentry.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetDate sets the "date" field.
func (m *LogentryMutation) SetDate(t time.Time) {
m.date = &t
}
// Date returns the value of the "date" field in the mutation.
func (m *LogentryMutation) Date() (r time.Time, exists bool) {
v := m.date
if v == nil {
return
}
return *v, true
}
// OldDate returns the old "date" field's value of the Logentry entity.
// If the Logentry 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 *LogentryMutation) OldDate(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDate is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDate requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDate: %w", err)
}
return oldValue.Date, nil
}
// ResetDate resets all changes to the "date" field.
func (m *LogentryMutation) ResetDate() {
m.date = nil
}
// SetContent sets the "content" field.
func (m *LogentryMutation) SetContent(s string) {
m.content = &s
}
// Content returns the value of the "content" field in the mutation.
func (m *LogentryMutation) Content() (r string, exists bool) {
v := m.content
if v == nil {
return
}
return *v, true
}
// OldContent returns the old "content" field's value of the Logentry entity.
// If the Logentry 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 *LogentryMutation) OldContent(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldContent is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldContent requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldContent: %w", err)
}
return oldValue.Content, nil
}
// ResetContent resets all changes to the "content" field.
func (m *LogentryMutation) ResetContent() {
m.content = nil
}
// SetProjectID sets the "project" edge to the Project entity by id.
func (m *LogentryMutation) SetProjectID(id int) {
m.project = &id
}
// ClearProject clears the "project" edge to the Project entity.
func (m *LogentryMutation) ClearProject() {
m.clearedproject = true
}
// ProjectCleared reports if the "project" edge to the Project entity was cleared.
func (m *LogentryMutation) ProjectCleared() bool {
return m.clearedproject
}
// ProjectID returns the "project" edge ID in the mutation.
func (m *LogentryMutation) ProjectID() (id int, exists bool) {
if m.project != nil {
return *m.project, true
}
return
}
// ProjectIDs returns the "project" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ProjectID instead. It exists only for internal usage by the builders.
func (m *LogentryMutation) ProjectIDs() (ids []int) {
if id := m.project; id != nil {
ids = append(ids, *id)
}
return
}
// ResetProject resets all changes to the "project" edge.
func (m *LogentryMutation) ResetProject() {
m.project = nil
m.clearedproject = false
}
// Where appends a list predicates to the LogentryMutation builder.
func (m *LogentryMutation) Where(ps ...predicate.Logentry) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the LogentryMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *LogentryMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Logentry, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *LogentryMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *LogentryMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Logentry).
func (m *LogentryMutation) 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 *LogentryMutation) Fields() []string {
fields := make([]string, 0, 2)
if m.date != nil {
fields = append(fields, logentry.FieldDate)
}
if m.content != nil {
fields = append(fields, logentry.FieldContent)
}
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 *LogentryMutation) Field(name string) (ent.Value, bool) {
switch name {
case logentry.FieldDate:
return m.Date()
case logentry.FieldContent:
return m.Content()
}
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 *LogentryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case logentry.FieldDate:
return m.OldDate(ctx)
case logentry.FieldContent:
return m.OldContent(ctx)
}
return nil, fmt.Errorf("unknown Logentry 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 *LogentryMutation) SetField(name string, value ent.Value) error {
switch name {
case logentry.FieldDate:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDate(v)
return nil
case logentry.FieldContent:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetContent(v)
return nil
}
return fmt.Errorf("unknown Logentry field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *LogentryMutation) 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 *LogentryMutation) 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 *LogentryMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown Logentry numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *LogentryMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *LogentryMutation) 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 *LogentryMutation) ClearField(name string) error {
return fmt.Errorf("unknown Logentry 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 *LogentryMutation) ResetField(name string) error {
switch name {
case logentry.FieldDate:
m.ResetDate()
return nil
case logentry.FieldContent:
m.ResetContent()
return nil
}
return fmt.Errorf("unknown Logentry field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *LogentryMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.project != nil {
edges = append(edges, logentry.EdgeProject)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *LogentryMutation) AddedIDs(name string) []ent.Value {
switch name {
case logentry.EdgeProject:
if id := m.project; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *LogentryMutation) RemovedEdges() []string {
edges := make([]string, 0, 1)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *LogentryMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *LogentryMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedproject {
edges = append(edges, logentry.EdgeProject)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *LogentryMutation) EdgeCleared(name string) bool {
switch name {
case logentry.EdgeProject:
return m.clearedproject
}
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 *LogentryMutation) ClearEdge(name string) error {
switch name {
case logentry.EdgeProject:
m.ClearProject()
return nil
}
return fmt.Errorf("unknown Logentry 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 *LogentryMutation) ResetEdge(name string) error {
switch name {
case logentry.EdgeProject:
m.ResetProject()
return nil
}
return fmt.Errorf("unknown Logentry edge %s", name)
}
// ProjectMutation represents an operation that mutates the Project nodes in the graph.
type ProjectMutation struct {
config
op Op
typ string
id *int
create_time *time.Time
user *string
group *string
root_path *string
service_name *string
binary_path *string
move_to_target *bool
binary_target_path *string
clearedFields map[string]struct{}
logentries map[int]struct{}
removedlogentries map[int]struct{}
clearedlogentries bool
done bool
oldValue func(context.Context) (*Project, error)
predicates []predicate.Project
}
var _ ent.Mutation = (*ProjectMutation)(nil)
// projectOption allows management of the mutation configuration using functional options.
type projectOption func(*ProjectMutation)
// newProjectMutation creates new mutation for the Project entity.
func newProjectMutation(c config, op Op, opts ...projectOption) *ProjectMutation {
m := &ProjectMutation{
config: c,
op: op,
typ: TypeProject,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withProjectID sets the ID field of the mutation.
func withProjectID(id int) projectOption {
return func(m *ProjectMutation) {
var (
err error
once sync.Once
value *Project
)
m.oldValue = func(ctx context.Context) (*Project, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Project.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withProject sets the old Project of the mutation.
func withProject(node *Project) projectOption {
return func(m *ProjectMutation) {
m.oldValue = func(context.Context) (*Project, 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 ProjectMutation) 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 ProjectMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Project entities.
func (m *ProjectMutation) SetID(id int) {
m.id = &id
}
// 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 *ProjectMutation) ID() (id int, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *ProjectMutation) IDs(ctx context.Context) ([]int, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []int{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Project.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetCreateTime sets the "create_time" field.
func (m *ProjectMutation) SetCreateTime(t time.Time) {
m.create_time = &t
}
// CreateTime returns the value of the "create_time" field in the mutation.
func (m *ProjectMutation) CreateTime() (r time.Time, exists bool) {
v := m.create_time
if v == nil {
return
}
return *v, true
}
// OldCreateTime returns the old "create_time" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCreateTime is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCreateTime requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCreateTime: %w", err)
}
return oldValue.CreateTime, nil
}
// ResetCreateTime resets all changes to the "create_time" field.
func (m *ProjectMutation) ResetCreateTime() {
m.create_time = nil
}
// SetUser sets the "user" field.
func (m *ProjectMutation) SetUser(s string) {
m.user = &s
}
// User returns the value of the "user" field in the mutation.
func (m *ProjectMutation) User() (r string, exists bool) {
v := m.user
if v == nil {
return
}
return *v, true
}
// OldUser returns the old "user" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldUser(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUser is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUser requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUser: %w", err)
}
return oldValue.User, nil
}
// ResetUser resets all changes to the "user" field.
func (m *ProjectMutation) ResetUser() {
m.user = nil
}
// SetGroup sets the "group" field.
func (m *ProjectMutation) SetGroup(s string) {
m.group = &s
}
// Group returns the value of the "group" field in the mutation.
func (m *ProjectMutation) Group() (r string, exists bool) {
v := m.group
if v == nil {
return
}
return *v, true
}
// OldGroup returns the old "group" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldGroup(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldGroup is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldGroup requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldGroup: %w", err)
}
return oldValue.Group, nil
}
// ResetGroup resets all changes to the "group" field.
func (m *ProjectMutation) ResetGroup() {
m.group = nil
}
// SetRootPath sets the "root_path" field.
func (m *ProjectMutation) SetRootPath(s string) {
m.root_path = &s
}
// RootPath returns the value of the "root_path" field in the mutation.
func (m *ProjectMutation) RootPath() (r string, exists bool) {
v := m.root_path
if v == nil {
return
}
return *v, true
}
// OldRootPath returns the old "root_path" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldRootPath(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRootPath is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRootPath requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRootPath: %w", err)
}
return oldValue.RootPath, nil
}
// ResetRootPath resets all changes to the "root_path" field.
func (m *ProjectMutation) ResetRootPath() {
m.root_path = nil
}
// SetServiceName sets the "service_name" field.
func (m *ProjectMutation) SetServiceName(s string) {
m.service_name = &s
}
// ServiceName returns the value of the "service_name" field in the mutation.
func (m *ProjectMutation) ServiceName() (r string, exists bool) {
v := m.service_name
if v == nil {
return
}
return *v, true
}
// OldServiceName returns the old "service_name" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldServiceName(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldServiceName is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldServiceName requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldServiceName: %w", err)
}
return oldValue.ServiceName, nil
}
// ResetServiceName resets all changes to the "service_name" field.
func (m *ProjectMutation) ResetServiceName() {
m.service_name = nil
}
// SetBinaryPath sets the "binary_path" field.
func (m *ProjectMutation) SetBinaryPath(s string) {
m.binary_path = &s
}
// BinaryPath returns the value of the "binary_path" field in the mutation.
func (m *ProjectMutation) BinaryPath() (r string, exists bool) {
v := m.binary_path
if v == nil {
return
}
return *v, true
}
// OldBinaryPath returns the old "binary_path" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldBinaryPath(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBinaryPath is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldBinaryPath requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBinaryPath: %w", err)
}
return oldValue.BinaryPath, nil
}
// ResetBinaryPath resets all changes to the "binary_path" field.
func (m *ProjectMutation) ResetBinaryPath() {
m.binary_path = nil
}
// SetMoveToTarget sets the "move_to_target" field.
func (m *ProjectMutation) SetMoveToTarget(b bool) {
m.move_to_target = &b
}
// MoveToTarget returns the value of the "move_to_target" field in the mutation.
func (m *ProjectMutation) MoveToTarget() (r bool, exists bool) {
v := m.move_to_target
if v == nil {
return
}
return *v, true
}
// OldMoveToTarget returns the old "move_to_target" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldMoveToTarget(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldMoveToTarget is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldMoveToTarget requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMoveToTarget: %w", err)
}
return oldValue.MoveToTarget, nil
}
// ResetMoveToTarget resets all changes to the "move_to_target" field.
func (m *ProjectMutation) ResetMoveToTarget() {
m.move_to_target = nil
}
// SetBinaryTargetPath sets the "binary_target_path" field.
func (m *ProjectMutation) SetBinaryTargetPath(s string) {
m.binary_target_path = &s
}
// BinaryTargetPath returns the value of the "binary_target_path" field in the mutation.
func (m *ProjectMutation) BinaryTargetPath() (r string, exists bool) {
v := m.binary_target_path
if v == nil {
return
}
return *v, true
}
// OldBinaryTargetPath returns the old "binary_target_path" field's value of the Project entity.
// If the Project 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 *ProjectMutation) OldBinaryTargetPath(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBinaryTargetPath is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldBinaryTargetPath requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBinaryTargetPath: %w", err)
}
return oldValue.BinaryTargetPath, nil
}
// ClearBinaryTargetPath clears the value of the "binary_target_path" field.
func (m *ProjectMutation) ClearBinaryTargetPath() {
m.binary_target_path = nil
m.clearedFields[project.FieldBinaryTargetPath] = struct{}{}
}
// BinaryTargetPathCleared returns if the "binary_target_path" field was cleared in this mutation.
func (m *ProjectMutation) BinaryTargetPathCleared() bool {
_, ok := m.clearedFields[project.FieldBinaryTargetPath]
return ok
}
// ResetBinaryTargetPath resets all changes to the "binary_target_path" field.
func (m *ProjectMutation) ResetBinaryTargetPath() {
m.binary_target_path = nil
delete(m.clearedFields, project.FieldBinaryTargetPath)
}
// AddLogentryIDs adds the "logentries" edge to the Logentry entity by ids.
func (m *ProjectMutation) AddLogentryIDs(ids ...int) {
if m.logentries == nil {
m.logentries = make(map[int]struct{})
}
for i := range ids {
m.logentries[ids[i]] = struct{}{}
}
}
// ClearLogentries clears the "logentries" edge to the Logentry entity.
func (m *ProjectMutation) ClearLogentries() {
m.clearedlogentries = true
}
// LogentriesCleared reports if the "logentries" edge to the Logentry entity was cleared.
func (m *ProjectMutation) LogentriesCleared() bool {
return m.clearedlogentries
}
// RemoveLogentryIDs removes the "logentries" edge to the Logentry entity by IDs.
func (m *ProjectMutation) RemoveLogentryIDs(ids ...int) {
if m.removedlogentries == nil {
m.removedlogentries = make(map[int]struct{})
}
for i := range ids {
delete(m.logentries, ids[i])
m.removedlogentries[ids[i]] = struct{}{}
}
}
// RemovedLogentries returns the removed IDs of the "logentries" edge to the Logentry entity.
func (m *ProjectMutation) RemovedLogentriesIDs() (ids []int) {
for id := range m.removedlogentries {
ids = append(ids, id)
}
return
}
// LogentriesIDs returns the "logentries" edge IDs in the mutation.
func (m *ProjectMutation) LogentriesIDs() (ids []int) {
for id := range m.logentries {
ids = append(ids, id)
}
return
}
// ResetLogentries resets all changes to the "logentries" edge.
func (m *ProjectMutation) ResetLogentries() {
m.logentries = nil
m.clearedlogentries = false
m.removedlogentries = nil
}
// Where appends a list predicates to the ProjectMutation builder.
func (m *ProjectMutation) Where(ps ...predicate.Project) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ProjectMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ProjectMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Project, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ProjectMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ProjectMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Project).
func (m *ProjectMutation) 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 *ProjectMutation) Fields() []string {
fields := make([]string, 0, 8)
if m.create_time != nil {
fields = append(fields, project.FieldCreateTime)
}
if m.user != nil {
fields = append(fields, project.FieldUser)
}
if m.group != nil {
fields = append(fields, project.FieldGroup)
}
if m.root_path != nil {
fields = append(fields, project.FieldRootPath)
}
if m.service_name != nil {
fields = append(fields, project.FieldServiceName)
}
if m.binary_path != nil {
fields = append(fields, project.FieldBinaryPath)
}
if m.move_to_target != nil {
fields = append(fields, project.FieldMoveToTarget)
}
if m.binary_target_path != nil {
fields = append(fields, project.FieldBinaryTargetPath)
}
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 *ProjectMutation) Field(name string) (ent.Value, bool) {
switch name {
case project.FieldCreateTime:
return m.CreateTime()
case project.FieldUser:
return m.User()
case project.FieldGroup:
return m.Group()
case project.FieldRootPath:
return m.RootPath()
case project.FieldServiceName:
return m.ServiceName()
case project.FieldBinaryPath:
return m.BinaryPath()
case project.FieldMoveToTarget:
return m.MoveToTarget()
case project.FieldBinaryTargetPath:
return m.BinaryTargetPath()
}
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 *ProjectMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case project.FieldCreateTime:
return m.OldCreateTime(ctx)
case project.FieldUser:
return m.OldUser(ctx)
case project.FieldGroup:
return m.OldGroup(ctx)
case project.FieldRootPath:
return m.OldRootPath(ctx)
case project.FieldServiceName:
return m.OldServiceName(ctx)
case project.FieldBinaryPath:
return m.OldBinaryPath(ctx)
case project.FieldMoveToTarget:
return m.OldMoveToTarget(ctx)
case project.FieldBinaryTargetPath:
return m.OldBinaryTargetPath(ctx)
}
return nil, fmt.Errorf("unknown Project 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 *ProjectMutation) SetField(name string, value ent.Value) error {
switch name {
case project.FieldCreateTime:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCreateTime(v)
return nil
case project.FieldUser:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUser(v)
return nil
case project.FieldGroup:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetGroup(v)
return nil
case project.FieldRootPath:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRootPath(v)
return nil
case project.FieldServiceName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetServiceName(v)
return nil
case project.FieldBinaryPath:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBinaryPath(v)
return nil
case project.FieldMoveToTarget:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetMoveToTarget(v)
return nil
case project.FieldBinaryTargetPath:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBinaryTargetPath(v)
return nil
}
return fmt.Errorf("unknown Project field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ProjectMutation) 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 *ProjectMutation) 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 *ProjectMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown Project numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ProjectMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(project.FieldBinaryTargetPath) {
fields = append(fields, project.FieldBinaryTargetPath)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ProjectMutation) 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 *ProjectMutation) ClearField(name string) error {
switch name {
case project.FieldBinaryTargetPath:
m.ClearBinaryTargetPath()
return nil
}
return fmt.Errorf("unknown Project 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 *ProjectMutation) ResetField(name string) error {
switch name {
case project.FieldCreateTime:
m.ResetCreateTime()
return nil
case project.FieldUser:
m.ResetUser()
return nil
case project.FieldGroup:
m.ResetGroup()
return nil
case project.FieldRootPath:
m.ResetRootPath()
return nil
case project.FieldServiceName:
m.ResetServiceName()
return nil
case project.FieldBinaryPath:
m.ResetBinaryPath()
return nil
case project.FieldMoveToTarget:
m.ResetMoveToTarget()
return nil
case project.FieldBinaryTargetPath:
m.ResetBinaryTargetPath()
return nil
}
return fmt.Errorf("unknown Project field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ProjectMutation) AddedEdges() []string {
edges := make([]string, 0, 1)
if m.logentries != nil {
edges = append(edges, project.EdgeLogentries)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *ProjectMutation) AddedIDs(name string) []ent.Value {
switch name {
case project.EdgeLogentries:
ids := make([]ent.Value, 0, len(m.logentries))
for id := range m.logentries {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ProjectMutation) RemovedEdges() []string {
edges := make([]string, 0, 1)
if m.removedlogentries != nil {
edges = append(edges, project.EdgeLogentries)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *ProjectMutation) RemovedIDs(name string) []ent.Value {
switch name {
case project.EdgeLogentries:
ids := make([]ent.Value, 0, len(m.removedlogentries))
for id := range m.removedlogentries {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ProjectMutation) ClearedEdges() []string {
edges := make([]string, 0, 1)
if m.clearedlogentries {
edges = append(edges, project.EdgeLogentries)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *ProjectMutation) EdgeCleared(name string) bool {
switch name {
case project.EdgeLogentries:
return m.clearedlogentries
}
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 *ProjectMutation) ClearEdge(name string) error {
switch name {
}
return fmt.Errorf("unknown Project 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 *ProjectMutation) ResetEdge(name string) error {
switch name {
case project.EdgeLogentries:
m.ResetLogentries()
return nil
}
return fmt.Errorf("unknown Project edge %s", name)
}