2022-08-31 07:49:08 +00:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
2022-08-31 06:18:14 +00:00
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"sync"
|
2022-08-31 07:49:08 +00:00
|
|
|
"t/ent/card"
|
|
|
|
"t/ent/group"
|
2022-08-31 06:18:14 +00:00
|
|
|
"t/ent/predicate"
|
2022-08-31 07:49:08 +00:00
|
|
|
"t/ent/user"
|
2022-08-31 06:18:14 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
2022-08-31 07:49:08 +00:00
|
|
|
"entgo.io/ent/dialect/sql"
|
2022-08-31 06:18:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Operation types.
|
|
|
|
OpCreate = ent.OpCreate
|
|
|
|
OpDelete = ent.OpDelete
|
|
|
|
OpDeleteOne = ent.OpDeleteOne
|
|
|
|
OpUpdate = ent.OpUpdate
|
|
|
|
OpUpdateOne = ent.OpUpdateOne
|
|
|
|
|
|
|
|
// Node types.
|
2022-08-31 07:49:08 +00:00
|
|
|
TypeCard = "Card"
|
|
|
|
TypeGroup = "Group"
|
|
|
|
TypeUser = "User"
|
2022-08-31 06:18:14 +00:00
|
|
|
)
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// CardMutation represents an operation that mutates the Card nodes in the graph.
|
|
|
|
type CardMutation struct {
|
2022-08-31 06:18:14 +00:00
|
|
|
config
|
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *int
|
2023-04-05 06:05:14 +00:00
|
|
|
password *string
|
2022-08-31 07:49:08 +00:00
|
|
|
card *int
|
|
|
|
addcard *int
|
2023-05-03 10:16:36 +00:00
|
|
|
skill *string
|
2022-08-31 06:18:14 +00:00
|
|
|
status *string
|
2022-08-31 07:49:08 +00:00
|
|
|
cp *int
|
|
|
|
addcp *int
|
2022-08-31 06:18:14 +00:00
|
|
|
url *string
|
2022-08-31 07:49:08 +00:00
|
|
|
created_at *time.Time
|
2022-08-31 06:18:14 +00:00
|
|
|
clearedFields map[string]struct{}
|
2022-08-31 07:49:08 +00:00
|
|
|
owner *int
|
|
|
|
clearedowner bool
|
2022-08-31 06:18:14 +00:00
|
|
|
done bool
|
2022-08-31 07:49:08 +00:00
|
|
|
oldValue func(context.Context) (*Card, error)
|
|
|
|
predicates []predicate.Card
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
var _ ent.Mutation = (*CardMutation)(nil)
|
2022-08-31 06:18:14 +00:00
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// cardOption allows management of the mutation configuration using functional options.
|
|
|
|
type cardOption func(*CardMutation)
|
2022-08-31 06:18:14 +00:00
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// newCardMutation creates new mutation for the Card entity.
|
|
|
|
func newCardMutation(c config, op Op, opts ...cardOption) *CardMutation {
|
|
|
|
m := &CardMutation{
|
2022-08-31 06:18:14 +00:00
|
|
|
config: c,
|
|
|
|
op: op,
|
2022-08-31 07:49:08 +00:00
|
|
|
typ: TypeCard,
|
2022-08-31 06:18:14 +00:00
|
|
|
clearedFields: make(map[string]struct{}),
|
|
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(m)
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// withCardID sets the ID field of the mutation.
|
|
|
|
func withCardID(id int) cardOption {
|
|
|
|
return func(m *CardMutation) {
|
2022-08-31 06:18:14 +00:00
|
|
|
var (
|
|
|
|
err error
|
|
|
|
once sync.Once
|
2022-08-31 07:49:08 +00:00
|
|
|
value *Card
|
2022-08-31 06:18:14 +00:00
|
|
|
)
|
2022-08-31 07:49:08 +00:00
|
|
|
m.oldValue = func(ctx context.Context) (*Card, error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
once.Do(func() {
|
|
|
|
if m.done {
|
|
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
|
|
} else {
|
2022-08-31 07:49:08 +00:00
|
|
|
value, err = m.Client().Card.Get(ctx, id)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return value, err
|
|
|
|
}
|
|
|
|
m.id = &id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// withCard sets the old Card of the mutation.
|
|
|
|
func withCard(node *Card) cardOption {
|
|
|
|
return func(m *CardMutation) {
|
|
|
|
m.oldValue = func(context.Context) (*Card, error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m CardMutation) Client() *Client {
|
2022-08-31 06:18:14 +00:00
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m CardMutation) Tx() (*Tx, error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *CardMutation) ID() (id int, exists bool) {
|
2022-08-31 06:18:14 +00:00
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *CardMutation) IDs(ctx context.Context) ([]int, error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
switch {
|
|
|
|
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
|
|
id, exists := m.ID()
|
|
|
|
if exists {
|
|
|
|
return []int{id}, nil
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case m.op.Is(OpUpdate | OpDelete):
|
2022-08-31 07:49:08 +00:00
|
|
|
return m.Client().Card.Query().Where(m.predicates...).IDs(ctx)
|
2022-08-31 06:18:14 +00:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-05 06:05:14 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetCard sets the "card" field.
|
|
|
|
func (m *CardMutation) SetCard(i int) {
|
|
|
|
m.card = &i
|
|
|
|
m.addcard = nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Card returns the value of the "card" field in the mutation.
|
|
|
|
func (m *CardMutation) Card() (r int, exists bool) {
|
|
|
|
v := m.card
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *CardMutation) OldCard(ctx context.Context) (v int, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldCard is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldCard requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldCard: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.Card, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// AddCard adds i to the "card" field.
|
|
|
|
func (m *CardMutation) AddCard(i int) {
|
|
|
|
if m.addcard != nil {
|
|
|
|
*m.addcard += i
|
|
|
|
} else {
|
|
|
|
m.addcard = &i
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ClearCard clears the value of the "card" field.
|
|
|
|
func (m *CardMutation) ClearCard() {
|
|
|
|
m.card = nil
|
|
|
|
m.addcard = nil
|
|
|
|
m.clearedFields[card.FieldCard] = struct{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// CardCleared returns if the "card" field was cleared in this mutation.
|
|
|
|
func (m *CardMutation) CardCleared() bool {
|
|
|
|
_, ok := m.clearedFields[card.FieldCard]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetCard resets all changes to the "card" field.
|
|
|
|
func (m *CardMutation) ResetCard() {
|
|
|
|
m.card = nil
|
|
|
|
m.addcard = nil
|
|
|
|
delete(m.clearedFields, card.FieldCard)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2023-05-03 10:16:36 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetStatus sets the "status" field.
|
|
|
|
func (m *CardMutation) SetStatus(s string) {
|
|
|
|
m.status = &s
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Status returns the value of the "status" field in the mutation.
|
|
|
|
func (m *CardMutation) Status() (r string, exists bool) {
|
|
|
|
v := m.status
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *CardMutation) OldStatus(ctx context.Context) (v string, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldStatus is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldStatus requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldStatus: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.Status, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ClearStatus clears the value of the "status" field.
|
|
|
|
func (m *CardMutation) ClearStatus() {
|
|
|
|
m.status = nil
|
|
|
|
m.clearedFields[card.FieldStatus] = struct{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// StatusCleared returns if the "status" field was cleared in this mutation.
|
|
|
|
func (m *CardMutation) StatusCleared() bool {
|
|
|
|
_, ok := m.clearedFields[card.FieldStatus]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetStatus resets all changes to the "status" field.
|
|
|
|
func (m *CardMutation) ResetStatus() {
|
|
|
|
m.status = nil
|
|
|
|
delete(m.clearedFields, card.FieldStatus)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetCp sets the "cp" field.
|
|
|
|
func (m *CardMutation) SetCp(i int) {
|
|
|
|
m.cp = &i
|
|
|
|
m.addcp = nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Cp returns the value of the "cp" field in the mutation.
|
|
|
|
func (m *CardMutation) Cp() (r int, exists bool) {
|
|
|
|
v := m.cp
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *CardMutation) OldCp(ctx context.Context) (v int, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldCp is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldCp requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldCp: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.Cp, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// AddCp adds i to the "cp" field.
|
|
|
|
func (m *CardMutation) AddCp(i int) {
|
|
|
|
if m.addcp != nil {
|
|
|
|
*m.addcp += i
|
2022-08-31 06:18:14 +00:00
|
|
|
} else {
|
2022-08-31 07:49:08 +00:00
|
|
|
m.addcp = &i
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ClearCp clears the value of the "cp" field.
|
|
|
|
func (m *CardMutation) ClearCp() {
|
|
|
|
m.cp = nil
|
|
|
|
m.addcp = nil
|
|
|
|
m.clearedFields[card.FieldCp] = struct{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// CpCleared returns if the "cp" field was cleared in this mutation.
|
|
|
|
func (m *CardMutation) CpCleared() bool {
|
|
|
|
_, ok := m.clearedFields[card.FieldCp]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetCp resets all changes to the "cp" field.
|
|
|
|
func (m *CardMutation) ResetCp() {
|
|
|
|
m.cp = nil
|
|
|
|
m.addcp = nil
|
|
|
|
delete(m.clearedFields, card.FieldCp)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetURL sets the "url" field.
|
|
|
|
func (m *CardMutation) SetURL(s string) {
|
|
|
|
m.url = &s
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// URL returns the value of the "url" field in the mutation.
|
|
|
|
func (m *CardMutation) URL() (r string, exists bool) {
|
|
|
|
v := m.url
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *CardMutation) OldURL(ctx context.Context) (v string, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldURL is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldURL requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldURL: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.URL, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ClearURL clears the value of the "url" field.
|
|
|
|
func (m *CardMutation) ClearURL() {
|
|
|
|
m.url = nil
|
|
|
|
m.clearedFields[card.FieldURL] = struct{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// URLCleared returns if the "url" field was cleared in this mutation.
|
|
|
|
func (m *CardMutation) URLCleared() bool {
|
|
|
|
_, ok := m.clearedFields[card.FieldURL]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetURL resets all changes to the "url" field.
|
|
|
|
func (m *CardMutation) ResetURL() {
|
|
|
|
m.url = nil
|
|
|
|
delete(m.clearedFields, card.FieldURL)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
|
|
func (m *CardMutation) SetCreatedAt(t time.Time) {
|
|
|
|
m.created_at = &t
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *CardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.CreatedAt, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ClearCreatedAt clears the value of the "created_at" field.
|
|
|
|
func (m *CardMutation) ClearCreatedAt() {
|
|
|
|
m.created_at = nil
|
|
|
|
m.clearedFields[card.FieldCreatedAt] = struct{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
|
|
|
|
func (m *CardMutation) CreatedAtCleared() bool {
|
|
|
|
_, ok := m.clearedFields[card.FieldCreatedAt]
|
|
|
|
return ok
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
|
|
func (m *CardMutation) ResetCreatedAt() {
|
|
|
|
m.created_at = nil
|
|
|
|
delete(m.clearedFields, card.FieldCreatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetOwnerID sets the "owner" edge to the User entity by id.
|
|
|
|
func (m *CardMutation) SetOwnerID(id int) {
|
|
|
|
m.owner = &id
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ClearOwner clears the "owner" edge to the User entity.
|
|
|
|
func (m *CardMutation) ClearOwner() {
|
|
|
|
m.clearedowner = true
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// OwnerCleared reports if the "owner" edge to the User entity was cleared.
|
|
|
|
func (m *CardMutation) OwnerCleared() bool {
|
|
|
|
return m.clearedowner
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetOwner resets all changes to the "owner" edge.
|
|
|
|
func (m *CardMutation) ResetOwner() {
|
|
|
|
m.owner = nil
|
|
|
|
m.clearedowner = false
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Where appends a list predicates to the CardMutation builder.
|
|
|
|
func (m *CardMutation) Where(ps ...predicate.Card) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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...)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Op returns the operation name.
|
|
|
|
func (m *CardMutation) Op() Op {
|
|
|
|
return m.op
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetOp allows setting the mutation operation.
|
|
|
|
func (m *CardMutation) SetOp(op Op) {
|
|
|
|
m.op = op
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Type returns the node type of this mutation (Card).
|
|
|
|
func (m *CardMutation) Type() string {
|
|
|
|
return m.typ
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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 {
|
2023-05-03 10:16:36 +00:00
|
|
|
fields := make([]string, 0, 7)
|
2023-04-05 06:05:14 +00:00
|
|
|
if m.password != nil {
|
|
|
|
fields = append(fields, card.FieldPassword)
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.card != nil {
|
|
|
|
fields = append(fields, card.FieldCard)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2023-05-03 10:16:36 +00:00
|
|
|
if m.skill != nil {
|
|
|
|
fields = append(fields, card.FieldSkill)
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.status != nil {
|
|
|
|
fields = append(fields, card.FieldStatus)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.cp != nil {
|
|
|
|
fields = append(fields, card.FieldCp)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.url != nil {
|
|
|
|
fields = append(fields, card.FieldURL)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.created_at != nil {
|
|
|
|
fields = append(fields, card.FieldCreatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fields
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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 {
|
2023-04-05 06:05:14 +00:00
|
|
|
case card.FieldPassword:
|
|
|
|
return m.Password()
|
2022-08-31 07:49:08 +00:00
|
|
|
case card.FieldCard:
|
|
|
|
return m.Card()
|
2023-05-03 10:16:36 +00:00
|
|
|
case card.FieldSkill:
|
|
|
|
return m.Skill()
|
2022-08-31 07:49:08 +00:00
|
|
|
case card.FieldStatus:
|
|
|
|
return m.Status()
|
|
|
|
case card.FieldCp:
|
|
|
|
return m.Cp()
|
|
|
|
case card.FieldURL:
|
|
|
|
return m.URL()
|
|
|
|
case card.FieldCreatedAt:
|
|
|
|
return m.CreatedAt()
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return nil, false
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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 {
|
2023-04-05 06:05:14 +00:00
|
|
|
case card.FieldPassword:
|
|
|
|
return m.OldPassword(ctx)
|
2022-08-31 07:49:08 +00:00
|
|
|
case card.FieldCard:
|
|
|
|
return m.OldCard(ctx)
|
2023-05-03 10:16:36 +00:00
|
|
|
case card.FieldSkill:
|
|
|
|
return m.OldSkill(ctx)
|
2022-08-31 07:49:08 +00:00
|
|
|
case card.FieldStatus:
|
|
|
|
return m.OldStatus(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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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 {
|
2023-04-05 06:05:14 +00:00
|
|
|
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
|
2022-08-31 07:49:08 +00:00
|
|
|
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
|
2023-05-03 10:16:36 +00:00
|
|
|
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
|
2022-08-31 07:49:08 +00:00
|
|
|
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.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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fmt.Errorf("unknown Card numeric field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2023-05-03 10:16:36 +00:00
|
|
|
if m.FieldCleared(card.FieldSkill) {
|
|
|
|
fields = append(fields, card.FieldSkill)
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.FieldCleared(card.FieldStatus) {
|
|
|
|
fields = append(fields, card.FieldStatus)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.FieldCleared(card.FieldCp) {
|
|
|
|
fields = append(fields, card.FieldCp)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.FieldCleared(card.FieldURL) {
|
|
|
|
fields = append(fields, card.FieldURL)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.FieldCleared(card.FieldCreatedAt) {
|
|
|
|
fields = append(fields, card.FieldCreatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fields
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2023-05-03 10:16:36 +00:00
|
|
|
case card.FieldSkill:
|
|
|
|
m.ClearSkill()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case card.FieldStatus:
|
|
|
|
m.ClearStatus()
|
|
|
|
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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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 {
|
2023-04-05 06:05:14 +00:00
|
|
|
case card.FieldPassword:
|
|
|
|
m.ResetPassword()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case card.FieldCard:
|
|
|
|
m.ResetCard()
|
|
|
|
return nil
|
2023-05-03 10:16:36 +00:00
|
|
|
case card.FieldSkill:
|
|
|
|
m.ResetSkill()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case card.FieldStatus:
|
|
|
|
m.ResetStatus()
|
|
|
|
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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return edges
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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}
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return false
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fmt.Errorf("unknown Card unique edge %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fmt.Errorf("unknown Card edge %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// GroupMutation represents an operation that mutates the Group nodes in the graph.
|
|
|
|
type GroupMutation struct {
|
|
|
|
config
|
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *int
|
|
|
|
name *string
|
2023-04-05 06:05:14 +00:00
|
|
|
password *string
|
2022-08-31 07:49:08 +00:00
|
|
|
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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetName sets the "name" field.
|
|
|
|
func (m *GroupMutation) SetName(s string) {
|
|
|
|
m.name = &s
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Name returns the value of the "name" field in the mutation.
|
|
|
|
func (m *GroupMutation) Name() (r string, exists bool) {
|
|
|
|
v := m.name
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *GroupMutation) OldName(ctx context.Context) (v string, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldName is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldName requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldName: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.Name, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetName resets all changes to the "name" field.
|
|
|
|
func (m *GroupMutation) ResetName() {
|
|
|
|
m.name = nil
|
|
|
|
}
|
|
|
|
|
2023-04-05 06:05:14 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetUsers resets all changes to the "users" edge.
|
|
|
|
func (m *GroupMutation) ResetUsers() {
|
|
|
|
m.users = nil
|
|
|
|
m.clearedusers = false
|
|
|
|
m.removedusers = nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Where appends a list predicates to the GroupMutation builder.
|
|
|
|
func (m *GroupMutation) Where(ps ...predicate.Group) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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]
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
m.Where(p...)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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 {
|
2023-04-05 06:05:14 +00:00
|
|
|
fields := make([]string, 0, 2)
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.name != nil {
|
|
|
|
fields = append(fields, group.FieldName)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2023-04-05 06:05:14 +00:00
|
|
|
if m.password != nil {
|
|
|
|
fields = append(fields, group.FieldPassword)
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
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()
|
2023-04-05 06:05:14 +00:00
|
|
|
case group.FieldPassword:
|
|
|
|
return m.Password()
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
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)
|
2023-04-05 06:05:14 +00:00
|
|
|
case group.FieldPassword:
|
|
|
|
return m.OldPassword(ctx)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return nil, fmt.Errorf("unknown Group field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2023-04-05 06:05:14 +00:00
|
|
|
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
|
2022-08-31 07:49:08 +00:00
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown Group field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2023-04-05 06:05:14 +00:00
|
|
|
case group.FieldPassword:
|
|
|
|
m.ResetPassword()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown Group field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return edges
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// UserMutation represents an operation that mutates the User nodes in the graph.
|
|
|
|
type UserMutation struct {
|
|
|
|
config
|
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *int
|
|
|
|
username *string
|
2023-04-13 07:50:11 +00:00
|
|
|
did *string
|
2023-05-01 14:00:17 +00:00
|
|
|
delete *bool
|
2023-04-18 12:18:38 +00:00
|
|
|
token *string
|
2023-04-05 06:05:14 +00:00
|
|
|
password *string
|
2022-08-31 07:49:08 +00:00
|
|
|
created_at *time.Time
|
|
|
|
updated_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
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldUsername is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldUsername requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldUsername: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.Username, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetUsername resets all changes to the "username" field.
|
|
|
|
func (m *UserMutation) ResetUsername() {
|
|
|
|
m.username = nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 07:50:11 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2023-05-01 14:00:17 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2023-04-18 12:18:38 +00:00
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
|
2023-04-05 06:05:14 +00:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2022-08-31 06:18:14 +00:00
|
|
|
// SetCreatedAt sets the "created_at" field.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) SetCreatedAt(t time.Time) {
|
2022-08-31 06:18:14 +00:00
|
|
|
m.created_at = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) CreatedAt() (r time.Time, exists bool) {
|
2022-08-31 06:18:14 +00:00
|
|
|
v := m.created_at
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) ClearCreatedAt() {
|
2022-08-31 06:18:14 +00:00
|
|
|
m.created_at = nil
|
2022-08-31 07:49:08 +00:00
|
|
|
m.clearedFields[user.FieldCreatedAt] = struct{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) CreatedAtCleared() bool {
|
|
|
|
_, ok := m.clearedFields[user.FieldCreatedAt]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) ResetCreatedAt() {
|
2022-08-31 06:18:14 +00:00
|
|
|
m.created_at = nil
|
2022-08-31 07:49:08 +00:00
|
|
|
delete(m.clearedFields, user.FieldCreatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
|
|
func (m *UserMutation) SetUpdatedAt(t time.Time) {
|
|
|
|
m.updated_at = &t
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.UpdatedAt, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ClearUpdatedAt clears the value of the "updated_at" field.
|
|
|
|
func (m *UserMutation) ClearUpdatedAt() {
|
|
|
|
m.updated_at = nil
|
|
|
|
m.clearedFields[user.FieldUpdatedAt] = struct{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
|
|
|
|
func (m *UserMutation) UpdatedAtCleared() bool {
|
|
|
|
_, ok := m.clearedFields[user.FieldUpdatedAt]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
|
|
func (m *UserMutation) ResetUpdatedAt() {
|
|
|
|
m.updated_at = nil
|
|
|
|
delete(m.clearedFields, user.FieldUpdatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// SetNext sets the "next" field.
|
|
|
|
func (m *UserMutation) SetNext(s string) {
|
|
|
|
m.next = &s
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Next returns the value of the "next" field in the mutation.
|
|
|
|
func (m *UserMutation) Next() (r string, exists bool) {
|
|
|
|
v := m.next
|
2022-08-31 06:18:14 +00:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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.
|
2022-08-31 06:18:14 +00:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) OldNext(ctx context.Context) (v string, err error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldNext is only allowed on UpdateOne operations")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, errors.New("OldNext requires an ID field in the mutation")
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
return v, fmt.Errorf("querying old value for OldNext: %w", err)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return oldValue.Next, nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ClearNext clears the value of the "next" field.
|
|
|
|
func (m *UserMutation) ClearNext() {
|
|
|
|
m.next = nil
|
|
|
|
m.clearedFields[user.FieldNext] = struct{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// NextCleared returns if the "next" field was cleared in this mutation.
|
|
|
|
func (m *UserMutation) NextCleared() bool {
|
|
|
|
_, ok := m.clearedFields[user.FieldNext]
|
2022-08-31 06:18:14 +00:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// CardCleared reports if the "card" edge to the Card entity was cleared.
|
|
|
|
func (m *UserMutation) CardCleared() bool {
|
|
|
|
return m.clearedcard
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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{}{}
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// ResetCard resets all changes to the "card" edge.
|
|
|
|
func (m *UserMutation) ResetCard() {
|
|
|
|
m.card = nil
|
|
|
|
m.clearedcard = false
|
|
|
|
m.removedcard = nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// Where appends a list predicates to the UserMutation builder.
|
|
|
|
func (m *UserMutation) Where(ps ...predicate.User) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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...)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Op returns the operation name.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) Op() Op {
|
2022-08-31 06:18:14 +00:00
|
|
|
return m.op
|
|
|
|
}
|
|
|
|
|
2022-08-31 07:49:08 +00:00
|
|
|
// 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 {
|
2022-08-31 06:18:14 +00:00
|
|
|
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().
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) Fields() []string {
|
2023-05-01 14:00:17 +00:00
|
|
|
fields := make([]string, 0, 8)
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.username != nil {
|
|
|
|
fields = append(fields, user.FieldUsername)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2023-04-13 07:50:11 +00:00
|
|
|
if m.did != nil {
|
|
|
|
fields = append(fields, user.FieldDid)
|
|
|
|
}
|
2023-05-01 14:00:17 +00:00
|
|
|
if m.delete != nil {
|
|
|
|
fields = append(fields, user.FieldDelete)
|
|
|
|
}
|
2023-04-18 12:18:38 +00:00
|
|
|
if m.token != nil {
|
|
|
|
fields = append(fields, user.FieldToken)
|
|
|
|
}
|
2023-04-05 06:05:14 +00:00
|
|
|
if m.password != nil {
|
|
|
|
fields = append(fields, user.FieldPassword)
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
if m.created_at != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
fields = append(fields, user.FieldCreatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
if m.updated_at != nil {
|
2022-08-31 07:49:08 +00:00
|
|
|
fields = append(fields, user.FieldUpdatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.next != nil {
|
|
|
|
fields = append(fields, user.FieldNext)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) Field(name string) (ent.Value, bool) {
|
2022-08-31 06:18:14 +00:00
|
|
|
switch name {
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUsername:
|
|
|
|
return m.Username()
|
2023-04-13 07:50:11 +00:00
|
|
|
case user.FieldDid:
|
|
|
|
return m.Did()
|
2023-05-01 14:00:17 +00:00
|
|
|
case user.FieldDelete:
|
|
|
|
return m.Delete()
|
2023-04-18 12:18:38 +00:00
|
|
|
case user.FieldToken:
|
|
|
|
return m.Token()
|
2023-04-05 06:05:14 +00:00
|
|
|
case user.FieldPassword:
|
|
|
|
return m.Password()
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldCreatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
return m.CreatedAt()
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUpdatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
return m.UpdatedAt()
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldNext:
|
|
|
|
return m.Next()
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
2022-08-31 06:18:14 +00:00
|
|
|
switch name {
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUsername:
|
|
|
|
return m.OldUsername(ctx)
|
2023-04-13 07:50:11 +00:00
|
|
|
case user.FieldDid:
|
|
|
|
return m.OldDid(ctx)
|
2023-05-01 14:00:17 +00:00
|
|
|
case user.FieldDelete:
|
|
|
|
return m.OldDelete(ctx)
|
2023-04-18 12:18:38 +00:00
|
|
|
case user.FieldToken:
|
|
|
|
return m.OldToken(ctx)
|
2023-04-05 06:05:14 +00:00
|
|
|
case user.FieldPassword:
|
|
|
|
return m.OldPassword(ctx)
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldCreatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
return m.OldCreatedAt(ctx)
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUpdatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
return m.OldUpdatedAt(ctx)
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldNext:
|
|
|
|
return m.OldNext(ctx)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return nil, fmt.Errorf("unknown User field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) SetField(name string, value ent.Value) error {
|
2022-08-31 06:18:14 +00:00
|
|
|
switch name {
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUsername:
|
2022-08-31 06:18:14 +00:00
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
m.SetUsername(v)
|
2022-08-31 06:18:14 +00:00
|
|
|
return nil
|
2023-04-13 07:50:11 +00:00
|
|
|
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
|
2023-05-01 14:00:17 +00:00
|
|
|
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
|
2023-04-18 12:18:38 +00:00
|
|
|
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
|
2023-04-05 06:05:14 +00:00
|
|
|
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
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldCreatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetCreatedAt(v)
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUpdatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetUpdatedAt(v)
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldNext:
|
2022-08-31 06:18:14 +00:00
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
m.SetNext(v)
|
2022-08-31 06:18:14 +00:00
|
|
|
return nil
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fmt.Errorf("unknown User field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) AddedFields() []string {
|
|
|
|
return nil
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) AddedField(name string) (ent.Value, bool) {
|
2022-08-31 06:18:14 +00:00
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) AddField(name string, value ent.Value) error {
|
2022-08-31 06:18:14 +00:00
|
|
|
switch name {
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fmt.Errorf("unknown User numeric field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) ClearedFields() []string {
|
2022-08-31 06:18:14 +00:00
|
|
|
var fields []string
|
2023-04-13 07:50:11 +00:00
|
|
|
if m.FieldCleared(user.FieldDid) {
|
|
|
|
fields = append(fields, user.FieldDid)
|
|
|
|
}
|
2023-05-01 14:00:17 +00:00
|
|
|
if m.FieldCleared(user.FieldDelete) {
|
|
|
|
fields = append(fields, user.FieldDelete)
|
|
|
|
}
|
2023-04-18 12:18:38 +00:00
|
|
|
if m.FieldCleared(user.FieldToken) {
|
|
|
|
fields = append(fields, user.FieldToken)
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.FieldCleared(user.FieldCreatedAt) {
|
|
|
|
fields = append(fields, user.FieldCreatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.FieldCleared(user.FieldUpdatedAt) {
|
|
|
|
fields = append(fields, user.FieldUpdatedAt)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
if m.FieldCleared(user.FieldNext) {
|
|
|
|
fields = append(fields, user.FieldNext)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) FieldCleared(name string) bool {
|
2022-08-31 06:18:14 +00:00
|
|
|
_, 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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) ClearField(name string) error {
|
2022-08-31 06:18:14 +00:00
|
|
|
switch name {
|
2023-04-13 07:50:11 +00:00
|
|
|
case user.FieldDid:
|
|
|
|
m.ClearDid()
|
|
|
|
return nil
|
2023-05-01 14:00:17 +00:00
|
|
|
case user.FieldDelete:
|
|
|
|
m.ClearDelete()
|
|
|
|
return nil
|
2023-04-18 12:18:38 +00:00
|
|
|
case user.FieldToken:
|
|
|
|
m.ClearToken()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldCreatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
m.ClearCreatedAt()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUpdatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
m.ClearUpdatedAt()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldNext:
|
|
|
|
m.ClearNext()
|
2022-08-31 06:18:14 +00:00
|
|
|
return nil
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fmt.Errorf("unknown User nullable field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) ResetField(name string) error {
|
2022-08-31 06:18:14 +00:00
|
|
|
switch name {
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUsername:
|
|
|
|
m.ResetUsername()
|
2022-08-31 06:18:14 +00:00
|
|
|
return nil
|
2023-04-13 07:50:11 +00:00
|
|
|
case user.FieldDid:
|
|
|
|
m.ResetDid()
|
|
|
|
return nil
|
2023-05-01 14:00:17 +00:00
|
|
|
case user.FieldDelete:
|
|
|
|
m.ResetDelete()
|
|
|
|
return nil
|
2023-04-18 12:18:38 +00:00
|
|
|
case user.FieldToken:
|
|
|
|
m.ResetToken()
|
|
|
|
return nil
|
2023-04-05 06:05:14 +00:00
|
|
|
case user.FieldPassword:
|
|
|
|
m.ResetPassword()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldCreatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
m.ResetCreatedAt()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldUpdatedAt:
|
2022-08-31 06:18:14 +00:00
|
|
|
m.ResetUpdatedAt()
|
|
|
|
return nil
|
2022-08-31 07:49:08 +00:00
|
|
|
case user.FieldNext:
|
|
|
|
m.ResetNext()
|
2022-08-31 06:18:14 +00:00
|
|
|
return nil
|
|
|
|
}
|
2022-08-31 07:49:08 +00:00
|
|
|
return fmt.Errorf("unknown User field %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) AddedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.card != nil {
|
|
|
|
edges = append(edges, user.EdgeCard)
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
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
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) RemovedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.removedcard != nil {
|
|
|
|
edges = append(edges, user.EdgeCard)
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
|
// the given name in this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
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
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) ClearedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.clearedcard {
|
|
|
|
edges = append(edges, user.EdgeCard)
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) EdgeCleared(name string) bool {
|
|
|
|
switch name {
|
|
|
|
case user.EdgeCard:
|
|
|
|
return m.clearedcard
|
|
|
|
}
|
2022-08-31 06:18:14 +00:00
|
|
|
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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) ClearEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown User unique edge %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2022-08-31 07:49:08 +00:00
|
|
|
func (m *UserMutation) ResetEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case user.EdgeCard:
|
|
|
|
m.ResetCard()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown User edge %s", name)
|
2022-08-31 06:18:14 +00:00
|
|
|
}
|