1437 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			1437 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Code generated by ent, DO NOT EDIT.
 | |
| 
 | |
| package ent
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"errors"
 | |
| 	"fmt"
 | |
| 	"sync"
 | |
| 	"time"
 | |
| 
 | |
| 	"code.icod.de/auth/accountserver/ent/account"
 | |
| 	"code.icod.de/auth/accountserver/ent/email"
 | |
| 	"code.icod.de/auth/accountserver/ent/predicate"
 | |
| 	"entgo.io/ent"
 | |
| 	"entgo.io/ent/dialect/sql"
 | |
| 	"github.com/google/uuid"
 | |
| )
 | |
| 
 | |
| const (
 | |
| 	// Operation types.
 | |
| 	OpCreate    = ent.OpCreate
 | |
| 	OpDelete    = ent.OpDelete
 | |
| 	OpDeleteOne = ent.OpDeleteOne
 | |
| 	OpUpdate    = ent.OpUpdate
 | |
| 	OpUpdateOne = ent.OpUpdateOne
 | |
| 
 | |
| 	// Node types.
 | |
| 	TypeAccount = "Account"
 | |
| 	TypeEmail   = "Email"
 | |
| )
 | |
| 
 | |
| // AccountMutation represents an operation that mutates the Account nodes in the graph.
 | |
| type AccountMutation struct {
 | |
| 	config
 | |
| 	op            Op
 | |
| 	typ           string
 | |
| 	id            *uuid.UUID
 | |
| 	created_at    *time.Time
 | |
| 	updated_at    *time.Time
 | |
| 	nickname      *string
 | |
| 	name          *string
 | |
| 	secret        *[]byte
 | |
| 	aes           *[]byte
 | |
| 	x509          *[]byte
 | |
| 	clearedFields map[string]struct{}
 | |
| 	emails        map[uuid.UUID]struct{}
 | |
| 	removedemails map[uuid.UUID]struct{}
 | |
| 	clearedemails bool
 | |
| 	done          bool
 | |
| 	oldValue      func(context.Context) (*Account, error)
 | |
| 	predicates    []predicate.Account
 | |
| }
 | |
| 
 | |
| var _ ent.Mutation = (*AccountMutation)(nil)
 | |
| 
 | |
| // accountOption allows management of the mutation configuration using functional options.
 | |
| type accountOption func(*AccountMutation)
 | |
| 
 | |
| // newAccountMutation creates new mutation for the Account entity.
 | |
| func newAccountMutation(c config, op Op, opts ...accountOption) *AccountMutation {
 | |
| 	m := &AccountMutation{
 | |
| 		config:        c,
 | |
| 		op:            op,
 | |
| 		typ:           TypeAccount,
 | |
| 		clearedFields: make(map[string]struct{}),
 | |
| 	}
 | |
| 	for _, opt := range opts {
 | |
| 		opt(m)
 | |
| 	}
 | |
| 	return m
 | |
| }
 | |
| 
 | |
| // withAccountID sets the ID field of the mutation.
 | |
| func withAccountID(id uuid.UUID) accountOption {
 | |
| 	return func(m *AccountMutation) {
 | |
| 		var (
 | |
| 			err   error
 | |
| 			once  sync.Once
 | |
| 			value *Account
 | |
| 		)
 | |
| 		m.oldValue = func(ctx context.Context) (*Account, error) {
 | |
| 			once.Do(func() {
 | |
| 				if m.done {
 | |
| 					err = errors.New("querying old values post mutation is not allowed")
 | |
| 				} else {
 | |
| 					value, err = m.Client().Account.Get(ctx, id)
 | |
| 				}
 | |
| 			})
 | |
| 			return value, err
 | |
| 		}
 | |
| 		m.id = &id
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // withAccount sets the old Account of the mutation.
 | |
| func withAccount(node *Account) accountOption {
 | |
| 	return func(m *AccountMutation) {
 | |
| 		m.oldValue = func(context.Context) (*Account, 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 AccountMutation) 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 AccountMutation) 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
 | |
| }
 | |
| 
 | |
| // SetID sets the value of the id field. Note that this
 | |
| // operation is only accepted on creation of Account entities.
 | |
| func (m *AccountMutation) SetID(id uuid.UUID) {
 | |
| 	m.id = &id
 | |
| }
 | |
| 
 | |
| // ID returns the ID value in the mutation. Note that the ID is only available
 | |
| // if it was provided to the builder or after it was returned from the database.
 | |
| func (m *AccountMutation) ID() (id uuid.UUID, 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 *AccountMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
 | |
| 	switch {
 | |
| 	case m.op.Is(OpUpdateOne | OpDeleteOne):
 | |
| 		id, exists := m.ID()
 | |
| 		if exists {
 | |
| 			return []uuid.UUID{id}, nil
 | |
| 		}
 | |
| 		fallthrough
 | |
| 	case m.op.Is(OpUpdate | OpDelete):
 | |
| 		return m.Client().Account.Query().Where(m.predicates...).IDs(ctx)
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // SetCreatedAt sets the "created_at" field.
 | |
| func (m *AccountMutation) SetCreatedAt(t time.Time) {
 | |
| 	m.created_at = &t
 | |
| }
 | |
| 
 | |
| // CreatedAt returns the value of the "created_at" field in the mutation.
 | |
| func (m *AccountMutation) CreatedAt() (r time.Time, exists bool) {
 | |
| 	v := m.created_at
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldCreatedAt returns the old "created_at" field's value of the Account entity.
 | |
| // If the Account 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 *AccountMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
 | |
| 	}
 | |
| 	return oldValue.CreatedAt, nil
 | |
| }
 | |
| 
 | |
| // ResetCreatedAt resets all changes to the "created_at" field.
 | |
| func (m *AccountMutation) ResetCreatedAt() {
 | |
| 	m.created_at = nil
 | |
| }
 | |
| 
 | |
| // SetUpdatedAt sets the "updated_at" field.
 | |
| func (m *AccountMutation) SetUpdatedAt(t time.Time) {
 | |
| 	m.updated_at = &t
 | |
| }
 | |
| 
 | |
| // UpdatedAt returns the value of the "updated_at" field in the mutation.
 | |
| func (m *AccountMutation) UpdatedAt() (r time.Time, exists bool) {
 | |
| 	v := m.updated_at
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldUpdatedAt returns the old "updated_at" field's value of the Account entity.
 | |
| // If the Account 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 *AccountMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
 | |
| 	}
 | |
| 	return oldValue.UpdatedAt, nil
 | |
| }
 | |
| 
 | |
| // ResetUpdatedAt resets all changes to the "updated_at" field.
 | |
| func (m *AccountMutation) ResetUpdatedAt() {
 | |
| 	m.updated_at = nil
 | |
| }
 | |
| 
 | |
| // SetNickname sets the "nickname" field.
 | |
| func (m *AccountMutation) SetNickname(s string) {
 | |
| 	m.nickname = &s
 | |
| }
 | |
| 
 | |
| // Nickname returns the value of the "nickname" field in the mutation.
 | |
| func (m *AccountMutation) Nickname() (r string, exists bool) {
 | |
| 	v := m.nickname
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldNickname returns the old "nickname" field's value of the Account entity.
 | |
| // If the Account 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 *AccountMutation) OldNickname(ctx context.Context) (v string, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldNickname is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldNickname requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldNickname: %w", err)
 | |
| 	}
 | |
| 	return oldValue.Nickname, nil
 | |
| }
 | |
| 
 | |
| // ResetNickname resets all changes to the "nickname" field.
 | |
| func (m *AccountMutation) ResetNickname() {
 | |
| 	m.nickname = nil
 | |
| }
 | |
| 
 | |
| // SetName sets the "name" field.
 | |
| func (m *AccountMutation) SetName(s string) {
 | |
| 	m.name = &s
 | |
| }
 | |
| 
 | |
| // Name returns the value of the "name" field in the mutation.
 | |
| func (m *AccountMutation) Name() (r string, exists bool) {
 | |
| 	v := m.name
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldName returns the old "name" field's value of the Account entity.
 | |
| // If the Account 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 *AccountMutation) OldName(ctx context.Context) (v string, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldName is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldName requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldName: %w", err)
 | |
| 	}
 | |
| 	return oldValue.Name, nil
 | |
| }
 | |
