2092 lines
64 KiB
Go
2092 lines
64 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sync"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"git.gorlug.de/code/ersteller/schema/ent/event"
|
|
"git.gorlug.de/code/ersteller/schema/ent/generalqueue"
|
|
"git.gorlug.de/code/ersteller/schema/ent/generalqueuestate"
|
|
"git.gorlug.de/code/ersteller/schema/ent/predicate"
|
|
)
|
|
|
|
const (
|
|
// Operation types.
|
|
OpCreate = ent.OpCreate
|
|
OpDelete = ent.OpDelete
|
|
OpDeleteOne = ent.OpDeleteOne
|
|
OpUpdate = ent.OpUpdate
|
|
OpUpdateOne = ent.OpUpdateOne
|
|
|
|
// Node types.
|
|
TypeEvent = "Event"
|
|
TypeGeneralQueue = "GeneralQueue"
|
|
TypeGeneralQueueState = "GeneralQueueState"
|
|
)
|
|
|
|
// EventMutation represents an operation that mutates the Event nodes in the graph.
|
|
type EventMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
name *string
|
|
data *map[string]interface{}
|
|
created_at *time.Time
|
|
user_id *int
|
|
adduser_id *int
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*Event, error)
|
|
predicates []predicate.Event
|
|
}
|
|
|
|
var _ ent.Mutation = (*EventMutation)(nil)
|
|
|
|
// eventOption allows management of the mutation configuration using functional options.
|
|
type eventOption func(*EventMutation)
|
|
|
|
// newEventMutation creates new mutation for the Event entity.
|
|
func newEventMutation(c config, op Op, opts ...eventOption) *EventMutation {
|
|
m := &EventMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeEvent,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withEventID sets the ID field of the mutation.
|
|
func withEventID(id int) eventOption {
|
|
return func(m *EventMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Event
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Event, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Event.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withEvent sets the old Event of the mutation.
|
|
func withEvent(node *Event) eventOption {
|
|
return func(m *EventMutation) {
|
|
m.oldValue = func(context.Context) (*Event, 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 EventMutation) 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 EventMutation) 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
|
|
}
|
|
|
|
// 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 *EventMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *EventMutation) 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().Event.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (m *EventMutation) SetName(s string) {
|
|
m.name = &s
|
|
}
|
|
|
|
// Name returns the value of the "name" field in the mutation.
|
|
func (m *EventMutation) Name() (r string, exists bool) {
|
|
v := m.name
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldName returns the old "name" field's value of the Event entity.
|
|
// If the Event 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 *EventMutation) 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 m.id == nil || 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
|
|
}
|
|
|
|
// ResetName resets all changes to the "name" field.
|
|
func (m *EventMutation) ResetName() {
|
|
m.name = nil
|
|
}
|
|
|
|
// SetData sets the "data" field.
|
|
func (m *EventMutation) SetData(value map[string]interface{}) {
|
|
m.data = &value
|
|
}
|
|
|
|
// Data returns the value of the "data" field in the mutation.
|
|
func (m *EventMutation) Data() (r map[string]interface{}, exists bool) {
|
|
v := m.data
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldData returns the old "data" field's value of the Event entity.
|
|
// If the Event 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 *EventMutation) OldData(ctx context.Context) (v map[string]interface{}, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldData is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldData requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldData: %w", err)
|
|
}
|
|
return oldValue.Data, nil
|
|
}
|
|
|
|
// ResetData resets all changes to the "data" field.
|
|
func (m *EventMutation) ResetData() {
|
|
m.data = nil
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (m *EventMutation) SetCreatedAt(t time.Time) {
|
|
m.created_at = &t
|
|
}
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
func (m *EventMutation) CreatedAt() (r time.Time, exists bool) {
|
|
v := m.created_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreatedAt returns the old "created_at" field's value of the Event entity.
|
|
// If the Event 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 *EventMutation) 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 m.id == nil || 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
|
|
}
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
func (m *EventMutation) ResetCreatedAt() {
|
|
m.created_at = nil
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (m *EventMutation) SetUserID(i int) {
|
|
m.user_id = &i
|
|
m.adduser_id = nil
|
|
}
|
|
|
|
// UserID returns the value of the "user_id" field in the mutation.
|
|
func (m *EventMutation) UserID() (r int, exists bool) {
|
|
v := m.user_id
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUserID returns the old "user_id" field's value of the Event entity.
|
|
// If the Event 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 *EventMutation) OldUserID(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUserID requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
|
|
}
|
|
return oldValue.UserID, nil
|
|
}
|
|
|
|
// AddUserID adds i to the "user_id" field.
|
|
func (m *EventMutation) AddUserID(i int) {
|
|
if m.adduser_id != nil {
|
|
*m.adduser_id += i
|
|
} else {
|
|
m.adduser_id = &i
|
|
}
|
|
}
|
|
|
|
// AddedUserID returns the value that was added to the "user_id" field in this mutation.
|
|
func (m *EventMutation) AddedUserID() (r int, exists bool) {
|
|
v := m.adduser_id
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetUserID resets all changes to the "user_id" field.
|
|
func (m *EventMutation) ResetUserID() {
|
|
m.user_id = nil
|
|
m.adduser_id = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the EventMutation builder.
|
|
func (m *EventMutation) Where(ps ...predicate.Event) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the EventMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *EventMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.Event, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *EventMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *EventMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Event).
|
|
func (m *EventMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *EventMutation) Fields() []string {
|
|
fields := make([]string, 0, 4)
|
|
if m.name != nil {
|
|
fields = append(fields, event.FieldName)
|
|
}
|
|
if m.data != nil {
|
|
fields = append(fields, event.FieldData)
|
|
}
|
|
if m.created_at != nil {
|
|
fields = append(fields, event.FieldCreatedAt)
|
|
}
|
|
if m.user_id != nil {
|
|
fields = append(fields, event.FieldUserID)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *EventMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case event.FieldName:
|
|
return m.Name()
|
|
case event.FieldData:
|
|
return m.Data()
|
|
case event.FieldCreatedAt:
|
|
return m.CreatedAt()
|
|
case event.FieldUserID:
|
|
return m.UserID()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *EventMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case event.FieldName:
|
|
return m.OldName(ctx)
|
|
case event.FieldData:
|
|
return m.OldData(ctx)
|
|
case event.FieldCreatedAt:
|
|
return m.OldCreatedAt(ctx)
|
|
case event.FieldUserID:
|
|
return m.OldUserID(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Event field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *EventMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case event.FieldName:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetName(v)
|
|
return nil
|
|
case event.FieldData:
|
|
v, ok := value.(map[string]interface{})
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetData(v)
|
|
return nil
|
|
case event.FieldCreatedAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreatedAt(v)
|
|
return nil
|
|
case event.FieldUserID:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUserID(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Event field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *EventMutation) AddedFields() []string {
|
|
var fields []string
|
|
if m.adduser_id != nil {
|
|
fields = append(fields, event.FieldUserID)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *EventMutation) AddedField(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case event.FieldUserID:
|
|
return m.AddedUserID()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *EventMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
case event.FieldUserID:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddUserID(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Event numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *EventMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *EventMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *EventMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Event nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *EventMutation) ResetField(name string) error {
|
|
switch name {
|
|
case event.FieldName:
|
|
m.ResetName()
|
|
return nil
|
|
case event.FieldData:
|
|
m.ResetData()
|
|
return nil
|
|
case event.FieldCreatedAt:
|
|
m.ResetCreatedAt()
|
|
return nil
|
|
case event.FieldUserID:
|
|
m.ResetUserID()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Event field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *EventMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *EventMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *EventMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *EventMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *EventMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *EventMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *EventMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown Event unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *EventMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown Event edge %s", name)
|
|
}
|
|
|
|
// GeneralQueueMutation represents an operation that mutates the GeneralQueue nodes in the graph.
|
|
type GeneralQueueMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
name *string
|
|
payload *map[string]interface{}
|
|
status *generalqueue.Status
|
|
number_of_tries *int
|
|
addnumber_of_tries *int
|
|
max_retries *int
|
|
addmax_retries *int
|
|
error_message *string
|
|
failure_payload *map[string]interface{}
|
|
result_payload *map[string]interface{}
|
|
created_at *time.Time
|
|
updated_at *time.Time
|
|
processed_at *time.Time
|
|
user_id *int
|
|
adduser_id *int
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*GeneralQueue, error)
|
|
predicates []predicate.GeneralQueue
|
|
}
|
|
|
|
var _ ent.Mutation = (*GeneralQueueMutation)(nil)
|
|
|
|
// generalqueueOption allows management of the mutation configuration using functional options.
|
|
type generalqueueOption func(*GeneralQueueMutation)
|
|
|
|
// newGeneralQueueMutation creates new mutation for the GeneralQueue entity.
|
|
func newGeneralQueueMutation(c config, op Op, opts ...generalqueueOption) *GeneralQueueMutation {
|
|
m := &GeneralQueueMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeGeneralQueue,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withGeneralQueueID sets the ID field of the mutation.
|
|
func withGeneralQueueID(id int) generalqueueOption {
|
|
return func(m *GeneralQueueMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *GeneralQueue
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*GeneralQueue, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().GeneralQueue.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withGeneralQueue sets the old GeneralQueue of the mutation.
|
|
func withGeneralQueue(node *GeneralQueue) generalqueueOption {
|
|
return func(m *GeneralQueueMutation) {
|
|
m.oldValue = func(context.Context) (*GeneralQueue, 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 GeneralQueueMutation) 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 GeneralQueueMutation) 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
|
|
}
|
|
|
|
// 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 *GeneralQueueMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *GeneralQueueMutation) 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().GeneralQueue.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (m *GeneralQueueMutation) SetName(s string) {
|
|
m.name = &s
|
|
}
|
|
|
|
// Name returns the value of the "name" field in the mutation.
|
|
func (m *GeneralQueueMutation) Name() (r string, exists bool) {
|
|
v := m.name
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldName returns the old "name" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) 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 m.id == nil || 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
|
|
}
|
|
|
|
// ResetName resets all changes to the "name" field.
|
|
func (m *GeneralQueueMutation) ResetName() {
|
|
m.name = nil
|
|
}
|
|
|
|
// SetPayload sets the "payload" field.
|
|
func (m *GeneralQueueMutation) SetPayload(value map[string]interface{}) {
|
|
m.payload = &value
|
|
}
|
|
|
|
// Payload returns the value of the "payload" field in the mutation.
|
|
func (m *GeneralQueueMutation) Payload() (r map[string]interface{}, exists bool) {
|
|
v := m.payload
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldPayload returns the old "payload" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldPayload(ctx context.Context) (v map[string]interface{}, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldPayload is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || 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
|
|
}
|
|
|
|
// ResetPayload resets all changes to the "payload" field.
|
|
func (m *GeneralQueueMutation) ResetPayload() {
|
|
m.payload = nil
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (m *GeneralQueueMutation) SetStatus(ge generalqueue.Status) {
|
|
m.status = &ge
|
|
}
|
|
|
|
// Status returns the value of the "status" field in the mutation.
|
|
func (m *GeneralQueueMutation) Status() (r generalqueue.Status, exists bool) {
|
|
v := m.status
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldStatus returns the old "status" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldStatus(ctx context.Context) (v generalqueue.Status, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldStatus requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
|
|
}
|
|
return oldValue.Status, nil
|
|
}
|
|
|
|
// ResetStatus resets all changes to the "status" field.
|
|
func (m *GeneralQueueMutation) ResetStatus() {
|
|
m.status = nil
|
|
}
|
|
|
|
// SetNumberOfTries sets the "number_of_tries" field.
|
|
func (m *GeneralQueueMutation) SetNumberOfTries(i int) {
|
|
m.number_of_tries = &i
|
|
m.addnumber_of_tries = nil
|
|
}
|
|
|
|
// NumberOfTries returns the value of the "number_of_tries" field in the mutation.
|
|
func (m *GeneralQueueMutation) NumberOfTries() (r int, exists bool) {
|
|
v := m.number_of_tries
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldNumberOfTries returns the old "number_of_tries" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldNumberOfTries(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldNumberOfTries is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldNumberOfTries requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldNumberOfTries: %w", err)
|
|
}
|
|
return oldValue.NumberOfTries, nil
|
|
}
|
|
|
|
// AddNumberOfTries adds i to the "number_of_tries" field.
|
|
func (m *GeneralQueueMutation) AddNumberOfTries(i int) {
|
|
if m.addnumber_of_tries != nil {
|
|
*m.addnumber_of_tries += i
|
|
} else {
|
|
m.addnumber_of_tries = &i
|
|
}
|
|
}
|
|
|
|
// AddedNumberOfTries returns the value that was added to the "number_of_tries" field in this mutation.
|
|
func (m *GeneralQueueMutation) AddedNumberOfTries() (r int, exists bool) {
|
|
v := m.addnumber_of_tries
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetNumberOfTries resets all changes to the "number_of_tries" field.
|
|
func (m *GeneralQueueMutation) ResetNumberOfTries() {
|
|
m.number_of_tries = nil
|
|
m.addnumber_of_tries = nil
|
|
}
|
|
|
|
// SetMaxRetries sets the "max_retries" field.
|
|
func (m *GeneralQueueMutation) SetMaxRetries(i int) {
|
|
m.max_retries = &i
|
|
m.addmax_retries = nil
|
|
}
|
|
|
|
// MaxRetries returns the value of the "max_retries" field in the mutation.
|
|
func (m *GeneralQueueMutation) MaxRetries() (r int, exists bool) {
|
|
v := m.max_retries
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldMaxRetries returns the old "max_retries" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldMaxRetries(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldMaxRetries is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldMaxRetries requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldMaxRetries: %w", err)
|
|
}
|
|
return oldValue.MaxRetries, nil
|
|
}
|
|
|
|
// AddMaxRetries adds i to the "max_retries" field.
|
|
func (m *GeneralQueueMutation) AddMaxRetries(i int) {
|
|
if m.addmax_retries != nil {
|
|
*m.addmax_retries += i
|
|
} else {
|
|
m.addmax_retries = &i
|
|
}
|
|
}
|
|
|
|
// AddedMaxRetries returns the value that was added to the "max_retries" field in this mutation.
|
|
func (m *GeneralQueueMutation) AddedMaxRetries() (r int, exists bool) {
|
|
v := m.addmax_retries
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetMaxRetries resets all changes to the "max_retries" field.
|
|
func (m *GeneralQueueMutation) ResetMaxRetries() {
|
|
m.max_retries = nil
|
|
m.addmax_retries = nil
|
|
}
|
|
|
|
// SetErrorMessage sets the "error_message" field.
|
|
func (m *GeneralQueueMutation) SetErrorMessage(s string) {
|
|
m.error_message = &s
|
|
}
|
|
|
|
// ErrorMessage returns the value of the "error_message" field in the mutation.
|
|
func (m *GeneralQueueMutation) ErrorMessage() (r string, exists bool) {
|
|
v := m.error_message
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldErrorMessage returns the old "error_message" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldErrorMessage(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldErrorMessage is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldErrorMessage requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldErrorMessage: %w", err)
|
|
}
|
|
return oldValue.ErrorMessage, nil
|
|
}
|
|
|
|
// ClearErrorMessage clears the value of the "error_message" field.
|
|
func (m *GeneralQueueMutation) ClearErrorMessage() {
|
|
m.error_message = nil
|
|
m.clearedFields[generalqueue.FieldErrorMessage] = struct{}{}
|
|
}
|
|
|
|
// ErrorMessageCleared returns if the "error_message" field was cleared in this mutation.
|
|
func (m *GeneralQueueMutation) ErrorMessageCleared() bool {
|
|
_, ok := m.clearedFields[generalqueue.FieldErrorMessage]
|
|
return ok
|
|
}
|
|
|
|
// ResetErrorMessage resets all changes to the "error_message" field.
|
|
func (m *GeneralQueueMutation) ResetErrorMessage() {
|
|
m.error_message = nil
|
|
delete(m.clearedFields, generalqueue.FieldErrorMessage)
|
|
}
|
|
|
|
// SetFailurePayload sets the "failure_payload" field.
|
|
func (m *GeneralQueueMutation) SetFailurePayload(value map[string]interface{}) {
|
|
m.failure_payload = &value
|
|
}
|
|
|
|
// FailurePayload returns the value of the "failure_payload" field in the mutation.
|
|
func (m *GeneralQueueMutation) FailurePayload() (r map[string]interface{}, exists bool) {
|
|
v := m.failure_payload
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldFailurePayload returns the old "failure_payload" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldFailurePayload(ctx context.Context) (v map[string]interface{}, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldFailurePayload is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldFailurePayload requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldFailurePayload: %w", err)
|
|
}
|
|
return oldValue.FailurePayload, nil
|
|
}
|
|
|
|
// ClearFailurePayload clears the value of the "failure_payload" field.
|
|
func (m *GeneralQueueMutation) ClearFailurePayload() {
|
|
m.failure_payload = nil
|
|
m.clearedFields[generalqueue.FieldFailurePayload] = struct{}{}
|
|
}
|
|
|
|
// FailurePayloadCleared returns if the "failure_payload" field was cleared in this mutation.
|
|
func (m *GeneralQueueMutation) FailurePayloadCleared() bool {
|
|
_, ok := m.clearedFields[generalqueue.FieldFailurePayload]
|
|
return ok
|
|
}
|
|
|
|
// ResetFailurePayload resets all changes to the "failure_payload" field.
|
|
func (m *GeneralQueueMutation) ResetFailurePayload() {
|
|
m.failure_payload = nil
|
|
delete(m.clearedFields, generalqueue.FieldFailurePayload)
|
|
}
|
|
|
|
// SetResultPayload sets the "result_payload" field.
|
|
func (m *GeneralQueueMutation) SetResultPayload(value map[string]interface{}) {
|
|
m.result_payload = &value
|
|
}
|
|
|
|
// ResultPayload returns the value of the "result_payload" field in the mutation.
|
|
func (m *GeneralQueueMutation) ResultPayload() (r map[string]interface{}, exists bool) {
|
|
v := m.result_payload
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldResultPayload returns the old "result_payload" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldResultPayload(ctx context.Context) (v map[string]interface{}, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldResultPayload is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldResultPayload requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldResultPayload: %w", err)
|
|
}
|
|
return oldValue.ResultPayload, nil
|
|
}
|
|
|
|
// ClearResultPayload clears the value of the "result_payload" field.
|
|
func (m *GeneralQueueMutation) ClearResultPayload() {
|
|
m.result_payload = nil
|
|
m.clearedFields[generalqueue.FieldResultPayload] = struct{}{}
|
|
}
|
|
|
|
// ResultPayloadCleared returns if the "result_payload" field was cleared in this mutation.
|
|
func (m *GeneralQueueMutation) ResultPayloadCleared() bool {
|
|
_, ok := m.clearedFields[generalqueue.FieldResultPayload]
|
|
return ok
|
|
}
|
|
|
|
// ResetResultPayload resets all changes to the "result_payload" field.
|
|
func (m *GeneralQueueMutation) ResetResultPayload() {
|
|
m.result_payload = nil
|
|
delete(m.clearedFields, generalqueue.FieldResultPayload)
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (m *GeneralQueueMutation) SetCreatedAt(t time.Time) {
|
|
m.created_at = &t
|
|
}
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
func (m *GeneralQueueMutation) CreatedAt() (r time.Time, exists bool) {
|
|
v := m.created_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCreatedAt returns the old "created_at" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) 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 m.id == nil || 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
|
|
}
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
func (m *GeneralQueueMutation) ResetCreatedAt() {
|
|
m.created_at = nil
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (m *GeneralQueueMutation) SetUpdatedAt(t time.Time) {
|
|
m.updated_at = &t
|
|
}
|
|
|
|
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
func (m *GeneralQueueMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
v := m.updated_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUpdatedAt returns the old "updated_at" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) 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 m.id == nil || 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
|
|
}
|
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
func (m *GeneralQueueMutation) ResetUpdatedAt() {
|
|
m.updated_at = nil
|
|
}
|
|
|
|
// SetProcessedAt sets the "processed_at" field.
|
|
func (m *GeneralQueueMutation) SetProcessedAt(t time.Time) {
|
|
m.processed_at = &t
|
|
}
|
|
|
|
// ProcessedAt returns the value of the "processed_at" field in the mutation.
|
|
func (m *GeneralQueueMutation) ProcessedAt() (r time.Time, exists bool) {
|
|
v := m.processed_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldProcessedAt returns the old "processed_at" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldProcessedAt(ctx context.Context) (v time.Time, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldProcessedAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldProcessedAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldProcessedAt: %w", err)
|
|
}
|
|
return oldValue.ProcessedAt, nil
|
|
}
|
|
|
|
// ClearProcessedAt clears the value of the "processed_at" field.
|
|
func (m *GeneralQueueMutation) ClearProcessedAt() {
|
|
m.processed_at = nil
|
|
m.clearedFields[generalqueue.FieldProcessedAt] = struct{}{}
|
|
}
|
|
|
|
// ProcessedAtCleared returns if the "processed_at" field was cleared in this mutation.
|
|
func (m *GeneralQueueMutation) ProcessedAtCleared() bool {
|
|
_, ok := m.clearedFields[generalqueue.FieldProcessedAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetProcessedAt resets all changes to the "processed_at" field.
|
|
func (m *GeneralQueueMutation) ResetProcessedAt() {
|
|
m.processed_at = nil
|
|
delete(m.clearedFields, generalqueue.FieldProcessedAt)
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (m *GeneralQueueMutation) SetUserID(i int) {
|
|
m.user_id = &i
|
|
m.adduser_id = nil
|
|
}
|
|
|
|
// UserID returns the value of the "user_id" field in the mutation.
|
|
func (m *GeneralQueueMutation) UserID() (r int, exists bool) {
|
|
v := m.user_id
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUserID returns the old "user_id" field's value of the GeneralQueue entity.
|
|
// If the GeneralQueue 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 *GeneralQueueMutation) OldUserID(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUserID requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
|
|
}
|
|
return oldValue.UserID, nil
|
|
}
|
|
|
|
// AddUserID adds i to the "user_id" field.
|
|
func (m *GeneralQueueMutation) AddUserID(i int) {
|
|
if m.adduser_id != nil {
|
|
*m.adduser_id += i
|
|
} else {
|
|
m.adduser_id = &i
|
|
}
|
|
}
|
|
|
|
// AddedUserID returns the value that was added to the "user_id" field in this mutation.
|
|
func (m *GeneralQueueMutation) AddedUserID() (r int, exists bool) {
|
|
v := m.adduser_id
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetUserID resets all changes to the "user_id" field.
|
|
func (m *GeneralQueueMutation) ResetUserID() {
|
|
m.user_id = nil
|
|
m.adduser_id = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the GeneralQueueMutation builder.
|
|
func (m *GeneralQueueMutation) Where(ps ...predicate.GeneralQueue) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the GeneralQueueMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *GeneralQueueMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.GeneralQueue, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *GeneralQueueMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *GeneralQueueMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (GeneralQueue).
|
|
func (m *GeneralQueueMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *GeneralQueueMutation) Fields() []string {
|
|
fields := make([]string, 0, 12)
|
|
if m.name != nil {
|
|
fields = append(fields, generalqueue.FieldName)
|
|
}
|
|
if m.payload != nil {
|
|
fields = append(fields, generalqueue.FieldPayload)
|
|
}
|
|
if m.status != nil {
|
|
fields = append(fields, generalqueue.FieldStatus)
|
|
}
|
|
if m.number_of_tries != nil {
|
|
fields = append(fields, generalqueue.FieldNumberOfTries)
|
|
}
|
|
if m.max_retries != nil {
|
|
fields = append(fields, generalqueue.FieldMaxRetries)
|
|
}
|
|
if m.error_message != nil {
|
|
fields = append(fields, generalqueue.FieldErrorMessage)
|
|
}
|
|
if m.failure_payload != nil {
|
|
fields = append(fields, generalqueue.FieldFailurePayload)
|
|
}
|
|
if m.result_payload != nil {
|
|
fields = append(fields, generalqueue.FieldResultPayload)
|
|
}
|
|
if m.created_at != nil {
|
|
fields = append(fields, generalqueue.FieldCreatedAt)
|
|
}
|
|
if m.updated_at != nil {
|
|
fields = append(fields, generalqueue.FieldUpdatedAt)
|
|
}
|
|
if m.processed_at != nil {
|
|
fields = append(fields, generalqueue.FieldProcessedAt)
|
|
}
|
|
if m.user_id != nil {
|
|
fields = append(fields, generalqueue.FieldUserID)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *GeneralQueueMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case generalqueue.FieldName:
|
|
return m.Name()
|
|
case generalqueue.FieldPayload:
|
|
return m.Payload()
|
|
case generalqueue.FieldStatus:
|
|
return m.Status()
|
|
case generalqueue.FieldNumberOfTries:
|
|
return m.NumberOfTries()
|
|
case generalqueue.FieldMaxRetries:
|
|
return m.MaxRetries()
|
|
case generalqueue.FieldErrorMessage:
|
|
return m.ErrorMessage()
|
|
case generalqueue.FieldFailurePayload:
|
|
return m.FailurePayload()
|
|
case generalqueue.FieldResultPayload:
|
|
return m.ResultPayload()
|
|
case generalqueue.FieldCreatedAt:
|
|
return m.CreatedAt()
|
|
case generalqueue.FieldUpdatedAt:
|
|
return m.UpdatedAt()
|
|
case generalqueue.FieldProcessedAt:
|
|
return m.ProcessedAt()
|
|
case generalqueue.FieldUserID:
|
|
return m.UserID()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *GeneralQueueMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case generalqueue.FieldName:
|
|
return m.OldName(ctx)
|
|
case generalqueue.FieldPayload:
|
|
return m.OldPayload(ctx)
|
|
case generalqueue.FieldStatus:
|
|
return m.OldStatus(ctx)
|
|
case generalqueue.FieldNumberOfTries:
|
|
return m.OldNumberOfTries(ctx)
|
|
case generalqueue.FieldMaxRetries:
|
|
return m.OldMaxRetries(ctx)
|
|
case generalqueue.FieldErrorMessage:
|
|
return m.OldErrorMessage(ctx)
|
|
case generalqueue.FieldFailurePayload:
|
|
return m.OldFailurePayload(ctx)
|
|
case generalqueue.FieldResultPayload:
|
|
return m.OldResultPayload(ctx)
|
|
case generalqueue.FieldCreatedAt:
|
|
return m.OldCreatedAt(ctx)
|
|
case generalqueue.FieldUpdatedAt:
|
|
return m.OldUpdatedAt(ctx)
|
|
case generalqueue.FieldProcessedAt:
|
|
return m.OldProcessedAt(ctx)
|
|
case generalqueue.FieldUserID:
|
|
return m.OldUserID(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown GeneralQueue field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *GeneralQueueMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case generalqueue.FieldName:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetName(v)
|
|
return nil
|
|
case generalqueue.FieldPayload:
|
|
v, ok := value.(map[string]interface{})
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetPayload(v)
|
|
return nil
|
|
case generalqueue.FieldStatus:
|
|
v, ok := value.(generalqueue.Status)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetStatus(v)
|
|
return nil
|
|
case generalqueue.FieldNumberOfTries:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetNumberOfTries(v)
|
|
return nil
|
|
case generalqueue.FieldMaxRetries:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetMaxRetries(v)
|
|
return nil
|
|
case generalqueue.FieldErrorMessage:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetErrorMessage(v)
|
|
return nil
|
|
case generalqueue.FieldFailurePayload:
|
|
v, ok := value.(map[string]interface{})
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetFailurePayload(v)
|
|
return nil
|
|
case generalqueue.FieldResultPayload:
|
|
v, ok := value.(map[string]interface{})
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetResultPayload(v)
|
|
return nil
|
|
case generalqueue.FieldCreatedAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreatedAt(v)
|
|
return nil
|
|
case generalqueue.FieldUpdatedAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUpdatedAt(v)
|
|
return nil
|
|
case generalqueue.FieldProcessedAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetProcessedAt(v)
|
|
return nil
|
|
case generalqueue.FieldUserID:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUserID(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown GeneralQueue field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *GeneralQueueMutation) AddedFields() []string {
|
|
var fields []string
|
|
if m.addnumber_of_tries != nil {
|
|
fields = append(fields, generalqueue.FieldNumberOfTries)
|
|
}
|
|
if m.addmax_retries != nil {
|
|
fields = append(fields, generalqueue.FieldMaxRetries)
|
|
}
|
|
if m.adduser_id != nil {
|
|
fields = append(fields, generalqueue.FieldUserID)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *GeneralQueueMutation) AddedField(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case generalqueue.FieldNumberOfTries:
|
|
return m.AddedNumberOfTries()
|
|
case generalqueue.FieldMaxRetries:
|
|
return m.AddedMaxRetries()
|
|
case generalqueue.FieldUserID:
|
|
return m.AddedUserID()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *GeneralQueueMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
case generalqueue.FieldNumberOfTries:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddNumberOfTries(v)
|
|
return nil
|
|
case generalqueue.FieldMaxRetries:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddMaxRetries(v)
|
|
return nil
|
|
case generalqueue.FieldUserID:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddUserID(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown GeneralQueue numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *GeneralQueueMutation) ClearedFields() []string {
|
|
var fields []string
|
|
if m.FieldCleared(generalqueue.FieldErrorMessage) {
|
|
fields = append(fields, generalqueue.FieldErrorMessage)
|
|
}
|
|
if m.FieldCleared(generalqueue.FieldFailurePayload) {
|
|
fields = append(fields, generalqueue.FieldFailurePayload)
|
|
}
|
|
if m.FieldCleared(generalqueue.FieldResultPayload) {
|
|
fields = append(fields, generalqueue.FieldResultPayload)
|
|
}
|
|
if m.FieldCleared(generalqueue.FieldProcessedAt) {
|
|
fields = append(fields, generalqueue.FieldProcessedAt)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *GeneralQueueMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *GeneralQueueMutation) ClearField(name string) error {
|
|
switch name {
|
|
case generalqueue.FieldErrorMessage:
|
|
m.ClearErrorMessage()
|
|
return nil
|
|
case generalqueue.FieldFailurePayload:
|
|
m.ClearFailurePayload()
|
|
return nil
|
|
case generalqueue.FieldResultPayload:
|
|
m.ClearResultPayload()
|
|
return nil
|
|
case generalqueue.FieldProcessedAt:
|
|
m.ClearProcessedAt()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown GeneralQueue nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *GeneralQueueMutation) ResetField(name string) error {
|
|
switch name {
|
|
case generalqueue.FieldName:
|
|
m.ResetName()
|
|
return nil
|
|
case generalqueue.FieldPayload:
|
|
m.ResetPayload()
|
|
return nil
|
|
case generalqueue.FieldStatus:
|
|
m.ResetStatus()
|
|
return nil
|
|
case generalqueue.FieldNumberOfTries:
|
|
m.ResetNumberOfTries()
|
|
return nil
|
|
case generalqueue.FieldMaxRetries:
|
|
m.ResetMaxRetries()
|
|
return nil
|
|
case generalqueue.FieldErrorMessage:
|
|
m.ResetErrorMessage()
|
|
return nil
|
|
case generalqueue.FieldFailurePayload:
|
|
m.ResetFailurePayload()
|
|
return nil
|
|
case generalqueue.FieldResultPayload:
|
|
m.ResetResultPayload()
|
|
return nil
|
|
case generalqueue.FieldCreatedAt:
|
|
m.ResetCreatedAt()
|
|
return nil
|
|
case generalqueue.FieldUpdatedAt:
|
|
m.ResetUpdatedAt()
|
|
return nil
|
|
case generalqueue.FieldProcessedAt:
|
|
m.ResetProcessedAt()
|
|
return nil
|
|
case generalqueue.FieldUserID:
|
|
m.ResetUserID()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown GeneralQueue field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *GeneralQueueMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *GeneralQueueMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *GeneralQueueMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *GeneralQueueMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *GeneralQueueMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *GeneralQueueMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *GeneralQueueMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown GeneralQueue unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *GeneralQueueMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown GeneralQueue edge %s", name)
|
|
}
|
|
|
|
// GeneralQueueStateMutation represents an operation that mutates the GeneralQueueState nodes in the graph.
|
|
type GeneralQueueStateMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
name *string
|
|
running *bool
|
|
updated_at *time.Time
|
|
clearedFields map[string]struct{}
|
|
done bool
|
|
oldValue func(context.Context) (*GeneralQueueState, error)
|
|
predicates []predicate.GeneralQueueState
|
|
}
|
|
|
|
var _ ent.Mutation = (*GeneralQueueStateMutation)(nil)
|
|
|
|
// generalqueuestateOption allows management of the mutation configuration using functional options.
|
|
type generalqueuestateOption func(*GeneralQueueStateMutation)
|
|
|
|
// newGeneralQueueStateMutation creates new mutation for the GeneralQueueState entity.
|
|
func newGeneralQueueStateMutation(c config, op Op, opts ...generalqueuestateOption) *GeneralQueueStateMutation {
|
|
m := &GeneralQueueStateMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeGeneralQueueState,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withGeneralQueueStateID sets the ID field of the mutation.
|
|
func withGeneralQueueStateID(id int) generalqueuestateOption {
|
|
return func(m *GeneralQueueStateMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *GeneralQueueState
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*GeneralQueueState, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().GeneralQueueState.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withGeneralQueueState sets the old GeneralQueueState of the mutation.
|
|
func withGeneralQueueState(node *GeneralQueueState) generalqueuestateOption {
|
|
return func(m *GeneralQueueStateMutation) {
|
|
m.oldValue = func(context.Context) (*GeneralQueueState, 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 GeneralQueueStateMutation) 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 GeneralQueueStateMutation) 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
|
|
}
|
|
|
|
// 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 *GeneralQueueStateMutation) ID() (id int, exists bool) {
|
|
if m.id == nil {
|
|
return
|
|
}
|
|
return *m.id, true
|
|
}
|
|
|
|
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
// That means, if the mutation is applied within a transaction with an isolation level such
|
|
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
// or updated by the mutation.
|
|
func (m *GeneralQueueStateMutation) 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().GeneralQueueState.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (m *GeneralQueueStateMutation) SetName(s string) {
|
|
m.name = &s
|
|
}
|
|
|
|
// Name returns the value of the "name" field in the mutation.
|
|
func (m *GeneralQueueStateMutation) Name() (r string, exists bool) {
|
|
v := m.name
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldName returns the old "name" field's value of the GeneralQueueState entity.
|
|
// If the GeneralQueueState 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 *GeneralQueueStateMutation) 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 m.id == nil || 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
|
|
}
|
|
|
|
// ResetName resets all changes to the "name" field.
|
|
func (m *GeneralQueueStateMutation) ResetName() {
|
|
m.name = nil
|
|
}
|
|
|
|
// SetRunning sets the "running" field.
|
|
func (m *GeneralQueueStateMutation) SetRunning(b bool) {
|
|
m.running = &b
|
|
}
|
|
|
|
// Running returns the value of the "running" field in the mutation.
|
|
func (m *GeneralQueueStateMutation) Running() (r bool, exists bool) {
|
|
v := m.running
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldRunning returns the old "running" field's value of the GeneralQueueState entity.
|
|
// If the GeneralQueueState 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 *GeneralQueueStateMutation) OldRunning(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldRunning is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldRunning requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldRunning: %w", err)
|
|
}
|
|
return oldValue.Running, nil
|
|
}
|
|
|
|
// ResetRunning resets all changes to the "running" field.
|
|
func (m *GeneralQueueStateMutation) ResetRunning() {
|
|
m.running = nil
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (m *GeneralQueueStateMutation) SetUpdatedAt(t time.Time) {
|
|
m.updated_at = &t
|
|
}
|
|
|
|
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
func (m *GeneralQueueStateMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
v := m.updated_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUpdatedAt returns the old "updated_at" field's value of the GeneralQueueState entity.
|
|
// If the GeneralQueueState 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 *GeneralQueueStateMutation) 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 m.id == nil || 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
|
|
}
|
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
func (m *GeneralQueueStateMutation) ResetUpdatedAt() {
|
|
m.updated_at = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the GeneralQueueStateMutation builder.
|
|
func (m *GeneralQueueStateMutation) Where(ps ...predicate.GeneralQueueState) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the GeneralQueueStateMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *GeneralQueueStateMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.GeneralQueueState, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *GeneralQueueStateMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *GeneralQueueStateMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (GeneralQueueState).
|
|
func (m *GeneralQueueStateMutation) Type() string {
|
|
return m.typ
|
|
}
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
// AddedFields().
|
|
func (m *GeneralQueueStateMutation) Fields() []string {
|
|
fields := make([]string, 0, 3)
|
|
if m.name != nil {
|
|
fields = append(fields, generalqueuestate.FieldName)
|
|
}
|
|
if m.running != nil {
|
|
fields = append(fields, generalqueuestate.FieldRunning)
|
|
}
|
|
if m.updated_at != nil {
|
|
fields = append(fields, generalqueuestate.FieldUpdatedAt)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
// schema.
|
|
func (m *GeneralQueueStateMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case generalqueuestate.FieldName:
|
|
return m.Name()
|
|
case generalqueuestate.FieldRunning:
|
|
return m.Running()
|
|
case generalqueuestate.FieldUpdatedAt:
|
|
return m.UpdatedAt()
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
// database failed.
|
|
func (m *GeneralQueueStateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case generalqueuestate.FieldName:
|
|
return m.OldName(ctx)
|
|
case generalqueuestate.FieldRunning:
|
|
return m.OldRunning(ctx)
|
|
case generalqueuestate.FieldUpdatedAt:
|
|
return m.OldUpdatedAt(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown GeneralQueueState field %s", name)
|
|
}
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *GeneralQueueStateMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case generalqueuestate.FieldName:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetName(v)
|
|
return nil
|
|
case generalqueuestate.FieldRunning:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetRunning(v)
|
|
return nil
|
|
case generalqueuestate.FieldUpdatedAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUpdatedAt(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown GeneralQueueState field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *GeneralQueueStateMutation) AddedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
// with the given name. The second boolean return value indicates that this field
|
|
// was not set, or was not defined in the schema.
|
|
func (m *GeneralQueueStateMutation) AddedField(name string) (ent.Value, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
// AddField adds the value to the field with the given name. It returns an error if
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
// type.
|
|
func (m *GeneralQueueStateMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown GeneralQueueState numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *GeneralQueueStateMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *GeneralQueueStateMutation) FieldCleared(name string) bool {
|
|
_, ok := m.clearedFields[name]
|
|
return ok
|
|
}
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
// error if the field is not defined in the schema.
|
|
func (m *GeneralQueueStateMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown GeneralQueueState nullable field %s", name)
|
|
}
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
// It returns an error if the field is not defined in the schema.
|
|
func (m *GeneralQueueStateMutation) ResetField(name string) error {
|
|
switch name {
|
|
case generalqueuestate.FieldName:
|
|
m.ResetName()
|
|
return nil
|
|
case generalqueuestate.FieldRunning:
|
|
m.ResetRunning()
|
|
return nil
|
|
case generalqueuestate.FieldUpdatedAt:
|
|
m.ResetUpdatedAt()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown GeneralQueueState field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *GeneralQueueStateMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *GeneralQueueStateMutation) AddedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *GeneralQueueStateMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *GeneralQueueStateMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *GeneralQueueStateMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 0)
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *GeneralQueueStateMutation) EdgeCleared(name string) bool {
|
|
return false
|
|
}
|
|
|
|
// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
// if that edge is not defined in the schema.
|
|
func (m *GeneralQueueStateMutation) ClearEdge(name string) error {
|
|
return fmt.Errorf("unknown GeneralQueueState unique edge %s", name)
|
|
}
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
// It returns an error if the edge is not defined in the schema.
|
|
func (m *GeneralQueueStateMutation) ResetEdge(name string) error {
|
|
return fmt.Errorf("unknown GeneralQueueState edge %s", name)
|
|
}
|