3880 lines
104 KiB
Go
3880 lines
104 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"sync"
|
|
"t/ent/card"
|
|
"t/ent/group"
|
|
"t/ent/predicate"
|
|
"t/ent/user"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
const (
|
|
// Operation types.
|
|
OpCreate = ent.OpCreate
|
|
OpDelete = ent.OpDelete
|
|
OpDeleteOne = ent.OpDeleteOne
|
|
OpUpdate = ent.OpUpdate
|
|
OpUpdateOne = ent.OpUpdateOne
|
|
|
|
// Node types.
|
|
TypeCard = "Card"
|
|
TypeGroup = "Group"
|
|
TypeUser = "User"
|
|
)
|
|
|
|
// CardMutation represents an operation that mutates the Card nodes in the graph.
|
|
type CardMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
password *string
|
|
card *int
|
|
addcard *int
|
|
skill *string
|
|
status *string
|
|
token *string
|
|
cp *int
|
|
addcp *int
|
|
url *string
|
|
created_at *time.Time
|
|
clearedFields map[string]struct{}
|
|
owner *int
|
|
clearedowner bool
|
|
done bool
|
|
oldValue func(context.Context) (*Card, error)
|
|
predicates []predicate.Card
|
|
}
|
|
|
|
var _ ent.Mutation = (*CardMutation)(nil)
|
|
|
|
// cardOption allows management of the mutation configuration using functional options.
|
|
type cardOption func(*CardMutation)
|
|
|
|
// newCardMutation creates new mutation for the Card entity.
|
|
func newCardMutation(c config, op Op, opts ...cardOption) *CardMutation {
|
|
m := &CardMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeCard,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withCardID sets the ID field of the mutation.
|
|
func withCardID(id int) cardOption {
|
|
return func(m *CardMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Card
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Card, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Card.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withCard sets the old Card of the mutation.
|
|
func withCard(node *Card) cardOption {
|
|
return func(m *CardMutation) {
|
|
m.oldValue = func(context.Context) (*Card, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m CardMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m CardMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *CardMutation) ID() (id 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 *CardMutation) 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().Card.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (m *CardMutation) SetPassword(s string) {
|
|
m.password = &s
|
|
}
|
|
|
|
// Password returns the value of the "password" field in the mutation.
|
|
func (m *CardMutation) Password() (r string, exists bool) {
|
|
v := m.password
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldPassword returns the old "password" field's value of the Card entity.
|
|
// If the Card object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *CardMutation) OldPassword(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldPassword requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldPassword: %w", err)
|
|
}
|
|
return oldValue.Password, nil
|
|
}
|
|
|
|
// ResetPassword resets all changes to the "password" field.
|
|
func (m *CardMutation) ResetPassword() {
|
|
m.password = nil
|
|
}
|
|
|
|
// SetCard sets the "card" field.
|
|
func (m *CardMutation) SetCard(i int) {
|
|
m.card = &i
|
|
m.addcard = nil
|
|
}
|
|
|
|
// Card returns the value of the "card" field in the mutation.
|
|
func (m *CardMutation) Card() (r int, exists bool) {
|
|
v := m.card
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCard returns the old "card" field's value of the Card entity.
|
|
// If the Card object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *CardMutation) OldCard(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCard is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCard requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCard: %w", err)
|
|
}
|
|
return oldValue.Card, nil
|
|
}
|
|
|
|
// AddCard adds i to the "card" field.
|
|
func (m *CardMutation) AddCard(i int) {
|
|
if m.addcard != nil {
|
|
*m.addcard += i
|
|
} else {
|
|
m.addcard = &i
|
|
}
|
|
}
|
|
|
|
// AddedCard returns the value that was added to the "card" field in this mutation.
|
|
func (m *CardMutation) AddedCard() (r int, exists bool) {
|
|
v := m.addcard
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearCard clears the value of the "card" field.
|
|
func (m *CardMutation) ClearCard() {
|
|
m.card = nil
|
|
m.addcard = nil
|
|
m.clearedFields[card.FieldCard] = struct{}{}
|
|
}
|
|
|
|
// CardCleared returns if the "card" field was cleared in this mutation.
|
|
func (m *CardMutation) CardCleared() bool {
|
|
_, ok := m.clearedFields[card.FieldCard]
|
|
return ok
|
|
}
|
|
|
|
// ResetCard resets all changes to the "card" field.
|
|
func (m *CardMutation) ResetCard() {
|
|
m.card = nil
|
|
m.addcard = nil
|
|
delete(m.clearedFields, card.FieldCard)
|
|
}
|
|
|
|
// SetSkill sets the "skill" field.
|
|
func (m *CardMutation) SetSkill(s string) {
|
|
m.skill = &s
|
|
}
|
|
|
|
// Skill returns the value of the "skill" field in the mutation.
|
|
func (m *CardMutation) Skill() (r string, exists bool) {
|
|
v := m.skill
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldSkill returns the old "skill" field's value of the Card entity.
|
|
// If the Card object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *CardMutation) OldSkill(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldSkill is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldSkill requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldSkill: %w", err)
|
|
}
|
|
return oldValue.Skill, nil
|
|
}
|
|
|
|
// ClearSkill clears the value of the "skill" field.
|
|
func (m *CardMutation) ClearSkill() {
|
|
m.skill = nil
|
|
m.clearedFields[card.FieldSkill] = struct{}{}
|
|
}
|
|
|
|
// SkillCleared returns if the "skill" field was cleared in this mutation.
|
|
func (m *CardMutation) SkillCleared() bool {
|
|
_, ok := m.clearedFields[card.FieldSkill]
|
|
return ok
|
|
}
|
|
|
|
// ResetSkill resets all changes to the "skill" field.
|
|
func (m *CardMutation) ResetSkill() {
|
|
m.skill = nil
|
|
delete(m.clearedFields, card.FieldSkill)
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (m *CardMutation) SetStatus(s string) {
|
|
m.status = &s
|
|
}
|
|
|
|
// Status returns the value of the "status" field in the mutation.
|
|
func (m *CardMutation) 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 Card entity.
|
|
// If the Card object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *CardMutation) 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
|
|
}
|
|
|
|
// ClearStatus clears the value of the "status" field.
|
|
func (m *CardMutation) ClearStatus() {
|
|
m.status = nil
|
|
m.clearedFields[card.FieldStatus] = struct{}{}
|
|
}
|
|
|
|
// StatusCleared returns if the "status" field was cleared in this mutation.
|
|
func (m *CardMutation) StatusCleared() bool {
|
|
_, ok := m.clearedFields[card.FieldStatus]
|
|
return ok
|
|
}
|
|
|
|
// ResetStatus resets all changes to the "status" field.
|
|
func (m *CardMutation) ResetStatus() {
|
|
m.status = nil
|
|
delete(m.clearedFields, card.FieldStatus)
|
|
}
|
|
|
|
// SetToken sets the "token" field.
|
|
func (m *CardMutation) SetToken(s string) {
|
|
m.token = &s
|
|
}
|
|
|
|
// Token returns the value of the "token" field in the mutation.
|
|
func (m *CardMutation) Token() (r string, exists bool) {
|
|
v := m.token
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldToken returns the old "token" field's value of the Card entity.
|
|
// If the Card object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *CardMutation) OldToken(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldToken is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldToken requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldToken: %w", err)
|
|
}
|
|
return oldValue.Token, nil
|
|
}
|
|
|
|
// ClearToken clears the value of the "token" field.
|
|
func (m *CardMutation) ClearToken() {
|
|
m.token = nil
|
|
m.clearedFields[card.FieldToken] = struct{}{}
|
|
}
|
|
|
|
// TokenCleared returns if the "token" field was cleared in this mutation.
|
|
func (m *CardMutation) TokenCleared() bool {
|
|
_, ok := m.clearedFields[card.FieldToken]
|
|
return ok
|
|
}
|
|
|
|
// ResetToken resets all changes to the "token" field.
|
|
func (m *CardMutation) ResetToken() {
|
|
m.token = nil
|
|
delete(m.clearedFields, card.FieldToken)
|
|
}
|
|
|
|
// SetCp sets the "cp" field.
|
|
func (m *CardMutation) SetCp(i int) {
|
|
m.cp = &i
|
|
m.addcp = nil
|
|
}
|
|
|
|
// Cp returns the value of the "cp" field in the mutation.
|
|
func (m *CardMutation) Cp() (r int, exists bool) {
|
|
v := m.cp
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldCp returns the old "cp" field's value of the Card entity.
|
|
// If the Card object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *CardMutation) OldCp(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldCp is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldCp requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldCp: %w", err)
|
|
}
|
|
return oldValue.Cp, nil
|
|
}
|
|
|
|
// AddCp adds i to the "cp" field.
|
|
func (m *CardMutation) AddCp(i int) {
|
|
if m.addcp != nil {
|
|
*m.addcp += i
|
|
} else {
|
|
m.addcp = &i
|
|
}
|
|
}
|
|
|
|
// AddedCp returns the value that was added to the "cp" field in this mutation.
|
|
func (m *CardMutation) AddedCp() (r int, exists bool) {
|
|
v := m.addcp
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearCp clears the value of the "cp" field.
|
|
func (m *CardMutation) ClearCp() {
|
|
m.cp = nil
|
|
m.addcp = nil
|
|
m.clearedFields[card.FieldCp] = struct{}{}
|
|
}
|
|
|
|
// CpCleared returns if the "cp" field was cleared in this mutation.
|
|
func (m *CardMutation) CpCleared() bool {
|
|
_, ok := m.clearedFields[card.FieldCp]
|
|
return ok
|
|
}
|
|
|
|
// ResetCp resets all changes to the "cp" field.
|
|
func (m *CardMutation) ResetCp() {
|
|
m.cp = nil
|
|
m.addcp = nil
|
|
delete(m.clearedFields, card.FieldCp)
|
|
}
|
|
|
|
// SetURL sets the "url" field.
|
|
func (m *CardMutation) SetURL(s string) {
|
|
m.url = &s
|
|
}
|
|
|
|
// URL returns the value of the "url" field in the mutation.
|
|
func (m *CardMutation) URL() (r string, exists bool) {
|
|
v := m.url
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldURL returns the old "url" field's value of the Card entity.
|
|
// If the Card object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *CardMutation) OldURL(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldURL is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldURL requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldURL: %w", err)
|
|
}
|
|
return oldValue.URL, nil
|
|
}
|
|
|
|
// ClearURL clears the value of the "url" field.
|
|
func (m *CardMutation) ClearURL() {
|
|
m.url = nil
|
|
m.clearedFields[card.FieldURL] = struct{}{}
|
|
}
|
|
|
|
// URLCleared returns if the "url" field was cleared in this mutation.
|
|
func (m *CardMutation) URLCleared() bool {
|
|
_, ok := m.clearedFields[card.FieldURL]
|
|
return ok
|
|
}
|
|
|
|
// ResetURL resets all changes to the "url" field.
|
|
func (m *CardMutation) ResetURL() {
|
|
m.url = nil
|
|
delete(m.clearedFields, card.FieldURL)
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (m *CardMutation) SetCreatedAt(t time.Time) {
|
|
m.created_at = &t
|
|
}
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
func (m *CardMutation) 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 Card entity.
|
|
// If the Card object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *CardMutation) 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
|
|
}
|
|
|
|
// ClearCreatedAt clears the value of the "created_at" field.
|
|
func (m *CardMutation) ClearCreatedAt() {
|
|
m.created_at = nil
|
|
m.clearedFields[card.FieldCreatedAt] = struct{}{}
|
|
}
|
|
|
|
// CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
|
|
func (m *CardMutation) CreatedAtCleared() bool {
|
|
_, ok := m.clearedFields[card.FieldCreatedAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
func (m *CardMutation) ResetCreatedAt() {
|
|
m.created_at = nil
|
|
delete(m.clearedFields, card.FieldCreatedAt)
|
|
}
|
|
|
|
// SetOwnerID sets the "owner" edge to the User entity by id.
|
|
func (m *CardMutation) SetOwnerID(id int) {
|
|
m.owner = &id
|
|
}
|
|
|
|
// ClearOwner clears the "owner" edge to the User entity.
|
|
func (m *CardMutation) ClearOwner() {
|
|
m.clearedowner = true
|
|
}
|
|
|
|
// OwnerCleared reports if the "owner" edge to the User entity was cleared.
|
|
func (m *CardMutation) OwnerCleared() bool {
|
|
return m.clearedowner
|
|
}
|
|
|
|
// OwnerID returns the "owner" edge ID in the mutation.
|
|
func (m *CardMutation) OwnerID() (id int, exists bool) {
|
|
if m.owner != nil {
|
|
return *m.owner, true
|
|
}
|
|
return
|
|
}
|
|
|
|
// OwnerIDs returns the "owner" edge IDs in the mutation.
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
// OwnerID instead. It exists only for internal usage by the builders.
|
|
func (m *CardMutation) OwnerIDs() (ids []int) {
|
|
if id := m.owner; id != nil {
|
|
ids = append(ids, *id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetOwner resets all changes to the "owner" edge.
|
|
func (m *CardMutation) ResetOwner() {
|
|
m.owner = nil
|
|
m.clearedowner = false
|
|
}
|
|
|
|
// Where appends a list predicates to the CardMutation builder.
|
|
func (m *CardMutation) Where(ps ...predicate.Card) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the CardMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *CardMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.Card, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *CardMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *CardMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Card).
|
|
func (m *CardMutation) 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 *CardMutation) Fields() []string {
|
|
fields := make([]string, 0, 8)
|
|
if m.password != nil {
|
|
fields = append(fields, card.FieldPassword)
|
|
}
|
|
if m.card != nil {
|
|
fields = append(fields, card.FieldCard)
|
|
}
|
|
if m.skill != nil {
|
|
fields = append(fields, card.FieldSkill)
|
|
}
|
|
if m.status != nil {
|
|
fields = append(fields, card.FieldStatus)
|
|
}
|
|
if m.token != nil {
|
|
fields = append(fields, card.FieldToken)
|
|
}
|
|
if m.cp != nil {
|
|
fields = append(fields, card.FieldCp)
|
|
}
|
|
if m.url != nil {
|
|
fields = append(fields, card.FieldURL)
|
|
}
|
|
if m.created_at != nil {
|
|
fields = append(fields, card.FieldCreatedAt)
|
|
}
|
|
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 *CardMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case card.FieldPassword:
|
|
return m.Password()
|
|
case card.FieldCard:
|
|
return m.Card()
|
|
case card.FieldSkill:
|
|
return m.Skill()
|
|
case card.FieldStatus:
|
|
return m.Status()
|
|
case card.FieldToken:
|
|
return m.Token()
|
|
case card.FieldCp:
|
|
return m.Cp()
|
|
case card.FieldURL:
|
|
return m.URL()
|
|
case card.FieldCreatedAt:
|
|
return m.CreatedAt()
|
|
}
|
|
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 *CardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case card.FieldPassword:
|
|
return m.OldPassword(ctx)
|
|
case card.FieldCard:
|
|
return m.OldCard(ctx)
|
|
case card.FieldSkill:
|
|
return m.OldSkill(ctx)
|
|
case card.FieldStatus:
|
|
return m.OldStatus(ctx)
|
|
case card.FieldToken:
|
|
return m.OldToken(ctx)
|
|
case card.FieldCp:
|
|
return m.OldCp(ctx)
|
|
case card.FieldURL:
|
|
return m.OldURL(ctx)
|
|
case card.FieldCreatedAt:
|
|
return m.OldCreatedAt(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Card 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 *CardMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case card.FieldPassword:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetPassword(v)
|
|
return nil
|
|
case card.FieldCard:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCard(v)
|
|
return nil
|
|
case card.FieldSkill:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetSkill(v)
|
|
return nil
|
|
case card.FieldStatus:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetStatus(v)
|
|
return nil
|
|
case card.FieldToken:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetToken(v)
|
|
return nil
|
|
case card.FieldCp:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCp(v)
|
|
return nil
|
|
case card.FieldURL:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetURL(v)
|
|
return nil
|
|
case card.FieldCreatedAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetCreatedAt(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Card field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *CardMutation) AddedFields() []string {
|
|
var fields []string
|
|
if m.addcard != nil {
|
|
fields = append(fields, card.FieldCard)
|
|
}
|
|
if m.addcp != nil {
|
|
fields = append(fields, card.FieldCp)
|
|
}
|
|
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 *CardMutation) AddedField(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case card.FieldCard:
|
|
return m.AddedCard()
|
|
case card.FieldCp:
|
|
return m.AddedCp()
|
|
}
|
|
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 *CardMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
case card.FieldCard:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddCard(v)
|
|
return nil
|
|
case card.FieldCp:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddCp(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Card numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *CardMutation) ClearedFields() []string {
|
|
var fields []string
|
|
if m.FieldCleared(card.FieldCard) {
|
|
fields = append(fields, card.FieldCard)
|
|
}
|
|
if m.FieldCleared(card.FieldSkill) {
|
|
fields = append(fields, card.FieldSkill)
|
|
}
|
|
if m.FieldCleared(card.FieldStatus) {
|
|
fields = append(fields, card.FieldStatus)
|
|
}
|
|
if m.FieldCleared(card.FieldToken) {
|
|
fields = append(fields, card.FieldToken)
|
|
}
|
|
if m.FieldCleared(card.FieldCp) {
|
|
fields = append(fields, card.FieldCp)
|
|
}
|
|
if m.FieldCleared(card.FieldURL) {
|
|
fields = append(fields, card.FieldURL)
|
|
}
|
|
if m.FieldCleared(card.FieldCreatedAt) {
|
|
fields = append(fields, card.FieldCreatedAt)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *CardMutation) 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 *CardMutation) ClearField(name string) error {
|
|
switch name {
|
|
case card.FieldCard:
|
|
m.ClearCard()
|
|
return nil
|
|
case card.FieldSkill:
|
|
m.ClearSkill()
|
|
return nil
|
|
case card.FieldStatus:
|
|
m.ClearStatus()
|
|
return nil
|
|
case card.FieldToken:
|
|
m.ClearToken()
|
|
return nil
|
|
case card.FieldCp:
|
|
m.ClearCp()
|
|
return nil
|
|
case card.FieldURL:
|
|
m.ClearURL()
|
|
return nil
|
|
case card.FieldCreatedAt:
|
|
m.ClearCreatedAt()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Card 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 *CardMutation) ResetField(name string) error {
|
|
switch name {
|
|
case card.FieldPassword:
|
|
m.ResetPassword()
|
|
return nil
|
|
case card.FieldCard:
|
|
m.ResetCard()
|
|
return nil
|
|
case card.FieldSkill:
|
|
m.ResetSkill()
|
|
return nil
|
|
case card.FieldStatus:
|
|
m.ResetStatus()
|
|
return nil
|
|
case card.FieldToken:
|
|
m.ResetToken()
|
|
return nil
|
|
case card.FieldCp:
|
|
m.ResetCp()
|
|
return nil
|
|
case card.FieldURL:
|
|
m.ResetURL()
|
|
return nil
|
|
case card.FieldCreatedAt:
|
|
m.ResetCreatedAt()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Card field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *CardMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
if m.owner != nil {
|
|
edges = append(edges, card.EdgeOwner)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *CardMutation) AddedIDs(name string) []ent.Value {
|
|
switch name {
|
|
case card.EdgeOwner:
|
|
if id := m.owner; id != nil {
|
|
return []ent.Value{*id}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *CardMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *CardMutation) RemovedIDs(name string) []ent.Value {
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *CardMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
if m.clearedowner {
|
|
edges = append(edges, card.EdgeOwner)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *CardMutation) EdgeCleared(name string) bool {
|
|
switch name {
|
|
case card.EdgeOwner:
|
|
return m.clearedowner
|
|
}
|
|
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 *CardMutation) ClearEdge(name string) error {
|
|
switch name {
|
|
case card.EdgeOwner:
|
|
m.ClearOwner()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Card 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 *CardMutation) ResetEdge(name string) error {
|
|
switch name {
|
|
case card.EdgeOwner:
|
|
m.ResetOwner()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Card edge %s", name)
|
|
}
|
|
|
|
// GroupMutation represents an operation that mutates the Group nodes in the graph.
|
|
type GroupMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
name *string
|
|
password *string
|
|
clearedFields map[string]struct{}
|
|
users map[int]struct{}
|
|
removedusers map[int]struct{}
|
|
clearedusers bool
|
|
done bool
|
|
oldValue func(context.Context) (*Group, error)
|
|
predicates []predicate.Group
|
|
}
|
|
|
|
var _ ent.Mutation = (*GroupMutation)(nil)
|
|
|
|
// groupOption allows management of the mutation configuration using functional options.
|
|
type groupOption func(*GroupMutation)
|
|
|
|
// newGroupMutation creates new mutation for the Group entity.
|
|
func newGroupMutation(c config, op Op, opts ...groupOption) *GroupMutation {
|
|
m := &GroupMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeGroup,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withGroupID sets the ID field of the mutation.
|
|
func withGroupID(id int) groupOption {
|
|
return func(m *GroupMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *Group
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*Group, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().Group.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withGroup sets the old Group of the mutation.
|
|
func withGroup(node *Group) groupOption {
|
|
return func(m *GroupMutation) {
|
|
m.oldValue = func(context.Context) (*Group, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m GroupMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m GroupMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *GroupMutation) ID() (id 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 *GroupMutation) 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().Group.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 *GroupMutation) SetName(s string) {
|
|
m.name = &s
|
|
}
|
|
|
|
// Name returns the value of the "name" field in the mutation.
|
|
func (m *GroupMutation) 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 Group entity.
|
|
// If the Group object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *GroupMutation) OldName(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldName is only allowed on UpdateOne operations")
|
|
}
|
|
if 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 *GroupMutation) ResetName() {
|
|
m.name = nil
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (m *GroupMutation) SetPassword(s string) {
|
|
m.password = &s
|
|
}
|
|
|
|
// Password returns the value of the "password" field in the mutation.
|
|
func (m *GroupMutation) Password() (r string, exists bool) {
|
|
v := m.password
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldPassword returns the old "password" field's value of the Group entity.
|
|
// If the Group object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *GroupMutation) OldPassword(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldPassword requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldPassword: %w", err)
|
|
}
|
|
return oldValue.Password, nil
|
|
}
|
|
|
|
// ResetPassword resets all changes to the "password" field.
|
|
func (m *GroupMutation) ResetPassword() {
|
|
m.password = nil
|
|
}
|
|
|
|
// AddUserIDs adds the "users" edge to the User entity by ids.
|
|
func (m *GroupMutation) AddUserIDs(ids ...int) {
|
|
if m.users == nil {
|
|
m.users = make(map[int]struct{})
|
|
}
|
|
for i := range ids {
|
|
m.users[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// ClearUsers clears the "users" edge to the User entity.
|
|
func (m *GroupMutation) ClearUsers() {
|
|
m.clearedusers = true
|
|
}
|
|
|
|
// UsersCleared reports if the "users" edge to the User entity was cleared.
|
|
func (m *GroupMutation) UsersCleared() bool {
|
|
return m.clearedusers
|
|
}
|
|
|
|
// RemoveUserIDs removes the "users" edge to the User entity by IDs.
|
|
func (m *GroupMutation) RemoveUserIDs(ids ...int) {
|
|
if m.removedusers == nil {
|
|
m.removedusers = make(map[int]struct{})
|
|
}
|
|
for i := range ids {
|
|
delete(m.users, ids[i])
|
|
m.removedusers[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// RemovedUsers returns the removed IDs of the "users" edge to the User entity.
|
|
func (m *GroupMutation) RemovedUsersIDs() (ids []int) {
|
|
for id := range m.removedusers {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// UsersIDs returns the "users" edge IDs in the mutation.
|
|
func (m *GroupMutation) UsersIDs() (ids []int) {
|
|
for id := range m.users {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetUsers resets all changes to the "users" edge.
|
|
func (m *GroupMutation) ResetUsers() {
|
|
m.users = nil
|
|
m.clearedusers = false
|
|
m.removedusers = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the GroupMutation builder.
|
|
func (m *GroupMutation) Where(ps ...predicate.Group) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the GroupMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *GroupMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.Group, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *GroupMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *GroupMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (Group).
|
|
func (m *GroupMutation) 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 *GroupMutation) Fields() []string {
|
|
fields := make([]string, 0, 2)
|
|
if m.name != nil {
|
|
fields = append(fields, group.FieldName)
|
|
}
|
|
if m.password != nil {
|
|
fields = append(fields, group.FieldPassword)
|
|
}
|
|
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 *GroupMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case group.FieldName:
|
|
return m.Name()
|
|
case group.FieldPassword:
|
|
return m.Password()
|
|
}
|
|
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 *GroupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case group.FieldName:
|
|
return m.OldName(ctx)
|
|
case group.FieldPassword:
|
|
return m.OldPassword(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown Group 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 *GroupMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case group.FieldName:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetName(v)
|
|
return nil
|
|
case group.FieldPassword:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetPassword(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Group field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *GroupMutation) 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 *GroupMutation) 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 *GroupMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Group numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *GroupMutation) ClearedFields() []string {
|
|
return nil
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *GroupMutation) 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 *GroupMutation) ClearField(name string) error {
|
|
return fmt.Errorf("unknown Group 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 *GroupMutation) ResetField(name string) error {
|
|
switch name {
|
|
case group.FieldName:
|
|
m.ResetName()
|
|
return nil
|
|
case group.FieldPassword:
|
|
m.ResetPassword()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Group field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *GroupMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
if m.users != nil {
|
|
edges = append(edges, group.EdgeUsers)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *GroupMutation) AddedIDs(name string) []ent.Value {
|
|
switch name {
|
|
case group.EdgeUsers:
|
|
ids := make([]ent.Value, 0, len(m.users))
|
|
for id := range m.users {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *GroupMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
if m.removedusers != nil {
|
|
edges = append(edges, group.EdgeUsers)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *GroupMutation) RemovedIDs(name string) []ent.Value {
|
|
switch name {
|
|
case group.EdgeUsers:
|
|
ids := make([]ent.Value, 0, len(m.removedusers))
|
|
for id := range m.removedusers {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *GroupMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
if m.clearedusers {
|
|
edges = append(edges, group.EdgeUsers)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *GroupMutation) EdgeCleared(name string) bool {
|
|
switch name {
|
|
case group.EdgeUsers:
|
|
return m.clearedusers
|
|
}
|
|
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 *GroupMutation) ClearEdge(name string) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown Group 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 *GroupMutation) ResetEdge(name string) error {
|
|
switch name {
|
|
case group.EdgeUsers:
|
|
m.ResetUsers()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Group edge %s", name)
|
|
}
|
|
|
|
// UserMutation represents an operation that mutates the User nodes in the graph.
|
|
type UserMutation struct {
|
|
config
|
|
op Op
|
|
typ string
|
|
id *int
|
|
username *string
|
|
did *string
|
|
delete *bool
|
|
handle *bool
|
|
token *string
|
|
password *string
|
|
created_at *time.Time
|
|
updated_at *time.Time
|
|
raid_at *time.Time
|
|
luck *int
|
|
addluck *int
|
|
luck_at *time.Time
|
|
like *int
|
|
addlike *int
|
|
like_rank *int
|
|
addlike_rank *int
|
|
like_at *time.Time
|
|
fav *int
|
|
addfav *int
|
|
ten *bool
|
|
ten_su *int
|
|
addten_su *int
|
|
ten_kai *int
|
|
addten_kai *int
|
|
aiten *int
|
|
addaiten *int
|
|
ten_card *string
|
|
ten_delete *string
|
|
ten_post *string
|
|
ten_get *string
|
|
ten_at *time.Time
|
|
next *string
|
|
clearedFields map[string]struct{}
|
|
card map[int]struct{}
|
|
removedcard map[int]struct{}
|
|
clearedcard bool
|
|
done bool
|
|
oldValue func(context.Context) (*User, error)
|
|
predicates []predicate.User
|
|
}
|
|
|
|
var _ ent.Mutation = (*UserMutation)(nil)
|
|
|
|
// userOption allows management of the mutation configuration using functional options.
|
|
type userOption func(*UserMutation)
|
|
|
|
// newUserMutation creates new mutation for the User entity.
|
|
func newUserMutation(c config, op Op, opts ...userOption) *UserMutation {
|
|
m := &UserMutation{
|
|
config: c,
|
|
op: op,
|
|
typ: TypeUser,
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
for _, opt := range opts {
|
|
opt(m)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// withUserID sets the ID field of the mutation.
|
|
func withUserID(id int) userOption {
|
|
return func(m *UserMutation) {
|
|
var (
|
|
err error
|
|
once sync.Once
|
|
value *User
|
|
)
|
|
m.oldValue = func(ctx context.Context) (*User, error) {
|
|
once.Do(func() {
|
|
if m.done {
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
} else {
|
|
value, err = m.Client().User.Get(ctx, id)
|
|
}
|
|
})
|
|
return value, err
|
|
}
|
|
m.id = &id
|
|
}
|
|
}
|
|
|
|
// withUser sets the old User of the mutation.
|
|
func withUser(node *User) userOption {
|
|
return func(m *UserMutation) {
|
|
m.oldValue = func(context.Context) (*User, error) {
|
|
return node, nil
|
|
}
|
|
m.id = &node.ID
|
|
}
|
|
}
|
|
|
|
// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
func (m UserMutation) Client() *Client {
|
|
client := &Client{config: m.config}
|
|
client.init()
|
|
return client
|
|
}
|
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
// it returns an error otherwise.
|
|
func (m UserMutation) Tx() (*Tx, error) {
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
|
}
|
|
tx := &Tx{config: m.config}
|
|
tx.init()
|
|
return tx, nil
|
|
}
|
|
|
|
// ID returns the ID value in the mutation. Note that the ID is only available
|
|
// if it was provided to the builder or after it was returned from the database.
|
|
func (m *UserMutation) ID() (id 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 *UserMutation) 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().User.Query().Where(m.predicates...).IDs(ctx)
|
|
default:
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
}
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (m *UserMutation) SetUsername(s string) {
|
|
m.username = &s
|
|
}
|
|
|
|
// Username returns the value of the "username" field in the mutation.
|
|
func (m *UserMutation) Username() (r string, exists bool) {
|
|
v := m.username
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldUsername returns the old "username" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldUsername is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldUsername requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldUsername: %w", err)
|
|
}
|
|
return oldValue.Username, nil
|
|
}
|
|
|
|
// ResetUsername resets all changes to the "username" field.
|
|
func (m *UserMutation) ResetUsername() {
|
|
m.username = nil
|
|
}
|
|
|
|
// SetDid sets the "did" field.
|
|
func (m *UserMutation) SetDid(s string) {
|
|
m.did = &s
|
|
}
|
|
|
|
// Did returns the value of the "did" field in the mutation.
|
|
func (m *UserMutation) Did() (r string, exists bool) {
|
|
v := m.did
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDid returns the old "did" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldDid(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDid is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDid requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDid: %w", err)
|
|
}
|
|
return oldValue.Did, nil
|
|
}
|
|
|
|
// ClearDid clears the value of the "did" field.
|
|
func (m *UserMutation) ClearDid() {
|
|
m.did = nil
|
|
m.clearedFields[user.FieldDid] = struct{}{}
|
|
}
|
|
|
|
// DidCleared returns if the "did" field was cleared in this mutation.
|
|
func (m *UserMutation) DidCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldDid]
|
|
return ok
|
|
}
|
|
|
|
// ResetDid resets all changes to the "did" field.
|
|
func (m *UserMutation) ResetDid() {
|
|
m.did = nil
|
|
delete(m.clearedFields, user.FieldDid)
|
|
}
|
|
|
|
// SetDelete sets the "delete" field.
|
|
func (m *UserMutation) SetDelete(b bool) {
|
|
m.delete = &b
|
|
}
|
|
|
|
// Delete returns the value of the "delete" field in the mutation.
|
|
func (m *UserMutation) Delete() (r bool, exists bool) {
|
|
v := m.delete
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldDelete returns the old "delete" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldDelete(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldDelete is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldDelete requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldDelete: %w", err)
|
|
}
|
|
return oldValue.Delete, nil
|
|
}
|
|
|
|
// ClearDelete clears the value of the "delete" field.
|
|
func (m *UserMutation) ClearDelete() {
|
|
m.delete = nil
|
|
m.clearedFields[user.FieldDelete] = struct{}{}
|
|
}
|
|
|
|
// DeleteCleared returns if the "delete" field was cleared in this mutation.
|
|
func (m *UserMutation) DeleteCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldDelete]
|
|
return ok
|
|
}
|
|
|
|
// ResetDelete resets all changes to the "delete" field.
|
|
func (m *UserMutation) ResetDelete() {
|
|
m.delete = nil
|
|
delete(m.clearedFields, user.FieldDelete)
|
|
}
|
|
|
|
// SetHandle sets the "handle" field.
|
|
func (m *UserMutation) SetHandle(b bool) {
|
|
m.handle = &b
|
|
}
|
|
|
|
// Handle returns the value of the "handle" field in the mutation.
|
|
func (m *UserMutation) Handle() (r bool, exists bool) {
|
|
v := m.handle
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldHandle returns the old "handle" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldHandle(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldHandle is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldHandle requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldHandle: %w", err)
|
|
}
|
|
return oldValue.Handle, nil
|
|
}
|
|
|
|
// ClearHandle clears the value of the "handle" field.
|
|
func (m *UserMutation) ClearHandle() {
|
|
m.handle = nil
|
|
m.clearedFields[user.FieldHandle] = struct{}{}
|
|
}
|
|
|
|
// HandleCleared returns if the "handle" field was cleared in this mutation.
|
|
func (m *UserMutation) HandleCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldHandle]
|
|
return ok
|
|
}
|
|
|
|
// ResetHandle resets all changes to the "handle" field.
|
|
func (m *UserMutation) ResetHandle() {
|
|
m.handle = nil
|
|
delete(m.clearedFields, user.FieldHandle)
|
|
}
|
|
|
|
// SetToken sets the "token" field.
|
|
func (m *UserMutation) SetToken(s string) {
|
|
m.token = &s
|
|
}
|
|
|
|
// Token returns the value of the "token" field in the mutation.
|
|
func (m *UserMutation) Token() (r string, exists bool) {
|
|
v := m.token
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldToken returns the old "token" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldToken(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldToken is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldToken requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldToken: %w", err)
|
|
}
|
|
return oldValue.Token, nil
|
|
}
|
|
|
|
// ClearToken clears the value of the "token" field.
|
|
func (m *UserMutation) ClearToken() {
|
|
m.token = nil
|
|
m.clearedFields[user.FieldToken] = struct{}{}
|
|
}
|
|
|
|
// TokenCleared returns if the "token" field was cleared in this mutation.
|
|
func (m *UserMutation) TokenCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldToken]
|
|
return ok
|
|
}
|
|
|
|
// ResetToken resets all changes to the "token" field.
|
|
func (m *UserMutation) ResetToken() {
|
|
m.token = nil
|
|
delete(m.clearedFields, user.FieldToken)
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (m *UserMutation) SetPassword(s string) {
|
|
m.password = &s
|
|
}
|
|
|
|
// Password returns the value of the "password" field in the mutation.
|
|
func (m *UserMutation) Password() (r string, exists bool) {
|
|
v := m.password
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldPassword returns the old "password" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldPassword requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldPassword: %w", err)
|
|
}
|
|
return oldValue.Password, nil
|
|
}
|
|
|
|
// ResetPassword resets all changes to the "password" field.
|
|
func (m *UserMutation) ResetPassword() {
|
|
m.password = nil
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (m *UserMutation) SetCreatedAt(t time.Time) {
|
|
m.created_at = &t
|
|
}
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
func (m *UserMutation) 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 User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) 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
|
|
}
|
|
|
|
// ClearCreatedAt clears the value of the "created_at" field.
|
|
func (m *UserMutation) ClearCreatedAt() {
|
|
m.created_at = nil
|
|
m.clearedFields[user.FieldCreatedAt] = struct{}{}
|
|
}
|
|
|
|
// CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
|
|
func (m *UserMutation) CreatedAtCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldCreatedAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
func (m *UserMutation) ResetCreatedAt() {
|
|
m.created_at = nil
|
|
delete(m.clearedFields, user.FieldCreatedAt)
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (m *UserMutation) SetUpdatedAt(t time.Time) {
|
|
m.updated_at = &t
|
|
}
|
|
|
|
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
func (m *UserMutation) 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 User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) 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
|
|
}
|
|
|
|
// ClearUpdatedAt clears the value of the "updated_at" field.
|
|
func (m *UserMutation) ClearUpdatedAt() {
|
|
m.updated_at = nil
|
|
m.clearedFields[user.FieldUpdatedAt] = struct{}{}
|
|
}
|
|
|
|
// UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
|
|
func (m *UserMutation) UpdatedAtCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldUpdatedAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
func (m *UserMutation) ResetUpdatedAt() {
|
|
m.updated_at = nil
|
|
delete(m.clearedFields, user.FieldUpdatedAt)
|
|
}
|
|
|
|
// SetRaidAt sets the "raid_at" field.
|
|
func (m *UserMutation) SetRaidAt(t time.Time) {
|
|
m.raid_at = &t
|
|
}
|
|
|
|
// RaidAt returns the value of the "raid_at" field in the mutation.
|
|
func (m *UserMutation) RaidAt() (r time.Time, exists bool) {
|
|
v := m.raid_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldRaidAt returns the old "raid_at" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldRaidAt(ctx context.Context) (v time.Time, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldRaidAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldRaidAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldRaidAt: %w", err)
|
|
}
|
|
return oldValue.RaidAt, nil
|
|
}
|
|
|
|
// ClearRaidAt clears the value of the "raid_at" field.
|
|
func (m *UserMutation) ClearRaidAt() {
|
|
m.raid_at = nil
|
|
m.clearedFields[user.FieldRaidAt] = struct{}{}
|
|
}
|
|
|
|
// RaidAtCleared returns if the "raid_at" field was cleared in this mutation.
|
|
func (m *UserMutation) RaidAtCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldRaidAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetRaidAt resets all changes to the "raid_at" field.
|
|
func (m *UserMutation) ResetRaidAt() {
|
|
m.raid_at = nil
|
|
delete(m.clearedFields, user.FieldRaidAt)
|
|
}
|
|
|
|
// SetLuck sets the "luck" field.
|
|
func (m *UserMutation) SetLuck(i int) {
|
|
m.luck = &i
|
|
m.addluck = nil
|
|
}
|
|
|
|
// Luck returns the value of the "luck" field in the mutation.
|
|
func (m *UserMutation) Luck() (r int, exists bool) {
|
|
v := m.luck
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLuck returns the old "luck" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldLuck(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLuck is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLuck requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLuck: %w", err)
|
|
}
|
|
return oldValue.Luck, nil
|
|
}
|
|
|
|
// AddLuck adds i to the "luck" field.
|
|
func (m *UserMutation) AddLuck(i int) {
|
|
if m.addluck != nil {
|
|
*m.addluck += i
|
|
} else {
|
|
m.addluck = &i
|
|
}
|
|
}
|
|
|
|
// AddedLuck returns the value that was added to the "luck" field in this mutation.
|
|
func (m *UserMutation) AddedLuck() (r int, exists bool) {
|
|
v := m.addluck
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearLuck clears the value of the "luck" field.
|
|
func (m *UserMutation) ClearLuck() {
|
|
m.luck = nil
|
|
m.addluck = nil
|
|
m.clearedFields[user.FieldLuck] = struct{}{}
|
|
}
|
|
|
|
// LuckCleared returns if the "luck" field was cleared in this mutation.
|
|
func (m *UserMutation) LuckCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldLuck]
|
|
return ok
|
|
}
|
|
|
|
// ResetLuck resets all changes to the "luck" field.
|
|
func (m *UserMutation) ResetLuck() {
|
|
m.luck = nil
|
|
m.addluck = nil
|
|
delete(m.clearedFields, user.FieldLuck)
|
|
}
|
|
|
|
// SetLuckAt sets the "luck_at" field.
|
|
func (m *UserMutation) SetLuckAt(t time.Time) {
|
|
m.luck_at = &t
|
|
}
|
|
|
|
// LuckAt returns the value of the "luck_at" field in the mutation.
|
|
func (m *UserMutation) LuckAt() (r time.Time, exists bool) {
|
|
v := m.luck_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLuckAt returns the old "luck_at" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldLuckAt(ctx context.Context) (v time.Time, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLuckAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLuckAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLuckAt: %w", err)
|
|
}
|
|
return oldValue.LuckAt, nil
|
|
}
|
|
|
|
// ClearLuckAt clears the value of the "luck_at" field.
|
|
func (m *UserMutation) ClearLuckAt() {
|
|
m.luck_at = nil
|
|
m.clearedFields[user.FieldLuckAt] = struct{}{}
|
|
}
|
|
|
|
// LuckAtCleared returns if the "luck_at" field was cleared in this mutation.
|
|
func (m *UserMutation) LuckAtCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldLuckAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetLuckAt resets all changes to the "luck_at" field.
|
|
func (m *UserMutation) ResetLuckAt() {
|
|
m.luck_at = nil
|
|
delete(m.clearedFields, user.FieldLuckAt)
|
|
}
|
|
|
|
// SetLike sets the "like" field.
|
|
func (m *UserMutation) SetLike(i int) {
|
|
m.like = &i
|
|
m.addlike = nil
|
|
}
|
|
|
|
// Like returns the value of the "like" field in the mutation.
|
|
func (m *UserMutation) Like() (r int, exists bool) {
|
|
v := m.like
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLike returns the old "like" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldLike(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLike is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLike requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLike: %w", err)
|
|
}
|
|
return oldValue.Like, nil
|
|
}
|
|
|
|
// AddLike adds i to the "like" field.
|
|
func (m *UserMutation) AddLike(i int) {
|
|
if m.addlike != nil {
|
|
*m.addlike += i
|
|
} else {
|
|
m.addlike = &i
|
|
}
|
|
}
|
|
|
|
// AddedLike returns the value that was added to the "like" field in this mutation.
|
|
func (m *UserMutation) AddedLike() (r int, exists bool) {
|
|
v := m.addlike
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearLike clears the value of the "like" field.
|
|
func (m *UserMutation) ClearLike() {
|
|
m.like = nil
|
|
m.addlike = nil
|
|
m.clearedFields[user.FieldLike] = struct{}{}
|
|
}
|
|
|
|
// LikeCleared returns if the "like" field was cleared in this mutation.
|
|
func (m *UserMutation) LikeCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldLike]
|
|
return ok
|
|
}
|
|
|
|
// ResetLike resets all changes to the "like" field.
|
|
func (m *UserMutation) ResetLike() {
|
|
m.like = nil
|
|
m.addlike = nil
|
|
delete(m.clearedFields, user.FieldLike)
|
|
}
|
|
|
|
// SetLikeRank sets the "like_rank" field.
|
|
func (m *UserMutation) SetLikeRank(i int) {
|
|
m.like_rank = &i
|
|
m.addlike_rank = nil
|
|
}
|
|
|
|
// LikeRank returns the value of the "like_rank" field in the mutation.
|
|
func (m *UserMutation) LikeRank() (r int, exists bool) {
|
|
v := m.like_rank
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLikeRank returns the old "like_rank" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldLikeRank(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLikeRank is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLikeRank requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLikeRank: %w", err)
|
|
}
|
|
return oldValue.LikeRank, nil
|
|
}
|
|
|
|
// AddLikeRank adds i to the "like_rank" field.
|
|
func (m *UserMutation) AddLikeRank(i int) {
|
|
if m.addlike_rank != nil {
|
|
*m.addlike_rank += i
|
|
} else {
|
|
m.addlike_rank = &i
|
|
}
|
|
}
|
|
|
|
// AddedLikeRank returns the value that was added to the "like_rank" field in this mutation.
|
|
func (m *UserMutation) AddedLikeRank() (r int, exists bool) {
|
|
v := m.addlike_rank
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearLikeRank clears the value of the "like_rank" field.
|
|
func (m *UserMutation) ClearLikeRank() {
|
|
m.like_rank = nil
|
|
m.addlike_rank = nil
|
|
m.clearedFields[user.FieldLikeRank] = struct{}{}
|
|
}
|
|
|
|
// LikeRankCleared returns if the "like_rank" field was cleared in this mutation.
|
|
func (m *UserMutation) LikeRankCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldLikeRank]
|
|
return ok
|
|
}
|
|
|
|
// ResetLikeRank resets all changes to the "like_rank" field.
|
|
func (m *UserMutation) ResetLikeRank() {
|
|
m.like_rank = nil
|
|
m.addlike_rank = nil
|
|
delete(m.clearedFields, user.FieldLikeRank)
|
|
}
|
|
|
|
// SetLikeAt sets the "like_at" field.
|
|
func (m *UserMutation) SetLikeAt(t time.Time) {
|
|
m.like_at = &t
|
|
}
|
|
|
|
// LikeAt returns the value of the "like_at" field in the mutation.
|
|
func (m *UserMutation) LikeAt() (r time.Time, exists bool) {
|
|
v := m.like_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldLikeAt returns the old "like_at" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldLikeAt(ctx context.Context) (v time.Time, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldLikeAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldLikeAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldLikeAt: %w", err)
|
|
}
|
|
return oldValue.LikeAt, nil
|
|
}
|
|
|
|
// ClearLikeAt clears the value of the "like_at" field.
|
|
func (m *UserMutation) ClearLikeAt() {
|
|
m.like_at = nil
|
|
m.clearedFields[user.FieldLikeAt] = struct{}{}
|
|
}
|
|
|
|
// LikeAtCleared returns if the "like_at" field was cleared in this mutation.
|
|
func (m *UserMutation) LikeAtCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldLikeAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetLikeAt resets all changes to the "like_at" field.
|
|
func (m *UserMutation) ResetLikeAt() {
|
|
m.like_at = nil
|
|
delete(m.clearedFields, user.FieldLikeAt)
|
|
}
|
|
|
|
// SetFav sets the "fav" field.
|
|
func (m *UserMutation) SetFav(i int) {
|
|
m.fav = &i
|
|
m.addfav = nil
|
|
}
|
|
|
|
// Fav returns the value of the "fav" field in the mutation.
|
|
func (m *UserMutation) Fav() (r int, exists bool) {
|
|
v := m.fav
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldFav returns the old "fav" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldFav(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldFav is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldFav requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldFav: %w", err)
|
|
}
|
|
return oldValue.Fav, nil
|
|
}
|
|
|
|
// AddFav adds i to the "fav" field.
|
|
func (m *UserMutation) AddFav(i int) {
|
|
if m.addfav != nil {
|
|
*m.addfav += i
|
|
} else {
|
|
m.addfav = &i
|
|
}
|
|
}
|
|
|
|
// AddedFav returns the value that was added to the "fav" field in this mutation.
|
|
func (m *UserMutation) AddedFav() (r int, exists bool) {
|
|
v := m.addfav
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearFav clears the value of the "fav" field.
|
|
func (m *UserMutation) ClearFav() {
|
|
m.fav = nil
|
|
m.addfav = nil
|
|
m.clearedFields[user.FieldFav] = struct{}{}
|
|
}
|
|
|
|
// FavCleared returns if the "fav" field was cleared in this mutation.
|
|
func (m *UserMutation) FavCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldFav]
|
|
return ok
|
|
}
|
|
|
|
// ResetFav resets all changes to the "fav" field.
|
|
func (m *UserMutation) ResetFav() {
|
|
m.fav = nil
|
|
m.addfav = nil
|
|
delete(m.clearedFields, user.FieldFav)
|
|
}
|
|
|
|
// SetTen sets the "ten" field.
|
|
func (m *UserMutation) SetTen(b bool) {
|
|
m.ten = &b
|
|
}
|
|
|
|
// Ten returns the value of the "ten" field in the mutation.
|
|
func (m *UserMutation) Ten() (r bool, exists bool) {
|
|
v := m.ten
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTen returns the old "ten" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldTen(ctx context.Context) (v bool, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTen is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTen requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTen: %w", err)
|
|
}
|
|
return oldValue.Ten, nil
|
|
}
|
|
|
|
// ClearTen clears the value of the "ten" field.
|
|
func (m *UserMutation) ClearTen() {
|
|
m.ten = nil
|
|
m.clearedFields[user.FieldTen] = struct{}{}
|
|
}
|
|
|
|
// TenCleared returns if the "ten" field was cleared in this mutation.
|
|
func (m *UserMutation) TenCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldTen]
|
|
return ok
|
|
}
|
|
|
|
// ResetTen resets all changes to the "ten" field.
|
|
func (m *UserMutation) ResetTen() {
|
|
m.ten = nil
|
|
delete(m.clearedFields, user.FieldTen)
|
|
}
|
|
|
|
// SetTenSu sets the "ten_su" field.
|
|
func (m *UserMutation) SetTenSu(i int) {
|
|
m.ten_su = &i
|
|
m.addten_su = nil
|
|
}
|
|
|
|
// TenSu returns the value of the "ten_su" field in the mutation.
|
|
func (m *UserMutation) TenSu() (r int, exists bool) {
|
|
v := m.ten_su
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTenSu returns the old "ten_su" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldTenSu(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTenSu is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTenSu requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTenSu: %w", err)
|
|
}
|
|
return oldValue.TenSu, nil
|
|
}
|
|
|
|
// AddTenSu adds i to the "ten_su" field.
|
|
func (m *UserMutation) AddTenSu(i int) {
|
|
if m.addten_su != nil {
|
|
*m.addten_su += i
|
|
} else {
|
|
m.addten_su = &i
|
|
}
|
|
}
|
|
|
|
// AddedTenSu returns the value that was added to the "ten_su" field in this mutation.
|
|
func (m *UserMutation) AddedTenSu() (r int, exists bool) {
|
|
v := m.addten_su
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearTenSu clears the value of the "ten_su" field.
|
|
func (m *UserMutation) ClearTenSu() {
|
|
m.ten_su = nil
|
|
m.addten_su = nil
|
|
m.clearedFields[user.FieldTenSu] = struct{}{}
|
|
}
|
|
|
|
// TenSuCleared returns if the "ten_su" field was cleared in this mutation.
|
|
func (m *UserMutation) TenSuCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldTenSu]
|
|
return ok
|
|
}
|
|
|
|
// ResetTenSu resets all changes to the "ten_su" field.
|
|
func (m *UserMutation) ResetTenSu() {
|
|
m.ten_su = nil
|
|
m.addten_su = nil
|
|
delete(m.clearedFields, user.FieldTenSu)
|
|
}
|
|
|
|
// SetTenKai sets the "ten_kai" field.
|
|
func (m *UserMutation) SetTenKai(i int) {
|
|
m.ten_kai = &i
|
|
m.addten_kai = nil
|
|
}
|
|
|
|
// TenKai returns the value of the "ten_kai" field in the mutation.
|
|
func (m *UserMutation) TenKai() (r int, exists bool) {
|
|
v := m.ten_kai
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTenKai returns the old "ten_kai" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldTenKai(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTenKai is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTenKai requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTenKai: %w", err)
|
|
}
|
|
return oldValue.TenKai, nil
|
|
}
|
|
|
|
// AddTenKai adds i to the "ten_kai" field.
|
|
func (m *UserMutation) AddTenKai(i int) {
|
|
if m.addten_kai != nil {
|
|
*m.addten_kai += i
|
|
} else {
|
|
m.addten_kai = &i
|
|
}
|
|
}
|
|
|
|
// AddedTenKai returns the value that was added to the "ten_kai" field in this mutation.
|
|
func (m *UserMutation) AddedTenKai() (r int, exists bool) {
|
|
v := m.addten_kai
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearTenKai clears the value of the "ten_kai" field.
|
|
func (m *UserMutation) ClearTenKai() {
|
|
m.ten_kai = nil
|
|
m.addten_kai = nil
|
|
m.clearedFields[user.FieldTenKai] = struct{}{}
|
|
}
|
|
|
|
// TenKaiCleared returns if the "ten_kai" field was cleared in this mutation.
|
|
func (m *UserMutation) TenKaiCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldTenKai]
|
|
return ok
|
|
}
|
|
|
|
// ResetTenKai resets all changes to the "ten_kai" field.
|
|
func (m *UserMutation) ResetTenKai() {
|
|
m.ten_kai = nil
|
|
m.addten_kai = nil
|
|
delete(m.clearedFields, user.FieldTenKai)
|
|
}
|
|
|
|
// SetAiten sets the "aiten" field.
|
|
func (m *UserMutation) SetAiten(i int) {
|
|
m.aiten = &i
|
|
m.addaiten = nil
|
|
}
|
|
|
|
// Aiten returns the value of the "aiten" field in the mutation.
|
|
func (m *UserMutation) Aiten() (r int, exists bool) {
|
|
v := m.aiten
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldAiten returns the old "aiten" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldAiten(ctx context.Context) (v int, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldAiten is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldAiten requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldAiten: %w", err)
|
|
}
|
|
return oldValue.Aiten, nil
|
|
}
|
|
|
|
// AddAiten adds i to the "aiten" field.
|
|
func (m *UserMutation) AddAiten(i int) {
|
|
if m.addaiten != nil {
|
|
*m.addaiten += i
|
|
} else {
|
|
m.addaiten = &i
|
|
}
|
|
}
|
|
|
|
// AddedAiten returns the value that was added to the "aiten" field in this mutation.
|
|
func (m *UserMutation) AddedAiten() (r int, exists bool) {
|
|
v := m.addaiten
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearAiten clears the value of the "aiten" field.
|
|
func (m *UserMutation) ClearAiten() {
|
|
m.aiten = nil
|
|
m.addaiten = nil
|
|
m.clearedFields[user.FieldAiten] = struct{}{}
|
|
}
|
|
|
|
// AitenCleared returns if the "aiten" field was cleared in this mutation.
|
|
func (m *UserMutation) AitenCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldAiten]
|
|
return ok
|
|
}
|
|
|
|
// ResetAiten resets all changes to the "aiten" field.
|
|
func (m *UserMutation) ResetAiten() {
|
|
m.aiten = nil
|
|
m.addaiten = nil
|
|
delete(m.clearedFields, user.FieldAiten)
|
|
}
|
|
|
|
// SetTenCard sets the "ten_card" field.
|
|
func (m *UserMutation) SetTenCard(s string) {
|
|
m.ten_card = &s
|
|
}
|
|
|
|
// TenCard returns the value of the "ten_card" field in the mutation.
|
|
func (m *UserMutation) TenCard() (r string, exists bool) {
|
|
v := m.ten_card
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTenCard returns the old "ten_card" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldTenCard(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTenCard is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTenCard requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTenCard: %w", err)
|
|
}
|
|
return oldValue.TenCard, nil
|
|
}
|
|
|
|
// ClearTenCard clears the value of the "ten_card" field.
|
|
func (m *UserMutation) ClearTenCard() {
|
|
m.ten_card = nil
|
|
m.clearedFields[user.FieldTenCard] = struct{}{}
|
|
}
|
|
|
|
// TenCardCleared returns if the "ten_card" field was cleared in this mutation.
|
|
func (m *UserMutation) TenCardCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldTenCard]
|
|
return ok
|
|
}
|
|
|
|
// ResetTenCard resets all changes to the "ten_card" field.
|
|
func (m *UserMutation) ResetTenCard() {
|
|
m.ten_card = nil
|
|
delete(m.clearedFields, user.FieldTenCard)
|
|
}
|
|
|
|
// SetTenDelete sets the "ten_delete" field.
|
|
func (m *UserMutation) SetTenDelete(s string) {
|
|
m.ten_delete = &s
|
|
}
|
|
|
|
// TenDelete returns the value of the "ten_delete" field in the mutation.
|
|
func (m *UserMutation) TenDelete() (r string, exists bool) {
|
|
v := m.ten_delete
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTenDelete returns the old "ten_delete" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldTenDelete(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTenDelete is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTenDelete requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTenDelete: %w", err)
|
|
}
|
|
return oldValue.TenDelete, nil
|
|
}
|
|
|
|
// ClearTenDelete clears the value of the "ten_delete" field.
|
|
func (m *UserMutation) ClearTenDelete() {
|
|
m.ten_delete = nil
|
|
m.clearedFields[user.FieldTenDelete] = struct{}{}
|
|
}
|
|
|
|
// TenDeleteCleared returns if the "ten_delete" field was cleared in this mutation.
|
|
func (m *UserMutation) TenDeleteCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldTenDelete]
|
|
return ok
|
|
}
|
|
|
|
// ResetTenDelete resets all changes to the "ten_delete" field.
|
|
func (m *UserMutation) ResetTenDelete() {
|
|
m.ten_delete = nil
|
|
delete(m.clearedFields, user.FieldTenDelete)
|
|
}
|
|
|
|
// SetTenPost sets the "ten_post" field.
|
|
func (m *UserMutation) SetTenPost(s string) {
|
|
m.ten_post = &s
|
|
}
|
|
|
|
// TenPost returns the value of the "ten_post" field in the mutation.
|
|
func (m *UserMutation) TenPost() (r string, exists bool) {
|
|
v := m.ten_post
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTenPost returns the old "ten_post" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldTenPost(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTenPost is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTenPost requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTenPost: %w", err)
|
|
}
|
|
return oldValue.TenPost, nil
|
|
}
|
|
|
|
// ClearTenPost clears the value of the "ten_post" field.
|
|
func (m *UserMutation) ClearTenPost() {
|
|
m.ten_post = nil
|
|
m.clearedFields[user.FieldTenPost] = struct{}{}
|
|
}
|
|
|
|
// TenPostCleared returns if the "ten_post" field was cleared in this mutation.
|
|
func (m *UserMutation) TenPostCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldTenPost]
|
|
return ok
|
|
}
|
|
|
|
// ResetTenPost resets all changes to the "ten_post" field.
|
|
func (m *UserMutation) ResetTenPost() {
|
|
m.ten_post = nil
|
|
delete(m.clearedFields, user.FieldTenPost)
|
|
}
|
|
|
|
// SetTenGet sets the "ten_get" field.
|
|
func (m *UserMutation) SetTenGet(s string) {
|
|
m.ten_get = &s
|
|
}
|
|
|
|
// TenGet returns the value of the "ten_get" field in the mutation.
|
|
func (m *UserMutation) TenGet() (r string, exists bool) {
|
|
v := m.ten_get
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTenGet returns the old "ten_get" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldTenGet(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTenGet is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTenGet requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTenGet: %w", err)
|
|
}
|
|
return oldValue.TenGet, nil
|
|
}
|
|
|
|
// ClearTenGet clears the value of the "ten_get" field.
|
|
func (m *UserMutation) ClearTenGet() {
|
|
m.ten_get = nil
|
|
m.clearedFields[user.FieldTenGet] = struct{}{}
|
|
}
|
|
|
|
// TenGetCleared returns if the "ten_get" field was cleared in this mutation.
|
|
func (m *UserMutation) TenGetCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldTenGet]
|
|
return ok
|
|
}
|
|
|
|
// ResetTenGet resets all changes to the "ten_get" field.
|
|
func (m *UserMutation) ResetTenGet() {
|
|
m.ten_get = nil
|
|
delete(m.clearedFields, user.FieldTenGet)
|
|
}
|
|
|
|
// SetTenAt sets the "ten_at" field.
|
|
func (m *UserMutation) SetTenAt(t time.Time) {
|
|
m.ten_at = &t
|
|
}
|
|
|
|
// TenAt returns the value of the "ten_at" field in the mutation.
|
|
func (m *UserMutation) TenAt() (r time.Time, exists bool) {
|
|
v := m.ten_at
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldTenAt returns the old "ten_at" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldTenAt(ctx context.Context) (v time.Time, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldTenAt is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldTenAt requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldTenAt: %w", err)
|
|
}
|
|
return oldValue.TenAt, nil
|
|
}
|
|
|
|
// ClearTenAt clears the value of the "ten_at" field.
|
|
func (m *UserMutation) ClearTenAt() {
|
|
m.ten_at = nil
|
|
m.clearedFields[user.FieldTenAt] = struct{}{}
|
|
}
|
|
|
|
// TenAtCleared returns if the "ten_at" field was cleared in this mutation.
|
|
func (m *UserMutation) TenAtCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldTenAt]
|
|
return ok
|
|
}
|
|
|
|
// ResetTenAt resets all changes to the "ten_at" field.
|
|
func (m *UserMutation) ResetTenAt() {
|
|
m.ten_at = nil
|
|
delete(m.clearedFields, user.FieldTenAt)
|
|
}
|
|
|
|
// SetNext sets the "next" field.
|
|
func (m *UserMutation) SetNext(s string) {
|
|
m.next = &s
|
|
}
|
|
|
|
// Next returns the value of the "next" field in the mutation.
|
|
func (m *UserMutation) Next() (r string, exists bool) {
|
|
v := m.next
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// OldNext returns the old "next" field's value of the User entity.
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
func (m *UserMutation) OldNext(ctx context.Context) (v string, err error) {
|
|
if !m.op.Is(OpUpdateOne) {
|
|
return v, errors.New("OldNext is only allowed on UpdateOne operations")
|
|
}
|
|
if m.id == nil || m.oldValue == nil {
|
|
return v, errors.New("OldNext requires an ID field in the mutation")
|
|
}
|
|
oldValue, err := m.oldValue(ctx)
|
|
if err != nil {
|
|
return v, fmt.Errorf("querying old value for OldNext: %w", err)
|
|
}
|
|
return oldValue.Next, nil
|
|
}
|
|
|
|
// ClearNext clears the value of the "next" field.
|
|
func (m *UserMutation) ClearNext() {
|
|
m.next = nil
|
|
m.clearedFields[user.FieldNext] = struct{}{}
|
|
}
|
|
|
|
// NextCleared returns if the "next" field was cleared in this mutation.
|
|
func (m *UserMutation) NextCleared() bool {
|
|
_, ok := m.clearedFields[user.FieldNext]
|
|
return ok
|
|
}
|
|
|
|
// ResetNext resets all changes to the "next" field.
|
|
func (m *UserMutation) ResetNext() {
|
|
m.next = nil
|
|
delete(m.clearedFields, user.FieldNext)
|
|
}
|
|
|
|
// AddCardIDs adds the "card" edge to the Card entity by ids.
|
|
func (m *UserMutation) AddCardIDs(ids ...int) {
|
|
if m.card == nil {
|
|
m.card = make(map[int]struct{})
|
|
}
|
|
for i := range ids {
|
|
m.card[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// ClearCard clears the "card" edge to the Card entity.
|
|
func (m *UserMutation) ClearCard() {
|
|
m.clearedcard = true
|
|
}
|
|
|
|
// CardCleared reports if the "card" edge to the Card entity was cleared.
|
|
func (m *UserMutation) CardCleared() bool {
|
|
return m.clearedcard
|
|
}
|
|
|
|
// RemoveCardIDs removes the "card" edge to the Card entity by IDs.
|
|
func (m *UserMutation) RemoveCardIDs(ids ...int) {
|
|
if m.removedcard == nil {
|
|
m.removedcard = make(map[int]struct{})
|
|
}
|
|
for i := range ids {
|
|
delete(m.card, ids[i])
|
|
m.removedcard[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// RemovedCard returns the removed IDs of the "card" edge to the Card entity.
|
|
func (m *UserMutation) RemovedCardIDs() (ids []int) {
|
|
for id := range m.removedcard {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// CardIDs returns the "card" edge IDs in the mutation.
|
|
func (m *UserMutation) CardIDs() (ids []int) {
|
|
for id := range m.card {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetCard resets all changes to the "card" edge.
|
|
func (m *UserMutation) ResetCard() {
|
|
m.card = nil
|
|
m.clearedcard = false
|
|
m.removedcard = nil
|
|
}
|
|
|
|
// Where appends a list predicates to the UserMutation builder.
|
|
func (m *UserMutation) Where(ps ...predicate.User) {
|
|
m.predicates = append(m.predicates, ps...)
|
|
}
|
|
|
|
// WhereP appends storage-level predicates to the UserMutation builder. Using this method,
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
p := make([]predicate.User, len(ps))
|
|
for i := range ps {
|
|
p[i] = ps[i]
|
|
}
|
|
m.Where(p...)
|
|
}
|
|
|
|
// Op returns the operation name.
|
|
func (m *UserMutation) Op() Op {
|
|
return m.op
|
|
}
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
func (m *UserMutation) SetOp(op Op) {
|
|
m.op = op
|
|
}
|
|
|
|
// Type returns the node type of this mutation (User).
|
|
func (m *UserMutation) 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 *UserMutation) Fields() []string {
|
|
fields := make([]string, 0, 25)
|
|
if m.username != nil {
|
|
fields = append(fields, user.FieldUsername)
|
|
}
|
|
if m.did != nil {
|
|
fields = append(fields, user.FieldDid)
|
|
}
|
|
if m.delete != nil {
|
|
fields = append(fields, user.FieldDelete)
|
|
}
|
|
if m.handle != nil {
|
|
fields = append(fields, user.FieldHandle)
|
|
}
|
|
if m.token != nil {
|
|
fields = append(fields, user.FieldToken)
|
|
}
|
|
if m.password != nil {
|
|
fields = append(fields, user.FieldPassword)
|
|
}
|
|
if m.created_at != nil {
|
|
fields = append(fields, user.FieldCreatedAt)
|
|
}
|
|
if m.updated_at != nil {
|
|
fields = append(fields, user.FieldUpdatedAt)
|
|
}
|
|
if m.raid_at != nil {
|
|
fields = append(fields, user.FieldRaidAt)
|
|
}
|
|
if m.luck != nil {
|
|
fields = append(fields, user.FieldLuck)
|
|
}
|
|
if m.luck_at != nil {
|
|
fields = append(fields, user.FieldLuckAt)
|
|
}
|
|
if m.like != nil {
|
|
fields = append(fields, user.FieldLike)
|
|
}
|
|
if m.like_rank != nil {
|
|
fields = append(fields, user.FieldLikeRank)
|
|
}
|
|
if m.like_at != nil {
|
|
fields = append(fields, user.FieldLikeAt)
|
|
}
|
|
if m.fav != nil {
|
|
fields = append(fields, user.FieldFav)
|
|
}
|
|
if m.ten != nil {
|
|
fields = append(fields, user.FieldTen)
|
|
}
|
|
if m.ten_su != nil {
|
|
fields = append(fields, user.FieldTenSu)
|
|
}
|
|
if m.ten_kai != nil {
|
|
fields = append(fields, user.FieldTenKai)
|
|
}
|
|
if m.aiten != nil {
|
|
fields = append(fields, user.FieldAiten)
|
|
}
|
|
if m.ten_card != nil {
|
|
fields = append(fields, user.FieldTenCard)
|
|
}
|
|
if m.ten_delete != nil {
|
|
fields = append(fields, user.FieldTenDelete)
|
|
}
|
|
if m.ten_post != nil {
|
|
fields = append(fields, user.FieldTenPost)
|
|
}
|
|
if m.ten_get != nil {
|
|
fields = append(fields, user.FieldTenGet)
|
|
}
|
|
if m.ten_at != nil {
|
|
fields = append(fields, user.FieldTenAt)
|
|
}
|
|
if m.next != nil {
|
|
fields = append(fields, user.FieldNext)
|
|
}
|
|
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 *UserMutation) Field(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case user.FieldUsername:
|
|
return m.Username()
|
|
case user.FieldDid:
|
|
return m.Did()
|
|
case user.FieldDelete:
|
|
return m.Delete()
|
|
case user.FieldHandle:
|
|
return m.Handle()
|
|
case user.FieldToken:
|
|
return m.Token()
|
|
case user.FieldPassword:
|
|
return m.Password()
|
|
case user.FieldCreatedAt:
|
|
return m.CreatedAt()
|
|
case user.FieldUpdatedAt:
|
|
return m.UpdatedAt()
|
|
case user.FieldRaidAt:
|
|
return m.RaidAt()
|
|
case user.FieldLuck:
|
|
return m.Luck()
|
|
case user.FieldLuckAt:
|
|
return m.LuckAt()
|
|
case user.FieldLike:
|
|
return m.Like()
|
|
case user.FieldLikeRank:
|
|
return m.LikeRank()
|
|
case user.FieldLikeAt:
|
|
return m.LikeAt()
|
|
case user.FieldFav:
|
|
return m.Fav()
|
|
case user.FieldTen:
|
|
return m.Ten()
|
|
case user.FieldTenSu:
|
|
return m.TenSu()
|
|
case user.FieldTenKai:
|
|
return m.TenKai()
|
|
case user.FieldAiten:
|
|
return m.Aiten()
|
|
case user.FieldTenCard:
|
|
return m.TenCard()
|
|
case user.FieldTenDelete:
|
|
return m.TenDelete()
|
|
case user.FieldTenPost:
|
|
return m.TenPost()
|
|
case user.FieldTenGet:
|
|
return m.TenGet()
|
|
case user.FieldTenAt:
|
|
return m.TenAt()
|
|
case user.FieldNext:
|
|
return m.Next()
|
|
}
|
|
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 *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
switch name {
|
|
case user.FieldUsername:
|
|
return m.OldUsername(ctx)
|
|
case user.FieldDid:
|
|
return m.OldDid(ctx)
|
|
case user.FieldDelete:
|
|
return m.OldDelete(ctx)
|
|
case user.FieldHandle:
|
|
return m.OldHandle(ctx)
|
|
case user.FieldToken:
|
|
return m.OldToken(ctx)
|
|
case user.FieldPassword:
|
|
return m.OldPassword(ctx)
|
|
case user.FieldCreatedAt:
|
|
return m.OldCreatedAt(ctx)
|
|
case user.FieldUpdatedAt:
|
|
return m.OldUpdatedAt(ctx)
|
|
case user.FieldRaidAt:
|
|
return m.OldRaidAt(ctx)
|
|
case user.FieldLuck:
|
|
return m.OldLuck(ctx)
|
|
case user.FieldLuckAt:
|
|
return m.OldLuckAt(ctx)
|
|
case user.FieldLike:
|
|
return m.OldLike(ctx)
|
|
case user.FieldLikeRank:
|
|
return m.OldLikeRank(ctx)
|
|
case user.FieldLikeAt:
|
|
return m.OldLikeAt(ctx)
|
|
case user.FieldFav:
|
|
return m.OldFav(ctx)
|
|
case user.FieldTen:
|
|
return m.OldTen(ctx)
|
|
case user.FieldTenSu:
|
|
return m.OldTenSu(ctx)
|
|
case user.FieldTenKai:
|
|
return m.OldTenKai(ctx)
|
|
case user.FieldAiten:
|
|
return m.OldAiten(ctx)
|
|
case user.FieldTenCard:
|
|
return m.OldTenCard(ctx)
|
|
case user.FieldTenDelete:
|
|
return m.OldTenDelete(ctx)
|
|
case user.FieldTenPost:
|
|
return m.OldTenPost(ctx)
|
|
case user.FieldTenGet:
|
|
return m.OldTenGet(ctx)
|
|
case user.FieldTenAt:
|
|
return m.OldTenAt(ctx)
|
|
case user.FieldNext:
|
|
return m.OldNext(ctx)
|
|
}
|
|
return nil, fmt.Errorf("unknown User 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 *UserMutation) SetField(name string, value ent.Value) error {
|
|
switch name {
|
|
case user.FieldUsername:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetUsername(v)
|
|
return nil
|
|
case user.FieldDid:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDid(v)
|
|
return nil
|
|
case user.FieldDelete:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetDelete(v)
|
|
return nil
|
|
case user.FieldHandle:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetHandle(v)
|
|
return nil
|
|
case user.FieldToken:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetToken(v)
|
|
return nil
|
|
case user.FieldPassword:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetPassword(v)
|
|
return nil
|
|
case user.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 user.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 user.FieldRaidAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetRaidAt(v)
|
|
return nil
|
|
case user.FieldLuck:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLuck(v)
|
|
return nil
|
|
case user.FieldLuckAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLuckAt(v)
|
|
return nil
|
|
case user.FieldLike:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLike(v)
|
|
return nil
|
|
case user.FieldLikeRank:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLikeRank(v)
|
|
return nil
|
|
case user.FieldLikeAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetLikeAt(v)
|
|
return nil
|
|
case user.FieldFav:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetFav(v)
|
|
return nil
|
|
case user.FieldTen:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTen(v)
|
|
return nil
|
|
case user.FieldTenSu:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTenSu(v)
|
|
return nil
|
|
case user.FieldTenKai:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTenKai(v)
|
|
return nil
|
|
case user.FieldAiten:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetAiten(v)
|
|
return nil
|
|
case user.FieldTenCard:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTenCard(v)
|
|
return nil
|
|
case user.FieldTenDelete:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTenDelete(v)
|
|
return nil
|
|
case user.FieldTenPost:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTenPost(v)
|
|
return nil
|
|
case user.FieldTenGet:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTenGet(v)
|
|
return nil
|
|
case user.FieldTenAt:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetTenAt(v)
|
|
return nil
|
|
case user.FieldNext:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetNext(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown User field %s", name)
|
|
}
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
// this mutation.
|
|
func (m *UserMutation) AddedFields() []string {
|
|
var fields []string
|
|
if m.addluck != nil {
|
|
fields = append(fields, user.FieldLuck)
|
|
}
|
|
if m.addlike != nil {
|
|
fields = append(fields, user.FieldLike)
|
|
}
|
|
if m.addlike_rank != nil {
|
|
fields = append(fields, user.FieldLikeRank)
|
|
}
|
|
if m.addfav != nil {
|
|
fields = append(fields, user.FieldFav)
|
|
}
|
|
if m.addten_su != nil {
|
|
fields = append(fields, user.FieldTenSu)
|
|
}
|
|
if m.addten_kai != nil {
|
|
fields = append(fields, user.FieldTenKai)
|
|
}
|
|
if m.addaiten != nil {
|
|
fields = append(fields, user.FieldAiten)
|
|
}
|
|
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 *UserMutation) AddedField(name string) (ent.Value, bool) {
|
|
switch name {
|
|
case user.FieldLuck:
|
|
return m.AddedLuck()
|
|
case user.FieldLike:
|
|
return m.AddedLike()
|
|
case user.FieldLikeRank:
|
|
return m.AddedLikeRank()
|
|
case user.FieldFav:
|
|
return m.AddedFav()
|
|
case user.FieldTenSu:
|
|
return m.AddedTenSu()
|
|
case user.FieldTenKai:
|
|
return m.AddedTenKai()
|
|
case user.FieldAiten:
|
|
return m.AddedAiten()
|
|
}
|
|
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 *UserMutation) AddField(name string, value ent.Value) error {
|
|
switch name {
|
|
case user.FieldLuck:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddLuck(v)
|
|
return nil
|
|
case user.FieldLike:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddLike(v)
|
|
return nil
|
|
case user.FieldLikeRank:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddLikeRank(v)
|
|
return nil
|
|
case user.FieldFav:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddFav(v)
|
|
return nil
|
|
case user.FieldTenSu:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddTenSu(v)
|
|
return nil
|
|
case user.FieldTenKai:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddTenKai(v)
|
|
return nil
|
|
case user.FieldAiten:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddAiten(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown User numeric field %s", name)
|
|
}
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
// mutation.
|
|
func (m *UserMutation) ClearedFields() []string {
|
|
var fields []string
|
|
if m.FieldCleared(user.FieldDid) {
|
|
fields = append(fields, user.FieldDid)
|
|
}
|
|
if m.FieldCleared(user.FieldDelete) {
|
|
fields = append(fields, user.FieldDelete)
|
|
}
|
|
if m.FieldCleared(user.FieldHandle) {
|
|
fields = append(fields, user.FieldHandle)
|
|
}
|
|
if m.FieldCleared(user.FieldToken) {
|
|
fields = append(fields, user.FieldToken)
|
|
}
|
|
if m.FieldCleared(user.FieldCreatedAt) {
|
|
fields = append(fields, user.FieldCreatedAt)
|
|
}
|
|
if m.FieldCleared(user.FieldUpdatedAt) {
|
|
fields = append(fields, user.FieldUpdatedAt)
|
|
}
|
|
if m.FieldCleared(user.FieldRaidAt) {
|
|
fields = append(fields, user.FieldRaidAt)
|
|
}
|
|
if m.FieldCleared(user.FieldLuck) {
|
|
fields = append(fields, user.FieldLuck)
|
|
}
|
|
if m.FieldCleared(user.FieldLuckAt) {
|
|
fields = append(fields, user.FieldLuckAt)
|
|
}
|
|
if m.FieldCleared(user.FieldLike) {
|
|
fields = append(fields, user.FieldLike)
|
|
}
|
|
if m.FieldCleared(user.FieldLikeRank) {
|
|
fields = append(fields, user.FieldLikeRank)
|
|
}
|
|
if m.FieldCleared(user.FieldLikeAt) {
|
|
fields = append(fields, user.FieldLikeAt)
|
|
}
|
|
if m.FieldCleared(user.FieldFav) {
|
|
fields = append(fields, user.FieldFav)
|
|
}
|
|
if m.FieldCleared(user.FieldTen) {
|
|
fields = append(fields, user.FieldTen)
|
|
}
|
|
if m.FieldCleared(user.FieldTenSu) {
|
|
fields = append(fields, user.FieldTenSu)
|
|
}
|
|
if m.FieldCleared(user.FieldTenKai) {
|
|
fields = append(fields, user.FieldTenKai)
|
|
}
|
|
if m.FieldCleared(user.FieldAiten) {
|
|
fields = append(fields, user.FieldAiten)
|
|
}
|
|
if m.FieldCleared(user.FieldTenCard) {
|
|
fields = append(fields, user.FieldTenCard)
|
|
}
|
|
if m.FieldCleared(user.FieldTenDelete) {
|
|
fields = append(fields, user.FieldTenDelete)
|
|
}
|
|
if m.FieldCleared(user.FieldTenPost) {
|
|
fields = append(fields, user.FieldTenPost)
|
|
}
|
|
if m.FieldCleared(user.FieldTenGet) {
|
|
fields = append(fields, user.FieldTenGet)
|
|
}
|
|
if m.FieldCleared(user.FieldTenAt) {
|
|
fields = append(fields, user.FieldTenAt)
|
|
}
|
|
if m.FieldCleared(user.FieldNext) {
|
|
fields = append(fields, user.FieldNext)
|
|
}
|
|
return fields
|
|
}
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
// cleared in this mutation.
|
|
func (m *UserMutation) 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 *UserMutation) ClearField(name string) error {
|
|
switch name {
|
|
case user.FieldDid:
|
|
m.ClearDid()
|
|
return nil
|
|
case user.FieldDelete:
|
|
m.ClearDelete()
|
|
return nil
|
|
case user.FieldHandle:
|
|
m.ClearHandle()
|
|
return nil
|
|
case user.FieldToken:
|
|
m.ClearToken()
|
|
return nil
|
|
case user.FieldCreatedAt:
|
|
m.ClearCreatedAt()
|
|
return nil
|
|
case user.FieldUpdatedAt:
|
|
m.ClearUpdatedAt()
|
|
return nil
|
|
case user.FieldRaidAt:
|
|
m.ClearRaidAt()
|
|
return nil
|
|
case user.FieldLuck:
|
|
m.ClearLuck()
|
|
return nil
|
|
case user.FieldLuckAt:
|
|
m.ClearLuckAt()
|
|
return nil
|
|
case user.FieldLike:
|
|
m.ClearLike()
|
|
return nil
|
|
case user.FieldLikeRank:
|
|
m.ClearLikeRank()
|
|
return nil
|
|
case user.FieldLikeAt:
|
|
m.ClearLikeAt()
|
|
return nil
|
|
case user.FieldFav:
|
|
m.ClearFav()
|
|
return nil
|
|
case user.FieldTen:
|
|
m.ClearTen()
|
|
return nil
|
|
case user.FieldTenSu:
|
|
m.ClearTenSu()
|
|
return nil
|
|
case user.FieldTenKai:
|
|
m.ClearTenKai()
|
|
return nil
|
|
case user.FieldAiten:
|
|
m.ClearAiten()
|
|
return nil
|
|
case user.FieldTenCard:
|
|
m.ClearTenCard()
|
|
return nil
|
|
case user.FieldTenDelete:
|
|
m.ClearTenDelete()
|
|
return nil
|
|
case user.FieldTenPost:
|
|
m.ClearTenPost()
|
|
return nil
|
|
case user.FieldTenGet:
|
|
m.ClearTenGet()
|
|
return nil
|
|
case user.FieldTenAt:
|
|
m.ClearTenAt()
|
|
return nil
|
|
case user.FieldNext:
|
|
m.ClearNext()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown User 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 *UserMutation) ResetField(name string) error {
|
|
switch name {
|
|
case user.FieldUsername:
|
|
m.ResetUsername()
|
|
return nil
|
|
case user.FieldDid:
|
|
m.ResetDid()
|
|
return nil
|
|
case user.FieldDelete:
|
|
m.ResetDelete()
|
|
return nil
|
|
case user.FieldHandle:
|
|
m.ResetHandle()
|
|
return nil
|
|
case user.FieldToken:
|
|
m.ResetToken()
|
|
return nil
|
|
case user.FieldPassword:
|
|
m.ResetPassword()
|
|
return nil
|
|
case user.FieldCreatedAt:
|
|
m.ResetCreatedAt()
|
|
return nil
|
|
case user.FieldUpdatedAt:
|
|
m.ResetUpdatedAt()
|
|
return nil
|
|
case user.FieldRaidAt:
|
|
m.ResetRaidAt()
|
|
return nil
|
|
case user.FieldLuck:
|
|
m.ResetLuck()
|
|
return nil
|
|
case user.FieldLuckAt:
|
|
m.ResetLuckAt()
|
|
return nil
|
|
case user.FieldLike:
|
|
m.ResetLike()
|
|
return nil
|
|
case user.FieldLikeRank:
|
|
m.ResetLikeRank()
|
|
return nil
|
|
case user.FieldLikeAt:
|
|
m.ResetLikeAt()
|
|
return nil
|
|
case user.FieldFav:
|
|
m.ResetFav()
|
|
return nil
|
|
case user.FieldTen:
|
|
m.ResetTen()
|
|
return nil
|
|
case user.FieldTenSu:
|
|
m.ResetTenSu()
|
|
return nil
|
|
case user.FieldTenKai:
|
|
m.ResetTenKai()
|
|
return nil
|
|
case user.FieldAiten:
|
|
m.ResetAiten()
|
|
return nil
|
|
case user.FieldTenCard:
|
|
m.ResetTenCard()
|
|
return nil
|
|
case user.FieldTenDelete:
|
|
m.ResetTenDelete()
|
|
return nil
|
|
case user.FieldTenPost:
|
|
m.ResetTenPost()
|
|
return nil
|
|
case user.FieldTenGet:
|
|
m.ResetTenGet()
|
|
return nil
|
|
case user.FieldTenAt:
|
|
m.ResetTenAt()
|
|
return nil
|
|
case user.FieldNext:
|
|
m.ResetNext()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown User field %s", name)
|
|
}
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
func (m *UserMutation) AddedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
if m.card != nil {
|
|
edges = append(edges, user.EdgeCard)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
// name in this mutation.
|
|
func (m *UserMutation) AddedIDs(name string) []ent.Value {
|
|
switch name {
|
|
case user.EdgeCard:
|
|
ids := make([]ent.Value, 0, len(m.card))
|
|
for id := range m.card {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
func (m *UserMutation) RemovedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
if m.removedcard != nil {
|
|
edges = append(edges, user.EdgeCard)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
// the given name in this mutation.
|
|
func (m *UserMutation) RemovedIDs(name string) []ent.Value {
|
|
switch name {
|
|
case user.EdgeCard:
|
|
ids := make([]ent.Value, 0, len(m.removedcard))
|
|
for id := range m.removedcard {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
func (m *UserMutation) ClearedEdges() []string {
|
|
edges := make([]string, 0, 1)
|
|
if m.clearedcard {
|
|
edges = append(edges, user.EdgeCard)
|
|
}
|
|
return edges
|
|
}
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
// was cleared in this mutation.
|
|
func (m *UserMutation) EdgeCleared(name string) bool {
|
|
switch name {
|
|
case user.EdgeCard:
|
|
return m.clearedcard
|
|
}
|
|
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 *UserMutation) ClearEdge(name string) error {
|
|
switch name {
|
|
}
|
|
return fmt.Errorf("unknown User 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 *UserMutation) ResetEdge(name string) error {
|
|
switch name {
|
|
case user.EdgeCard:
|
|
m.ResetCard()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown User edge %s", name)
|
|
}
|