Files
juwan-backend/app/shop/rpc/internal/models/mutation.go
T
2026-02-28 05:33:16 +08:00

2855 lines
86 KiB
Go

// Code generated by ent, DO NOT EDIT.
package models
import (
"context"
"errors"
"fmt"
"juwan-backend/app/shop/rpc/internal/models/predicate"
"juwan-backend/app/shop/rpc/internal/models/shopinvitations"
"juwan-backend/app/shop/rpc/internal/models/shopplayers"
"juwan-backend/app/shop/rpc/internal/models/shops"
"sync"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/shopspring/decimal"
)
const (
// Operation types.
OpCreate = ent.OpCreate
OpDelete = ent.OpDelete
OpDeleteOne = ent.OpDeleteOne
OpUpdate = ent.OpUpdate
OpUpdateOne = ent.OpUpdateOne
// Node types.
TypeShopInvitations = "ShopInvitations"
TypeShopPlayers = "ShopPlayers"
TypeShops = "Shops"
)
// ShopInvitationsMutation represents an operation that mutates the ShopInvitations nodes in the graph.
type ShopInvitationsMutation struct {
config
op Op
typ string
id *int64
shop_id *int64
addshop_id *int64
player_id *int64
addplayer_id *int64
status *string
invited_by *int64
addinvited_by *int64
created_at *time.Time
responded_at *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*ShopInvitations, error)
predicates []predicate.ShopInvitations
}
var _ ent.Mutation = (*ShopInvitationsMutation)(nil)
// shopinvitationsOption allows management of the mutation configuration using functional options.
type shopinvitationsOption func(*ShopInvitationsMutation)
// newShopInvitationsMutation creates new mutation for the ShopInvitations entity.
func newShopInvitationsMutation(c config, op Op, opts ...shopinvitationsOption) *ShopInvitationsMutation {
m := &ShopInvitationsMutation{
config: c,
op: op,
typ: TypeShopInvitations,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withShopInvitationsID sets the ID field of the mutation.
func withShopInvitationsID(id int64) shopinvitationsOption {
return func(m *ShopInvitationsMutation) {
var (
err error
once sync.Once
value *ShopInvitations
)
m.oldValue = func(ctx context.Context) (*ShopInvitations, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ShopInvitations.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withShopInvitations sets the old ShopInvitations of the mutation.
func withShopInvitations(node *ShopInvitations) shopinvitationsOption {
return func(m *ShopInvitationsMutation) {
m.oldValue = func(context.Context) (*ShopInvitations, 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 ShopInvitationsMutation) 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 ShopInvitationsMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("models: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of ShopInvitations entities.
func (m *ShopInvitationsMutation) SetID(id int64) {
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 *ShopInvitationsMutation) ID() (id int64, 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 *ShopInvitationsMutation) IDs(ctx context.Context) ([]int64, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []int64{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ShopInvitations.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetShopID sets the "shop_id" field.
func (m *ShopInvitationsMutation) SetShopID(i int64) {
m.shop_id = &i
m.addshop_id = nil
}
// ShopID returns the value of the "shop_id" field in the mutation.
func (m *ShopInvitationsMutation) ShopID() (r int64, exists bool) {
v := m.shop_id
if v == nil {
return
}
return *v, true
}
// OldShopID returns the old "shop_id" field's value of the ShopInvitations entity.
// If the ShopInvitations 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 *ShopInvitationsMutation) OldShopID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldShopID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldShopID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldShopID: %w", err)
}
return oldValue.ShopID, nil
}
// AddShopID adds i to the "shop_id" field.
func (m *ShopInvitationsMutation) AddShopID(i int64) {
if m.addshop_id != nil {
*m.addshop_id += i
} else {
m.addshop_id = &i
}
}
// AddedShopID returns the value that was added to the "shop_id" field in this mutation.
func (m *ShopInvitationsMutation) AddedShopID() (r int64, exists bool) {
v := m.addshop_id
if v == nil {
return
}
return *v, true
}
// ResetShopID resets all changes to the "shop_id" field.
func (m *ShopInvitationsMutation) ResetShopID() {
m.shop_id = nil
m.addshop_id = nil
}
// SetPlayerID sets the "player_id" field.
func (m *ShopInvitationsMutation) SetPlayerID(i int64) {
m.player_id = &i
m.addplayer_id = nil
}
// PlayerID returns the value of the "player_id" field in the mutation.
func (m *ShopInvitationsMutation) PlayerID() (r int64, exists bool) {
v := m.player_id
if v == nil {
return
}
return *v, true
}
// OldPlayerID returns the old "player_id" field's value of the ShopInvitations entity.
// If the ShopInvitations 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 *ShopInvitationsMutation) OldPlayerID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPlayerID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPlayerID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPlayerID: %w", err)
}
return oldValue.PlayerID, nil
}
// AddPlayerID adds i to the "player_id" field.
func (m *ShopInvitationsMutation) AddPlayerID(i int64) {
if m.addplayer_id != nil {
*m.addplayer_id += i
} else {
m.addplayer_id = &i
}
}
// AddedPlayerID returns the value that was added to the "player_id" field in this mutation.
func (m *ShopInvitationsMutation) AddedPlayerID() (r int64, exists bool) {
v := m.addplayer_id
if v == nil {
return
}
return *v, true
}
// ResetPlayerID resets all changes to the "player_id" field.
func (m *ShopInvitationsMutation) ResetPlayerID() {
m.player_id = nil
m.addplayer_id = nil
}
// SetStatus sets the "status" field.
func (m *ShopInvitationsMutation) SetStatus(s string) {
m.status = &s
}
// Status returns the value of the "status" field in the mutation.
func (m *ShopInvitationsMutation) Status() (r string, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// OldStatus returns the old "status" field's value of the ShopInvitations entity.
// If the ShopInvitations 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 *ShopInvitationsMutation) OldStatus(ctx context.Context) (v string, 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 *ShopInvitationsMutation) ResetStatus() {
m.status = nil
}
// SetInvitedBy sets the "invited_by" field.
func (m *ShopInvitationsMutation) SetInvitedBy(i int64) {
m.invited_by = &i
m.addinvited_by = nil
}
// InvitedBy returns the value of the "invited_by" field in the mutation.
func (m *ShopInvitationsMutation) InvitedBy() (r int64, exists bool) {
v := m.invited_by
if v == nil {
return
}
return *v, true
}
// OldInvitedBy returns the old "invited_by" field's value of the ShopInvitations entity.
// If the ShopInvitations 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 *ShopInvitationsMutation) OldInvitedBy(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldInvitedBy is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldInvitedBy requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldInvitedBy: %w", err)
}
return oldValue.InvitedBy, nil
}
// AddInvitedBy adds i to the "invited_by" field.
func (m *ShopInvitationsMutation) AddInvitedBy(i int64) {
if m.addinvited_by != nil {
*m.addinvited_by += i
} else {
m.addinvited_by = &i
}
}
// AddedInvitedBy returns the value that was added to the "invited_by" field in this mutation.
func (m *ShopInvitationsMutation) AddedInvitedBy() (r int64, exists bool) {
v := m.addinvited_by
if v == nil {
return
}
return *v, true
}
// ResetInvitedBy resets all changes to the "invited_by" field.
func (m *ShopInvitationsMutation) ResetInvitedBy() {
m.invited_by = nil
m.addinvited_by = nil
}
// SetCreatedAt sets the "created_at" field.
func (m *ShopInvitationsMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ShopInvitationsMutation) 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 ShopInvitations entity.
// If the ShopInvitations 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 *ShopInvitationsMutation) 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 *ShopInvitationsMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetRespondedAt sets the "responded_at" field.
func (m *ShopInvitationsMutation) SetRespondedAt(t time.Time) {
m.responded_at = &t
}
// RespondedAt returns the value of the "responded_at" field in the mutation.
func (m *ShopInvitationsMutation) RespondedAt() (r time.Time, exists bool) {
v := m.responded_at
if v == nil {
return
}
return *v, true
}
// OldRespondedAt returns the old "responded_at" field's value of the ShopInvitations entity.
// If the ShopInvitations 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 *ShopInvitationsMutation) OldRespondedAt(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRespondedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRespondedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRespondedAt: %w", err)
}
return oldValue.RespondedAt, nil
}
// ClearRespondedAt clears the value of the "responded_at" field.
func (m *ShopInvitationsMutation) ClearRespondedAt() {
m.responded_at = nil
m.clearedFields[shopinvitations.FieldRespondedAt] = struct{}{}
}
// RespondedAtCleared returns if the "responded_at" field was cleared in this mutation.
func (m *ShopInvitationsMutation) RespondedAtCleared() bool {
_, ok := m.clearedFields[shopinvitations.FieldRespondedAt]
return ok
}
// ResetRespondedAt resets all changes to the "responded_at" field.
func (m *ShopInvitationsMutation) ResetRespondedAt() {
m.responded_at = nil
delete(m.clearedFields, shopinvitations.FieldRespondedAt)
}
// Where appends a list predicates to the ShopInvitationsMutation builder.
func (m *ShopInvitationsMutation) Where(ps ...predicate.ShopInvitations) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ShopInvitationsMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ShopInvitationsMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ShopInvitations, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ShopInvitationsMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ShopInvitationsMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ShopInvitations).
func (m *ShopInvitationsMutation) 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 *ShopInvitationsMutation) Fields() []string {
fields := make([]string, 0, 6)
if m.shop_id != nil {
fields = append(fields, shopinvitations.FieldShopID)
}
if m.player_id != nil {
fields = append(fields, shopinvitations.FieldPlayerID)
}
if m.status != nil {
fields = append(fields, shopinvitations.FieldStatus)
}
if m.invited_by != nil {
fields = append(fields, shopinvitations.FieldInvitedBy)
}
if m.created_at != nil {
fields = append(fields, shopinvitations.FieldCreatedAt)
}
if m.responded_at != nil {
fields = append(fields, shopinvitations.FieldRespondedAt)
}
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 *ShopInvitationsMutation) Field(name string) (ent.Value, bool) {
switch name {
case shopinvitations.FieldShopID:
return m.ShopID()
case shopinvitations.FieldPlayerID:
return m.PlayerID()
case shopinvitations.FieldStatus:
return m.Status()
case shopinvitations.FieldInvitedBy:
return m.InvitedBy()
case shopinvitations.FieldCreatedAt:
return m.CreatedAt()
case shopinvitations.FieldRespondedAt:
return m.RespondedAt()
}
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 *ShopInvitationsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case shopinvitations.FieldShopID:
return m.OldShopID(ctx)
case shopinvitations.FieldPlayerID:
return m.OldPlayerID(ctx)
case shopinvitations.FieldStatus:
return m.OldStatus(ctx)
case shopinvitations.FieldInvitedBy:
return m.OldInvitedBy(ctx)
case shopinvitations.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case shopinvitations.FieldRespondedAt:
return m.OldRespondedAt(ctx)
}
return nil, fmt.Errorf("unknown ShopInvitations 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 *ShopInvitationsMutation) SetField(name string, value ent.Value) error {
switch name {
case shopinvitations.FieldShopID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetShopID(v)
return nil
case shopinvitations.FieldPlayerID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPlayerID(v)
return nil
case shopinvitations.FieldStatus:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case shopinvitations.FieldInvitedBy:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetInvitedBy(v)
return nil
case shopinvitations.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 shopinvitations.FieldRespondedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRespondedAt(v)
return nil
}
return fmt.Errorf("unknown ShopInvitations field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ShopInvitationsMutation) AddedFields() []string {
var fields []string
if m.addshop_id != nil {
fields = append(fields, shopinvitations.FieldShopID)
}
if m.addplayer_id != nil {
fields = append(fields, shopinvitations.FieldPlayerID)
}
if m.addinvited_by != nil {
fields = append(fields, shopinvitations.FieldInvitedBy)
}
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 *ShopInvitationsMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case shopinvitations.FieldShopID:
return m.AddedShopID()
case shopinvitations.FieldPlayerID:
return m.AddedPlayerID()
case shopinvitations.FieldInvitedBy:
return m.AddedInvitedBy()
}
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 *ShopInvitationsMutation) AddField(name string, value ent.Value) error {
switch name {
case shopinvitations.FieldShopID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddShopID(v)
return nil
case shopinvitations.FieldPlayerID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddPlayerID(v)
return nil
case shopinvitations.FieldInvitedBy:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddInvitedBy(v)
return nil
}
return fmt.Errorf("unknown ShopInvitations numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ShopInvitationsMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(shopinvitations.FieldRespondedAt) {
fields = append(fields, shopinvitations.FieldRespondedAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ShopInvitationsMutation) 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 *ShopInvitationsMutation) ClearField(name string) error {
switch name {
case shopinvitations.FieldRespondedAt:
m.ClearRespondedAt()
return nil
}
return fmt.Errorf("unknown ShopInvitations 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 *ShopInvitationsMutation) ResetField(name string) error {
switch name {
case shopinvitations.FieldShopID:
m.ResetShopID()
return nil
case shopinvitations.FieldPlayerID:
m.ResetPlayerID()
return nil
case shopinvitations.FieldStatus:
m.ResetStatus()
return nil
case shopinvitations.FieldInvitedBy:
m.ResetInvitedBy()
return nil
case shopinvitations.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case shopinvitations.FieldRespondedAt:
m.ResetRespondedAt()
return nil
}
return fmt.Errorf("unknown ShopInvitations field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ShopInvitationsMutation) 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 *ShopInvitationsMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ShopInvitationsMutation) 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 *ShopInvitationsMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ShopInvitationsMutation) 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 *ShopInvitationsMutation) 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 *ShopInvitationsMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown ShopInvitations 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 *ShopInvitationsMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown ShopInvitations edge %s", name)
}
// ShopPlayersMutation represents an operation that mutates the ShopPlayers nodes in the graph.
type ShopPlayersMutation struct {
config
op Op
typ string
id *int64
shop_id *int64
addshop_id *int64
player_id *int64
addplayer_id *int64
is_primary *bool
joined_at *time.Time
left_at *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*ShopPlayers, error)
predicates []predicate.ShopPlayers
}
var _ ent.Mutation = (*ShopPlayersMutation)(nil)
// shopplayersOption allows management of the mutation configuration using functional options.
type shopplayersOption func(*ShopPlayersMutation)
// newShopPlayersMutation creates new mutation for the ShopPlayers entity.
func newShopPlayersMutation(c config, op Op, opts ...shopplayersOption) *ShopPlayersMutation {
m := &ShopPlayersMutation{
config: c,
op: op,
typ: TypeShopPlayers,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withShopPlayersID sets the ID field of the mutation.
func withShopPlayersID(id int64) shopplayersOption {
return func(m *ShopPlayersMutation) {
var (
err error
once sync.Once
value *ShopPlayers
)
m.oldValue = func(ctx context.Context) (*ShopPlayers, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().ShopPlayers.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withShopPlayers sets the old ShopPlayers of the mutation.
func withShopPlayers(node *ShopPlayers) shopplayersOption {
return func(m *ShopPlayersMutation) {
m.oldValue = func(context.Context) (*ShopPlayers, 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 ShopPlayersMutation) 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 ShopPlayersMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("models: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of ShopPlayers entities.
func (m *ShopPlayersMutation) SetID(id int64) {
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 *ShopPlayersMutation) ID() (id int64, 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 *ShopPlayersMutation) IDs(ctx context.Context) ([]int64, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []int64{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().ShopPlayers.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetShopID sets the "shop_id" field.
func (m *ShopPlayersMutation) SetShopID(i int64) {
m.shop_id = &i
m.addshop_id = nil
}
// ShopID returns the value of the "shop_id" field in the mutation.
func (m *ShopPlayersMutation) ShopID() (r int64, exists bool) {
v := m.shop_id
if v == nil {
return
}
return *v, true
}
// OldShopID returns the old "shop_id" field's value of the ShopPlayers entity.
// If the ShopPlayers 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 *ShopPlayersMutation) OldShopID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldShopID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldShopID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldShopID: %w", err)
}
return oldValue.ShopID, nil
}
// AddShopID adds i to the "shop_id" field.
func (m *ShopPlayersMutation) AddShopID(i int64) {
if m.addshop_id != nil {
*m.addshop_id += i
} else {
m.addshop_id = &i
}
}
// AddedShopID returns the value that was added to the "shop_id" field in this mutation.
func (m *ShopPlayersMutation) AddedShopID() (r int64, exists bool) {
v := m.addshop_id
if v == nil {
return
}
return *v, true
}
// ResetShopID resets all changes to the "shop_id" field.
func (m *ShopPlayersMutation) ResetShopID() {
m.shop_id = nil
m.addshop_id = nil
}
// SetPlayerID sets the "player_id" field.
func (m *ShopPlayersMutation) SetPlayerID(i int64) {
m.player_id = &i
m.addplayer_id = nil
}
// PlayerID returns the value of the "player_id" field in the mutation.
func (m *ShopPlayersMutation) PlayerID() (r int64, exists bool) {
v := m.player_id
if v == nil {
return
}
return *v, true
}
// OldPlayerID returns the old "player_id" field's value of the ShopPlayers entity.
// If the ShopPlayers 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 *ShopPlayersMutation) OldPlayerID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPlayerID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPlayerID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPlayerID: %w", err)
}
return oldValue.PlayerID, nil
}
// AddPlayerID adds i to the "player_id" field.
func (m *ShopPlayersMutation) AddPlayerID(i int64) {
if m.addplayer_id != nil {
*m.addplayer_id += i
} else {
m.addplayer_id = &i
}
}
// AddedPlayerID returns the value that was added to the "player_id" field in this mutation.
func (m *ShopPlayersMutation) AddedPlayerID() (r int64, exists bool) {
v := m.addplayer_id
if v == nil {
return
}
return *v, true
}
// ResetPlayerID resets all changes to the "player_id" field.
func (m *ShopPlayersMutation) ResetPlayerID() {
m.player_id = nil
m.addplayer_id = nil
}
// SetIsPrimary sets the "is_primary" field.
func (m *ShopPlayersMutation) SetIsPrimary(b bool) {
m.is_primary = &b
}
// IsPrimary returns the value of the "is_primary" field in the mutation.
func (m *ShopPlayersMutation) IsPrimary() (r bool, exists bool) {
v := m.is_primary
if v == nil {
return
}
return *v, true
}
// OldIsPrimary returns the old "is_primary" field's value of the ShopPlayers entity.
// If the ShopPlayers 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 *ShopPlayersMutation) OldIsPrimary(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldIsPrimary is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldIsPrimary requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldIsPrimary: %w", err)
}
return oldValue.IsPrimary, nil
}
// ClearIsPrimary clears the value of the "is_primary" field.
func (m *ShopPlayersMutation) ClearIsPrimary() {
m.is_primary = nil
m.clearedFields[shopplayers.FieldIsPrimary] = struct{}{}
}
// IsPrimaryCleared returns if the "is_primary" field was cleared in this mutation.
func (m *ShopPlayersMutation) IsPrimaryCleared() bool {
_, ok := m.clearedFields[shopplayers.FieldIsPrimary]
return ok
}
// ResetIsPrimary resets all changes to the "is_primary" field.
func (m *ShopPlayersMutation) ResetIsPrimary() {
m.is_primary = nil
delete(m.clearedFields, shopplayers.FieldIsPrimary)
}
// SetJoinedAt sets the "joined_at" field.
func (m *ShopPlayersMutation) SetJoinedAt(t time.Time) {
m.joined_at = &t
}
// JoinedAt returns the value of the "joined_at" field in the mutation.
func (m *ShopPlayersMutation) JoinedAt() (r time.Time, exists bool) {
v := m.joined_at
if v == nil {
return
}
return *v, true
}
// OldJoinedAt returns the old "joined_at" field's value of the ShopPlayers entity.
// If the ShopPlayers 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 *ShopPlayersMutation) OldJoinedAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldJoinedAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldJoinedAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldJoinedAt: %w", err)
}
return oldValue.JoinedAt, nil
}
// ResetJoinedAt resets all changes to the "joined_at" field.
func (m *ShopPlayersMutation) ResetJoinedAt() {
m.joined_at = nil
}
// SetLeftAt sets the "left_at" field.
func (m *ShopPlayersMutation) SetLeftAt(t time.Time) {
m.left_at = &t
}
// LeftAt returns the value of the "left_at" field in the mutation.
func (m *ShopPlayersMutation) LeftAt() (r time.Time, exists bool) {
v := m.left_at
if v == nil {
return
}
return *v, true
}
// OldLeftAt returns the old "left_at" field's value of the ShopPlayers entity.
// If the ShopPlayers 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 *ShopPlayersMutation) OldLeftAt(ctx context.Context) (v *time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLeftAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLeftAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLeftAt: %w", err)
}
return oldValue.LeftAt, nil
}
// ClearLeftAt clears the value of the "left_at" field.
func (m *ShopPlayersMutation) ClearLeftAt() {
m.left_at = nil
m.clearedFields[shopplayers.FieldLeftAt] = struct{}{}
}
// LeftAtCleared returns if the "left_at" field was cleared in this mutation.
func (m *ShopPlayersMutation) LeftAtCleared() bool {
_, ok := m.clearedFields[shopplayers.FieldLeftAt]
return ok
}
// ResetLeftAt resets all changes to the "left_at" field.
func (m *ShopPlayersMutation) ResetLeftAt() {
m.left_at = nil
delete(m.clearedFields, shopplayers.FieldLeftAt)
}
// Where appends a list predicates to the ShopPlayersMutation builder.
func (m *ShopPlayersMutation) Where(ps ...predicate.ShopPlayers) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ShopPlayersMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ShopPlayersMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.ShopPlayers, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ShopPlayersMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ShopPlayersMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (ShopPlayers).
func (m *ShopPlayersMutation) 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 *ShopPlayersMutation) Fields() []string {
fields := make([]string, 0, 5)
if m.shop_id != nil {
fields = append(fields, shopplayers.FieldShopID)
}
if m.player_id != nil {
fields = append(fields, shopplayers.FieldPlayerID)
}
if m.is_primary != nil {
fields = append(fields, shopplayers.FieldIsPrimary)
}
if m.joined_at != nil {
fields = append(fields, shopplayers.FieldJoinedAt)
}
if m.left_at != nil {
fields = append(fields, shopplayers.FieldLeftAt)
}
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 *ShopPlayersMutation) Field(name string) (ent.Value, bool) {
switch name {
case shopplayers.FieldShopID:
return m.ShopID()
case shopplayers.FieldPlayerID:
return m.PlayerID()
case shopplayers.FieldIsPrimary:
return m.IsPrimary()
case shopplayers.FieldJoinedAt:
return m.JoinedAt()
case shopplayers.FieldLeftAt:
return m.LeftAt()
}
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 *ShopPlayersMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case shopplayers.FieldShopID:
return m.OldShopID(ctx)
case shopplayers.FieldPlayerID:
return m.OldPlayerID(ctx)
case shopplayers.FieldIsPrimary:
return m.OldIsPrimary(ctx)
case shopplayers.FieldJoinedAt:
return m.OldJoinedAt(ctx)
case shopplayers.FieldLeftAt:
return m.OldLeftAt(ctx)
}
return nil, fmt.Errorf("unknown ShopPlayers 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 *ShopPlayersMutation) SetField(name string, value ent.Value) error {
switch name {
case shopplayers.FieldShopID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetShopID(v)
return nil
case shopplayers.FieldPlayerID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPlayerID(v)
return nil
case shopplayers.FieldIsPrimary:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetIsPrimary(v)
return nil
case shopplayers.FieldJoinedAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetJoinedAt(v)
return nil
case shopplayers.FieldLeftAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLeftAt(v)
return nil
}
return fmt.Errorf("unknown ShopPlayers field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ShopPlayersMutation) AddedFields() []string {
var fields []string
if m.addshop_id != nil {
fields = append(fields, shopplayers.FieldShopID)
}
if m.addplayer_id != nil {
fields = append(fields, shopplayers.FieldPlayerID)
}
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 *ShopPlayersMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case shopplayers.FieldShopID:
return m.AddedShopID()
case shopplayers.FieldPlayerID:
return m.AddedPlayerID()
}
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 *ShopPlayersMutation) AddField(name string, value ent.Value) error {
switch name {
case shopplayers.FieldShopID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddShopID(v)
return nil
case shopplayers.FieldPlayerID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddPlayerID(v)
return nil
}
return fmt.Errorf("unknown ShopPlayers numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ShopPlayersMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(shopplayers.FieldIsPrimary) {
fields = append(fields, shopplayers.FieldIsPrimary)
}
if m.FieldCleared(shopplayers.FieldLeftAt) {
fields = append(fields, shopplayers.FieldLeftAt)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ShopPlayersMutation) 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 *ShopPlayersMutation) ClearField(name string) error {
switch name {
case shopplayers.FieldIsPrimary:
m.ClearIsPrimary()
return nil
case shopplayers.FieldLeftAt:
m.ClearLeftAt()
return nil
}
return fmt.Errorf("unknown ShopPlayers 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 *ShopPlayersMutation) ResetField(name string) error {
switch name {
case shopplayers.FieldShopID:
m.ResetShopID()
return nil
case shopplayers.FieldPlayerID:
m.ResetPlayerID()
return nil
case shopplayers.FieldIsPrimary:
m.ResetIsPrimary()
return nil
case shopplayers.FieldJoinedAt:
m.ResetJoinedAt()
return nil
case shopplayers.FieldLeftAt:
m.ResetLeftAt()
return nil
}
return fmt.Errorf("unknown ShopPlayers field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ShopPlayersMutation) 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 *ShopPlayersMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ShopPlayersMutation) 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 *ShopPlayersMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ShopPlayersMutation) 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 *ShopPlayersMutation) 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 *ShopPlayersMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown ShopPlayers 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 *ShopPlayersMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown ShopPlayers edge %s", name)
}
// ShopsMutation represents an operation that mutates the Shops nodes in the graph.
type ShopsMutation struct {
config
op Op
typ string
id *int64
owner_id *int64
addowner_id *int64
name *string
banner *string
description *string
rating *decimal.Decimal
total_orders *int
addtotal_orders *int
player_count *int
addplayer_count *int
commission_type *string
commission_value *decimal.Decimal
allow_multi_shop *bool
allow_independent_orders *bool
dispatch_mode *string
announcements *[]string
appendannouncements []string
template_config *map[string]interface{}
created_at *time.Time
updated_at *time.Time
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*Shops, error)
predicates []predicate.Shops
}
var _ ent.Mutation = (*ShopsMutation)(nil)
// shopsOption allows management of the mutation configuration using functional options.
type shopsOption func(*ShopsMutation)
// newShopsMutation creates new mutation for the Shops entity.
func newShopsMutation(c config, op Op, opts ...shopsOption) *ShopsMutation {
m := &ShopsMutation{
config: c,
op: op,
typ: TypeShops,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withShopsID sets the ID field of the mutation.
func withShopsID(id int64) shopsOption {
return func(m *ShopsMutation) {
var (
err error
once sync.Once
value *Shops
)
m.oldValue = func(ctx context.Context) (*Shops, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().Shops.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withShops sets the old Shops of the mutation.
func withShops(node *Shops) shopsOption {
return func(m *ShopsMutation) {
m.oldValue = func(context.Context) (*Shops, 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 ShopsMutation) 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 ShopsMutation) Tx() (*Tx, error) {
if _, ok := m.driver.(*txDriver); !ok {
return nil, errors.New("models: mutation is not running in a transaction")
}
tx := &Tx{config: m.config}
tx.init()
return tx, nil
}
// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of Shops entities.
func (m *ShopsMutation) SetID(id int64) {
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 *ShopsMutation) ID() (id int64, 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 *ShopsMutation) IDs(ctx context.Context) ([]int64, error) {
switch {
case m.op.Is(OpUpdateOne | OpDeleteOne):
id, exists := m.ID()
if exists {
return []int64{id}, nil
}
fallthrough
case m.op.Is(OpUpdate | OpDelete):
return m.Client().Shops.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetOwnerID sets the "owner_id" field.
func (m *ShopsMutation) SetOwnerID(i int64) {
m.owner_id = &i
m.addowner_id = nil
}
// OwnerID returns the value of the "owner_id" field in the mutation.
func (m *ShopsMutation) OwnerID() (r int64, exists bool) {
v := m.owner_id
if v == nil {
return
}
return *v, true
}
// OldOwnerID returns the old "owner_id" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldOwnerID(ctx context.Context) (v int64, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldOwnerID is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldOwnerID requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldOwnerID: %w", err)
}
return oldValue.OwnerID, nil
}
// AddOwnerID adds i to the "owner_id" field.
func (m *ShopsMutation) AddOwnerID(i int64) {
if m.addowner_id != nil {
*m.addowner_id += i
} else {
m.addowner_id = &i
}
}
// AddedOwnerID returns the value that was added to the "owner_id" field in this mutation.
func (m *ShopsMutation) AddedOwnerID() (r int64, exists bool) {
v := m.addowner_id
if v == nil {
return
}
return *v, true
}
// ResetOwnerID resets all changes to the "owner_id" field.
func (m *ShopsMutation) ResetOwnerID() {
m.owner_id = nil
m.addowner_id = nil
}
// SetName sets the "name" field.
func (m *ShopsMutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *ShopsMutation) 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 Shops entity.
// If the Shops 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 *ShopsMutation) 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 *ShopsMutation) ResetName() {
m.name = nil
}
// SetBanner sets the "banner" field.
func (m *ShopsMutation) SetBanner(s string) {
m.banner = &s
}
// Banner returns the value of the "banner" field in the mutation.
func (m *ShopsMutation) Banner() (r string, exists bool) {
v := m.banner
if v == nil {
return
}
return *v, true
}
// OldBanner returns the old "banner" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldBanner(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldBanner is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldBanner requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldBanner: %w", err)
}
return oldValue.Banner, nil
}
// ClearBanner clears the value of the "banner" field.
func (m *ShopsMutation) ClearBanner() {
m.banner = nil
m.clearedFields[shops.FieldBanner] = struct{}{}
}
// BannerCleared returns if the "banner" field was cleared in this mutation.
func (m *ShopsMutation) BannerCleared() bool {
_, ok := m.clearedFields[shops.FieldBanner]
return ok
}
// ResetBanner resets all changes to the "banner" field.
func (m *ShopsMutation) ResetBanner() {
m.banner = nil
delete(m.clearedFields, shops.FieldBanner)
}
// SetDescription sets the "description" field.
func (m *ShopsMutation) SetDescription(s string) {
m.description = &s
}
// Description returns the value of the "description" field in the mutation.
func (m *ShopsMutation) Description() (r string, exists bool) {
v := m.description
if v == nil {
return
}
return *v, true
}
// OldDescription returns the old "description" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) 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 m.id == nil || 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
}
// ClearDescription clears the value of the "description" field.
func (m *ShopsMutation) ClearDescription() {
m.description = nil
m.clearedFields[shops.FieldDescription] = struct{}{}
}
// DescriptionCleared returns if the "description" field was cleared in this mutation.
func (m *ShopsMutation) DescriptionCleared() bool {
_, ok := m.clearedFields[shops.FieldDescription]
return ok
}
// ResetDescription resets all changes to the "description" field.
func (m *ShopsMutation) ResetDescription() {
m.description = nil
delete(m.clearedFields, shops.FieldDescription)
}
// SetRating sets the "rating" field.
func (m *ShopsMutation) SetRating(d decimal.Decimal) {
m.rating = &d
}
// Rating returns the value of the "rating" field in the mutation.
func (m *ShopsMutation) Rating() (r decimal.Decimal, exists bool) {
v := m.rating
if v == nil {
return
}
return *v, true
}
// OldRating returns the old "rating" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldRating(ctx context.Context) (v decimal.Decimal, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldRating is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldRating requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldRating: %w", err)
}
return oldValue.Rating, nil
}
// ClearRating clears the value of the "rating" field.
func (m *ShopsMutation) ClearRating() {
m.rating = nil
m.clearedFields[shops.FieldRating] = struct{}{}
}
// RatingCleared returns if the "rating" field was cleared in this mutation.
func (m *ShopsMutation) RatingCleared() bool {
_, ok := m.clearedFields[shops.FieldRating]
return ok
}
// ResetRating resets all changes to the "rating" field.
func (m *ShopsMutation) ResetRating() {
m.rating = nil
delete(m.clearedFields, shops.FieldRating)
}
// SetTotalOrders sets the "total_orders" field.
func (m *ShopsMutation) SetTotalOrders(i int) {
m.total_orders = &i
m.addtotal_orders = nil
}
// TotalOrders returns the value of the "total_orders" field in the mutation.
func (m *ShopsMutation) TotalOrders() (r int, exists bool) {
v := m.total_orders
if v == nil {
return
}
return *v, true
}
// OldTotalOrders returns the old "total_orders" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldTotalOrders(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTotalOrders is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTotalOrders requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTotalOrders: %w", err)
}
return oldValue.TotalOrders, nil
}
// AddTotalOrders adds i to the "total_orders" field.
func (m *ShopsMutation) AddTotalOrders(i int) {
if m.addtotal_orders != nil {
*m.addtotal_orders += i
} else {
m.addtotal_orders = &i
}
}
// AddedTotalOrders returns the value that was added to the "total_orders" field in this mutation.
func (m *ShopsMutation) AddedTotalOrders() (r int, exists bool) {
v := m.addtotal_orders
if v == nil {
return
}
return *v, true
}
// ClearTotalOrders clears the value of the "total_orders" field.
func (m *ShopsMutation) ClearTotalOrders() {
m.total_orders = nil
m.addtotal_orders = nil
m.clearedFields[shops.FieldTotalOrders] = struct{}{}
}
// TotalOrdersCleared returns if the "total_orders" field was cleared in this mutation.
func (m *ShopsMutation) TotalOrdersCleared() bool {
_, ok := m.clearedFields[shops.FieldTotalOrders]
return ok
}
// ResetTotalOrders resets all changes to the "total_orders" field.
func (m *ShopsMutation) ResetTotalOrders() {
m.total_orders = nil
m.addtotal_orders = nil
delete(m.clearedFields, shops.FieldTotalOrders)
}
// SetPlayerCount sets the "player_count" field.
func (m *ShopsMutation) SetPlayerCount(i int) {
m.player_count = &i
m.addplayer_count = nil
}
// PlayerCount returns the value of the "player_count" field in the mutation.
func (m *ShopsMutation) PlayerCount() (r int, exists bool) {
v := m.player_count
if v == nil {
return
}
return *v, true
}
// OldPlayerCount returns the old "player_count" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldPlayerCount(ctx context.Context) (v int, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPlayerCount is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPlayerCount requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPlayerCount: %w", err)
}
return oldValue.PlayerCount, nil
}
// AddPlayerCount adds i to the "player_count" field.
func (m *ShopsMutation) AddPlayerCount(i int) {
if m.addplayer_count != nil {
*m.addplayer_count += i
} else {
m.addplayer_count = &i
}
}
// AddedPlayerCount returns the value that was added to the "player_count" field in this mutation.
func (m *ShopsMutation) AddedPlayerCount() (r int, exists bool) {
v := m.addplayer_count
if v == nil {
return
}
return *v, true
}
// ClearPlayerCount clears the value of the "player_count" field.
func (m *ShopsMutation) ClearPlayerCount() {
m.player_count = nil
m.addplayer_count = nil
m.clearedFields[shops.FieldPlayerCount] = struct{}{}
}
// PlayerCountCleared returns if the "player_count" field was cleared in this mutation.
func (m *ShopsMutation) PlayerCountCleared() bool {
_, ok := m.clearedFields[shops.FieldPlayerCount]
return ok
}
// ResetPlayerCount resets all changes to the "player_count" field.
func (m *ShopsMutation) ResetPlayerCount() {
m.player_count = nil
m.addplayer_count = nil
delete(m.clearedFields, shops.FieldPlayerCount)
}
// SetCommissionType sets the "commission_type" field.
func (m *ShopsMutation) SetCommissionType(s string) {
m.commission_type = &s
}
// CommissionType returns the value of the "commission_type" field in the mutation.
func (m *ShopsMutation) CommissionType() (r string, exists bool) {
v := m.commission_type
if v == nil {
return
}
return *v, true
}
// OldCommissionType returns the old "commission_type" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldCommissionType(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCommissionType is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCommissionType requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCommissionType: %w", err)
}
return oldValue.CommissionType, nil
}
// ResetCommissionType resets all changes to the "commission_type" field.
func (m *ShopsMutation) ResetCommissionType() {
m.commission_type = nil
}
// SetCommissionValue sets the "commission_value" field.
func (m *ShopsMutation) SetCommissionValue(d decimal.Decimal) {
m.commission_value = &d
}
// CommissionValue returns the value of the "commission_value" field in the mutation.
func (m *ShopsMutation) CommissionValue() (r decimal.Decimal, exists bool) {
v := m.commission_value
if v == nil {
return
}
return *v, true
}
// OldCommissionValue returns the old "commission_value" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldCommissionValue(ctx context.Context) (v decimal.Decimal, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldCommissionValue is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldCommissionValue requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldCommissionValue: %w", err)
}
return oldValue.CommissionValue, nil
}
// ResetCommissionValue resets all changes to the "commission_value" field.
func (m *ShopsMutation) ResetCommissionValue() {
m.commission_value = nil
}
// SetAllowMultiShop sets the "allow_multi_shop" field.
func (m *ShopsMutation) SetAllowMultiShop(b bool) {
m.allow_multi_shop = &b
}
// AllowMultiShop returns the value of the "allow_multi_shop" field in the mutation.
func (m *ShopsMutation) AllowMultiShop() (r bool, exists bool) {
v := m.allow_multi_shop
if v == nil {
return
}
return *v, true
}
// OldAllowMultiShop returns the old "allow_multi_shop" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldAllowMultiShop(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAllowMultiShop is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAllowMultiShop requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAllowMultiShop: %w", err)
}
return oldValue.AllowMultiShop, nil
}
// ClearAllowMultiShop clears the value of the "allow_multi_shop" field.
func (m *ShopsMutation) ClearAllowMultiShop() {
m.allow_multi_shop = nil
m.clearedFields[shops.FieldAllowMultiShop] = struct{}{}
}
// AllowMultiShopCleared returns if the "allow_multi_shop" field was cleared in this mutation.
func (m *ShopsMutation) AllowMultiShopCleared() bool {
_, ok := m.clearedFields[shops.FieldAllowMultiShop]
return ok
}
// ResetAllowMultiShop resets all changes to the "allow_multi_shop" field.
func (m *ShopsMutation) ResetAllowMultiShop() {
m.allow_multi_shop = nil
delete(m.clearedFields, shops.FieldAllowMultiShop)
}
// SetAllowIndependentOrders sets the "allow_independent_orders" field.
func (m *ShopsMutation) SetAllowIndependentOrders(b bool) {
m.allow_independent_orders = &b
}
// AllowIndependentOrders returns the value of the "allow_independent_orders" field in the mutation.
func (m *ShopsMutation) AllowIndependentOrders() (r bool, exists bool) {
v := m.allow_independent_orders
if v == nil {
return
}
return *v, true
}
// OldAllowIndependentOrders returns the old "allow_independent_orders" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldAllowIndependentOrders(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAllowIndependentOrders is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAllowIndependentOrders requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAllowIndependentOrders: %w", err)
}
return oldValue.AllowIndependentOrders, nil
}
// ClearAllowIndependentOrders clears the value of the "allow_independent_orders" field.
func (m *ShopsMutation) ClearAllowIndependentOrders() {
m.allow_independent_orders = nil
m.clearedFields[shops.FieldAllowIndependentOrders] = struct{}{}
}
// AllowIndependentOrdersCleared returns if the "allow_independent_orders" field was cleared in this mutation.
func (m *ShopsMutation) AllowIndependentOrdersCleared() bool {
_, ok := m.clearedFields[shops.FieldAllowIndependentOrders]
return ok
}
// ResetAllowIndependentOrders resets all changes to the "allow_independent_orders" field.
func (m *ShopsMutation) ResetAllowIndependentOrders() {
m.allow_independent_orders = nil
delete(m.clearedFields, shops.FieldAllowIndependentOrders)
}
// SetDispatchMode sets the "dispatch_mode" field.
func (m *ShopsMutation) SetDispatchMode(s string) {
m.dispatch_mode = &s
}
// DispatchMode returns the value of the "dispatch_mode" field in the mutation.
func (m *ShopsMutation) DispatchMode() (r string, exists bool) {
v := m.dispatch_mode
if v == nil {
return
}
return *v, true
}
// OldDispatchMode returns the old "dispatch_mode" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldDispatchMode(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDispatchMode is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDispatchMode requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDispatchMode: %w", err)
}
return oldValue.DispatchMode, nil
}
// ResetDispatchMode resets all changes to the "dispatch_mode" field.
func (m *ShopsMutation) ResetDispatchMode() {
m.dispatch_mode = nil
}
// SetAnnouncements sets the "announcements" field.
func (m *ShopsMutation) SetAnnouncements(s []string) {
m.announcements = &s
m.appendannouncements = nil
}
// Announcements returns the value of the "announcements" field in the mutation.
func (m *ShopsMutation) Announcements() (r []string, exists bool) {
v := m.announcements
if v == nil {
return
}
return *v, true
}
// OldAnnouncements returns the old "announcements" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldAnnouncements(ctx context.Context) (v []string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldAnnouncements is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldAnnouncements requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldAnnouncements: %w", err)
}
return oldValue.Announcements, nil
}
// AppendAnnouncements adds s to the "announcements" field.
func (m *ShopsMutation) AppendAnnouncements(s []string) {
m.appendannouncements = append(m.appendannouncements, s...)
}
// AppendedAnnouncements returns the list of values that were appended to the "announcements" field in this mutation.
func (m *ShopsMutation) AppendedAnnouncements() ([]string, bool) {
if len(m.appendannouncements) == 0 {
return nil, false
}
return m.appendannouncements, true
}
// ClearAnnouncements clears the value of the "announcements" field.
func (m *ShopsMutation) ClearAnnouncements() {
m.announcements = nil
m.appendannouncements = nil
m.clearedFields[shops.FieldAnnouncements] = struct{}{}
}
// AnnouncementsCleared returns if the "announcements" field was cleared in this mutation.
func (m *ShopsMutation) AnnouncementsCleared() bool {
_, ok := m.clearedFields[shops.FieldAnnouncements]
return ok
}
// ResetAnnouncements resets all changes to the "announcements" field.
func (m *ShopsMutation) ResetAnnouncements() {
m.announcements = nil
m.appendannouncements = nil
delete(m.clearedFields, shops.FieldAnnouncements)
}
// SetTemplateConfig sets the "template_config" field.
func (m *ShopsMutation) SetTemplateConfig(value map[string]interface{}) {
m.template_config = &value
}
// TemplateConfig returns the value of the "template_config" field in the mutation.
func (m *ShopsMutation) TemplateConfig() (r map[string]interface{}, exists bool) {
v := m.template_config
if v == nil {
return
}
return *v, true
}
// OldTemplateConfig returns the old "template_config" field's value of the Shops entity.
// If the Shops 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 *ShopsMutation) OldTemplateConfig(ctx context.Context) (v map[string]interface{}, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldTemplateConfig is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldTemplateConfig requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldTemplateConfig: %w", err)
}
return oldValue.TemplateConfig, nil
}
// ClearTemplateConfig clears the value of the "template_config" field.
func (m *ShopsMutation) ClearTemplateConfig() {
m.template_config = nil
m.clearedFields[shops.FieldTemplateConfig] = struct{}{}
}
// TemplateConfigCleared returns if the "template_config" field was cleared in this mutation.
func (m *ShopsMutation) TemplateConfigCleared() bool {
_, ok := m.clearedFields[shops.FieldTemplateConfig]
return ok
}
// ResetTemplateConfig resets all changes to the "template_config" field.
func (m *ShopsMutation) ResetTemplateConfig() {
m.template_config = nil
delete(m.clearedFields, shops.FieldTemplateConfig)
}
// SetCreatedAt sets the "created_at" field.
func (m *ShopsMutation) SetCreatedAt(t time.Time) {
m.created_at = &t
}
// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *ShopsMutation) 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 Shops entity.
// If the Shops 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 *ShopsMutation) 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 *ShopsMutation) ResetCreatedAt() {
m.created_at = nil
}
// SetUpdatedAt sets the "updated_at" field.
func (m *ShopsMutation) SetUpdatedAt(t time.Time) {
m.updated_at = &t
}
// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *ShopsMutation) 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 Shops entity.
// If the Shops 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 *ShopsMutation) 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 *ShopsMutation) ResetUpdatedAt() {
m.updated_at = nil
}
// Where appends a list predicates to the ShopsMutation builder.
func (m *ShopsMutation) Where(ps ...predicate.Shops) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the ShopsMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *ShopsMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Shops, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *ShopsMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *ShopsMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Shops).
func (m *ShopsMutation) 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 *ShopsMutation) Fields() []string {
fields := make([]string, 0, 16)
if m.owner_id != nil {
fields = append(fields, shops.FieldOwnerID)
}
if m.name != nil {
fields = append(fields, shops.FieldName)
}
if m.banner != nil {
fields = append(fields, shops.FieldBanner)
}
if m.description != nil {
fields = append(fields, shops.FieldDescription)
}
if m.rating != nil {
fields = append(fields, shops.FieldRating)
}
if m.total_orders != nil {
fields = append(fields, shops.FieldTotalOrders)
}
if m.player_count != nil {
fields = append(fields, shops.FieldPlayerCount)
}
if m.commission_type != nil {
fields = append(fields, shops.FieldCommissionType)
}
if m.commission_value != nil {
fields = append(fields, shops.FieldCommissionValue)
}
if m.allow_multi_shop != nil {
fields = append(fields, shops.FieldAllowMultiShop)
}
if m.allow_independent_orders != nil {
fields = append(fields, shops.FieldAllowIndependentOrders)
}
if m.dispatch_mode != nil {
fields = append(fields, shops.FieldDispatchMode)
}
if m.announcements != nil {
fields = append(fields, shops.FieldAnnouncements)
}
if m.template_config != nil {
fields = append(fields, shops.FieldTemplateConfig)
}
if m.created_at != nil {
fields = append(fields, shops.FieldCreatedAt)
}
if m.updated_at != nil {
fields = append(fields, shops.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 *ShopsMutation) Field(name string) (ent.Value, bool) {
switch name {
case shops.FieldOwnerID:
return m.OwnerID()
case shops.FieldName:
return m.Name()
case shops.FieldBanner:
return m.Banner()
case shops.FieldDescription:
return m.Description()
case shops.FieldRating:
return m.Rating()
case shops.FieldTotalOrders:
return m.TotalOrders()
case shops.FieldPlayerCount:
return m.PlayerCount()
case shops.FieldCommissionType:
return m.CommissionType()
case shops.FieldCommissionValue:
return m.CommissionValue()
case shops.FieldAllowMultiShop:
return m.AllowMultiShop()
case shops.FieldAllowIndependentOrders:
return m.AllowIndependentOrders()
case shops.FieldDispatchMode:
return m.DispatchMode()
case shops.FieldAnnouncements:
return m.Announcements()
case shops.FieldTemplateConfig:
return m.TemplateConfig()
case shops.FieldCreatedAt:
return m.CreatedAt()
case shops.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 *ShopsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case shops.FieldOwnerID:
return m.OldOwnerID(ctx)
case shops.FieldName:
return m.OldName(ctx)
case shops.FieldBanner:
return m.OldBanner(ctx)
case shops.FieldDescription:
return m.OldDescription(ctx)
case shops.FieldRating:
return m.OldRating(ctx)
case shops.FieldTotalOrders:
return m.OldTotalOrders(ctx)
case shops.FieldPlayerCount:
return m.OldPlayerCount(ctx)
case shops.FieldCommissionType:
return m.OldCommissionType(ctx)
case shops.FieldCommissionValue:
return m.OldCommissionValue(ctx)
case shops.FieldAllowMultiShop:
return m.OldAllowMultiShop(ctx)
case shops.FieldAllowIndependentOrders:
return m.OldAllowIndependentOrders(ctx)
case shops.FieldDispatchMode:
return m.OldDispatchMode(ctx)
case shops.FieldAnnouncements:
return m.OldAnnouncements(ctx)
case shops.FieldTemplateConfig:
return m.OldTemplateConfig(ctx)
case shops.FieldCreatedAt:
return m.OldCreatedAt(ctx)
case shops.FieldUpdatedAt:
return m.OldUpdatedAt(ctx)
}
return nil, fmt.Errorf("unknown Shops 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 *ShopsMutation) SetField(name string, value ent.Value) error {
switch name {
case shops.FieldOwnerID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOwnerID(v)
return nil
case shops.FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case shops.FieldBanner:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBanner(v)
return nil
case shops.FieldDescription:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDescription(v)
return nil
case shops.FieldRating:
v, ok := value.(decimal.Decimal)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRating(v)
return nil
case shops.FieldTotalOrders:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTotalOrders(v)
return nil
case shops.FieldPlayerCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPlayerCount(v)
return nil
case shops.FieldCommissionType:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCommissionType(v)
return nil
case shops.FieldCommissionValue:
v, ok := value.(decimal.Decimal)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCommissionValue(v)
return nil
case shops.FieldAllowMultiShop:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAllowMultiShop(v)
return nil
case shops.FieldAllowIndependentOrders:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAllowIndependentOrders(v)
return nil
case shops.FieldDispatchMode:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDispatchMode(v)
return nil
case shops.FieldAnnouncements:
v, ok := value.([]string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAnnouncements(v)
return nil
case shops.FieldTemplateConfig:
v, ok := value.(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetTemplateConfig(v)
return nil
case shops.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 shops.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 Shops field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *ShopsMutation) AddedFields() []string {
var fields []string
if m.addowner_id != nil {
fields = append(fields, shops.FieldOwnerID)
}
if m.addtotal_orders != nil {
fields = append(fields, shops.FieldTotalOrders)
}
if m.addplayer_count != nil {
fields = append(fields, shops.FieldPlayerCount)
}
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 *ShopsMutation) AddedField(name string) (ent.Value, bool) {
switch name {
case shops.FieldOwnerID:
return m.AddedOwnerID()
case shops.FieldTotalOrders:
return m.AddedTotalOrders()
case shops.FieldPlayerCount:
return m.AddedPlayerCount()
}
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 *ShopsMutation) AddField(name string, value ent.Value) error {
switch name {
case shops.FieldOwnerID:
v, ok := value.(int64)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddOwnerID(v)
return nil
case shops.FieldTotalOrders:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddTotalOrders(v)
return nil
case shops.FieldPlayerCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddPlayerCount(v)
return nil
}
return fmt.Errorf("unknown Shops numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *ShopsMutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(shops.FieldBanner) {
fields = append(fields, shops.FieldBanner)
}
if m.FieldCleared(shops.FieldDescription) {
fields = append(fields, shops.FieldDescription)
}
if m.FieldCleared(shops.FieldRating) {
fields = append(fields, shops.FieldRating)
}
if m.FieldCleared(shops.FieldTotalOrders) {
fields = append(fields, shops.FieldTotalOrders)
}
if m.FieldCleared(shops.FieldPlayerCount) {
fields = append(fields, shops.FieldPlayerCount)
}
if m.FieldCleared(shops.FieldAllowMultiShop) {
fields = append(fields, shops.FieldAllowMultiShop)
}
if m.FieldCleared(shops.FieldAllowIndependentOrders) {
fields = append(fields, shops.FieldAllowIndependentOrders)
}
if m.FieldCleared(shops.FieldAnnouncements) {
fields = append(fields, shops.FieldAnnouncements)
}
if m.FieldCleared(shops.FieldTemplateConfig) {
fields = append(fields, shops.FieldTemplateConfig)
}
return fields
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *ShopsMutation) 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 *ShopsMutation) ClearField(name string) error {
switch name {
case shops.FieldBanner:
m.ClearBanner()
return nil
case shops.FieldDescription:
m.ClearDescription()
return nil
case shops.FieldRating:
m.ClearRating()
return nil
case shops.FieldTotalOrders:
m.ClearTotalOrders()
return nil
case shops.FieldPlayerCount:
m.ClearPlayerCount()
return nil
case shops.FieldAllowMultiShop:
m.ClearAllowMultiShop()
return nil
case shops.FieldAllowIndependentOrders:
m.ClearAllowIndependentOrders()
return nil
case shops.FieldAnnouncements:
m.ClearAnnouncements()
return nil
case shops.FieldTemplateConfig:
m.ClearTemplateConfig()
return nil
}
return fmt.Errorf("unknown Shops 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 *ShopsMutation) ResetField(name string) error {
switch name {
case shops.FieldOwnerID:
m.ResetOwnerID()
return nil
case shops.FieldName:
m.ResetName()
return nil
case shops.FieldBanner:
m.ResetBanner()
return nil
case shops.FieldDescription:
m.ResetDescription()
return nil
case shops.FieldRating:
m.ResetRating()
return nil
case shops.FieldTotalOrders:
m.ResetTotalOrders()
return nil
case shops.FieldPlayerCount:
m.ResetPlayerCount()
return nil
case shops.FieldCommissionType:
m.ResetCommissionType()
return nil
case shops.FieldCommissionValue:
m.ResetCommissionValue()
return nil
case shops.FieldAllowMultiShop:
m.ResetAllowMultiShop()
return nil
case shops.FieldAllowIndependentOrders:
m.ResetAllowIndependentOrders()
return nil
case shops.FieldDispatchMode:
m.ResetDispatchMode()
return nil
case shops.FieldAnnouncements:
m.ResetAnnouncements()
return nil
case shops.FieldTemplateConfig:
m.ResetTemplateConfig()
return nil
case shops.FieldCreatedAt:
m.ResetCreatedAt()
return nil
case shops.FieldUpdatedAt:
m.ResetUpdatedAt()
return nil
}
return fmt.Errorf("unknown Shops field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *ShopsMutation) 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 *ShopsMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *ShopsMutation) 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 *ShopsMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *ShopsMutation) 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 *ShopsMutation) 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 *ShopsMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown Shops 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 *ShopsMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown Shops edge %s", name)
}