Files
2026-09-16 00:26:48 +05:00

4983 lines
177 KiB
Go

// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql"
"errors"
"fmt"
"math/big"
"net"
"net/http"
"net/url"
"sync"
"time"
"entgo.io/ent"
"entgo.io/ent/entc/integration/ent/role"
"entgo.io/ent/entc/integration/ent/schema"
schemadir "entgo.io/ent/entc/integration/ent/schema/dir"
"entgo.io/ent/entc/integration/ent/schema/task"
"entgo.io/ent/entc/integration/gremlin/ent/api"
"entgo.io/ent/entc/integration/gremlin/ent/builder"
"entgo.io/ent/entc/integration/gremlin/ent/card"
"entgo.io/ent/entc/integration/gremlin/ent/comment"
"entgo.io/ent/entc/integration/gremlin/ent/document"
"entgo.io/ent/entc/integration/gremlin/ent/exvaluescan"
"entgo.io/ent/entc/integration/gremlin/ent/fieldtype"
"entgo.io/ent/entc/integration/gremlin/ent/file"
"entgo.io/ent/entc/integration/gremlin/ent/filetype"
"entgo.io/ent/entc/integration/gremlin/ent/goods"
"entgo.io/ent/entc/integration/gremlin/ent/group"
"entgo.io/ent/entc/integration/gremlin/ent/groupinfo"
"entgo.io/ent/entc/integration/gremlin/ent/item"
"entgo.io/ent/entc/integration/gremlin/ent/license"
"entgo.io/ent/entc/integration/gremlin/ent/node"
"entgo.io/ent/entc/integration/gremlin/ent/pc"
"entgo.io/ent/entc/integration/gremlin/ent/pet"
"entgo.io/ent/entc/integration/gremlin/ent/spec"
enttask "entgo.io/ent/entc/integration/gremlin/ent/task"
"entgo.io/ent/entc/integration/gremlin/ent/user"
"github.com/google/uuid"
)
const (
// Operation types.
OpCreate = ent.OpCreate
OpDelete = ent.OpDelete
OpDeleteOne = ent.OpDeleteOne
OpUpdate = ent.OpUpdate
OpUpdateOne = ent.OpUpdateOne
// Node types.
TypeAPI = "Api"
TypeBuilder = "Builder"
TypeCard = "Card"
TypeComment = "Comment"
TypeDocument = "Document"
TypeExValueScan = "ExValueScan"
TypeFieldType = "FieldType"
TypeFile = "File"
TypeFileType = "FileType"
TypeGoods = "Goods"
TypeGroup = "Group"
TypeGroupInfo = "GroupInfo"
TypeItem = "Item"
TypeLicense = "License"
TypeNode = "Node"
TypePC = "PC"
TypePet = "Pet"
TypeSpec = "Spec"
TypeTask = "Task"
TypeUser = "User"
)
// APIMutation represents an operation that mutates the Api nodes in the graph.
type APIMutation struct {
api.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Api, error)
}
var _ ent.Mutation = (*APIMutation)(nil)
// apiOption allows management of the mutation configuration using functional options.
type apiOption func(*APIMutation)
// newAPIMutation creates new mutation for the Api entity.
func newAPIMutation(c config, op Op, opts ...apiOption) *APIMutation {
m := &APIMutation{
Mutation: *api.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *APIMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withApiID sets the ID field of the mutation.
func withApiID(id string) apiOption {
return func(m *APIMutation) {
var (
err error
once sync.Once
value *Api
)
m.oldValue = func(ctx context.Context) (*Api, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Api.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withApi sets the old Api of the mutation.
func withApi(node *Api) apiOption {
return func(m *APIMutation) {
m.oldValue = func(context.Context) (*Api, 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 APIMutation) 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 APIMutation) 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
}
// 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 *APIMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Api.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// 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 *APIMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
return nil, fmt.Errorf("unknown Api field %s", name)
}
// BuilderMutation represents an operation that mutates the Builder nodes in the graph.
type BuilderMutation struct {
builder.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Builder, error)
}
var _ ent.Mutation = (*BuilderMutation)(nil)
// builderOption allows management of the mutation configuration using functional options.
type builderOption func(*BuilderMutation)
// newBuilderMutation creates new mutation for the Builder entity.
func newBuilderMutation(c config, op Op, opts ...builderOption) *BuilderMutation {
m := &BuilderMutation{
Mutation: *builder.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *BuilderMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withBuilderID sets the ID field of the mutation.
func withBuilderID(id string) builderOption {
return func(m *BuilderMutation) {
var (
err error
once sync.Once
value *Builder
)
m.oldValue = func(ctx context.Context) (*Builder, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Builder.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withBuilder sets the old Builder of the mutation.
func withBuilder(node *Builder) builderOption {
return func(m *BuilderMutation) {
m.oldValue = func(context.Context) (*Builder, 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 BuilderMutation) 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 BuilderMutation) 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
}
// 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 *BuilderMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Builder.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// 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 *BuilderMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
return nil, fmt.Errorf("unknown Builder field %s", name)
}
// CardMutation represents an operation that mutates the Card nodes in the graph.
type CardMutation struct {
card.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Card, error)
}
var _ ent.Mutation = (*CardMutation)(nil)
// cardOption allows management of the mutation configuration using functional options.
type cardOption func(*CardMutation)
// newCardMutation creates new mutation for the Card entity.
func newCardMutation(c config, op Op, opts ...cardOption) *CardMutation {
m := &CardMutation{
Mutation: *card.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *CardMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withCardID sets the ID field of the mutation.
func withCardID(id string) cardOption {
return func(m *CardMutation) {
var (
err error
once sync.Once
value *Card
)
m.oldValue = func(ctx context.Context) (*Card, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Card.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withCard sets the old Card of the mutation.
func withCard(node *Card) cardOption {
return func(m *CardMutation) {
m.oldValue = func(context.Context) (*Card, 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 CardMutation) 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 CardMutation) 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
}
// 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 *CardMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Card.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldCreateTime returns the old "create_time" field's value of the Card entity.
// If the Card 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 *CardMutation) 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 _, exists := m.ID(); !exists || 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
}
// OldUpdateTime returns the old "update_time" field's value of the Card entity.
// If the Card 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 *CardMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldUpdateTime requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err)
}
return oldValue.UpdateTime, nil
}
// OldBalance returns the old "balance" field's value of the Card entity.
// If the Card 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 *CardMutation) OldBalance(ctx context.Context) (v float64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldBalance is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldBalance requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBalance: %w", err)
}
return oldValue.Balance, nil
}
// OldNumber returns the old "number" field's value of the Card entity.
// If the Card 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 *CardMutation) OldNumber(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNumber is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNumber requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNumber: %w", err)
}
return oldValue.Number, nil
}
// OldName returns the old "name" field's value of the Card entity.
// If the Card 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 *CardMutation) OldName(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// 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 *CardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case card.FieldCreateTime:
return m.OldCreateTime(ctx)
case card.FieldUpdateTime:
return m.OldUpdateTime(ctx)
case card.FieldBalance:
return m.OldBalance(ctx)
case card.FieldNumber:
return m.OldNumber(ctx)
case card.FieldName:
return m.OldName(ctx)
}
return nil, fmt.Errorf("unknown Card field %s", name)
}
// CommentMutation represents an operation that mutates the Comment nodes in the graph.
type CommentMutation struct {
comment.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Comment, error)
}
var _ ent.Mutation = (*CommentMutation)(nil)
// commentOption allows management of the mutation configuration using functional options.
type commentOption func(*CommentMutation)
// newCommentMutation creates new mutation for the Comment entity.
func newCommentMutation(c config, op Op, opts ...commentOption) *CommentMutation {
m := &CommentMutation{
Mutation: *comment.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *CommentMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withCommentID sets the ID field of the mutation.
func withCommentID(id string) commentOption {
return func(m *CommentMutation) {
var (
err error
once sync.Once
value *Comment
)
m.oldValue = func(ctx context.Context) (*Comment, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Comment.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withComment sets the old Comment of the mutation.
func withComment(node *Comment) commentOption {
return func(m *CommentMutation) {
m.oldValue = func(context.Context) (*Comment, 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 CommentMutation) 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 CommentMutation) 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
}
// 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 *CommentMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Comment.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldUniqueInt returns the old "unique_int" field's value of the Comment entity.
// If the Comment 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 *CommentMutation) OldUniqueInt(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldUniqueInt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldUniqueInt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUniqueInt: %w", err)
}
return oldValue.UniqueInt, nil
}
// OldUniqueFloat returns the old "unique_float" field's value of the Comment entity.
// If the Comment 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 *CommentMutation) OldUniqueFloat(ctx context.Context) (v float64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldUniqueFloat is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldUniqueFloat requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUniqueFloat: %w", err)
}
return oldValue.UniqueFloat, nil
}
// OldNillableInt returns the old "nillable_int" field's value of the Comment entity.
// If the Comment 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 *CommentMutation) OldNillableInt(ctx context.Context) (v *int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNillableInt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNillableInt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNillableInt: %w", err)
}
return oldValue.NillableInt, nil
}
// OldTable returns the old "table" field's value of the Comment entity.
// If the Comment 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 *CommentMutation) OldTable(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldTable is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldTable requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTable: %w", err)
}
return oldValue.Table, nil
}
// OldDir returns the old "dir" field's value of the Comment entity.
// If the Comment 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 *CommentMutation) OldDir(ctx context.Context) (v schemadir.Dir, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDir is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldDir requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDir: %w", err)
}
return oldValue.Dir, nil
}
// OldClient returns the old "client" field's value of the Comment entity.
// If the Comment 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 *CommentMutation) OldClient(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldClient is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldClient requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldClient: %w", err)
}
return oldValue.Client, nil
}
// 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 *CommentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case comment.FieldUniqueInt:
return m.OldUniqueInt(ctx)
case comment.FieldUniqueFloat:
return m.OldUniqueFloat(ctx)
case comment.FieldNillableInt:
return m.OldNillableInt(ctx)
case comment.FieldTable:
return m.OldTable(ctx)
case comment.FieldDir:
return m.OldDir(ctx)
case comment.FieldClient:
return m.OldClient(ctx)
}
return nil, fmt.Errorf("unknown Comment field %s", name)
}
// DocumentMutation represents an operation that mutates the Document nodes in the graph.
type DocumentMutation struct {
document.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Document, error)
}
var _ ent.Mutation = (*DocumentMutation)(nil)
// documentOption allows management of the mutation configuration using functional options.
type documentOption func(*DocumentMutation)
// newDocumentMutation creates new mutation for the Document entity.
func newDocumentMutation(c config, op Op, opts ...documentOption) *DocumentMutation {
m := &DocumentMutation{
Mutation: *document.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *DocumentMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withDocumentID sets the ID field of the mutation.
func withDocumentID(id string) documentOption {
return func(m *DocumentMutation) {
var (
err error
once sync.Once
value *Document
)
m.oldValue = func(ctx context.Context) (*Document, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Document.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withDocument sets the old Document of the mutation.
func withDocument(node *Document) documentOption {
return func(m *DocumentMutation) {
m.oldValue = func(context.Context) (*Document, 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 DocumentMutation) 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 DocumentMutation) 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
}
// 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 *DocumentMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Document.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldName returns the old "name" field's value of the Document entity.
// If the Document 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 *DocumentMutation) OldName(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldAttachment returns the old "attachment" field's value of the Document entity.
// If the Document 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 *DocumentMutation) OldAttachment(ctx context.Context) (v []byte, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldAttachment is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldAttachment requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAttachment: %w", err)
}
return oldValue.Attachment, nil
}
// OldMetadata returns the old "metadata" field's value of the Document entity.
// If the Document 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 *DocumentMutation) OldMetadata(ctx context.Context) (v []byte, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldMetadata is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldMetadata requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMetadata: %w", err)
}
return oldValue.Metadata, nil
}
// OldPayload returns the old "payload" field's value of the Document entity.
// If the Document 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 *DocumentMutation) OldPayload(ctx context.Context) (v *schema.DocPayload, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldPayload is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldPayload requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPayload: %w", err)
}
return oldValue.Payload, nil
}
// OldDescription returns the old "description" field's value of the Document entity.
// If the Document 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 *DocumentMutation) OldDescription(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// 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 *DocumentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case document.FieldName:
return m.OldName(ctx)
case document.FieldAttachment:
return m.OldAttachment(ctx)
case document.FieldMetadata:
return m.OldMetadata(ctx)
case document.FieldPayload:
return m.OldPayload(ctx)
case document.FieldDescription:
return m.OldDescription(ctx)
}
return nil, fmt.Errorf("unknown Document field %s", name)
}
// ExValueScanMutation represents an operation that mutates the ExValueScan nodes in the graph.
type ExValueScanMutation struct {
exvaluescan.Mutation
config
id *string
done bool
oldValue func(context.Context) (*ExValueScan, error)
}
var _ ent.Mutation = (*ExValueScanMutation)(nil)
// exvaluescanOption allows management of the mutation configuration using functional options.
type exvaluescanOption func(*ExValueScanMutation)
// newExValueScanMutation creates new mutation for the ExValueScan entity.
func newExValueScanMutation(c config, op Op, opts ...exvaluescanOption) *ExValueScanMutation {
m := &ExValueScanMutation{
Mutation: *exvaluescan.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *ExValueScanMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withExValueScanID sets the ID field of the mutation.
func withExValueScanID(id string) exvaluescanOption {
return func(m *ExValueScanMutation) {
var (
err error
once sync.Once
value *ExValueScan
)
m.oldValue = func(ctx context.Context) (*ExValueScan, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ExValueScan.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withExValueScan sets the old ExValueScan of the mutation.
func withExValueScan(node *ExValueScan) exvaluescanOption {
return func(m *ExValueScanMutation) {
m.oldValue = func(context.Context) (*ExValueScan, 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 ExValueScanMutation) 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 ExValueScanMutation) 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
}
// 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 *ExValueScanMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().ExValueScan.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldBinary returns the old "binary" field's value of the ExValueScan entity.
// If the ExValueScan 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 *ExValueScanMutation) OldBinary(ctx context.Context) (v *url.URL, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldBinary is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldBinary requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBinary: %w", err)
}
return oldValue.Binary, nil
}
// OldBinaryBytes returns the old "binary_bytes" field's value of the ExValueScan entity.
// If the ExValueScan 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 *ExValueScanMutation) OldBinaryBytes(ctx context.Context) (v *url.URL, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldBinaryBytes is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldBinaryBytes requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBinaryBytes: %w", err)
}
return oldValue.BinaryBytes, nil
}
// OldBinaryOptional returns the old "binary_optional" field's value of the ExValueScan entity.
// If the ExValueScan 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 *ExValueScanMutation) OldBinaryOptional(ctx context.Context) (v *url.URL, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldBinaryOptional is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldBinaryOptional requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBinaryOptional: %w", err)
}
return oldValue.BinaryOptional, nil
}
// OldText returns the old "text" field's value of the ExValueScan entity.
// If the ExValueScan 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 *ExValueScanMutation) OldText(ctx context.Context) (v *big.Int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldText is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldTextOptional returns the old "text_optional" field's value of the ExValueScan entity.
// If the ExValueScan 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 *ExValueScanMutation) OldTextOptional(ctx context.Context) (v *big.Int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldTextOptional is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldTextOptional requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTextOptional: %w", err)
}
return oldValue.TextOptional, nil
}
// OldBase64 returns the old "base64" field's value of the ExValueScan entity.
// If the ExValueScan 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 *ExValueScanMutation) OldBase64(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldBase64 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldBase64 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBase64: %w", err)
}
return oldValue.Base64, nil
}
// OldCustom returns the old "custom" field's value of the ExValueScan entity.
// If the ExValueScan 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 *ExValueScanMutation) OldCustom(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldCustom is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldCustom requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCustom: %w", err)
}
return oldValue.Custom, nil
}
// OldCustomOptional returns the old "custom_optional" field's value of the ExValueScan entity.
// If the ExValueScan 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 *ExValueScanMutation) OldCustomOptional(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldCustomOptional is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldCustomOptional requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCustomOptional: %w", err)
}
return oldValue.CustomOptional, nil
}
// 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 *ExValueScanMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case exvaluescan.FieldBinary:
return m.OldBinary(ctx)
case exvaluescan.FieldBinaryBytes:
return m.OldBinaryBytes(ctx)
case exvaluescan.FieldBinaryOptional:
return m.OldBinaryOptional(ctx)
case exvaluescan.FieldText:
return m.OldText(ctx)
case exvaluescan.FieldTextOptional:
return m.OldTextOptional(ctx)
case exvaluescan.FieldBase64:
return m.OldBase64(ctx)
case exvaluescan.FieldCustom:
return m.OldCustom(ctx)
case exvaluescan.FieldCustomOptional:
return m.OldCustomOptional(ctx)
}
return nil, fmt.Errorf("unknown ExValueScan field %s", name)
}
// FieldTypeMutation represents an operation that mutates the FieldType nodes in the graph.
type FieldTypeMutation struct {
fieldtype.Mutation
config
id *string
done bool
oldValue func(context.Context) (*FieldType, error)
}
var _ ent.Mutation = (*FieldTypeMutation)(nil)
// fieldtypeOption allows management of the mutation configuration using functional options.
type fieldtypeOption func(*FieldTypeMutation)
// newFieldTypeMutation creates new mutation for the FieldType entity.
func newFieldTypeMutation(c config, op Op, opts ...fieldtypeOption) *FieldTypeMutation {
m := &FieldTypeMutation{
Mutation: *fieldtype.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *FieldTypeMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withFieldTypeID sets the ID field of the mutation.
func withFieldTypeID(id string) fieldtypeOption {
return func(m *FieldTypeMutation) {
var (
err error
once sync.Once
value *FieldType
)
m.oldValue = func(ctx context.Context) (*FieldType, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().FieldType.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withFieldType sets the old FieldType of the mutation.
func withFieldType(node *FieldType) fieldtypeOption {
return func(m *FieldTypeMutation) {
m.oldValue = func(context.Context) (*FieldType, 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 FieldTypeMutation) 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 FieldTypeMutation) 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
}
// 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 *FieldTypeMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().FieldType.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldInt returns the old "int" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldInt(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldInt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldInt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInt: %w", err)
}
return oldValue.Int, nil
}
// OldInt8 returns the old "int8" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldInt8(ctx context.Context) (v int8, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldInt8 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldInt8 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInt8: %w", err)
}
return oldValue.Int8, nil
}
// OldInt16 returns the old "int16" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldInt16(ctx context.Context) (v int16, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldInt16 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldInt16 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInt16: %w", err)
}
return oldValue.Int16, nil
}
// OldInt32 returns the old "int32" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldInt32(ctx context.Context) (v int32, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldInt32 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldInt32 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInt32: %w", err)
}
return oldValue.Int32, nil
}
// OldInt64 returns the old "int64" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldInt64(ctx context.Context) (v int64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldInt64 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldInt64 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInt64: %w", err)
}
return oldValue.Int64, nil
}
// OldOptionalInt returns the old "optional_int" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalInt(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalInt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalInt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalInt: %w", err)
}
return oldValue.OptionalInt, nil
}
// OldOptionalInt8 returns the old "optional_int8" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalInt8(ctx context.Context) (v int8, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalInt8 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalInt8 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalInt8: %w", err)
}
return oldValue.OptionalInt8, nil
}
// OldOptionalInt16 returns the old "optional_int16" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalInt16(ctx context.Context) (v int16, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalInt16 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalInt16 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalInt16: %w", err)
}
return oldValue.OptionalInt16, nil
}
// OldOptionalInt32 returns the old "optional_int32" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalInt32(ctx context.Context) (v int32, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalInt32 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalInt32 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalInt32: %w", err)
}
return oldValue.OptionalInt32, nil
}
// OldOptionalInt64 returns the old "optional_int64" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalInt64(ctx context.Context) (v int64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalInt64 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalInt64 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalInt64: %w", err)
}
return oldValue.OptionalInt64, nil
}
// OldNillableInt returns the old "nillable_int" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNillableInt(ctx context.Context) (v *int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNillableInt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNillableInt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNillableInt: %w", err)
}
return oldValue.NillableInt, nil
}
// OldNillableInt8 returns the old "nillable_int8" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNillableInt8(ctx context.Context) (v *int8, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNillableInt8 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNillableInt8 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNillableInt8: %w", err)
}
return oldValue.NillableInt8, nil
}
// OldNillableInt16 returns the old "nillable_int16" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNillableInt16(ctx context.Context) (v *int16, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNillableInt16 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNillableInt16 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNillableInt16: %w", err)
}
return oldValue.NillableInt16, nil
}
// OldNillableInt32 returns the old "nillable_int32" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNillableInt32(ctx context.Context) (v *int32, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNillableInt32 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNillableInt32 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNillableInt32: %w", err)
}
return oldValue.NillableInt32, nil
}
// OldNillableInt64 returns the old "nillable_int64" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNillableInt64(ctx context.Context) (v *int64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNillableInt64 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNillableInt64 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNillableInt64: %w", err)
}
return oldValue.NillableInt64, nil
}
// OldValidateOptionalInt32 returns the old "validate_optional_int32" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldValidateOptionalInt32(ctx context.Context) (v int32, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldValidateOptionalInt32 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldValidateOptionalInt32 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldValidateOptionalInt32: %w", err)
}
return oldValue.ValidateOptionalInt32, nil
}
// OldOptionalUint returns the old "optional_uint" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalUint(ctx context.Context) (v uint, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalUint is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalUint requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalUint: %w", err)
}
return oldValue.OptionalUint, nil
}
// OldOptionalUint8 returns the old "optional_uint8" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalUint8(ctx context.Context) (v uint8, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalUint8 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalUint8 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalUint8: %w", err)
}
return oldValue.OptionalUint8, nil
}
// OldOptionalUint16 returns the old "optional_uint16" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalUint16(ctx context.Context) (v uint16, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalUint16 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalUint16 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalUint16: %w", err)
}
return oldValue.OptionalUint16, nil
}
// OldOptionalUint32 returns the old "optional_uint32" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalUint32(ctx context.Context) (v uint32, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalUint32 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalUint32 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalUint32: %w", err)
}
return oldValue.OptionalUint32, nil
}
// OldOptionalUint64 returns the old "optional_uint64" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalUint64(ctx context.Context) (v uint64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalUint64 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalUint64 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalUint64: %w", err)
}
return oldValue.OptionalUint64, nil
}
// OldState returns the old "state" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldState(ctx context.Context) (v fieldtype.State, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldState is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldState requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldState: %w", err)
}
return oldValue.State, nil
}
// OldOptionalFloat returns the old "optional_float" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalFloat(ctx context.Context) (v float64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalFloat is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalFloat requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalFloat: %w", err)
}
return oldValue.OptionalFloat, nil
}
// OldOptionalFloat32 returns the old "optional_float32" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalFloat32(ctx context.Context) (v float32, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalFloat32 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalFloat32 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalFloat32: %w", err)
}
return oldValue.OptionalFloat32, nil
}
// OldText returns the old "text" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldText(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldText is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldDatetime returns the old "datetime" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldDatetime(ctx context.Context) (v time.Time, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDatetime is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldDatetime requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDatetime: %w", err)
}
return oldValue.Datetime, nil
}
// OldDecimal returns the old "decimal" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldDecimal(ctx context.Context) (v float64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDecimal is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldDecimal requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDecimal: %w", err)
}
return oldValue.Decimal, nil
}
// OldLinkOther returns the old "link_other" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldLinkOther(ctx context.Context) (v *schema.Link, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldLinkOther is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldLinkOther requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLinkOther: %w", err)
}
return oldValue.LinkOther, nil
}
// OldLinkOtherFunc returns the old "link_other_func" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldLinkOtherFunc(ctx context.Context) (v *schema.Link, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldLinkOtherFunc is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldLinkOtherFunc requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLinkOtherFunc: %w", err)
}
return oldValue.LinkOtherFunc, nil
}
// OldMAC returns the old "mac" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldMAC(ctx context.Context) (v schema.MAC, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldMAC is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldMAC requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMAC: %w", err)
}
return oldValue.MAC, nil
}
// OldStringArray returns the old "string_array" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldStringArray(ctx context.Context) (v schema.Strings, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldStringArray is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldStringArray requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStringArray: %w", err)
}
return oldValue.StringArray, nil
}
// OldPassword returns the old "password" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldPassword(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldStringScanner returns the old "string_scanner" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldStringScanner(ctx context.Context) (v *schema.StringScanner, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldStringScanner is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldStringScanner requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStringScanner: %w", err)
}
return oldValue.StringScanner, nil
}
// OldDuration returns the old "duration" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldDuration(ctx context.Context) (v time.Duration, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDuration is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldDuration requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDuration: %w", err)
}
return oldValue.Duration, nil
}
// OldDir returns the old "dir" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldDir(ctx context.Context) (v http.Dir, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDir is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldDir requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDir: %w", err)
}
return oldValue.Dir, nil
}
// OldNdir returns the old "ndir" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNdir(ctx context.Context) (v *http.Dir, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNdir is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNdir requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNdir: %w", err)
}
return oldValue.Ndir, nil
}
// OldStr returns the old "str" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldStr(ctx context.Context) (v sql.NullString, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldStr is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldStr requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStr: %w", err)
}
return oldValue.Str, nil
}
// OldNullStr returns the old "null_str" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNullStr(ctx context.Context) (v *sql.NullString, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNullStr is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNullStr requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNullStr: %w", err)
}
return oldValue.NullStr, nil
}
// OldLink returns the old "link" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldLink(ctx context.Context) (v schema.Link, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldLink is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldLink requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLink: %w", err)
}
return oldValue.Link, nil
}
// OldNullLink returns the old "null_link" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNullLink(ctx context.Context) (v *schema.Link, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNullLink is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNullLink requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNullLink: %w", err)
}
return oldValue.NullLink, nil
}
// OldActive returns the old "active" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldActive(ctx context.Context) (v schema.Status, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldActive is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldActive requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldActive: %w", err)
}
return oldValue.Active, nil
}
// OldNullActive returns the old "null_active" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNullActive(ctx context.Context) (v *schema.Status, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNullActive is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNullActive requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNullActive: %w", err)
}
return oldValue.NullActive, nil
}
// OldDeleted returns the old "deleted" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldDeleted(ctx context.Context) (v *sql.NullBool, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDeleted is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldDeleted requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDeleted: %w", err)
}
return oldValue.Deleted, nil
}
// OldDeletedAt returns the old "deleted_at" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldDeletedAt(ctx context.Context) (v *sql.NullTime, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldDeletedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
}
return oldValue.DeletedAt, nil
}
// OldRawData returns the old "raw_data" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldRawData(ctx context.Context) (v []byte, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldRawData is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldRawData requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRawData: %w", err)
}
return oldValue.RawData, nil
}
// OldSensitive returns the old "sensitive" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldSensitive(ctx context.Context) (v []byte, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSensitive is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldSensitive requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSensitive: %w", err)
}
return oldValue.Sensitive, nil
}
// OldIP returns the old "ip" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldIP(ctx context.Context) (v net.IP, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldIP is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldIP requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIP: %w", err)
}
return oldValue.IP, nil
}
// OldNullInt64 returns the old "null_int64" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNullInt64(ctx context.Context) (v *sql.NullInt64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNullInt64 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNullInt64 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNullInt64: %w", err)
}
return oldValue.NullInt64, nil
}
// OldSchemaInt returns the old "schema_int" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldSchemaInt(ctx context.Context) (v schema.Int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSchemaInt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldSchemaInt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSchemaInt: %w", err)
}
return oldValue.SchemaInt, nil
}
// OldSchemaInt8 returns the old "schema_int8" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldSchemaInt8(ctx context.Context) (v schema.Int8, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSchemaInt8 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldSchemaInt8 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSchemaInt8: %w", err)
}
return oldValue.SchemaInt8, nil
}
// OldSchemaInt64 returns the old "schema_int64" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldSchemaInt64(ctx context.Context) (v schema.Int64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSchemaInt64 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldSchemaInt64 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSchemaInt64: %w", err)
}
return oldValue.SchemaInt64, nil
}
// OldSchemaFloat returns the old "schema_float" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldSchemaFloat(ctx context.Context) (v schema.Float64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSchemaFloat is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldSchemaFloat requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSchemaFloat: %w", err)
}
return oldValue.SchemaFloat, nil
}
// OldSchemaFloat32 returns the old "schema_float32" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldSchemaFloat32(ctx context.Context) (v schema.Float32, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSchemaFloat32 is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldSchemaFloat32 requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSchemaFloat32: %w", err)
}
return oldValue.SchemaFloat32, nil
}
// OldNullFloat returns the old "null_float" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNullFloat(ctx context.Context) (v *sql.NullFloat64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNullFloat is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNullFloat requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNullFloat: %w", err)
}
return oldValue.NullFloat, nil
}
// OldRole returns the old "role" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldRole(ctx context.Context) (v role.Role, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldRole is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldRole requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRole: %w", err)
}
return oldValue.Role, nil
}
// OldPriority returns the old "priority" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldPriority(ctx context.Context) (v role.Priority, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldPriority is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldPriority requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPriority: %w", err)
}
return oldValue.Priority, nil
}
// OldOptionalUUID returns the old "optional_uuid" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldOptionalUUID(ctx context.Context) (v uuid.UUID, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalUUID is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalUUID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalUUID: %w", err)
}
return oldValue.OptionalUUID, nil
}
// OldNillableUUID returns the old "nillable_uuid" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNillableUUID(ctx context.Context) (v *uuid.UUID, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNillableUUID is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNillableUUID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNillableUUID: %w", err)
}
return oldValue.NillableUUID, nil
}
// OldStrings returns the old "strings" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldStrings(ctx context.Context) (v []string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldStrings is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldStrings requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldStrings: %w", err)
}
return oldValue.Strings, nil
}
// OldPair returns the old "pair" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldPair(ctx context.Context) (v schema.Pair, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldPair is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldPair requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPair: %w", err)
}
return oldValue.Pair, nil
}
// OldNilPair returns the old "nil_pair" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldNilPair(ctx context.Context) (v *schema.Pair, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNilPair is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNilPair requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNilPair: %w", err)
}
return oldValue.NilPair, nil
}
// OldVstring returns the old "vstring" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldVstring(ctx context.Context) (v schema.VString, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldVstring is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldVstring requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldVstring: %w", err)
}
return oldValue.Vstring, nil
}
// OldTriple returns the old "triple" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldTriple(ctx context.Context) (v schema.Triple, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldTriple is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldTriple requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTriple: %w", err)
}
return oldValue.Triple, nil
}
// OldBigInt returns the old "big_int" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldBigInt(ctx context.Context) (v schema.BigInt, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldBigInt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldBigInt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBigInt: %w", err)
}
return oldValue.BigInt, nil
}
// OldPasswordOther returns the old "password_other" field's value of the FieldType entity.
// If the FieldType 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 *FieldTypeMutation) OldPasswordOther(ctx context.Context) (v schema.Password, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldPasswordOther is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldPasswordOther requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPasswordOther: %w", err)
}
return oldValue.PasswordOther, nil
}
// 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 *FieldTypeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case fieldtype.FieldInt:
return m.OldInt(ctx)
case fieldtype.FieldInt8:
return m.OldInt8(ctx)
case fieldtype.FieldInt16:
return m.OldInt16(ctx)
case fieldtype.FieldInt32:
return m.OldInt32(ctx)
case fieldtype.FieldInt64:
return m.OldInt64(ctx)
case fieldtype.FieldOptionalInt:
return m.OldOptionalInt(ctx)
case fieldtype.FieldOptionalInt8:
return m.OldOptionalInt8(ctx)
case fieldtype.FieldOptionalInt16:
return m.OldOptionalInt16(ctx)
case fieldtype.FieldOptionalInt32:
return m.OldOptionalInt32(ctx)
case fieldtype.FieldOptionalInt64:
return m.OldOptionalInt64(ctx)
case fieldtype.FieldNillableInt:
return m.OldNillableInt(ctx)
case fieldtype.FieldNillableInt8:
return m.OldNillableInt8(ctx)
case fieldtype.FieldNillableInt16:
return m.OldNillableInt16(ctx)
case fieldtype.FieldNillableInt32:
return m.OldNillableInt32(ctx)
case fieldtype.FieldNillableInt64:
return m.OldNillableInt64(ctx)
case fieldtype.FieldValidateOptionalInt32:
return m.OldValidateOptionalInt32(ctx)
case fieldtype.FieldOptionalUint:
return m.OldOptionalUint(ctx)
case fieldtype.FieldOptionalUint8:
return m.OldOptionalUint8(ctx)
case fieldtype.FieldOptionalUint16:
return m.OldOptionalUint16(ctx)
case fieldtype.FieldOptionalUint32:
return m.OldOptionalUint32(ctx)
case fieldtype.FieldOptionalUint64:
return m.OldOptionalUint64(ctx)
case fieldtype.FieldState:
return m.OldState(ctx)
case fieldtype.FieldOptionalFloat:
return m.OldOptionalFloat(ctx)
case fieldtype.FieldOptionalFloat32:
return m.OldOptionalFloat32(ctx)
case fieldtype.FieldText:
return m.OldText(ctx)
case fieldtype.FieldDatetime:
return m.OldDatetime(ctx)
case fieldtype.FieldDecimal:
return m.OldDecimal(ctx)
case fieldtype.FieldLinkOther:
return m.OldLinkOther(ctx)
case fieldtype.FieldLinkOtherFunc:
return m.OldLinkOtherFunc(ctx)
case fieldtype.FieldMAC:
return m.OldMAC(ctx)
case fieldtype.FieldStringArray:
return m.OldStringArray(ctx)
case fieldtype.FieldPassword:
return m.OldPassword(ctx)
case fieldtype.FieldStringScanner:
return m.OldStringScanner(ctx)
case fieldtype.FieldDuration:
return m.OldDuration(ctx)
case fieldtype.FieldDir:
return m.OldDir(ctx)
case fieldtype.FieldNdir:
return m.OldNdir(ctx)
case fieldtype.FieldStr:
return m.OldStr(ctx)
case fieldtype.FieldNullStr:
return m.OldNullStr(ctx)
case fieldtype.FieldLink:
return m.OldLink(ctx)
case fieldtype.FieldNullLink:
return m.OldNullLink(ctx)
case fieldtype.FieldActive:
return m.OldActive(ctx)
case fieldtype.FieldNullActive:
return m.OldNullActive(ctx)
case fieldtype.FieldDeleted:
return m.OldDeleted(ctx)
case fieldtype.FieldDeletedAt:
return m.OldDeletedAt(ctx)
case fieldtype.FieldRawData:
return m.OldRawData(ctx)
case fieldtype.FieldSensitive:
return m.OldSensitive(ctx)
case fieldtype.FieldIP:
return m.OldIP(ctx)
case fieldtype.FieldNullInt64:
return m.OldNullInt64(ctx)
case fieldtype.FieldSchemaInt:
return m.OldSchemaInt(ctx)
case fieldtype.FieldSchemaInt8:
return m.OldSchemaInt8(ctx)
case fieldtype.FieldSchemaInt64:
return m.OldSchemaInt64(ctx)
case fieldtype.FieldSchemaFloat:
return m.OldSchemaFloat(ctx)
case fieldtype.FieldSchemaFloat32:
return m.OldSchemaFloat32(ctx)
case fieldtype.FieldNullFloat:
return m.OldNullFloat(ctx)
case fieldtype.FieldRole:
return m.OldRole(ctx)
case fieldtype.FieldPriority:
return m.OldPriority(ctx)
case fieldtype.FieldOptionalUUID:
return m.OldOptionalUUID(ctx)
case fieldtype.FieldNillableUUID:
return m.OldNillableUUID(ctx)
case fieldtype.FieldStrings:
return m.OldStrings(ctx)
case fieldtype.FieldPair:
return m.OldPair(ctx)
case fieldtype.FieldNilPair:
return m.OldNilPair(ctx)
case fieldtype.FieldVstring:
return m.OldVstring(ctx)
case fieldtype.FieldTriple:
return m.OldTriple(ctx)
case fieldtype.FieldBigInt:
return m.OldBigInt(ctx)
case fieldtype.FieldPasswordOther:
return m.OldPasswordOther(ctx)
}
return nil, fmt.Errorf("unknown FieldType field %s", name)
}
// FileMutation represents an operation that mutates the File nodes in the graph.
type FileMutation struct {
file.Mutation
config
id *string
done bool
oldValue func(context.Context) (*File, error)
}
var _ ent.Mutation = (*FileMutation)(nil)
// fileOption allows management of the mutation configuration using functional options.
type fileOption func(*FileMutation)
// newFileMutation creates new mutation for the File entity.
func newFileMutation(c config, op Op, opts ...fileOption) *FileMutation {
m := &FileMutation{
Mutation: *file.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *FileMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withFileID sets the ID field of the mutation.
func withFileID(id string) fileOption {
return func(m *FileMutation) {
var (
err error
once sync.Once
value *File
)
m.oldValue = func(ctx context.Context) (*File, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().File.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withFile sets the old File of the mutation.
func withFile(node *File) fileOption {
return func(m *FileMutation) {
m.oldValue = func(context.Context) (*File, 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 FileMutation) 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 FileMutation) 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
}
// 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 *FileMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().File.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldSetID returns the old "set_id" field's value of the File entity.
// If the File 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 *FileMutation) OldSetID(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSetID is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldSetID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSetID: %w", err)
}
return oldValue.SetID, nil
}
// OldSize returns the old "size" field's value of the File entity.
// If the File 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 *FileMutation) OldSize(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSize is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldName returns the old "name" field's value of the File entity.
// If the File 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 *FileMutation) OldName(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldUser returns the old "user" field's value of the File entity.
// If the File 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 *FileMutation) 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 _, exists := m.ID(); !exists || 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
}
// OldGroup returns the old "group" field's value of the File entity.
// If the File 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 *FileMutation) 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 _, exists := m.ID(); !exists || 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
}
// OldOp returns the old "op" field's value of the File entity.
// If the File 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 *FileMutation) OldOp(ctx context.Context) (v bool, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOp is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOp requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOp: %w", err)
}
return oldValue.Op, nil
}
// OldFieldID returns the old "field_id" field's value of the File entity.
// If the File 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 *FileMutation) OldFieldID(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldFieldID is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldFieldID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFieldID: %w", err)
}
return oldValue.FieldID, nil
}
// OldCreateTime returns the old "create_time" field's value of the File entity.
// If the File 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 *FileMutation) 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 _, exists := m.ID(); !exists || 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
}
// 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 *FileMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case file.FieldSetID:
return m.OldSetID(ctx)
case file.FieldSize:
return m.OldSize(ctx)
case file.FieldName:
return m.OldName(ctx)
case file.FieldUser:
return m.OldUser(ctx)
case file.FieldGroup:
return m.OldGroup(ctx)
case file.FieldOp:
return m.OldOp(ctx)
case file.FieldFieldID:
return m.OldFieldID(ctx)
case file.FieldCreateTime:
return m.OldCreateTime(ctx)
}
return nil, fmt.Errorf("unknown File field %s", name)
}
// FileTypeMutation represents an operation that mutates the FileType nodes in the graph.
type FileTypeMutation struct {
filetype.Mutation
config
id *string
done bool
oldValue func(context.Context) (*FileType, error)
}
var _ ent.Mutation = (*FileTypeMutation)(nil)
// filetypeOption allows management of the mutation configuration using functional options.
type filetypeOption func(*FileTypeMutation)
// newFileTypeMutation creates new mutation for the FileType entity.
func newFileTypeMutation(c config, op Op, opts ...filetypeOption) *FileTypeMutation {
m := &FileTypeMutation{
Mutation: *filetype.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *FileTypeMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withFileTypeID sets the ID field of the mutation.
func withFileTypeID(id string) filetypeOption {
return func(m *FileTypeMutation) {
var (
err error
once sync.Once
value *FileType
)
m.oldValue = func(ctx context.Context) (*FileType, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().FileType.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withFileType sets the old FileType of the mutation.
func withFileType(node *FileType) filetypeOption {
return func(m *FileTypeMutation) {
m.oldValue = func(context.Context) (*FileType, 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 FileTypeMutation) 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 FileTypeMutation) 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
}
// 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 *FileTypeMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().FileType.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldName returns the old "name" field's value of the FileType entity.
// If the FileType 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 *FileTypeMutation) OldName(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldType returns the old "type" field's value of the FileType entity.
// If the FileType 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 *FileTypeMutation) OldType(ctx context.Context) (v filetype.Type, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldType is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldType: %w", err)
}
return oldValue.Type, nil
}
// OldState returns the old "state" field's value of the FileType entity.
// If the FileType 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 *FileTypeMutation) OldState(ctx context.Context) (v filetype.State, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldState is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldState requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldState: %w", err)
}
return oldValue.State, nil
}
// 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 *FileTypeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case filetype.FieldName:
return m.OldName(ctx)
case filetype.FieldType:
return m.OldType(ctx)
case filetype.FieldState:
return m.OldState(ctx)
}
return nil, fmt.Errorf("unknown FileType field %s", name)
}
// GoodsMutation represents an operation that mutates the Goods nodes in the graph.
type GoodsMutation struct {
goods.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Goods, error)
}
var _ ent.Mutation = (*GoodsMutation)(nil)
// goodsOption allows management of the mutation configuration using functional options.
type goodsOption func(*GoodsMutation)
// newGoodsMutation creates new mutation for the Goods entity.
func newGoodsMutation(c config, op Op, opts ...goodsOption) *GoodsMutation {
m := &GoodsMutation{
Mutation: *goods.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *GoodsMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withGoodsID sets the ID field of the mutation.
func withGoodsID(id string) goodsOption {
return func(m *GoodsMutation) {
var (
err error
once sync.Once
value *Goods
)
m.oldValue = func(ctx context.Context) (*Goods, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Goods.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withGoods sets the old Goods of the mutation.
func withGoods(node *Goods) goodsOption {
return func(m *GoodsMutation) {
m.oldValue = func(context.Context) (*Goods, 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 GoodsMutation) 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 GoodsMutation) 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
}
// 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 *GoodsMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Goods.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// 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 *GoodsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
return nil, fmt.Errorf("unknown Goods field %s", name)
}
// GroupMutation represents an operation that mutates the Group nodes in the graph.
type GroupMutation struct {
group.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Group, error)
}
var _ ent.Mutation = (*GroupMutation)(nil)
// groupOption allows management of the mutation configuration using functional options.
type groupOption func(*GroupMutation)
// newGroupMutation creates new mutation for the Group entity.
func newGroupMutation(c config, op Op, opts ...groupOption) *GroupMutation {
m := &GroupMutation{
Mutation: *group.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *GroupMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withGroupID sets the ID field of the mutation.
func withGroupID(id string) groupOption {
return func(m *GroupMutation) {
var (
err error
once sync.Once
value *Group
)
m.oldValue = func(ctx context.Context) (*Group, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Group.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withGroup sets the old Group of the mutation.
func withGroup(node *Group) groupOption {
return func(m *GroupMutation) {
m.oldValue = func(context.Context) (*Group, 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 GroupMutation) 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 GroupMutation) 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
}
// 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 *GroupMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Group.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldActive returns the old "active" field's value of the Group entity.
// If the Group 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 *GroupMutation) OldActive(ctx context.Context) (v bool, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldActive is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldActive requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldActive: %w", err)
}
return oldValue.Active, nil
}
// OldExpire returns the old "expire" field's value of the Group entity.
// If the Group 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 *GroupMutation) OldExpire(ctx context.Context) (v time.Time, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldExpire is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldExpire requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldExpire: %w", err)
}
return oldValue.Expire, nil
}
// OldType returns the old "type" field's value of the Group entity.
// If the Group 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 *GroupMutation) OldType(ctx context.Context) (v *string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldType is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldType: %w", err)
}
return oldValue.Type, nil
}
// OldMaxUsers returns the old "max_users" field's value of the Group entity.
// If the Group 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 *GroupMutation) OldMaxUsers(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldMaxUsers is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldMaxUsers requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMaxUsers: %w", err)
}
return oldValue.MaxUsers, nil
}
// OldName returns the old "name" field's value of the Group entity.
// If the Group 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 *GroupMutation) OldName(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// 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 *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case group.FieldActive:
return m.OldActive(ctx)
case group.FieldExpire:
return m.OldExpire(ctx)
case group.FieldType:
return m.OldType(ctx)
case group.FieldMaxUsers:
return m.OldMaxUsers(ctx)
case group.FieldName:
return m.OldName(ctx)
}
return nil, fmt.Errorf("unknown Group field %s", name)
}
// GroupInfoMutation represents an operation that mutates the GroupInfo nodes in the graph.
type GroupInfoMutation struct {
groupinfo.Mutation
config
id *string
done bool
oldValue func(context.Context) (*GroupInfo, error)
}
var _ ent.Mutation = (*GroupInfoMutation)(nil)
// groupinfoOption allows management of the mutation configuration using functional options.
type groupinfoOption func(*GroupInfoMutation)
// newGroupInfoMutation creates new mutation for the GroupInfo entity.
func newGroupInfoMutation(c config, op Op, opts ...groupinfoOption) *GroupInfoMutation {
m := &GroupInfoMutation{
Mutation: *groupinfo.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *GroupInfoMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withGroupInfoID sets the ID field of the mutation.
func withGroupInfoID(id string) groupinfoOption {
return func(m *GroupInfoMutation) {
var (
err error
once sync.Once
value *GroupInfo
)
m.oldValue = func(ctx context.Context) (*GroupInfo, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().GroupInfo.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withGroupInfo sets the old GroupInfo of the mutation.
func withGroupInfo(node *GroupInfo) groupinfoOption {
return func(m *GroupInfoMutation) {
m.oldValue = func(context.Context) (*GroupInfo, 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 GroupInfoMutation) 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 GroupInfoMutation) 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
}
// 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 *GroupInfoMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().GroupInfo.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldDesc returns the old "desc" field's value of the GroupInfo entity.
// If the GroupInfo 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 *GroupInfoMutation) OldDesc(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldDesc is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldDesc requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDesc: %w", err)
}
return oldValue.Desc, nil
}
// OldMaxUsers returns the old "max_users" field's value of the GroupInfo entity.
// If the GroupInfo 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 *GroupInfoMutation) OldMaxUsers(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldMaxUsers is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldMaxUsers requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldMaxUsers: %w", err)
}
return oldValue.MaxUsers, nil
}
// 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 *GroupInfoMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case groupinfo.FieldDesc:
return m.OldDesc(ctx)
case groupinfo.FieldMaxUsers:
return m.OldMaxUsers(ctx)
}
return nil, fmt.Errorf("unknown GroupInfo field %s", name)
}
// ItemMutation represents an operation that mutates the Item nodes in the graph.
type ItemMutation struct {
item.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Item, error)
}
var _ ent.Mutation = (*ItemMutation)(nil)
// itemOption allows management of the mutation configuration using functional options.
type itemOption func(*ItemMutation)
// newItemMutation creates new mutation for the Item entity.
func newItemMutation(c config, op Op, opts ...itemOption) *ItemMutation {
m := &ItemMutation{
Mutation: *item.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Item entities.
func (m *ItemMutation) SetID(id string) {
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 *ItemMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withItemID sets the ID field of the mutation.
func withItemID(id string) itemOption {
return func(m *ItemMutation) {
var (
err error
once sync.Once
value *Item
)
m.oldValue = func(ctx context.Context) (*Item, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Item.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withItem sets the old Item of the mutation.
func withItem(node *Item) itemOption {
return func(m *ItemMutation) {
m.oldValue = func(context.Context) (*Item, 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 ItemMutation) 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 ItemMutation) 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
}
// 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 *ItemMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Item.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldText returns the old "text" field's value of the Item entity.
// If the Item 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 *ItemMutation) OldText(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldText is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// 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 *ItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case item.FieldText:
return m.OldText(ctx)
}
return nil, fmt.Errorf("unknown Item field %s", name)
}
// LicenseMutation represents an operation that mutates the License nodes in the graph.
type LicenseMutation struct {
license.Mutation
config
id *int
done bool
oldValue func(context.Context) (*License, error)
}
var _ ent.Mutation = (*LicenseMutation)(nil)
// licenseOption allows management of the mutation configuration using functional options.
type licenseOption func(*LicenseMutation)
// newLicenseMutation creates new mutation for the License entity.
func newLicenseMutation(c config, op Op, opts ...licenseOption) *LicenseMutation {
m := &LicenseMutation{
Mutation: *license.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of License entities.
func (m *LicenseMutation) 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 *LicenseMutation) ID() (id int, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withLicenseID sets the ID field of the mutation.
func withLicenseID(id int) licenseOption {
return func(m *LicenseMutation) {
var (
err error
once sync.Once
value *License
)
m.oldValue = func(ctx context.Context) (*License, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().License.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withLicense sets the old License of the mutation.
func withLicense(node *License) licenseOption {
return func(m *LicenseMutation) {
m.oldValue = func(context.Context) (*License, 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 LicenseMutation) 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 LicenseMutation) 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
}
// 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 *LicenseMutation) 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().License.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldCreateTime returns the old "create_time" field's value of the License entity.
// If the License 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 *LicenseMutation) 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 _, exists := m.ID(); !exists || 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
}
// OldUpdateTime returns the old "update_time" field's value of the License entity.
// If the License 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 *LicenseMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldUpdateTime requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err)
}
return oldValue.UpdateTime, nil
}
// 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 *LicenseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case license.FieldCreateTime:
return m.OldCreateTime(ctx)
case license.FieldUpdateTime:
return m.OldUpdateTime(ctx)
}
return nil, fmt.Errorf("unknown License field %s", name)
}
// NodeMutation represents an operation that mutates the Node nodes in the graph.
type NodeMutation struct {
node.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Node, error)
}
var _ ent.Mutation = (*NodeMutation)(nil)
// nodeOption allows management of the mutation configuration using functional options.
type nodeOption func(*NodeMutation)
// newNodeMutation creates new mutation for the Node entity.
func newNodeMutation(c config, op Op, opts ...nodeOption) *NodeMutation {
m := &NodeMutation{
Mutation: *node.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *NodeMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withNodeID sets the ID field of the mutation.
func withNodeID(id string) nodeOption {
return func(m *NodeMutation) {
var (
err error
once sync.Once
value *Node
)
m.oldValue = func(ctx context.Context) (*Node, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Node.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withNode sets the old Node of the mutation.
func withNode(node *Node) nodeOption {
return func(m *NodeMutation) {
m.oldValue = func(context.Context) (*Node, 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 NodeMutation) 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 NodeMutation) 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
}
// 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 *NodeMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Node.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldValue returns the old "value" field's value of the Node entity.
// If the Node 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 *NodeMutation) OldValue(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldValue is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldValue requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldValue: %w", err)
}
return oldValue.Value, nil
}
// OldUpdatedAt returns the old "updated_at" field's value of the Node entity.
// If the Node 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 *NodeMutation) OldUpdatedAt(ctx context.Context) (v *time.Time, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// 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 *NodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case node.FieldValue:
return m.OldValue(ctx)
case node.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown Node field %s", name)
}
// PCMutation represents an operation that mutates the PC nodes in the graph.
type PCMutation struct {
pc.Mutation
config
id *string
done bool
oldValue func(context.Context) (*PC, error)
}
var _ ent.Mutation = (*PCMutation)(nil)
// pcOption allows management of the mutation configuration using functional options.
type pcOption func(*PCMutation)
// newPCMutation creates new mutation for the PC entity.
func newPCMutation(c config, op Op, opts ...pcOption) *PCMutation {
m := &PCMutation{
Mutation: *pc.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *PCMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withPCID sets the ID field of the mutation.
func withPCID(id string) pcOption {
return func(m *PCMutation) {
var (
err error
once sync.Once
value *PC
)
m.oldValue = func(ctx context.Context) (*PC, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().PC.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withPC sets the old PC of the mutation.
func withPC(node *PC) pcOption {
return func(m *PCMutation) {
m.oldValue = func(context.Context) (*PC, 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 PCMutation) 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 PCMutation) 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
}
// 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 *PCMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().PC.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// 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 *PCMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
return nil, fmt.Errorf("unknown PC field %s", name)
}
// PetMutation represents an operation that mutates the Pet nodes in the graph.
type PetMutation struct {
pet.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Pet, error)
}
var _ ent.Mutation = (*PetMutation)(nil)
// petOption allows management of the mutation configuration using functional options.
type petOption func(*PetMutation)
// newPetMutation creates new mutation for the Pet entity.
func newPetMutation(c config, op Op, opts ...petOption) *PetMutation {
m := &PetMutation{
Mutation: *pet.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *PetMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withPetID sets the ID field of the mutation.
func withPetID(id string) petOption {
return func(m *PetMutation) {
var (
err error
once sync.Once
value *Pet
)
m.oldValue = func(ctx context.Context) (*Pet, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Pet.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withPet sets the old Pet of the mutation.
func withPet(node *Pet) petOption {
return func(m *PetMutation) {
m.oldValue = func(context.Context) (*Pet, 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 PetMutation) 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 PetMutation) 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
}
// 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 *PetMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Pet.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldAge returns the old "age" field's value of the Pet entity.
// If the Pet 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 *PetMutation) OldAge(ctx context.Context) (v float64, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldAge is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldAge requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAge: %w", err)
}
return oldValue.Age, nil
}
// OldName returns the old "name" field's value of the Pet entity.
// If the Pet 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 *PetMutation) OldName(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldUUID returns the old "uuid" field's value of the Pet entity.
// If the Pet 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 *PetMutation) OldUUID(ctx context.Context) (v uuid.UUID, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldUUID is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldUUID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUUID: %w", err)
}
return oldValue.UUID, nil
}
// OldNickname returns the old "nickname" field's value of the Pet entity.
// If the Pet 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 *PetMutation) OldNickname(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNickname is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNickname requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNickname: %w", err)
}
return oldValue.Nickname, nil
}
// OldTrained returns the old "trained" field's value of the Pet entity.
// If the Pet 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 *PetMutation) OldTrained(ctx context.Context) (v bool, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldTrained is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldTrained requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTrained: %w", err)
}
return oldValue.Trained, nil
}
// OldOptionalTime returns the old "optional_time" field's value of the Pet entity.
// If the Pet 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 *PetMutation) OldOptionalTime(ctx context.Context) (v time.Time, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalTime is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalTime requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalTime: %w", err)
}
return oldValue.OptionalTime, nil
}
// 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 *PetMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case pet.FieldAge:
return m.OldAge(ctx)
case pet.FieldName:
return m.OldName(ctx)
case pet.FieldUUID:
return m.OldUUID(ctx)
case pet.FieldNickname:
return m.OldNickname(ctx)
case pet.FieldTrained:
return m.OldTrained(ctx)
case pet.FieldOptionalTime:
return m.OldOptionalTime(ctx)
}
return nil, fmt.Errorf("unknown Pet field %s", name)
}
// SpecMutation represents an operation that mutates the Spec nodes in the graph.
type SpecMutation struct {
spec.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Spec, error)
}
var _ ent.Mutation = (*SpecMutation)(nil)
// specOption allows management of the mutation configuration using functional options.
type specOption func(*SpecMutation)
// newSpecMutation creates new mutation for the Spec entity.
func newSpecMutation(c config, op Op, opts ...specOption) *SpecMutation {
m := &SpecMutation{
Mutation: *spec.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *SpecMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withSpecID sets the ID field of the mutation.
func withSpecID(id string) specOption {
return func(m *SpecMutation) {
var (
err error
once sync.Once
value *Spec
)
m.oldValue = func(ctx context.Context) (*Spec, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Spec.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withSpec sets the old Spec of the mutation.
func withSpec(node *Spec) specOption {
return func(m *SpecMutation) {
m.oldValue = func(context.Context) (*Spec, 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 SpecMutation) 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 SpecMutation) 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
}
// 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 *SpecMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Spec.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// 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 *SpecMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
return nil, fmt.Errorf("unknown Spec field %s", name)
}
// TaskMutation represents an operation that mutates the Task nodes in the graph.
type TaskMutation struct {
enttask.Mutation
config
id *string
done bool
oldValue func(context.Context) (*Task, error)
}
var _ ent.Mutation = (*TaskMutation)(nil)
// taskOption allows management of the mutation configuration using functional options.
type taskOption func(*TaskMutation)
// newTaskMutation creates new mutation for the Task entity.
func newTaskMutation(c config, op Op, opts ...taskOption) *TaskMutation {
m := &TaskMutation{
Mutation: *enttask.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 *TaskMutation) ID() (id string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withTaskID sets the ID field of the mutation.
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 = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Task.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTask sets the old Task of the mutation.
func withTask(node *Task) taskOption {
return func(m *TaskMutation) {
m.oldValue = func(context.Context) (*Task, 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 TaskMutation) 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 TaskMutation) 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
}
// 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 *TaskMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().Task.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldPriority returns the old "priority" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldPriority(ctx context.Context) (v task.Priority, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldPriority is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldPriority requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPriority: %w", err)
}
return oldValue.Priority, nil
}
// OldPriorities returns the old "priorities" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldPriorities(ctx context.Context) (v map[string]task.Priority, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldPriorities is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldPriorities requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPriorities: %w", err)
}
return oldValue.Priorities, nil
}
// OldCreatedAt returns the old "created_at" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldCreatedAt(ctx context.Context) (v *time.Time, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldName returns the old "name" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldName(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldOwner returns the old "owner" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldOwner(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOwner is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldOrder returns the old "order" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldOrder(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOrder is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOrder requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOrder: %w", err)
}
return oldValue.Order, nil
}
// OldOrderOption returns the old "order_option" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldOrderOption(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOrderOption is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOrderOption requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOrderOption: %w", err)
}
return oldValue.OrderOption, nil
}
// OldOp returns the old "op" field's value of the Task entity.
// If the Task 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 *TaskMutation) OldOp(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOp is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOp requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOp: %w", err)
}
return oldValue.Op, nil
}
// 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 *TaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case enttask.FieldPriority:
return m.OldPriority(ctx)
case enttask.FieldPriorities:
return m.OldPriorities(ctx)
case enttask.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case enttask.FieldName:
return m.OldName(ctx)
case enttask.FieldOwner:
return m.OldOwner(ctx)
case enttask.FieldOrder:
return m.OldOrder(ctx)
case enttask.FieldOrderOption:
return m.OldOrderOption(ctx)
case enttask.FieldOp:
return m.OldOp(ctx)
}
return nil, fmt.Errorf("unknown Task field %s", name)
}
// UserMutation represents an operation that mutates the User nodes in the graph.
type UserMutation struct {
user.Mutation
config
id *string
done bool
oldValue func(context.Context) (*User, error)
}
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{
Mutation: *user.NewMutation(op),
config: c,
}
for _, opt := range opts {
opt(m)
}
return m
}
// 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 string, exists bool) {
if m.id == nil {
return
}
return *m.id, true
}
// withUserID sets the ID field of the mutation.
func withUserID(id string) 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 = errors.New("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, errors.New("ent: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// 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 *UserMutation) IDs(ctx context.Context) ([]string, error) {
switch {
case m.Op().Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []string{id}, nil
}
fallthrough
case m.Op().Is(OpUpdate | OpDelete):
return m.Client().User.Query().Where(m.Predicates()...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.Op())
}
}
// OldOptionalInt returns the old "optional_int" 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) OldOptionalInt(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldOptionalInt is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldOptionalInt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOptionalInt: %w", err)
}
return oldValue.OptionalInt, nil
}
// OldAge returns the old "age" 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) OldAge(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldAge is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldAge requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAge: %w", err)
}
return oldValue.Age, nil
}
// OldName returns the old "name" 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) OldName(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldName is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldLast returns the old "last" 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) OldLast(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldLast is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldLast requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLast: %w", err)
}
return oldValue.Last, nil
}
// OldNickname returns the old "nickname" 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) OldNickname(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldNickname is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldNickname requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldNickname: %w", err)
}
return oldValue.Nickname, nil
}
// OldAddress returns the old "address" 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) OldAddress(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldAddress is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldAddress requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAddress: %w", err)
}
return oldValue.Address, nil
}
// 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, errors.New("OldPhone is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// 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, errors.New("OldPassword is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("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
}
// OldRole returns the old "role" 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) OldRole(ctx context.Context) (v user.Role, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldRole is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldRole requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRole: %w", err)
}
return oldValue.Role, nil
}
// OldEmployment returns the old "employment" 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) OldEmployment(ctx context.Context) (v user.Employment, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldEmployment is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldEmployment requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldEmployment: %w", err)
}
return oldValue.Employment, nil
}
// OldSSOCert returns the old "SSOCert" 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) OldSSOCert(ctx context.Context) (v string, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldSSOCert is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldSSOCert requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSSOCert: %w", err)
}
return oldValue.SSOCert, nil
}
// OldFilesCount returns the old "files_count" 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) OldFilesCount(ctx context.Context) (v int, err error) {
if !m.Op().Is(OpUpdateOne) {
return v, errors.New("OldFilesCount is only allowed on UpdateOne operations")
}
if _, exists := m.ID(); !exists || m.oldValue == nil {
return v, errors.New("OldFilesCount requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldFilesCount: %w", err)
}
return oldValue.FilesCount, nil
}
// 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.FieldOptionalInt:
return m.OldOptionalInt(ctx)
case user.FieldAge:
return m.OldAge(ctx)
case user.FieldName:
return m.OldName(ctx)
case user.FieldLast:
return m.OldLast(ctx)
case user.FieldNickname:
return m.OldNickname(ctx)
case user.FieldAddress:
return m.OldAddress(ctx)
case user.FieldPhone:
return m.OldPhone(ctx)
case user.FieldPassword:
return m.OldPassword(ctx)
case user.FieldRole:
return m.OldRole(ctx)
case user.FieldEmployment:
return m.OldEmployment(ctx)
case user.FieldSSOCert:
return m.OldSSOCert(ctx)
case user.FieldFilesCount:
return m.OldFilesCount(ctx)
}
return nil, fmt.Errorf("unknown User field %s", name)
}