| 
 | |
| // ResetName resets all changes to the "name" field.
 | |
| func (m *AccountMutation) ResetName() {
 | |
| 	m.name = nil
 | |
| }
 | |
| 
 | |
| // SetSecret sets the "secret" field.
 | |
| func (m *AccountMutation) SetSecret(b []byte) {
 | |
| 	m.secret = &b
 | |
| }
 | |
| 
 | |
| // Secret returns the value of the "secret" field in the mutation.
 | |
| func (m *AccountMutation) Secret() (r []byte, exists bool) {
 | |
| 	v := m.secret
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldSecret returns the old "secret" field's value of the Account entity.
 | |
| // If the Account 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 *AccountMutation) OldSecret(ctx context.Context) (v []byte, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldSecret is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldSecret requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldSecret: %w", err)
 | |
| 	}
 | |
| 	return oldValue.Secret, nil
 | |
| }
 | |
| 
 | |
| // ResetSecret resets all changes to the "secret" field.
 | |
| func (m *AccountMutation) ResetSecret() {
 | |
| 	m.secret = nil
 | |
| }
 | |
| 
 | |
| // SetAes sets the "aes" field.
 | |
| func (m *AccountMutation) SetAes(b []byte) {
 | |
| 	m.aes = &b
 | |
| }
 | |
| 
 | |
| // Aes returns the value of the "aes" field in the mutation.
 | |
| func (m *AccountMutation) Aes() (r []byte, exists bool) {
 | |
| 	v := m.aes
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldAes returns the old "aes" field's value of the Account entity.
 | |
| // If the Account 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 *AccountMutation) OldAes(ctx context.Context) (v []byte, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldAes is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldAes requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldAes: %w", err)
 | |
| 	}
 | |
| 	return oldValue.Aes, nil
 | |
| }
 | |
| 
 | |
| // ResetAes resets all changes to the "aes" field.
 | |
| func (m *AccountMutation) ResetAes() {
 | |
| 	m.aes = nil
 | |
| }
 | |
| 
 | |
| // SetX509 sets the "x509" field.
 | |
| func (m *AccountMutation) SetX509(b []byte) {
 | |
| 	m.x509 = &b
 | |
| }
 | |
| 
 | |
| // X509 returns the value of the "x509" field in the mutation.
 | |
| func (m *AccountMutation) X509() (r []byte, exists bool) {
 | |
| 	v := m.x509
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldX509 returns the old "x509" field's value of the Account entity.
 | |
| // If the Account 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 *AccountMutation) OldX509(ctx context.Context) (v []byte, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldX509 is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldX509 requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldX509: %w", err)
 | |
| 	}
 | |
| 	return oldValue.X509, nil
 | |
| }
 | |
| 
 | |
| // ResetX509 resets all changes to the "x509" field.
 | |
| func (m *AccountMutation) ResetX509() {
 | |
| 	m.x509 = nil
 | |
| }
 | |
| 
 | |
| // AddEmailIDs adds the "emails" edge to the Email entity by ids.
 | |
| func (m *AccountMutation) AddEmailIDs(ids ...uuid.UUID) {
 | |
| 	if m.emails == nil {
 | |
| 		m.emails = make(map[uuid.UUID]struct{})
 | |
| 	}
 | |
| 	for i := range ids {
 | |
| 		m.emails[ids[i]] = struct{}{}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // ClearEmails clears the "emails" edge to the Email entity.
 | |
| func (m *AccountMutation) ClearEmails() {
 | |
| 	m.clearedemails = true
 | |
| }
 | |
| 
 | |
| // EmailsCleared reports if the "emails" edge to the Email entity was cleared.
 | |
| func (m *AccountMutation) EmailsCleared() bool {
 | |
| 	return m.clearedemails
 | |
| }
 | |
| 
 | |
| // RemoveEmailIDs removes the "emails" edge to the Email entity by IDs.
 | |
| func (m *AccountMutation) RemoveEmailIDs(ids ...uuid.UUID) {
 | |
| 	if m.removedemails == nil {
 | |
| 		m.removedemails = make(map[uuid.UUID]struct{})
 | |
| 	}
 | |
| 	for i := range ids {
 | |
| 		delete(m.emails, ids[i])
 | |
| 		m.removedemails[ids[i]] = struct{}{}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // RemovedEmails returns the removed IDs of the "emails" edge to the Email entity.
 | |
| func (m *AccountMutation) RemovedEmailsIDs() (ids []uuid.UUID) {
 | |
| 	for id := range m.removedemails {
 | |
| 		ids = append(ids, id)
 | |
| 	}
 | |
| 	return
 | |
| }
 | |
| 
 | |
| // EmailsIDs returns the "emails" edge IDs in the mutation.
 | |
| func (m *AccountMutation) EmailsIDs() (ids []uuid.UUID) {
 | |
| 	for id := range m.emails {
 | |
| 		ids = append(ids, id)
 | |
| 	}
 | |
| 	return
 | |
| }
 | |
| 
 | |
| // ResetEmails resets all changes to the "emails" edge.
 | |
| func (m *AccountMutation) ResetEmails() {
 | |
| 	m.emails = nil
 | |
| 	m.clearedemails = false
 | |
| 	m.removedemails = nil
 | |
| }
 | |
| 
 | |
| // Where appends a list predicates to the AccountMutation builder.
 | |
| func (m *AccountMutation) Where(ps ...predicate.Account) {
 | |
| 	m.predicates = append(m.predicates, ps...)
 | |
| }
 | |
| 
 | |
| // WhereP appends storage-level predicates to the AccountMutation builder. Using this method,
 | |
| // users can use type-assertion to append predicates that do not depend on any generated package.
 | |
| func (m *AccountMutation) WhereP(ps ...func(*sql.Selector)) {
 | |
| 	p := make([]predicate.Account, len(ps))
 | |
| 	for i := range ps {
 | |
| 		p[i] = ps[i]
 | |
| 	}
 | |
| 	m.Where(p...)
 | |
| }
 | |
| 
 | |
| // Op returns the operation name.
 | |
| func (m *AccountMutation) Op() Op {
 | |
| 	return m.op
 | |
| }
 | |
| 
 | |
| // SetOp allows setting the mutation operation.
 | |
| func (m *AccountMutation) SetOp(op Op) {
 | |
| 	m.op = op
 | |
| }
 | |
| 
 | |
| // Type returns the node type of this mutation (Account).
 | |
| func (m *AccountMutation) 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 *AccountMutation) Fields() []string {
 | |
| 	fields := make([]string, 0, 7)
 | |
| 	if m.created_at != nil {
 | |
| 		fields = append(fields, account.FieldCreatedAt)
 | |
| 	}
 | |
| 	if m.updated_at != nil {
 | |
| 		fields = append(fields, account.FieldUpdatedAt)
 | |
| 	}
 | |
| 	if m.nickname != nil {
 | |
| 		fields = append(fields, account.FieldNickname)
 | |
| 	}
 | |
| 	if m.name != nil {
 | |
| 		fields = append(fields, account.FieldName)
 | |
| 	}
 | |
| 	if m.secret != nil {
 | |
| 		fields = append(fields, account.FieldSecret)
 | |
| 	}
 | |
| 	if m.aes != nil {
 | |
| 		fields = append(fields, account.FieldAes)
 | |
| 	}
 | |
| 	if m.x509 != nil {
 | |
| 		fields = append(fields, account.FieldX509)
 | |
| 	}
 | |
| 	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 *AccountMutation) Field(name string) (ent.Value, bool) {
 | |
| 	switch name {
 | |
| 	case account.FieldCreatedAt:
 | |
| 		return m.CreatedAt()
 | |
| 	case account.FieldUpdatedAt:
 | |
| 		return m.UpdatedAt()
 | |
| 	case account.FieldNickname:
 | |
| 		return m.Nickname()
 | |
| 	case account.FieldName:
 | |
| 		return m.Name()
 | |
| 	case account.FieldSecret:
 | |
| 		return m.Secret()
 | |
| 	case account.FieldAes:
 | |
| 		return m.Aes()
 | |
| 	case account.FieldX509:
 | |
| 		return m.X509()
 | |
| 	}
 | |
| 	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 *AccountMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
 | |
| 	switch name {
 | |
| 	case account.FieldCreatedAt:
 | |
| 		return m.OldCreatedAt(ctx)
 | |
| 	case account.FieldUpdatedAt:
 | |
| 		return m.OldUpdatedAt(ctx)
 | |
| 	case account.FieldNickname:
 | |
| 		return m.OldNickname(ctx)
 | |
| 	case account.FieldName:
 | |
| 		return m.OldName(ctx)
 | |
| 	case account.FieldSecret:
 | |
| 		return m.OldSecret(ctx)
 | |
| 	case account.FieldAes:
 | |
| 		return m.OldAes(ctx)
 | |
| 	case account.FieldX509:
 | |
| 		return m.OldX509(ctx)
 | |
| 	}
 | |
| 	return nil, fmt.Errorf("unknown Account field %s", name)
 | |
| }
 | |
| 
 | |
| // SetField sets the value of a field with the given name. It returns an error if
 | |
| // the field is not defined in the schema, or if the type mismatched the field
 | |
| // type.
 | |
| func (m *AccountMutation) SetField(name string, value ent.Value) error {
 | |
| 	switch name {
 | |
| 	case account.FieldCreatedAt:
 | |
| 		v, ok := value.(time.Time)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetCreatedAt(v)
 | |
| 		return nil
 | |
| 	case account.FieldUpdatedAt:
 | |
| 		v, ok := value.(time.Time)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetUpdatedAt(v)
 | |
| 		return nil
 | |
| 	case account.FieldNickname:
 | |
| 		v, ok := value.(string)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetNickname(v)
 | |
| 		return nil
 | |
| 	case account.FieldName:
 | |
| 		v, ok := value.(string)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetName(v)
 | |
| 		return nil
 | |
| 	case account.FieldSecret:
 | |
| 		v, ok := value.([]byte)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetSecret(v)
 | |
| 		return nil
 | |
| 	case account.FieldAes:
 | |
| 		v, ok := value.([]byte)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetAes(v)
 | |
| 		return nil
 | |
| 	case account.FieldX509:
 | |
| 		v, ok := value.([]byte)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetX509(v)
 | |
| 		return nil
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Account field %s", name)
 | |
| }
 | |
| 
 | |
| // AddedFields returns all numeric fields that were incremented/decremented during
 | |
| // this mutation.
 | |
| func (m *AccountMutation) 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 *AccountMutation) 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 *AccountMutation) AddField(name string, value ent.Value) error {
 | |
| 	switch name {
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Account numeric field %s", name)
 | |
| }
 | |
| 
 | |
| // ClearedFields returns all nullable fields that were cleared during this
 | |
| // mutation.
 | |
| func (m *AccountMutation) ClearedFields() []string {
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // FieldCleared returns a boolean indicating if a field with the given name was
 | |
| // cleared in this mutation.
 | |
| func (m *AccountMutation) FieldCleared(name string) bool {
 | |
| 	_, ok := m.clearedFields[name]
 | |
| 	return ok
 | |
| }
 | |
| 
 | |
| // ClearField clears the value of the field with the given name. It returns an
 | |
| // error if the field is not defined in the schema.
 | |
| func (m *AccountMutation) ClearField(name string) error {
 | |
| 	return fmt.Errorf("unknown Account nullable field %s", name)
 | |
| }
 | |
| 
 | |
| // ResetField resets all changes in the mutation for the field with the given name.
 | |
| // It returns an error if the field is not defined in the schema.
 | |
| func (m *AccountMutation) ResetField(name string) error {
 | |
| 	switch name {
 | |
| 	case account.FieldCreatedAt:
 | |
| 		m.ResetCreatedAt()
 | |
| 		return nil
 | |
| 	case account.FieldUpdatedAt:
 | |
| 		m.ResetUpdatedAt()
 | |
| 		return nil
 | |
| 	case account.FieldNickname:
 | |
| 		m.ResetNickname()
 | |
| 		return nil
 | |
| 	case account.FieldName:
 | |
| 		m.ResetName()
 | |
| 		return nil
 | |
| 	case account.FieldSecret:
 | |
| 		m.ResetSecret()
 | |
| 		return nil
 | |
| 	case account.FieldAes:
 | |
| 		m.ResetAes()
 | |
| 		return nil
 | |
| 	case account.FieldX509:
 | |
| 		m.ResetX509()
 | |
| 		return nil
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Account field %s", name)
 | |
| }
 | |
| 
 | |
| // AddedEdges returns all edge names that were set/added in this mutation.
 | |
| func (m *AccountMutation) AddedEdges() []string {
 | |
| 	edges := make([]string, 0, 1)
 | |
| 	if m.emails != nil {
 | |
| 		edges = append(edges, account.EdgeEmails)
 | |
| 	}
 | |
| 	return edges
 | |
| }
 | |
| 
 | |
| // AddedIDs returns all IDs (to other nodes) that were added for the given edge
 | |
| // name in this mutation.
 | |
| func (m *AccountMutation) AddedIDs(name string) []ent.Value {
 | |
| 	switch name {
 | |
| 	case account.EdgeEmails:
 | |
| 		ids := make([]ent.Value, 0, len(m.emails))
 | |
| 		for id := range m.emails {
 | |
| 			ids = append(ids, id)
 | |
| 		}
 | |
| 		return ids
 | |
| 	}
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // RemovedEdges returns all edge names that were removed in this mutation.
 | |
| func (m *AccountMutation) RemovedEdges() []string {
 | |
| 	edges := make([]string, 0, 1)
 | |
| 	if m.removedemails != nil {
 | |
| 		edges = append(edges, account.EdgeEmails)
 | |
| 	}
 | |
| 	return edges
 | |
| }
 | |
| 
 | |
| // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
 | |
| // the given name in this mutation.
 | |
| func (m *AccountMutation) RemovedIDs(name string) []ent.Value {
 | |
| 	switch name {
 | |
| 	case account.EdgeEmails:
 | |
| 		ids := make([]ent.Value, 0, len(m.removedemails))
 | |
| 		for id := range m.removedemails {
 | |
| 			ids = append(ids, id)
 | |
| 		}
 | |
| 		return ids
 | |
| 	}
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // ClearedEdges returns all edge names that were cleared in this mutation.
 | |
| func (m *AccountMutation) ClearedEdges() []string {
 | |
| 	edges := make([]string, 0, 1)
 | |
| 	if m.clearedemails {
 | |
| 		edges = append(edges, account.EdgeEmails)
 | |
| 	}
 | |
| 	return edges
 | |
| }
 | |
| 
 | |
| // EdgeCleared returns a boolean which indicates if the edge with the given name
 | |
| // was cleared in this mutation.
 | |
| func (m *AccountMutation) EdgeCleared(name string) bool {
 | |
| 	switch name {
 | |
| 	case account.EdgeEmails:
 | |
| 		return m.clearedemails
 | |
| 	}
 | |
| 	return false
 | |
| }
 | |
| 
 | |
| // ClearEdge clears the value of the edge with the given name. It returns an error
 | |
| // if that edge is not defined in the schema.
 | |
| func (m *AccountMutation) ClearEdge(name string) error {
 | |
| 	switch name {
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Account unique edge %s", name)
 | |
| }
 | |
| 
 | |
| // ResetEdge resets all changes to the edge with the given name in this mutation.
 | |
| // It returns an error if the edge is not defined in the schema.
 | |
| func (m *AccountMutation) ResetEdge(name string) error {
 | |
| 	switch name {
 | |
| 	case account.EdgeEmails:
 | |
| 		m.ResetEmails()
 | |
| 		return nil
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Account edge %s", name)
 | |
| }
 | |
| 
 | |
| // EmailMutation represents an operation that mutates the Email nodes in the graph.
 | |
| type EmailMutation struct {
 | |
| 	config
 | |
| 	op                Op
 | |
| 	typ               string
 | |
| 	id                *uuid.UUID
 | |
| 	email             *string
 | |
| 	primary           *bool
 | |
| 	verified          *bool
 | |
| 	verification_code *string
 | |
| 	reset_code        *string
 | |
| 	clearedFields     map[string]struct{}
 | |
| 	accounts          *uuid.UUID
 | |
| 	clearedaccounts   bool
 | |
| 	done              bool
 | |
| 	oldValue          func(context.Context) (*Email, error)
 | |
| 	predicates        []predicate.Email
 | |
| }
 | |
| 
 | |
| var _ ent.Mutation = (*EmailMutation)(nil)
 | |
| 
 | |
| // emailOption allows management of the mutation configuration using functional options.
 | |
| type emailOption func(*EmailMutation)
 | |
| 
 | |
| // newEmailMutation creates new mutation for the Email entity.
 | |
| func newEmailMutation(c config, op Op, opts ...emailOption) *EmailMutation {
 | |
| 	m := &EmailMutation{
 | |
| 		config:        c,
 | |
| 		op:            op,
 | |
| 		typ:           TypeEmail,
 | |
| 		clearedFields: make(map[string]struct{}),
 | |
| 	}
 | |
| 	for _, opt := range opts {
 | |
| 		opt(m)
 | |
| 	}
 | |
| 	return m
 | |
| }
 | |
| 
 | |
| // withEmailID sets the ID field of the mutation.
 | |
| func withEmailID(id uuid.UUID) emailOption {
 | |
| 	return func(m *EmailMutation) {
 | |
| 		var (
 | |
| 			err   error
 | |
| 			once  sync.Once
 | |
| 			value *Email
 | |
| 		)
 | |
| 		m.oldValue = func(ctx context.Context) (*Email, error) {
 | |
| 			once.Do(func() {
 | |
| 				if m.done {
 | |
| 					err = errors.New("querying old values post mutation is not allowed")
 | |
| 				} else {
 | |
| 					value, err = m.Client().Email.Get(ctx, id)
 | |
| 				}
 | |
| 			})
 | |
| 			return value, err
 | |
| 		}
 | |
| 		m.id = &id
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // withEmail sets the old Email of the mutation.
 | |
| func withEmail(node *Email) emailOption {
 | |
| 	return func(m *EmailMutation) {
 | |
| 		m.oldValue = func(context.Context) (*Email, 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 EmailMutation) 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 EmailMutation) 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
 | |
| }
 | |
| 
 | |
| // SetID sets the value of the id field. Note that this
 | |
| // operation is only accepted on creation of Email entities.
 | |
| func (m *EmailMutation) SetID(id uuid.UUID) {
 | |
| 	m.id = &id
 | |
| }
 | |
| 
 | |
| // ID returns the ID value in the mutation. Note that the ID is only available
 | |
| // if it was provided to the builder or after it was returned from the database.
 | |
| func (m *EmailMutation) ID() (id uuid.UUID, 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 *EmailMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
 | |
| 	switch {
 | |
| 	case m.op.Is(OpUpdateOne | OpDeleteOne):
 | |
| 		id, exists := m.ID()
 | |
| 		if exists {
 | |
| 			return []uuid.UUID{id}, nil
 | |
| 		}
 | |
| 		fallthrough
 | |
| 	case m.op.Is(OpUpdate | OpDelete):
 | |
| 		return m.Client().Email.Query().Where(m.predicates...).IDs(ctx)
 | |
| 	default:
 | |
| 		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
 | |
| 	}
 | |
| }
 | |
| 
 | |
| // SetEmail sets the "email" field.
 | |
| func (m *EmailMutation) SetEmail(s string) {
 | |
| 	m.email = &s
 | |
| }
 | |
| 
 | |
| // Email returns the value of the "email" field in the mutation.
 | |
| func (m *EmailMutation) Email() (r string, exists bool) {
 | |
| 	v := m.email
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldEmail returns the old "email" field's value of the Email entity.
 | |
| // If the Email 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 *EmailMutation) OldEmail(ctx context.Context) (v string, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldEmail is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldEmail requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldEmail: %w", err)
 | |
| 	}
 | |
| 	return oldValue.Email, nil
 | |
| }
 | |
| 
 | |
| // ResetEmail resets all changes to the "email" field.
 | |
| func (m *EmailMutation) ResetEmail() {
 | |
| 	m.email = nil
 | |
| }
 | |
| 
 | |
| // SetPrimary sets the "primary" field.
 | |
| func (m *EmailMutation) SetPrimary(b bool) {
 | |
| 	m.primary = &b
 | |
| }
 | |
| 
 | |
| // Primary returns the value of the "primary" field in the mutation.
 | |
| func (m *EmailMutation) Primary() (r bool, exists bool) {
 | |
| 	v := m.primary
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldPrimary returns the old "primary" field's value of the Email entity.
 | |
| // If the Email 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 *EmailMutation) OldPrimary(ctx context.Context) (v bool, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldPrimary is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldPrimary requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldPrimary: %w", err)
 | |
| 	}
 | |
| 	return oldValue.Primary, nil
 | |
| }
 | |
| 
 | |
| // ResetPrimary resets all changes to the "primary" field.
 | |
| func (m *EmailMutation) ResetPrimary() {
 | |
| 	m.primary = nil
 | |
| }
 | |
| 
 | |
| // SetVerified sets the "verified" field.
 | |
| func (m *EmailMutation) SetVerified(b bool) {
 | |
| 	m.verified = &b
 | |
| }
 | |
| 
 | |
| // Verified returns the value of the "verified" field in the mutation.
 | |
| func (m *EmailMutation) Verified() (r bool, exists bool) {
 | |
| 	v := m.verified
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldVerified returns the old "verified" field's value of the Email entity.
 | |
| // If the Email 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 *EmailMutation) OldVerified(ctx context.Context) (v bool, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldVerified is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldVerified requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldVerified: %w", err)
 | |
| 	}
 | |
| 	return oldValue.Verified, nil
 | |
| }
 | |
| 
 | |
| // ResetVerified resets all changes to the "verified" field.
 | |
| func (m *EmailMutation) ResetVerified() {
 | |
| 	m.verified = nil
 | |
| }
 | |
| 
 | |
| // SetVerificationCode sets the "verification_code" field.
 | |
| func (m *EmailMutation) SetVerificationCode(s string) {
 | |
| 	m.verification_code = &s
 | |
| }
 | |
| 
 | |
| // VerificationCode returns the value of the "verification_code" field in the mutation.
 | |
| func (m *EmailMutation) VerificationCode() (r string, exists bool) {
 | |
| 	v := m.verification_code
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldVerificationCode returns the old "verification_code" field's value of the Email entity.
 | |
| // If the Email 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 *EmailMutation) OldVerificationCode(ctx context.Context) (v string, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldVerificationCode is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldVerificationCode requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldVerificationCode: %w", err)
 | |
| 	}
 | |
| 	return oldValue.VerificationCode, nil
 | |
| }
 | |
| 
 | |
| // ClearVerificationCode clears the value of the "verification_code" field.
 | |
| func (m *EmailMutation) ClearVerificationCode() {
 | |
| 	m.verification_code = nil
 | |
| 	m.clearedFields[email.FieldVerificationCode] = struct{}{}
 | |
| }
 | |
| 
 | |
| // VerificationCodeCleared returns if the "verification_code" field was cleared in this mutation.
 | |
| func (m *EmailMutation) VerificationCodeCleared() bool {
 | |
| 	_, ok := m.clearedFields[email.FieldVerificationCode]
 | |
| 	return ok
 | |
| }
 | |
| 
 | |
| // ResetVerificationCode resets all changes to the "verification_code" field.
 | |
| func (m *EmailMutation) ResetVerificationCode() {
 | |
| 	m.verification_code = nil
 | |
| 	delete(m.clearedFields, email.FieldVerificationCode)
 | |
| }
 | |
| 
 | |
| // SetResetCode sets the "reset_code" field.
 | |
| func (m *EmailMutation) SetResetCode(s string) {
 | |
| 	m.reset_code = &s
 | |
| }
 | |
| 
 | |
| // ResetCode returns the value of the "reset_code" field in the mutation.
 | |
| func (m *EmailMutation) ResetCode() (r string, exists bool) {
 | |
| 	v := m.reset_code
 | |
| 	if v == nil {
 | |
| 		return
 | |
| 	}
 | |
| 	return *v, true
 | |
| }
 | |
| 
 | |
| // OldResetCode returns the old "reset_code" field's value of the Email entity.
 | |
| // If the Email 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 *EmailMutation) OldResetCode(ctx context.Context) (v string, err error) {
 | |
| 	if !m.op.Is(OpUpdateOne) {
 | |
| 		return v, errors.New("OldResetCode is only allowed on UpdateOne operations")
 | |
| 	}
 | |
| 	if m.id == nil || m.oldValue == nil {
 | |
| 		return v, errors.New("OldResetCode requires an ID field in the mutation")
 | |
| 	}
 | |
| 	oldValue, err := m.oldValue(ctx)
 | |
| 	if err != nil {
 | |
| 		return v, fmt.Errorf("querying old value for OldResetCode: %w", err)
 | |
| 	}
 | |
| 	return oldValue.ResetCode, nil
 | |
| }
 | |
| 
 | |
| // ClearResetCode clears the value of the "reset_code" field.
 | |
| func (m *EmailMutation) ClearResetCode() {
 | |
| 	m.reset_code = nil
 | |
| 	m.clearedFields[email.FieldResetCode] = struct{}{}
 | |
| }
 | |
| 
 | |
| // ResetCodeCleared returns if the "reset_code" field was cleared in this mutation.
 | |
| func (m *EmailMutation) ResetCodeCleared() bool {
 | |
| 	_, ok := m.clearedFields[email.FieldResetCode]
 | |
| 	return ok
 | |
| }
 | |
| 
 | |
| // ResetResetCode resets all changes to the "reset_code" field.
 | |
| func (m *EmailMutation) ResetResetCode() {
 | |
| 	m.reset_code = nil
 | |
| 	delete(m.clearedFields, email.FieldResetCode)
 | |
| }
 | |
| 
 | |
| // SetAccountsID sets the "accounts" edge to the Account entity by id.
 | |
| func (m *EmailMutation) SetAccountsID(id uuid.UUID) {
 | |
| 	m.accounts = &id
 | |
| }
 | |
| 
 | |
| // ClearAccounts clears the "accounts" edge to the Account entity.
 | |
| func (m *EmailMutation) ClearAccounts() {
 | |
| 	m.clearedaccounts = true
 | |
| }
 | |
| 
 | |
| // AccountsCleared reports if the "accounts" edge to the Account entity was cleared.
 | |
| func (m *EmailMutation) AccountsCleared() bool {
 | |
| 	return m.clearedaccounts
 | |
| }
 | |
| 
 | |
| // AccountsID returns the "accounts" edge ID in the mutation.
 | |
| func (m *EmailMutation) AccountsID() (id uuid.UUID, exists bool) {
 | |
| 	if m.accounts != nil {
 | |
| 		return *m.accounts, true
 | |
| 	}
 | |
| 	return
 | |
| }
 | |
| 
 | |
| // AccountsIDs returns the "accounts" edge IDs in the mutation.
 | |
| // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
 | |
| // AccountsID instead. It exists only for internal usage by the builders.
 | |
| func (m *EmailMutation) AccountsIDs() (ids []uuid.UUID) {
 | |
| 	if id := m.accounts; id != nil {
 | |
| 		ids = append(ids, *id)
 | |
| 	}
 | |
| 	return
 | |
| }
 | |
| 
 | |
| // ResetAccounts resets all changes to the "accounts" edge.
 | |
| func (m *EmailMutation) ResetAccounts() {
 | |
| 	m.accounts = nil
 | |
| 	m.clearedaccounts = false
 | |
| }
 | |
| 
 | |
| // Where appends a list predicates to the EmailMutation builder.
 | |
| func (m *EmailMutation) Where(ps ...predicate.Email) {
 | |
| 	m.predicates = append(m.predicates, ps...)
 | |
| }
 | |
| 
 | |
| // WhereP appends storage-level predicates to the EmailMutation builder. Using this method,
 | |
| // users can use type-assertion to append predicates that do not depend on any generated package.
 | |
| func (m *EmailMutation) WhereP(ps ...func(*sql.Selector)) {
 | |
| 	p := make([]predicate.Email, len(ps))
 | |
| 	for i := range ps {
 | |
| 		p[i] = ps[i]
 | |
| 	}
 | |
| 	m.Where(p...)
 | |
| }
 | |
| 
 | |
| // Op returns the operation name.
 | |
| func (m *EmailMutation) Op() Op {
 | |
| 	return m.op
 | |
| }
 | |
| 
 | |
| // SetOp allows setting the mutation operation.
 | |
| func (m *EmailMutation) SetOp(op Op) {
 | |
| 	m.op = op
 | |
| }
 | |
| 
 | |
| // Type returns the node type of this mutation (Email).
 | |
| func (m *EmailMutation) 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 *EmailMutation) Fields() []string {
 | |
| 	fields := make([]string, 0, 5)
 | |
| 	if m.email != nil {
 | |
| 		fields = append(fields, email.FieldEmail)
 | |
| 	}
 | |
| 	if m.primary != nil {
 | |
| 		fields = append(fields, email.FieldPrimary)
 | |
| 	}
 | |
| 	if m.verified != nil {
 | |
| 		fields = append(fields, email.FieldVerified)
 | |
| 	}
 | |
| 	if m.verification_code != nil {
 | |
| 		fields = append(fields, email.FieldVerificationCode)
 | |
| 	}
 | |
| 	if m.reset_code != nil {
 | |
| 		fields = append(fields, email.FieldResetCode)
 | |
| 	}
 | |
| 	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 *EmailMutation) Field(name string) (ent.Value, bool) {
 | |
| 	switch name {
 | |
| 	case email.FieldEmail:
 | |
| 		return m.Email()
 | |
| 	case email.FieldPrimary:
 | |
| 		return m.Primary()
 | |
| 	case email.FieldVerified:
 | |
| 		return m.Verified()
 | |
| 	case email.FieldVerificationCode:
 | |
| 		return m.VerificationCode()
 | |
| 	case email.FieldResetCode:
 | |
| 		return m.ResetCode()
 | |
| 	}
 | |
| 	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 *EmailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
 | |
| 	switch name {
 | |
| 	case email.FieldEmail:
 | |
| 		return m.OldEmail(ctx)
 | |
| 	case email.FieldPrimary:
 | |
| 		return m.OldPrimary(ctx)
 | |
| 	case email.FieldVerified:
 | |
| 		return m.OldVerified(ctx)
 | |
| 	case email.FieldVerificationCode:
 | |
| 		return m.OldVerificationCode(ctx)
 | |
| 	case email.FieldResetCode:
 | |
| 		return m.OldResetCode(ctx)
 | |
| 	}
 | |
| 	return nil, fmt.Errorf("unknown Email field %s", name)
 | |
| }
 | |
| 
 | |
| // SetField sets the value of a field with the given name. It returns an error if
 | |
| // the field is not defined in the schema, or if the type mismatched the field
 | |
| // type.
 | |
| func (m *EmailMutation) SetField(name string, value ent.Value) error {
 | |
| 	switch name {
 | |
| 	case email.FieldEmail:
 | |
| 		v, ok := value.(string)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetEmail(v)
 | |
| 		return nil
 | |
| 	case email.FieldPrimary:
 | |
| 		v, ok := value.(bool)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetPrimary(v)
 | |
| 		return nil
 | |
| 	case email.FieldVerified:
 | |
| 		v, ok := value.(bool)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetVerified(v)
 | |
| 		return nil
 | |
| 	case email.FieldVerificationCode:
 | |
| 		v, ok := value.(string)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetVerificationCode(v)
 | |
| 		return nil
 | |
| 	case email.FieldResetCode:
 | |
| 		v, ok := value.(string)
 | |
| 		if !ok {
 | |
| 			return fmt.Errorf("unexpected type %T for field %s", value, name)
 | |
| 		}
 | |
| 		m.SetResetCode(v)
 | |
| 		return nil
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Email field %s", name)
 | |
| }
 | |
| 
 | |
| // AddedFields returns all numeric fields that were incremented/decremented during
 | |
| // this mutation.
 | |
| func (m *EmailMutation) 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 *EmailMutation) 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 *EmailMutation) AddField(name string, value ent.Value) error {
 | |
| 	switch name {
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Email numeric field %s", name)
 | |
| }
 | |
| 
 | |
| // ClearedFields returns all nullable fields that were cleared during this
 | |
| // mutation.
 | |
| func (m *EmailMutation) ClearedFields() []string {
 | |
| 	var fields []string
 | |
| 	if m.FieldCleared(email.FieldVerificationCode) {
 | |
| 		fields = append(fields, email.FieldVerificationCode)
 | |
| 	}
 | |
| 	if m.FieldCleared(email.FieldResetCode) {
 | |
| 		fields = append(fields, email.FieldResetCode)
 | |
| 	}
 | |
| 	return fields
 | |
| }
 | |
| 
 | |
| // FieldCleared returns a boolean indicating if a field with the given name was
 | |
| // cleared in this mutation.
 | |
| func (m *EmailMutation) FieldCleared(name string) bool {
 | |
| 	_, ok := m.clearedFields[name]
 | |
| 	return ok
 | |
| }
 | |
| 
 | |
| // ClearField clears the value of the field with the given name. It returns an
 | |
| // error if the field is not defined in the schema.
 | |
| func (m *EmailMutation) ClearField(name string) error {
 | |
| 	switch name {
 | |
| 	case email.FieldVerificationCode:
 | |
| 		m.ClearVerificationCode()
 | |
| 		return nil
 | |
| 	case email.FieldResetCode:
 | |
| 		m.ClearResetCode()
 | |
| 		return nil
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Email nullable field %s", name)
 | |
| }
 | |
| 
 | |
| // ResetField resets all changes in the mutation for the field with the given name.
 | |
| // It returns an error if the field is not defined in the schema.
 | |
| func (m *EmailMutation) ResetField(name string) error {
 | |
| 	switch name {
 | |
| 	case email.FieldEmail:
 | |
| 		m.ResetEmail()
 | |
| 		return nil
 | |
| 	case email.FieldPrimary:
 | |
| 		m.ResetPrimary()
 | |
| 		return nil
 | |
| 	case email.FieldVerified:
 | |
| 		m.ResetVerified()
 | |
| 		return nil
 | |
| 	case email.FieldVerificationCode:
 | |
| 		m.ResetVerificationCode()
 | |
| 		return nil
 | |
| 	case email.FieldResetCode:
 | |
| 		m.ResetResetCode()
 | |
| 		return nil
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Email field %s", name)
 | |
| }
 | |
| 
 | |
| // AddedEdges returns all edge names that were set/added in this mutation.
 | |
| func (m *EmailMutation) AddedEdges() []string {
 | |
| 	edges := make([]string, 0, 1)
 | |
| 	if m.accounts != nil {
 | |
| 		edges = append(edges, email.EdgeAccounts)
 | |
| 	}
 | |
| 	return edges
 | |
| }
 | |
| 
 | |
| // AddedIDs returns all IDs (to other nodes) that were added for the given edge
 | |
| // name in this mutation.
 | |
| func (m *EmailMutation) AddedIDs(name string) []ent.Value {
 | |
| 	switch name {
 | |
| 	case email.EdgeAccounts:
 | |
| 		if id := m.accounts; id != nil {
 | |
| 			return []ent.Value{*id}
 | |
| 		}
 | |
| 	}
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // RemovedEdges returns all edge names that were removed in this mutation.
 | |
| func (m *EmailMutation) 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 *EmailMutation) RemovedIDs(name string) []ent.Value {
 | |
| 	return nil
 | |
| }
 | |
| 
 | |
| // ClearedEdges returns all edge names that were cleared in this mutation.
 | |
| func (m *EmailMutation) ClearedEdges() []string {
 | |
| 	edges := make([]string, 0, 1)
 | |
| 	if m.clearedaccounts {
 | |
| 		edges = append(edges, email.EdgeAccounts)
 | |
| 	}
 | |
| 	return edges
 | |
| }
 | |
| 
 | |
| // EdgeCleared returns a boolean which indicates if the edge with the given name
 | |
| // was cleared in this mutation.
 | |
| func (m *EmailMutation) EdgeCleared(name string) bool {
 | |
| 	switch name {
 | |
| 	case email.EdgeAccounts:
 | |
| 		return m.clearedaccounts
 | |
| 	}
 | |
| 	return false
 | |
| }
 | |
| 
 | |
| // ClearEdge clears the value of the edge with the given name. It returns an error
 | |
| // if that edge is not defined in the schema.
 | |
| func (m *EmailMutation) ClearEdge(name string) error {
 | |
| 	switch name {
 | |
| 	case email.EdgeAccounts:
 | |
| 		m.ClearAccounts()
 | |
| 		return nil
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Email unique edge %s", name)
 | |
| }
 | |
| 
 | |
| // ResetEdge resets all changes to the edge with the given name in this mutation.
 | |
| // It returns an error if the edge is not defined in the schema.
 | |
| func (m *EmailMutation) ResetEdge(name string) error {
 | |
| 	switch name {
 | |
| 	case email.EdgeAccounts:
 | |
| 		m.ResetAccounts()
 | |
| 		return nil
 | |
| 	}
 | |
| 	return fmt.Errorf("unknown Email edge %s", name)
 | |
| }
 |