2023-04-13 00:07:08 +02:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
2023-08-19 04:52:15 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/agekey"
|
2023-04-21 13:57:32 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/hibp"
|
2023-08-19 04:52:15 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/localbreach"
|
2023-04-13 00:07:08 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/predicate"
|
2023-08-20 05:20:33 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/schema"
|
2023-08-19 04:52:15 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/searchquery"
|
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/settings"
|
2023-05-05 22:52:59 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/setup"
|
2023-08-19 04:52:15 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/trackedbreaches"
|
2023-04-13 00:07:08 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/user"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Operation types.
|
|
|
|
OpCreate = ent.OpCreate
|
|
|
|
OpDelete = ent.OpDelete
|
|
|
|
OpDeleteOne = ent.OpDeleteOne
|
|
|
|
OpUpdate = ent.OpUpdate
|
|
|
|
OpUpdateOne = ent.OpUpdateOne
|
|
|
|
|
|
|
|
// Node types.
|
2023-08-19 04:52:15 +02:00
|
|
|
TypeAgeKey = "AgeKey"
|
|
|
|
TypeHIBP = "HIBP"
|
|
|
|
TypeLocalBreach = "LocalBreach"
|
|
|
|
TypeSearchQuery = "SearchQuery"
|
|
|
|
TypeSettings = "Settings"
|
|
|
|
TypeSetup = "Setup"
|
|
|
|
TypeTrackedBreaches = "TrackedBreaches"
|
|
|
|
TypeUser = "User"
|
2023-04-13 00:07:08 +02:00
|
|
|
)
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// AgeKeyMutation represents an operation that mutates the AgeKey nodes in the graph.
|
|
|
|
type AgeKeyMutation struct {
|
2023-04-21 13:57:32 +02:00
|
|
|
config
|
2023-08-19 04:52:15 +02:00
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *uuid.UUID
|
|
|
|
key *[]byte
|
|
|
|
created *time.Time
|
|
|
|
updated *time.Time
|
|
|
|
clearedFields map[string]struct{}
|
|
|
|
user *uuid.UUID
|
|
|
|
cleareduser bool
|
|
|
|
done bool
|
|
|
|
oldValue func(context.Context) (*AgeKey, error)
|
|
|
|
predicates []predicate.AgeKey
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
var _ ent.Mutation = (*AgeKeyMutation)(nil)
|
2023-04-21 13:57:32 +02:00
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// agekeyOption allows management of the mutation configuration using functional options.
|
|
|
|
type agekeyOption func(*AgeKeyMutation)
|
2023-04-21 13:57:32 +02:00
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// newAgeKeyMutation creates new mutation for the AgeKey entity.
|
|
|
|
func newAgeKeyMutation(c config, op Op, opts ...agekeyOption) *AgeKeyMutation {
|
|
|
|
m := &AgeKeyMutation{
|
2023-04-21 13:57:32 +02:00
|
|
|
config: c,
|
|
|
|
op: op,
|
2023-08-19 04:52:15 +02:00
|
|
|
typ: TypeAgeKey,
|
2023-04-21 13:57:32 +02:00
|
|
|
clearedFields: make(map[string]struct{}),
|
|
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(m)
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// withAgeKeyID sets the ID field of the mutation.
|
|
|
|
func withAgeKeyID(id uuid.UUID) agekeyOption {
|
|
|
|
return func(m *AgeKeyMutation) {
|
2023-04-21 13:57:32 +02:00
|
|
|
var (
|
|
|
|
err error
|
|
|
|
once sync.Once
|
2023-08-19 04:52:15 +02:00
|
|
|
value *AgeKey
|
2023-04-21 13:57:32 +02:00
|
|
|
)
|
2023-08-19 04:52:15 +02:00
|
|
|
m.oldValue = func(ctx context.Context) (*AgeKey, error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
once.Do(func() {
|
|
|
|
if m.done {
|
|
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
|
|
} else {
|
2023-08-19 04:52:15 +02:00
|
|
|
value, err = m.Client().AgeKey.Get(ctx, id)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return value, err
|
|
|
|
}
|
|
|
|
m.id = &id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// withAgeKey sets the old AgeKey of the mutation.
|
|
|
|
func withAgeKey(node *AgeKey) agekeyOption {
|
|
|
|
return func(m *AgeKeyMutation) {
|
|
|
|
m.oldValue = func(context.Context) (*AgeKey, error) {
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m AgeKeyMutation) Client() *Client {
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m AgeKeyMutation) Tx() (*Tx, error) {
|
2023-04-21 13:57:32 +02: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
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetID sets the value of the id field. Note that this
|
2023-08-19 04:52:15 +02:00
|
|
|
// operation is only accepted on creation of AgeKey entities.
|
|
|
|
func (m *AgeKeyMutation) SetID(id uuid.UUID) {
|
2023-04-21 13:57:32 +02:00
|
|
|
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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *AgeKeyMutation) ID() (id uuid.UUID, exists bool) {
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *AgeKeyMutation) IDs(ctx context.Context) ([]uuid.UUID, error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
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):
|
2023-08-19 04:52:15 +02:00
|
|
|
return m.Client().AgeKey.Query().Where(m.predicates...).IDs(ctx)
|
2023-04-21 13:57:32 +02:00
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetKey sets the "key" field.
|
|
|
|
func (m *AgeKeyMutation) SetKey(b []byte) {
|
|
|
|
m.key = &b
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Key returns the value of the "key" field in the mutation.
|
|
|
|
func (m *AgeKeyMutation) Key() (r []byte, exists bool) {
|
|
|
|
v := m.key
|
2023-04-21 13:57:32 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// OldKey returns the old "key" field's value of the AgeKey entity.
|
|
|
|
// If the AgeKey object wasn't provided to the builder, the object is fetched from the database.
|
2023-04-21 13:57:32 +02:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *AgeKeyMutation) OldKey(ctx context.Context) (v *[]byte, err error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldKey is only allowed on UpdateOne operations")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldKey requires an ID field in the mutation")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldKey: %w", err)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return oldValue.Key, nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetKey resets all changes to the "key" field.
|
|
|
|
func (m *AgeKeyMutation) ResetKey() {
|
|
|
|
m.key = nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetCreated sets the "created" field.
|
|
|
|
func (m *AgeKeyMutation) SetCreated(t time.Time) {
|
|
|
|
m.created = &t
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Created returns the value of the "created" field in the mutation.
|
|
|
|
func (m *AgeKeyMutation) Created() (r time.Time, exists bool) {
|
|
|
|
v := m.created
|
2023-04-21 13:57:32 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// OldCreated returns the old "created" field's value of the AgeKey entity.
|
|
|
|
// If the AgeKey object wasn't provided to the builder, the object is fetched from the database.
|
2023-04-21 13:57:32 +02:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *AgeKeyMutation) OldCreated(ctx context.Context) (v time.Time, err error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldCreated is only allowed on UpdateOne operations")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldCreated requires an ID field in the mutation")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldCreated: %w", err)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return oldValue.Created, nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetCreated resets all changes to the "created" field.
|
|
|
|
func (m *AgeKeyMutation) ResetCreated() {
|
|
|
|
m.created = nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetUpdated sets the "updated" field.
|
|
|
|
func (m *AgeKeyMutation) SetUpdated(t time.Time) {
|
|
|
|
m.updated = &t
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Updated returns the value of the "updated" field in the mutation.
|
|
|
|
func (m *AgeKeyMutation) Updated() (r time.Time, exists bool) {
|
|
|
|
v := m.updated
|
2023-04-21 13:57:32 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// OldUpdated returns the old "updated" field's value of the AgeKey entity.
|
|
|
|
// If the AgeKey object wasn't provided to the builder, the object is fetched from the database.
|
2023-04-21 13:57:32 +02:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *AgeKeyMutation) OldUpdated(ctx context.Context) (v time.Time, err error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldUpdated is only allowed on UpdateOne operations")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldUpdated requires an ID field in the mutation")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldUpdated: %w", err)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return oldValue.Updated, nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetUpdated resets all changes to the "updated" field.
|
|
|
|
func (m *AgeKeyMutation) ResetUpdated() {
|
|
|
|
m.updated = nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetOwner sets the "owner" field.
|
|
|
|
func (m *AgeKeyMutation) SetOwner(u uuid.UUID) {
|
|
|
|
m.user = &u
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Owner returns the value of the "owner" field in the mutation.
|
|
|
|
func (m *AgeKeyMutation) Owner() (r uuid.UUID, exists bool) {
|
|
|
|
v := m.user
|
2023-04-21 13:57:32 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// OldOwner returns the old "owner" field's value of the AgeKey entity.
|
|
|
|
// If the AgeKey object wasn't provided to the builder, the object is fetched from the database.
|
2023-04-21 13:57:32 +02:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *AgeKeyMutation) OldOwner(ctx context.Context) (v uuid.UUID, err error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldOwner is only allowed on UpdateOne operations")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldOwner requires an ID field in the mutation")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldOwner: %w", err)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return oldValue.Owner, nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetOwner resets all changes to the "owner" field.
|
|
|
|
func (m *AgeKeyMutation) ResetOwner() {
|
|
|
|
m.user = nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetUserID sets the "user" edge to the User entity by id.
|
|
|
|
func (m *AgeKeyMutation) SetUserID(id uuid.UUID) {
|
|
|
|
m.user = &id
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
|
|
func (m *AgeKeyMutation) ClearUser() {
|
|
|
|
m.cleareduser = true
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// UserCleared reports if the "user" edge to the User entity was cleared.
|
|
|
|
func (m *AgeKeyMutation) UserCleared() bool {
|
|
|
|
return m.cleareduser
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// UserID returns the "user" edge ID in the mutation.
|
|
|
|
func (m *AgeKeyMutation) UserID() (id uuid.UUID, exists bool) {
|
|
|
|
if m.user != nil {
|
|
|
|
return *m.user, true
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// UserIDs returns the "user" edge IDs in the mutation.
|
|
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
|
|
// UserID instead. It exists only for internal usage by the builders.
|
|
|
|
func (m *AgeKeyMutation) UserIDs() (ids []uuid.UUID) {
|
|
|
|
if id := m.user; id != nil {
|
|
|
|
ids = append(ids, *id)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetUser resets all changes to the "user" edge.
|
|
|
|
func (m *AgeKeyMutation) ResetUser() {
|
|
|
|
m.user = nil
|
|
|
|
m.cleareduser = false
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Where appends a list predicates to the AgeKeyMutation builder.
|
|
|
|
func (m *AgeKeyMutation) Where(ps ...predicate.AgeKey) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// WhereP appends storage-level predicates to the AgeKeyMutation builder. Using this method,
|
|
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
|
func (m *AgeKeyMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
|
p := make([]predicate.AgeKey, len(ps))
|
|
|
|
for i := range ps {
|
|
|
|
p[i] = ps[i]
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
m.Where(p...)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Op returns the operation name.
|
|
|
|
func (m *AgeKeyMutation) Op() Op {
|
|
|
|
return m.op
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetOp allows setting the mutation operation.
|
|
|
|
func (m *AgeKeyMutation) SetOp(op Op) {
|
|
|
|
m.op = op
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Type returns the node type of this mutation (AgeKey).
|
|
|
|
func (m *AgeKeyMutation) Type() string {
|
|
|
|
return m.typ
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02: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 *AgeKeyMutation) Fields() []string {
|
|
|
|
fields := make([]string, 0, 4)
|
|
|
|
if m.key != nil {
|
|
|
|
fields = append(fields, agekey.FieldKey)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
if m.created != nil {
|
|
|
|
fields = append(fields, agekey.FieldCreated)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
if m.updated != nil {
|
|
|
|
fields = append(fields, agekey.FieldUpdated)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
if m.user != nil {
|
|
|
|
fields = append(fields, agekey.FieldOwner)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return fields
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02: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 *AgeKeyMutation) Field(name string) (ent.Value, bool) {
|
|
|
|
switch name {
|
|
|
|
case agekey.FieldKey:
|
|
|
|
return m.Key()
|
|
|
|
case agekey.FieldCreated:
|
|
|
|
return m.Created()
|
|
|
|
case agekey.FieldUpdated:
|
|
|
|
return m.Updated()
|
|
|
|
case agekey.FieldOwner:
|
|
|
|
return m.Owner()
|
|
|
|
}
|
|
|
|
return nil, false
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02: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 *AgeKeyMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
|
switch name {
|
|
|
|
case agekey.FieldKey:
|
|
|
|
return m.OldKey(ctx)
|
|
|
|
case agekey.FieldCreated:
|
|
|
|
return m.OldCreated(ctx)
|
|
|
|
case agekey.FieldUpdated:
|
|
|
|
return m.OldUpdated(ctx)
|
|
|
|
case agekey.FieldOwner:
|
|
|
|
return m.OldOwner(ctx)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return nil, fmt.Errorf("unknown AgeKey field %s", name)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02: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 *AgeKeyMutation) SetField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
case agekey.FieldKey:
|
|
|
|
v, ok := value.([]byte)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetKey(v)
|
|
|
|
return nil
|
|
|
|
case agekey.FieldCreated:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetCreated(v)
|
|
|
|
return nil
|
|
|
|
case agekey.FieldUpdated:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetUpdated(v)
|
|
|
|
return nil
|
|
|
|
case agekey.FieldOwner:
|
|
|
|
v, ok := value.(uuid.UUID)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetOwner(v)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown AgeKey field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
|
|
|
func (m *AgeKeyMutation) 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 *AgeKeyMutation) 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 *AgeKeyMutation) AddField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown AgeKey numeric field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
|
|
|
func (m *AgeKeyMutation) ClearedFields() []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
|
|
|
func (m *AgeKeyMutation) 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 *AgeKeyMutation) ClearField(name string) error {
|
|
|
|
return fmt.Errorf("unknown AgeKey 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 *AgeKeyMutation) ResetField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case agekey.FieldKey:
|
|
|
|
m.ResetKey()
|
|
|
|
return nil
|
|
|
|
case agekey.FieldCreated:
|
|
|
|
m.ResetCreated()
|
|
|
|
return nil
|
|
|
|
case agekey.FieldUpdated:
|
|
|
|
m.ResetUpdated()
|
|
|
|
return nil
|
|
|
|
case agekey.FieldOwner:
|
|
|
|
m.ResetOwner()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown AgeKey field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
|
func (m *AgeKeyMutation) AddedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.user != nil {
|
|
|
|
edges = append(edges, agekey.EdgeUser)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
|
|
|
func (m *AgeKeyMutation) AddedIDs(name string) []ent.Value {
|
|
|
|
switch name {
|
|
|
|
case agekey.EdgeUser:
|
|
|
|
if id := m.user; id != nil {
|
|
|
|
return []ent.Value{*id}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
|
func (m *AgeKeyMutation) 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 *AgeKeyMutation) RemovedIDs(name string) []ent.Value {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
|
func (m *AgeKeyMutation) ClearedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.cleareduser {
|
|
|
|
edges = append(edges, agekey.EdgeUser)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
|
|
|
func (m *AgeKeyMutation) EdgeCleared(name string) bool {
|
|
|
|
switch name {
|
|
|
|
case agekey.EdgeUser:
|
|
|
|
return m.cleareduser
|
|
|
|
}
|
|
|
|
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 *AgeKeyMutation) ClearEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case agekey.EdgeUser:
|
|
|
|
m.ClearUser()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown AgeKey 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 *AgeKeyMutation) ResetEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case agekey.EdgeUser:
|
|
|
|
m.ResetUser()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown AgeKey edge %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// HIBPMutation represents an operation that mutates the HIBP nodes in the graph.
|
|
|
|
type HIBPMutation struct {
|
|
|
|
config
|
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *uuid.UUID
|
|
|
|
name *string
|
2023-08-20 23:16:12 +02:00
|
|
|
title *string
|
2023-08-19 04:52:15 +02:00
|
|
|
domain *string
|
2023-08-24 03:59:50 +02:00
|
|
|
breach_date *string
|
2023-08-19 04:52:15 +02:00
|
|
|
added_date *time.Time
|
|
|
|
modified_date *time.Time
|
|
|
|
pwn_count *int
|
|
|
|
addpwn_count *int
|
|
|
|
description *string
|
|
|
|
dataclasses *[]string
|
|
|
|
appenddataclasses []string
|
|
|
|
is_verified *bool
|
|
|
|
is_fabricated *bool
|
|
|
|
is_sensitive *bool
|
|
|
|
is_retired *bool
|
|
|
|
is_spamList *bool
|
|
|
|
is_malware *bool
|
2023-08-20 23:16:12 +02:00
|
|
|
logo_path *string
|
2023-08-19 04:52:15 +02:00
|
|
|
clearedFields map[string]struct{}
|
|
|
|
tracked_breaches *uuid.UUID
|
|
|
|
clearedtracked_breaches bool
|
|
|
|
done bool
|
|
|
|
oldValue func(context.Context) (*HIBP, error)
|
|
|
|
predicates []predicate.HIBP
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ ent.Mutation = (*HIBPMutation)(nil)
|
|
|
|
|
|
|
|
// hibpOption allows management of the mutation configuration using functional options.
|
|
|
|
type hibpOption func(*HIBPMutation)
|
|
|
|
|
|
|
|
// newHIBPMutation creates new mutation for the HIBP entity.
|
|
|
|
func newHIBPMutation(c config, op Op, opts ...hibpOption) *HIBPMutation {
|
|
|
|
m := &HIBPMutation{
|
|
|
|
config: c,
|
|
|
|
op: op,
|
|
|
|
typ: TypeHIBP,
|
|
|
|
clearedFields: make(map[string]struct{}),
|
|
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(m)
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// withHIBPID sets the ID field of the mutation.
|
|
|
|
func withHIBPID(id uuid.UUID) hibpOption {
|
|
|
|
return func(m *HIBPMutation) {
|
|
|
|
var (
|
|
|
|
err error
|
|
|
|
once sync.Once
|
|
|
|
value *HIBP
|
|
|
|
)
|
|
|
|
m.oldValue = func(ctx context.Context) (*HIBP, error) {
|
|
|
|
once.Do(func() {
|
|
|
|
if m.done {
|
|
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
|
|
} else {
|
|
|
|
value, err = m.Client().HIBP.Get(ctx, id)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return value, err
|
|
|
|
}
|
|
|
|
m.id = &id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// withHIBP sets the old HIBP of the mutation.
|
|
|
|
func withHIBP(node *HIBP) hibpOption {
|
|
|
|
return func(m *HIBPMutation) {
|
|
|
|
m.oldValue = func(context.Context) (*HIBP, 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 HIBPMutation) 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 HIBPMutation) 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 HIBP entities.
|
|
|
|
func (m *HIBPMutation) 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 *HIBPMutation) 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 *HIBPMutation) 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().HIBP.Query().Where(m.predicates...).IDs(ctx)
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetName sets the "name" field.
|
|
|
|
func (m *HIBPMutation) SetName(s string) {
|
|
|
|
m.name = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Name returns the value of the "name" field in the mutation.
|
|
|
|
func (m *HIBPMutation) 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 HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) 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 *HIBPMutation) ResetName() {
|
|
|
|
m.name = nil
|
|
|
|
}
|
|
|
|
|
2023-08-20 23:16:12 +02:00
|
|
|
// SetTitle sets the "title" field.
|
|
|
|
func (m *HIBPMutation) SetTitle(s string) {
|
|
|
|
m.title = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Title returns the value of the "title" field in the mutation.
|
|
|
|
func (m *HIBPMutation) Title() (r string, exists bool) {
|
|
|
|
v := m.title
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldTitle returns the old "title" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldTitle(ctx context.Context) (v string, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldTitle is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldTitle requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldTitle: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Title, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetTitle resets all changes to the "title" field.
|
|
|
|
func (m *HIBPMutation) ResetTitle() {
|
|
|
|
m.title = nil
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetDomain sets the "domain" field.
|
|
|
|
func (m *HIBPMutation) SetDomain(s string) {
|
|
|
|
m.domain = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Domain returns the value of the "domain" field in the mutation.
|
|
|
|
func (m *HIBPMutation) Domain() (r string, exists bool) {
|
|
|
|
v := m.domain
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldDomain returns the old "domain" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldDomain(ctx context.Context) (v string, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldDomain is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldDomain requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldDomain: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Domain, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetDomain resets all changes to the "domain" field.
|
|
|
|
func (m *HIBPMutation) ResetDomain() {
|
|
|
|
m.domain = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBreachDate sets the "breach_date" field.
|
2023-08-24 03:59:50 +02:00
|
|
|
func (m *HIBPMutation) SetBreachDate(s string) {
|
|
|
|
m.breach_date = &s
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// BreachDate returns the value of the "breach_date" field in the mutation.
|
2023-08-24 03:59:50 +02:00
|
|
|
func (m *HIBPMutation) BreachDate() (r string, exists bool) {
|
2023-08-19 04:52:15 +02:00
|
|
|
v := m.breach_date
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldBreachDate returns the old "breach_date" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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.
|
2023-08-24 03:59:50 +02:00
|
|
|
func (m *HIBPMutation) OldBreachDate(ctx context.Context) (v string, err error) {
|
2023-08-19 04:52:15 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldBreachDate is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldBreachDate requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldBreachDate: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.BreachDate, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetBreachDate resets all changes to the "breach_date" field.
|
|
|
|
func (m *HIBPMutation) ResetBreachDate() {
|
|
|
|
m.breach_date = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetAddedDate sets the "added_date" field.
|
|
|
|
func (m *HIBPMutation) SetAddedDate(t time.Time) {
|
|
|
|
m.added_date = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedDate returns the value of the "added_date" field in the mutation.
|
|
|
|
func (m *HIBPMutation) AddedDate() (r time.Time, exists bool) {
|
|
|
|
v := m.added_date
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldAddedDate returns the old "added_date" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldAddedDate(ctx context.Context) (v time.Time, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldAddedDate is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldAddedDate requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldAddedDate: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.AddedDate, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetAddedDate resets all changes to the "added_date" field.
|
|
|
|
func (m *HIBPMutation) ResetAddedDate() {
|
|
|
|
m.added_date = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetModifiedDate sets the "modified_date" field.
|
|
|
|
func (m *HIBPMutation) SetModifiedDate(t time.Time) {
|
|
|
|
m.modified_date = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// ModifiedDate returns the value of the "modified_date" field in the mutation.
|
|
|
|
func (m *HIBPMutation) ModifiedDate() (r time.Time, exists bool) {
|
|
|
|
v := m.modified_date
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldModifiedDate returns the old "modified_date" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldModifiedDate(ctx context.Context) (v time.Time, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldModifiedDate is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldModifiedDate requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldModifiedDate: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.ModifiedDate, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetModifiedDate resets all changes to the "modified_date" field.
|
|
|
|
func (m *HIBPMutation) ResetModifiedDate() {
|
|
|
|
m.modified_date = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetPwnCount sets the "pwn_count" field.
|
|
|
|
func (m *HIBPMutation) SetPwnCount(i int) {
|
|
|
|
m.pwn_count = &i
|
|
|
|
m.addpwn_count = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// PwnCount returns the value of the "pwn_count" field in the mutation.
|
|
|
|
func (m *HIBPMutation) PwnCount() (r int, exists bool) {
|
|
|
|
v := m.pwn_count
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldPwnCount returns the old "pwn_count" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldPwnCount(ctx context.Context) (v int, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldPwnCount is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldPwnCount requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldPwnCount: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.PwnCount, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddPwnCount adds i to the "pwn_count" field.
|
|
|
|
func (m *HIBPMutation) AddPwnCount(i int) {
|
|
|
|
if m.addpwn_count != nil {
|
|
|
|
*m.addpwn_count += i
|
|
|
|
} else {
|
|
|
|
m.addpwn_count = &i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedPwnCount returns the value that was added to the "pwn_count" field in this mutation.
|
|
|
|
func (m *HIBPMutation) AddedPwnCount() (r int, exists bool) {
|
|
|
|
v := m.addpwn_count
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetPwnCount resets all changes to the "pwn_count" field.
|
|
|
|
func (m *HIBPMutation) ResetPwnCount() {
|
|
|
|
m.pwn_count = nil
|
|
|
|
m.addpwn_count = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDescription sets the "description" field.
|
|
|
|
func (m *HIBPMutation) SetDescription(s string) {
|
|
|
|
m.description = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Description returns the value of the "description" field in the mutation.
|
|
|
|
func (m *HIBPMutation) Description() (r string, exists bool) {
|
|
|
|
v := m.description
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldDescription returns the old "description" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldDescription(ctx context.Context) (v *string, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldDescription requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldDescription: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Description, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
|
|
func (m *HIBPMutation) ClearDescription() {
|
|
|
|
m.description = nil
|
|
|
|
m.clearedFields[hibp.FieldDescription] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DescriptionCleared returns if the "description" field was cleared in this mutation.
|
|
|
|
func (m *HIBPMutation) DescriptionCleared() bool {
|
|
|
|
_, ok := m.clearedFields[hibp.FieldDescription]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetDescription resets all changes to the "description" field.
|
|
|
|
func (m *HIBPMutation) ResetDescription() {
|
|
|
|
m.description = nil
|
|
|
|
delete(m.clearedFields, hibp.FieldDescription)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDataclasses sets the "dataclasses" field.
|
|
|
|
func (m *HIBPMutation) SetDataclasses(s []string) {
|
|
|
|
m.dataclasses = &s
|
|
|
|
m.appenddataclasses = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Dataclasses returns the value of the "dataclasses" field in the mutation.
|
|
|
|
func (m *HIBPMutation) Dataclasses() (r []string, exists bool) {
|
|
|
|
v := m.dataclasses
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldDataclasses returns the old "dataclasses" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldDataclasses(ctx context.Context) (v []string, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldDataclasses is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldDataclasses requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldDataclasses: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Dataclasses, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AppendDataclasses adds s to the "dataclasses" field.
|
|
|
|
func (m *HIBPMutation) AppendDataclasses(s []string) {
|
|
|
|
m.appenddataclasses = append(m.appenddataclasses, s...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AppendedDataclasses returns the list of values that were appended to the "dataclasses" field in this mutation.
|
|
|
|
func (m *HIBPMutation) AppendedDataclasses() ([]string, bool) {
|
|
|
|
if len(m.appenddataclasses) == 0 {
|
|
|
|
return nil, false
|
|
|
|
}
|
|
|
|
return m.appenddataclasses, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetDataclasses resets all changes to the "dataclasses" field.
|
2023-04-21 13:57:32 +02:00
|
|
|
func (m *HIBPMutation) ResetDataclasses() {
|
|
|
|
m.dataclasses = nil
|
|
|
|
m.appenddataclasses = nil
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetIsVerified sets the "is_verified" field.
|
|
|
|
func (m *HIBPMutation) SetIsVerified(b bool) {
|
|
|
|
m.is_verified = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsVerified returns the value of the "is_verified" field in the mutation.
|
|
|
|
func (m *HIBPMutation) IsVerified() (r bool, exists bool) {
|
|
|
|
v := m.is_verified
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsVerified returns the old "is_verified" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldIsVerified(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsVerified is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsVerified requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsVerified: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsVerified, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsVerified resets all changes to the "is_verified" field.
|
|
|
|
func (m *HIBPMutation) ResetIsVerified() {
|
|
|
|
m.is_verified = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsFabricated sets the "is_fabricated" field.
|
|
|
|
func (m *HIBPMutation) SetIsFabricated(b bool) {
|
|
|
|
m.is_fabricated = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsFabricated returns the value of the "is_fabricated" field in the mutation.
|
|
|
|
func (m *HIBPMutation) IsFabricated() (r bool, exists bool) {
|
|
|
|
v := m.is_fabricated
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsFabricated returns the old "is_fabricated" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldIsFabricated(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsFabricated is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsFabricated requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsFabricated: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsFabricated, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsFabricated resets all changes to the "is_fabricated" field.
|
|
|
|
func (m *HIBPMutation) ResetIsFabricated() {
|
|
|
|
m.is_fabricated = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsSensitive sets the "is_sensitive" field.
|
|
|
|
func (m *HIBPMutation) SetIsSensitive(b bool) {
|
|
|
|
m.is_sensitive = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsSensitive returns the value of the "is_sensitive" field in the mutation.
|
|
|
|
func (m *HIBPMutation) IsSensitive() (r bool, exists bool) {
|
|
|
|
v := m.is_sensitive
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsSensitive returns the old "is_sensitive" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldIsSensitive(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsSensitive is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsSensitive requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsSensitive: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsSensitive, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsSensitive resets all changes to the "is_sensitive" field.
|
|
|
|
func (m *HIBPMutation) ResetIsSensitive() {
|
|
|
|
m.is_sensitive = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsRetired sets the "is_retired" field.
|
|
|
|
func (m *HIBPMutation) SetIsRetired(b bool) {
|
|
|
|
m.is_retired = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsRetired returns the value of the "is_retired" field in the mutation.
|
|
|
|
func (m *HIBPMutation) IsRetired() (r bool, exists bool) {
|
|
|
|
v := m.is_retired
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsRetired returns the old "is_retired" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldIsRetired(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsRetired is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsRetired requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsRetired: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsRetired, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsRetired resets all changes to the "is_retired" field.
|
|
|
|
func (m *HIBPMutation) ResetIsRetired() {
|
|
|
|
m.is_retired = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsSpamList sets the "is_spamList" field.
|
|
|
|
func (m *HIBPMutation) SetIsSpamList(b bool) {
|
|
|
|
m.is_spamList = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsSpamList returns the value of the "is_spamList" field in the mutation.
|
|
|
|
func (m *HIBPMutation) IsSpamList() (r bool, exists bool) {
|
|
|
|
v := m.is_spamList
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsSpamList returns the old "is_spamList" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldIsSpamList(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsSpamList is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsSpamList requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsSpamList: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsSpamList, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsSpamList resets all changes to the "is_spamList" field.
|
|
|
|
func (m *HIBPMutation) ResetIsSpamList() {
|
|
|
|
m.is_spamList = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsMalware sets the "is_malware" field.
|
|
|
|
func (m *HIBPMutation) SetIsMalware(b bool) {
|
|
|
|
m.is_malware = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsMalware returns the value of the "is_malware" field in the mutation.
|
|
|
|
func (m *HIBPMutation) IsMalware() (r bool, exists bool) {
|
|
|
|
v := m.is_malware
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsMalware returns the old "is_malware" field's value of the HIBP entity.
|
|
|
|
// If the HIBP 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 *HIBPMutation) OldIsMalware(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsMalware is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsMalware requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsMalware: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsMalware, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsMalware resets all changes to the "is_malware" field.
|
|
|
|
func (m *HIBPMutation) ResetIsMalware() {
|
|
|
|
m.is_malware = nil
|
|
|
|
}
|
|
|
|
|
2023-08-20 23:16:12 +02:00
|
|
|
// SetLogoPath sets the "logo_path" field.
|
|
|
|
func (m *HIBPMutation) SetLogoPath(s string) {
|
|
|
|
m.logo_path = &s
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
2023-08-20 23:16:12 +02:00
|
|
|
// LogoPath returns the value of the "logo_path" field in the mutation.
|
|
|
|
func (m *HIBPMutation) LogoPath() (r string, exists bool) {
|
|
|
|
v := m.logo_path
|
2023-08-19 04:52:15 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-20 23:16:12 +02:00
|
|
|
// OldLogoPath returns the old "logo_path" field's value of the HIBP entity.
|
2023-08-19 04:52:15 +02:00
|
|
|
// If the HIBP 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.
|
2023-08-20 23:16:12 +02:00
|
|
|
func (m *HIBPMutation) OldLogoPath(ctx context.Context) (v *string, err error) {
|
2023-08-19 04:52:15 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-20 23:16:12 +02:00
|
|
|
return v, errors.New("OldLogoPath is only allowed on UpdateOne operations")
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-20 23:16:12 +02:00
|
|
|
return v, errors.New("OldLogoPath requires an ID field in the mutation")
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-20 23:16:12 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldLogoPath: %w", err)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
2023-08-20 23:16:12 +02:00
|
|
|
return oldValue.LogoPath, nil
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
2023-08-20 23:16:12 +02:00
|
|
|
// ClearLogoPath clears the value of the "logo_path" field.
|
|
|
|
func (m *HIBPMutation) ClearLogoPath() {
|
|
|
|
m.logo_path = nil
|
|
|
|
m.clearedFields[hibp.FieldLogoPath] = struct{}{}
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
2023-08-20 23:16:12 +02:00
|
|
|
// LogoPathCleared returns if the "logo_path" field was cleared in this mutation.
|
|
|
|
func (m *HIBPMutation) LogoPathCleared() bool {
|
|
|
|
_, ok := m.clearedFields[hibp.FieldLogoPath]
|
2023-08-19 04:52:15 +02:00
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
2023-08-20 23:16:12 +02:00
|
|
|
// ResetLogoPath resets all changes to the "logo_path" field.
|
|
|
|
func (m *HIBPMutation) ResetLogoPath() {
|
|
|
|
m.logo_path = nil
|
|
|
|
delete(m.clearedFields, hibp.FieldLogoPath)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetTrackedBreachesID sets the "tracked_breaches" edge to the TrackedBreaches entity by id.
|
|
|
|
func (m *HIBPMutation) SetTrackedBreachesID(id uuid.UUID) {
|
|
|
|
m.tracked_breaches = &id
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearTrackedBreaches clears the "tracked_breaches" edge to the TrackedBreaches entity.
|
|
|
|
func (m *HIBPMutation) ClearTrackedBreaches() {
|
|
|
|
m.clearedtracked_breaches = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackedBreachesCleared reports if the "tracked_breaches" edge to the TrackedBreaches entity was cleared.
|
|
|
|
func (m *HIBPMutation) TrackedBreachesCleared() bool {
|
|
|
|
return m.clearedtracked_breaches
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackedBreachesID returns the "tracked_breaches" edge ID in the mutation.
|
|
|
|
func (m *HIBPMutation) TrackedBreachesID() (id uuid.UUID, exists bool) {
|
|
|
|
if m.tracked_breaches != nil {
|
|
|
|
return *m.tracked_breaches, true
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackedBreachesIDs returns the "tracked_breaches" edge IDs in the mutation.
|
|
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
|
|
// TrackedBreachesID instead. It exists only for internal usage by the builders.
|
|
|
|
func (m *HIBPMutation) TrackedBreachesIDs() (ids []uuid.UUID) {
|
|
|
|
if id := m.tracked_breaches; id != nil {
|
|
|
|
ids = append(ids, *id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetTrackedBreaches resets all changes to the "tracked_breaches" edge.
|
|
|
|
func (m *HIBPMutation) ResetTrackedBreaches() {
|
|
|
|
m.tracked_breaches = nil
|
|
|
|
m.clearedtracked_breaches = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the HIBPMutation builder.
|
|
|
|
func (m *HIBPMutation) Where(ps ...predicate.HIBP) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// WhereP appends storage-level predicates to the HIBPMutation builder. Using this method,
|
|
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
|
func (m *HIBPMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
|
p := make([]predicate.HIBP, len(ps))
|
|
|
|
for i := range ps {
|
|
|
|
p[i] = ps[i]
|
|
|
|
}
|
|
|
|
m.Where(p...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Op returns the operation name.
|
|
|
|
func (m *HIBPMutation) Op() Op {
|
|
|
|
return m.op
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
|
|
func (m *HIBPMutation) SetOp(op Op) {
|
|
|
|
m.op = op
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type returns the node type of this mutation (HIBP).
|
|
|
|
func (m *HIBPMutation) 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 *HIBPMutation) Fields() []string {
|
2023-08-20 23:16:12 +02:00
|
|
|
fields := make([]string, 0, 16)
|
2023-08-19 04:52:15 +02:00
|
|
|
if m.name != nil {
|
|
|
|
fields = append(fields, hibp.FieldName)
|
|
|
|
}
|
2023-08-20 23:16:12 +02:00
|
|
|
if m.title != nil {
|
|
|
|
fields = append(fields, hibp.FieldTitle)
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
if m.domain != nil {
|
|
|
|
fields = append(fields, hibp.FieldDomain)
|
|
|
|
}
|
|
|
|
if m.breach_date != nil {
|
|
|
|
fields = append(fields, hibp.FieldBreachDate)
|
|
|
|
}
|
|
|
|
if m.added_date != nil {
|
|
|
|
fields = append(fields, hibp.FieldAddedDate)
|
|
|
|
}
|
|
|
|
if m.modified_date != nil {
|
|
|
|
fields = append(fields, hibp.FieldModifiedDate)
|
|
|
|
}
|
|
|
|
if m.pwn_count != nil {
|
|
|
|
fields = append(fields, hibp.FieldPwnCount)
|
|
|
|
}
|
|
|
|
if m.description != nil {
|
|
|
|
fields = append(fields, hibp.FieldDescription)
|
|
|
|
}
|
|
|
|
if m.dataclasses != nil {
|
|
|
|
fields = append(fields, hibp.FieldDataclasses)
|
|
|
|
}
|
|
|
|
if m.is_verified != nil {
|
|
|
|
fields = append(fields, hibp.FieldIsVerified)
|
|
|
|
}
|
|
|
|
if m.is_fabricated != nil {
|
|
|
|
fields = append(fields, hibp.FieldIsFabricated)
|
|
|
|
}
|
|
|
|
if m.is_sensitive != nil {
|
|
|
|
fields = append(fields, hibp.FieldIsSensitive)
|
|
|
|
}
|
|
|
|
if m.is_retired != nil {
|
|
|
|
fields = append(fields, hibp.FieldIsRetired)
|
|
|
|
}
|
|
|
|
if m.is_spamList != nil {
|
|
|
|
fields = append(fields, hibp.FieldIsSpamList)
|
|
|
|
}
|
|
|
|
if m.is_malware != nil {
|
|
|
|
fields = append(fields, hibp.FieldIsMalware)
|
|
|
|
}
|
2023-08-20 23:16:12 +02:00
|
|
|
if m.logo_path != nil {
|
|
|
|
fields = append(fields, hibp.FieldLogoPath)
|
2023-08-19 04:52:15 +02: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 *HIBPMutation) Field(name string) (ent.Value, bool) {
|
|
|
|
switch name {
|
|
|
|
case hibp.FieldName:
|
|
|
|
return m.Name()
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldTitle:
|
|
|
|
return m.Title()
|
2023-08-19 04:52:15 +02:00
|
|
|
case hibp.FieldDomain:
|
|
|
|
return m.Domain()
|
|
|
|
case hibp.FieldBreachDate:
|
|
|
|
return m.BreachDate()
|
|
|
|
case hibp.FieldAddedDate:
|
|
|
|
return m.AddedDate()
|
|
|
|
case hibp.FieldModifiedDate:
|
|
|
|
return m.ModifiedDate()
|
|
|
|
case hibp.FieldPwnCount:
|
|
|
|
return m.PwnCount()
|
|
|
|
case hibp.FieldDescription:
|
|
|
|
return m.Description()
|
|
|
|
case hibp.FieldDataclasses:
|
|
|
|
return m.Dataclasses()
|
|
|
|
case hibp.FieldIsVerified:
|
|
|
|
return m.IsVerified()
|
|
|
|
case hibp.FieldIsFabricated:
|
|
|
|
return m.IsFabricated()
|
|
|
|
case hibp.FieldIsSensitive:
|
|
|
|
return m.IsSensitive()
|
|
|
|
case hibp.FieldIsRetired:
|
|
|
|
return m.IsRetired()
|
|
|
|
case hibp.FieldIsSpamList:
|
|
|
|
return m.IsSpamList()
|
|
|
|
case hibp.FieldIsMalware:
|
|
|
|
return m.IsMalware()
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldLogoPath:
|
|
|
|
return m.LogoPath()
|
2023-08-19 04:52:15 +02: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 *HIBPMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
|
switch name {
|
|
|
|
case hibp.FieldName:
|
|
|
|
return m.OldName(ctx)
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldTitle:
|
|
|
|
return m.OldTitle(ctx)
|
2023-08-19 04:52:15 +02:00
|
|
|
case hibp.FieldDomain:
|
|
|
|
return m.OldDomain(ctx)
|
|
|
|
case hibp.FieldBreachDate:
|
|
|
|
return m.OldBreachDate(ctx)
|
|
|
|
case hibp.FieldAddedDate:
|
|
|
|
return m.OldAddedDate(ctx)
|
|
|
|
case hibp.FieldModifiedDate:
|
|
|
|
return m.OldModifiedDate(ctx)
|
|
|
|
case hibp.FieldPwnCount:
|
|
|
|
return m.OldPwnCount(ctx)
|
|
|
|
case hibp.FieldDescription:
|
|
|
|
return m.OldDescription(ctx)
|
|
|
|
case hibp.FieldDataclasses:
|
|
|
|
return m.OldDataclasses(ctx)
|
|
|
|
case hibp.FieldIsVerified:
|
|
|
|
return m.OldIsVerified(ctx)
|
|
|
|
case hibp.FieldIsFabricated:
|
|
|
|
return m.OldIsFabricated(ctx)
|
|
|
|
case hibp.FieldIsSensitive:
|
|
|
|
return m.OldIsSensitive(ctx)
|
|
|
|
case hibp.FieldIsRetired:
|
|
|
|
return m.OldIsRetired(ctx)
|
|
|
|
case hibp.FieldIsSpamList:
|
|
|
|
return m.OldIsSpamList(ctx)
|
|
|
|
case hibp.FieldIsMalware:
|
|
|
|
return m.OldIsMalware(ctx)
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldLogoPath:
|
|
|
|
return m.OldLogoPath(ctx)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown HIBP 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 *HIBPMutation) SetField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
case hibp.FieldName:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetName(v)
|
|
|
|
return nil
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldTitle:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetTitle(v)
|
|
|
|
return nil
|
2023-08-19 04:52:15 +02:00
|
|
|
case hibp.FieldDomain:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetDomain(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldBreachDate:
|
2023-08-24 03:59:50 +02:00
|
|
|
v, ok := value.(string)
|
2023-08-19 04:52:15 +02:00
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetBreachDate(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldAddedDate:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetAddedDate(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldModifiedDate:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetModifiedDate(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldPwnCount:
|
|
|
|
v, ok := value.(int)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetPwnCount(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldDescription:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetDescription(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldDataclasses:
|
|
|
|
v, ok := value.([]string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetDataclasses(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsVerified:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsVerified(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsFabricated:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsFabricated(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsSensitive:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsSensitive(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsRetired:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsRetired(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsSpamList:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsSpamList(v)
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsMalware:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsMalware(v)
|
|
|
|
return nil
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldLogoPath:
|
2023-08-19 04:52:15 +02:00
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
2023-08-20 23:16:12 +02:00
|
|
|
m.SetLogoPath(v)
|
2023-08-19 04:52:15 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown HIBP field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
|
|
|
func (m *HIBPMutation) AddedFields() []string {
|
|
|
|
var fields []string
|
|
|
|
if m.addpwn_count != nil {
|
|
|
|
fields = append(fields, hibp.FieldPwnCount)
|
|
|
|
}
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
|
|
// with the given name. The second boolean return value indicates that this field
|
|
|
|
// was not set, or was not defined in the schema.
|
|
|
|
func (m *HIBPMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
|
switch name {
|
|
|
|
case hibp.FieldPwnCount:
|
|
|
|
return m.AddedPwnCount()
|
|
|
|
}
|
|
|
|
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 *HIBPMutation) AddField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
case hibp.FieldPwnCount:
|
|
|
|
v, ok := value.(int)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.AddPwnCount(v)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown HIBP numeric field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
|
|
|
func (m *HIBPMutation) ClearedFields() []string {
|
|
|
|
var fields []string
|
|
|
|
if m.FieldCleared(hibp.FieldDescription) {
|
|
|
|
fields = append(fields, hibp.FieldDescription)
|
|
|
|
}
|
2023-08-20 23:16:12 +02:00
|
|
|
if m.FieldCleared(hibp.FieldLogoPath) {
|
|
|
|
fields = append(fields, hibp.FieldLogoPath)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
|
|
|
func (m *HIBPMutation) 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 *HIBPMutation) ClearField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case hibp.FieldDescription:
|
|
|
|
m.ClearDescription()
|
|
|
|
return nil
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldLogoPath:
|
|
|
|
m.ClearLogoPath()
|
2023-08-19 04:52:15 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown HIBP 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 *HIBPMutation) ResetField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case hibp.FieldName:
|
|
|
|
m.ResetName()
|
|
|
|
return nil
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldTitle:
|
|
|
|
m.ResetTitle()
|
|
|
|
return nil
|
2023-08-19 04:52:15 +02:00
|
|
|
case hibp.FieldDomain:
|
|
|
|
m.ResetDomain()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldBreachDate:
|
|
|
|
m.ResetBreachDate()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldAddedDate:
|
|
|
|
m.ResetAddedDate()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldModifiedDate:
|
|
|
|
m.ResetModifiedDate()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldPwnCount:
|
|
|
|
m.ResetPwnCount()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldDescription:
|
|
|
|
m.ResetDescription()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldDataclasses:
|
|
|
|
m.ResetDataclasses()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsVerified:
|
|
|
|
m.ResetIsVerified()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsFabricated:
|
|
|
|
m.ResetIsFabricated()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsSensitive:
|
|
|
|
m.ResetIsSensitive()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsRetired:
|
|
|
|
m.ResetIsRetired()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsSpamList:
|
|
|
|
m.ResetIsSpamList()
|
|
|
|
return nil
|
|
|
|
case hibp.FieldIsMalware:
|
|
|
|
m.ResetIsMalware()
|
|
|
|
return nil
|
2023-08-20 23:16:12 +02:00
|
|
|
case hibp.FieldLogoPath:
|
|
|
|
m.ResetLogoPath()
|
2023-08-19 04:52:15 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown HIBP field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
|
func (m *HIBPMutation) AddedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.tracked_breaches != nil {
|
|
|
|
edges = append(edges, hibp.EdgeTrackedBreaches)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
|
|
|
func (m *HIBPMutation) AddedIDs(name string) []ent.Value {
|
|
|
|
switch name {
|
|
|
|
case hibp.EdgeTrackedBreaches:
|
|
|
|
if id := m.tracked_breaches; id != nil {
|
|
|
|
return []ent.Value{*id}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
|
func (m *HIBPMutation) 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 *HIBPMutation) RemovedIDs(name string) []ent.Value {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
|
func (m *HIBPMutation) ClearedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.clearedtracked_breaches {
|
|
|
|
edges = append(edges, hibp.EdgeTrackedBreaches)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
|
|
|
func (m *HIBPMutation) EdgeCleared(name string) bool {
|
|
|
|
switch name {
|
|
|
|
case hibp.EdgeTrackedBreaches:
|
|
|
|
return m.clearedtracked_breaches
|
|
|
|
}
|
|
|
|
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 *HIBPMutation) ClearEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case hibp.EdgeTrackedBreaches:
|
|
|
|
m.ClearTrackedBreaches()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown HIBP 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 *HIBPMutation) ResetEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case hibp.EdgeTrackedBreaches:
|
|
|
|
m.ResetTrackedBreaches()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown HIBP edge %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// LocalBreachMutation represents an operation that mutates the LocalBreach nodes in the graph.
|
|
|
|
type LocalBreachMutation struct {
|
|
|
|
config
|
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *uuid.UUID
|
|
|
|
name *string
|
|
|
|
date *time.Time
|
|
|
|
description *string
|
|
|
|
is_verified *bool
|
2023-08-20 05:20:33 +02:00
|
|
|
contains_passwords *bool
|
2023-08-19 04:52:15 +02:00
|
|
|
contains_hashes *bool
|
|
|
|
contains_emails *bool
|
2023-08-20 05:20:33 +02:00
|
|
|
contains_usernames *bool
|
2023-08-19 04:52:15 +02:00
|
|
|
hash_type *string
|
|
|
|
hash_salted *bool
|
|
|
|
hash_peppered *bool
|
2023-08-20 05:20:33 +02:00
|
|
|
data **schema.Data
|
2023-08-19 04:52:15 +02:00
|
|
|
created_at *time.Time
|
|
|
|
clearedFields map[string]struct{}
|
|
|
|
tracked_breaches map[uuid.UUID]struct{}
|
|
|
|
removedtracked_breaches map[uuid.UUID]struct{}
|
|
|
|
clearedtracked_breaches bool
|
|
|
|
done bool
|
|
|
|
oldValue func(context.Context) (*LocalBreach, error)
|
|
|
|
predicates []predicate.LocalBreach
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ ent.Mutation = (*LocalBreachMutation)(nil)
|
|
|
|
|
|
|
|
// localbreachOption allows management of the mutation configuration using functional options.
|
|
|
|
type localbreachOption func(*LocalBreachMutation)
|
|
|
|
|
|
|
|
// newLocalBreachMutation creates new mutation for the LocalBreach entity.
|
|
|
|
func newLocalBreachMutation(c config, op Op, opts ...localbreachOption) *LocalBreachMutation {
|
|
|
|
m := &LocalBreachMutation{
|
|
|
|
config: c,
|
|
|
|
op: op,
|
|
|
|
typ: TypeLocalBreach,
|
|
|
|
clearedFields: make(map[string]struct{}),
|
|
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(m)
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// withLocalBreachID sets the ID field of the mutation.
|
|
|
|
func withLocalBreachID(id uuid.UUID) localbreachOption {
|
|
|
|
return func(m *LocalBreachMutation) {
|
|
|
|
var (
|
|
|
|
err error
|
|
|
|
once sync.Once
|
|
|
|
value *LocalBreach
|
|
|
|
)
|
|
|
|
m.oldValue = func(ctx context.Context) (*LocalBreach, error) {
|
|
|
|
once.Do(func() {
|
|
|
|
if m.done {
|
|
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
|
|
} else {
|
|
|
|
value, err = m.Client().LocalBreach.Get(ctx, id)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return value, err
|
|
|
|
}
|
|
|
|
m.id = &id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// withLocalBreach sets the old LocalBreach of the mutation.
|
|
|
|
func withLocalBreach(node *LocalBreach) localbreachOption {
|
|
|
|
return func(m *LocalBreachMutation) {
|
|
|
|
m.oldValue = func(context.Context) (*LocalBreach, 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 LocalBreachMutation) 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 LocalBreachMutation) 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 LocalBreach entities.
|
|
|
|
func (m *LocalBreachMutation) 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 *LocalBreachMutation) 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 *LocalBreachMutation) 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().LocalBreach.Query().Where(m.predicates...).IDs(ctx)
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetName sets the "name" field.
|
|
|
|
func (m *LocalBreachMutation) SetName(s string) {
|
|
|
|
m.name = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Name returns the value of the "name" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) 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 LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) 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 *LocalBreachMutation) ResetName() {
|
|
|
|
m.name = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDate sets the "date" field.
|
|
|
|
func (m *LocalBreachMutation) SetDate(t time.Time) {
|
|
|
|
m.date = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// Date returns the value of the "date" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) Date() (r time.Time, exists bool) {
|
|
|
|
v := m.date
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldDate returns the old "date" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldDate(ctx context.Context) (v time.Time, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldDate is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldDate requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldDate: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Date, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetDate resets all changes to the "date" field.
|
|
|
|
func (m *LocalBreachMutation) ResetDate() {
|
|
|
|
m.date = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDescription sets the "description" field.
|
|
|
|
func (m *LocalBreachMutation) SetDescription(s string) {
|
|
|
|
m.description = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Description returns the value of the "description" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) Description() (r string, exists bool) {
|
|
|
|
v := m.description
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldDescription returns the old "description" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldDescription(ctx context.Context) (v *string, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldDescription is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldDescription requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldDescription: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Description, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
|
|
func (m *LocalBreachMutation) ClearDescription() {
|
|
|
|
m.description = nil
|
|
|
|
m.clearedFields[localbreach.FieldDescription] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DescriptionCleared returns if the "description" field was cleared in this mutation.
|
|
|
|
func (m *LocalBreachMutation) DescriptionCleared() bool {
|
|
|
|
_, ok := m.clearedFields[localbreach.FieldDescription]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetDescription resets all changes to the "description" field.
|
|
|
|
func (m *LocalBreachMutation) ResetDescription() {
|
|
|
|
m.description = nil
|
|
|
|
delete(m.clearedFields, localbreach.FieldDescription)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsVerified sets the "is_verified" field.
|
|
|
|
func (m *LocalBreachMutation) SetIsVerified(b bool) {
|
|
|
|
m.is_verified = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsVerified returns the value of the "is_verified" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) IsVerified() (r bool, exists bool) {
|
|
|
|
v := m.is_verified
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsVerified returns the old "is_verified" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldIsVerified(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsVerified is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsVerified requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsVerified: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsVerified, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsVerified resets all changes to the "is_verified" field.
|
|
|
|
func (m *LocalBreachMutation) ResetIsVerified() {
|
|
|
|
m.is_verified = nil
|
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// SetContainsPasswords sets the "contains_passwords" field.
|
|
|
|
func (m *LocalBreachMutation) SetContainsPasswords(b bool) {
|
|
|
|
m.contains_passwords = &b
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// ContainsPasswords returns the value of the "contains_passwords" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) ContainsPasswords() (r bool, exists bool) {
|
|
|
|
v := m.contains_passwords
|
2023-08-19 04:52:15 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// OldContainsPasswords returns the old "contains_passwords" field's value of the LocalBreach entity.
|
2023-08-19 04:52:15 +02:00
|
|
|
// If the LocalBreach 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.
|
2023-08-20 05:20:33 +02:00
|
|
|
func (m *LocalBreachMutation) OldContainsPasswords(ctx context.Context) (v bool, err error) {
|
2023-08-19 04:52:15 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-20 05:20:33 +02:00
|
|
|
return v, errors.New("OldContainsPasswords is only allowed on UpdateOne operations")
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-20 05:20:33 +02:00
|
|
|
return v, errors.New("OldContainsPasswords requires an ID field in the mutation")
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-20 05:20:33 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldContainsPasswords: %w", err)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
2023-08-20 05:20:33 +02:00
|
|
|
return oldValue.ContainsPasswords, nil
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// ResetContainsPasswords resets all changes to the "contains_passwords" field.
|
|
|
|
func (m *LocalBreachMutation) ResetContainsPasswords() {
|
|
|
|
m.contains_passwords = nil
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetContainsHashes sets the "contains_hashes" field.
|
|
|
|
func (m *LocalBreachMutation) SetContainsHashes(b bool) {
|
|
|
|
m.contains_hashes = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainsHashes returns the value of the "contains_hashes" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) ContainsHashes() (r bool, exists bool) {
|
|
|
|
v := m.contains_hashes
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldContainsHashes returns the old "contains_hashes" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldContainsHashes(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldContainsHashes is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldContainsHashes requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldContainsHashes: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.ContainsHashes, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetContainsHashes resets all changes to the "contains_hashes" field.
|
|
|
|
func (m *LocalBreachMutation) ResetContainsHashes() {
|
|
|
|
m.contains_hashes = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetContainsEmails sets the "contains_emails" field.
|
|
|
|
func (m *LocalBreachMutation) SetContainsEmails(b bool) {
|
|
|
|
m.contains_emails = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainsEmails returns the value of the "contains_emails" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) ContainsEmails() (r bool, exists bool) {
|
|
|
|
v := m.contains_emails
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldContainsEmails returns the old "contains_emails" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldContainsEmails(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldContainsEmails is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldContainsEmails requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldContainsEmails: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.ContainsEmails, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetContainsEmails resets all changes to the "contains_emails" field.
|
|
|
|
func (m *LocalBreachMutation) ResetContainsEmails() {
|
|
|
|
m.contains_emails = nil
|
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// SetContainsUsernames sets the "contains_usernames" field.
|
|
|
|
func (m *LocalBreachMutation) SetContainsUsernames(b bool) {
|
|
|
|
m.contains_usernames = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainsUsernames returns the value of the "contains_usernames" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) ContainsUsernames() (r bool, exists bool) {
|
|
|
|
v := m.contains_usernames
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldContainsUsernames returns the old "contains_usernames" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldContainsUsernames(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldContainsUsernames is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldContainsUsernames requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldContainsUsernames: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.ContainsUsernames, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetContainsUsernames resets all changes to the "contains_usernames" field.
|
|
|
|
func (m *LocalBreachMutation) ResetContainsUsernames() {
|
|
|
|
m.contains_usernames = nil
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetHashType sets the "hash_type" field.
|
|
|
|
func (m *LocalBreachMutation) SetHashType(s string) {
|
|
|
|
m.hash_type = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// HashType returns the value of the "hash_type" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) HashType() (r string, exists bool) {
|
|
|
|
v := m.hash_type
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldHashType returns the old "hash_type" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldHashType(ctx context.Context) (v *string, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldHashType is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldHashType requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldHashType: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.HashType, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashType clears the value of the "hash_type" field.
|
|
|
|
func (m *LocalBreachMutation) ClearHashType() {
|
|
|
|
m.hash_type = nil
|
|
|
|
m.clearedFields[localbreach.FieldHashType] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// HashTypeCleared returns if the "hash_type" field was cleared in this mutation.
|
|
|
|
func (m *LocalBreachMutation) HashTypeCleared() bool {
|
|
|
|
_, ok := m.clearedFields[localbreach.FieldHashType]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetHashType resets all changes to the "hash_type" field.
|
|
|
|
func (m *LocalBreachMutation) ResetHashType() {
|
|
|
|
m.hash_type = nil
|
|
|
|
delete(m.clearedFields, localbreach.FieldHashType)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetHashSalted sets the "hash_salted" field.
|
|
|
|
func (m *LocalBreachMutation) SetHashSalted(b bool) {
|
|
|
|
m.hash_salted = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// HashSalted returns the value of the "hash_salted" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) HashSalted() (r bool, exists bool) {
|
|
|
|
v := m.hash_salted
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldHashSalted returns the old "hash_salted" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldHashSalted(ctx context.Context) (v *bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldHashSalted is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldHashSalted requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldHashSalted: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.HashSalted, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashSalted clears the value of the "hash_salted" field.
|
|
|
|
func (m *LocalBreachMutation) ClearHashSalted() {
|
|
|
|
m.hash_salted = nil
|
|
|
|
m.clearedFields[localbreach.FieldHashSalted] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// HashSaltedCleared returns if the "hash_salted" field was cleared in this mutation.
|
|
|
|
func (m *LocalBreachMutation) HashSaltedCleared() bool {
|
|
|
|
_, ok := m.clearedFields[localbreach.FieldHashSalted]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetHashSalted resets all changes to the "hash_salted" field.
|
|
|
|
func (m *LocalBreachMutation) ResetHashSalted() {
|
|
|
|
m.hash_salted = nil
|
|
|
|
delete(m.clearedFields, localbreach.FieldHashSalted)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetHashPeppered sets the "hash_peppered" field.
|
|
|
|
func (m *LocalBreachMutation) SetHashPeppered(b bool) {
|
|
|
|
m.hash_peppered = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// HashPeppered returns the value of the "hash_peppered" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) HashPeppered() (r bool, exists bool) {
|
|
|
|
v := m.hash_peppered
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldHashPeppered returns the old "hash_peppered" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) OldHashPeppered(ctx context.Context) (v *bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldHashPeppered is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldHashPeppered requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldHashPeppered: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.HashPeppered, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashPeppered clears the value of the "hash_peppered" field.
|
|
|
|
func (m *LocalBreachMutation) ClearHashPeppered() {
|
|
|
|
m.hash_peppered = nil
|
|
|
|
m.clearedFields[localbreach.FieldHashPeppered] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// HashPepperedCleared returns if the "hash_peppered" field was cleared in this mutation.
|
|
|
|
func (m *LocalBreachMutation) HashPepperedCleared() bool {
|
|
|
|
_, ok := m.clearedFields[localbreach.FieldHashPeppered]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetHashPeppered resets all changes to the "hash_peppered" field.
|
|
|
|
func (m *LocalBreachMutation) ResetHashPeppered() {
|
|
|
|
m.hash_peppered = nil
|
|
|
|
delete(m.clearedFields, localbreach.FieldHashPeppered)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetData sets the "data" field.
|
2023-08-20 05:20:33 +02:00
|
|
|
func (m *LocalBreachMutation) SetData(s *schema.Data) {
|
2023-08-19 04:52:15 +02:00
|
|
|
m.data = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Data returns the value of the "data" field in the mutation.
|
2023-08-20 05:20:33 +02:00
|
|
|
func (m *LocalBreachMutation) Data() (r *schema.Data, exists bool) {
|
2023-08-19 04:52:15 +02:00
|
|
|
v := m.data
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldData returns the old "data" field's value of the LocalBreach entity.
|
|
|
|
// If the LocalBreach 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.
|
2023-08-20 05:20:33 +02:00
|
|
|
func (m *LocalBreachMutation) OldData(ctx context.Context) (v *schema.Data, err error) {
|
2023-08-19 04:52:15 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldData is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldData requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldData: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Data, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearData clears the value of the "data" field.
|
|
|
|
func (m *LocalBreachMutation) ClearData() {
|
|
|
|
m.data = nil
|
|
|
|
m.clearedFields[localbreach.FieldData] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DataCleared returns if the "data" field was cleared in this mutation.
|
|
|
|
func (m *LocalBreachMutation) DataCleared() bool {
|
|
|
|
_, ok := m.clearedFields[localbreach.FieldData]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetData resets all changes to the "data" field.
|
|
|
|
func (m *LocalBreachMutation) ResetData() {
|
|
|
|
m.data = nil
|
|
|
|
delete(m.clearedFields, localbreach.FieldData)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
|
|
func (m *LocalBreachMutation) SetCreatedAt(t time.Time) {
|
|
|
|
m.created_at = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
|
func (m *LocalBreachMutation) 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 LocalBreach entity.
|
|
|
|
// If the LocalBreach 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 *LocalBreachMutation) 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 *LocalBreachMutation) ResetCreatedAt() {
|
|
|
|
m.created_at = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddTrackedBreachIDs adds the "tracked_breaches" edge to the TrackedBreaches entity by ids.
|
|
|
|
func (m *LocalBreachMutation) AddTrackedBreachIDs(ids ...uuid.UUID) {
|
|
|
|
if m.tracked_breaches == nil {
|
|
|
|
m.tracked_breaches = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
m.tracked_breaches[ids[i]] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearTrackedBreaches clears the "tracked_breaches" edge to the TrackedBreaches entity.
|
|
|
|
func (m *LocalBreachMutation) ClearTrackedBreaches() {
|
|
|
|
m.clearedtracked_breaches = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackedBreachesCleared reports if the "tracked_breaches" edge to the TrackedBreaches entity was cleared.
|
|
|
|
func (m *LocalBreachMutation) TrackedBreachesCleared() bool {
|
|
|
|
return m.clearedtracked_breaches
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveTrackedBreachIDs removes the "tracked_breaches" edge to the TrackedBreaches entity by IDs.
|
|
|
|
func (m *LocalBreachMutation) RemoveTrackedBreachIDs(ids ...uuid.UUID) {
|
|
|
|
if m.removedtracked_breaches == nil {
|
|
|
|
m.removedtracked_breaches = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
delete(m.tracked_breaches, ids[i])
|
|
|
|
m.removedtracked_breaches[ids[i]] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedTrackedBreaches returns the removed IDs of the "tracked_breaches" edge to the TrackedBreaches entity.
|
|
|
|
func (m *LocalBreachMutation) RemovedTrackedBreachesIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.removedtracked_breaches {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackedBreachesIDs returns the "tracked_breaches" edge IDs in the mutation.
|
|
|
|
func (m *LocalBreachMutation) TrackedBreachesIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.tracked_breaches {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetTrackedBreaches resets all changes to the "tracked_breaches" edge.
|
|
|
|
func (m *LocalBreachMutation) ResetTrackedBreaches() {
|
|
|
|
m.tracked_breaches = nil
|
|
|
|
m.clearedtracked_breaches = false
|
|
|
|
m.removedtracked_breaches = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the LocalBreachMutation builder.
|
|
|
|
func (m *LocalBreachMutation) Where(ps ...predicate.LocalBreach) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// WhereP appends storage-level predicates to the LocalBreachMutation builder. Using this method,
|
|
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
|
func (m *LocalBreachMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
|
p := make([]predicate.LocalBreach, len(ps))
|
|
|
|
for i := range ps {
|
|
|
|
p[i] = ps[i]
|
|
|
|
}
|
|
|
|
m.Where(p...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Op returns the operation name.
|
|
|
|
func (m *LocalBreachMutation) Op() Op {
|
|
|
|
return m.op
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
|
|
func (m *LocalBreachMutation) SetOp(op Op) {
|
|
|
|
m.op = op
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type returns the node type of this mutation (LocalBreach).
|
|
|
|
func (m *LocalBreachMutation) 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 *LocalBreachMutation) Fields() []string {
|
2023-08-20 05:20:33 +02:00
|
|
|
fields := make([]string, 0, 13)
|
2023-08-19 04:52:15 +02:00
|
|
|
if m.name != nil {
|
|
|
|
fields = append(fields, localbreach.FieldName)
|
|
|
|
}
|
|
|
|
if m.date != nil {
|
|
|
|
fields = append(fields, localbreach.FieldDate)
|
|
|
|
}
|
|
|
|
if m.description != nil {
|
|
|
|
fields = append(fields, localbreach.FieldDescription)
|
|
|
|
}
|
|
|
|
if m.is_verified != nil {
|
|
|
|
fields = append(fields, localbreach.FieldIsVerified)
|
|
|
|
}
|
2023-08-20 05:20:33 +02:00
|
|
|
if m.contains_passwords != nil {
|
|
|
|
fields = append(fields, localbreach.FieldContainsPasswords)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if m.contains_hashes != nil {
|
|
|
|
fields = append(fields, localbreach.FieldContainsHashes)
|
|
|
|
}
|
|
|
|
if m.contains_emails != nil {
|
|
|
|
fields = append(fields, localbreach.FieldContainsEmails)
|
|
|
|
}
|
2023-08-20 05:20:33 +02:00
|
|
|
if m.contains_usernames != nil {
|
|
|
|
fields = append(fields, localbreach.FieldContainsUsernames)
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
if m.hash_type != nil {
|
|
|
|
fields = append(fields, localbreach.FieldHashType)
|
|
|
|
}
|
|
|
|
if m.hash_salted != nil {
|
|
|
|
fields = append(fields, localbreach.FieldHashSalted)
|
|
|
|
}
|
|
|
|
if m.hash_peppered != nil {
|
|
|
|
fields = append(fields, localbreach.FieldHashPeppered)
|
|
|
|
}
|
|
|
|
if m.data != nil {
|
|
|
|
fields = append(fields, localbreach.FieldData)
|
|
|
|
}
|
|
|
|
if m.created_at != nil {
|
|
|
|
fields = append(fields, localbreach.FieldCreatedAt)
|
|
|
|
}
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
|
|
|
|
// Field returns the value of a field with the given name. The second boolean
|
|
|
|
// return value indicates that this field was not set, or was not defined in the
|
|
|
|
// schema.
|
|
|
|
func (m *LocalBreachMutation) Field(name string) (ent.Value, bool) {
|
|
|
|
switch name {
|
|
|
|
case localbreach.FieldName:
|
|
|
|
return m.Name()
|
|
|
|
case localbreach.FieldDate:
|
|
|
|
return m.Date()
|
|
|
|
case localbreach.FieldDescription:
|
|
|
|
return m.Description()
|
|
|
|
case localbreach.FieldIsVerified:
|
|
|
|
return m.IsVerified()
|
2023-08-20 05:20:33 +02:00
|
|
|
case localbreach.FieldContainsPasswords:
|
|
|
|
return m.ContainsPasswords()
|
2023-08-19 04:52:15 +02:00
|
|
|
case localbreach.FieldContainsHashes:
|
|
|
|
return m.ContainsHashes()
|
|
|
|
case localbreach.FieldContainsEmails:
|
|
|
|
return m.ContainsEmails()
|
2023-08-20 05:20:33 +02:00
|
|
|
case localbreach.FieldContainsUsernames:
|
|
|
|
return m.ContainsUsernames()
|
2023-08-19 04:52:15 +02:00
|
|
|
case localbreach.FieldHashType:
|
|
|
|
return m.HashType()
|
|
|
|
case localbreach.FieldHashSalted:
|
|
|
|
return m.HashSalted()
|
|
|
|
case localbreach.FieldHashPeppered:
|
|
|
|
return m.HashPeppered()
|
|
|
|
case localbreach.FieldData:
|
|
|
|
return m.Data()
|
|
|
|
case localbreach.FieldCreatedAt:
|
|
|
|
return m.CreatedAt()
|
|
|
|
}
|
|
|
|
return nil, false
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldField returns the old value of the field from the database. An error is
|
|
|
|
// returned if the mutation operation is not UpdateOne, or the query to the
|
|
|
|
// database failed.
|
|
|
|
func (m *LocalBreachMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
|
switch name {
|
|
|
|
case localbreach.FieldName:
|
|
|
|
return m.OldName(ctx)
|
|
|
|
case localbreach.FieldDate:
|
|
|
|
return m.OldDate(ctx)
|
|
|
|
case localbreach.FieldDescription:
|
|
|
|
return m.OldDescription(ctx)
|
|
|
|
case localbreach.FieldIsVerified:
|
|
|
|
return m.OldIsVerified(ctx)
|
2023-08-20 05:20:33 +02:00
|
|
|
case localbreach.FieldContainsPasswords:
|
|
|
|
return m.OldContainsPasswords(ctx)
|
2023-08-19 04:52:15 +02:00
|
|
|
case localbreach.FieldContainsHashes:
|
|
|
|
return m.OldContainsHashes(ctx)
|
|
|
|
case localbreach.FieldContainsEmails:
|
|
|
|
return m.OldContainsEmails(ctx)
|
2023-08-20 05:20:33 +02:00
|
|
|
case localbreach.FieldContainsUsernames:
|
|
|
|
return m.OldContainsUsernames(ctx)
|
2023-08-19 04:52:15 +02:00
|
|
|
case localbreach.FieldHashType:
|
|
|
|
return m.OldHashType(ctx)
|
|
|
|
case localbreach.FieldHashSalted:
|
|
|
|
return m.OldHashSalted(ctx)
|
|
|
|
case localbreach.FieldHashPeppered:
|
|
|
|
return m.OldHashPeppered(ctx)
|
|
|
|
case localbreach.FieldData:
|
|
|
|
return m.OldData(ctx)
|
|
|
|
case localbreach.FieldCreatedAt:
|
|
|
|
return m.OldCreatedAt(ctx)
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown LocalBreach 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 *LocalBreachMutation) SetField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
case localbreach.FieldName:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetName(v)
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldDate:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetDate(v)
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldDescription:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetDescription(v)
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldIsVerified:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsVerified(v)
|
|
|
|
return nil
|
2023-08-20 05:20:33 +02:00
|
|
|
case localbreach.FieldContainsPasswords:
|
2023-08-19 04:52:15 +02:00
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
2023-08-20 05:20:33 +02:00
|
|
|
m.SetContainsPasswords(v)
|
2023-08-19 04:52:15 +02:00
|
|
|
return nil
|
|
|
|
case localbreach.FieldContainsHashes:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetContainsHashes(v)
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldContainsEmails:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetContainsEmails(v)
|
|
|
|
return nil
|
2023-08-20 05:20:33 +02:00
|
|
|
case localbreach.FieldContainsUsernames:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetContainsUsernames(v)
|
|
|
|
return nil
|
2023-08-19 04:52:15 +02:00
|
|
|
case localbreach.FieldHashType:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetHashType(v)
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldHashSalted:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetHashSalted(v)
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldHashPeppered:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetHashPeppered(v)
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldData:
|
2023-08-20 05:20:33 +02:00
|
|
|
v, ok := value.(*schema.Data)
|
2023-08-19 04:52:15 +02:00
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetData(v)
|
|
|
|
return nil
|
|
|
|
case localbreach.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 LocalBreach field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
|
|
|
func (m *LocalBreachMutation) 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 *LocalBreachMutation) 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 *LocalBreachMutation) AddField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown LocalBreach numeric field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
|
|
|
func (m *LocalBreachMutation) ClearedFields() []string {
|
|
|
|
var fields []string
|
|
|
|
if m.FieldCleared(localbreach.FieldDescription) {
|
|
|
|
fields = append(fields, localbreach.FieldDescription)
|
|
|
|
}
|
|
|
|
if m.FieldCleared(localbreach.FieldHashType) {
|
|
|
|
fields = append(fields, localbreach.FieldHashType)
|
|
|
|
}
|
|
|
|
if m.FieldCleared(localbreach.FieldHashSalted) {
|
|
|
|
fields = append(fields, localbreach.FieldHashSalted)
|
|
|
|
}
|
|
|
|
if m.FieldCleared(localbreach.FieldHashPeppered) {
|
|
|
|
fields = append(fields, localbreach.FieldHashPeppered)
|
|
|
|
}
|
|
|
|
if m.FieldCleared(localbreach.FieldData) {
|
|
|
|
fields = append(fields, localbreach.FieldData)
|
|
|
|
}
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
|
|
|
func (m *LocalBreachMutation) 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 *LocalBreachMutation) ClearField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case localbreach.FieldDescription:
|
|
|
|
m.ClearDescription()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldHashType:
|
|
|
|
m.ClearHashType()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldHashSalted:
|
|
|
|
m.ClearHashSalted()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldHashPeppered:
|
|
|
|
m.ClearHashPeppered()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldData:
|
|
|
|
m.ClearData()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown LocalBreach 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 *LocalBreachMutation) ResetField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case localbreach.FieldName:
|
|
|
|
m.ResetName()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldDate:
|
|
|
|
m.ResetDate()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldDescription:
|
|
|
|
m.ResetDescription()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldIsVerified:
|
|
|
|
m.ResetIsVerified()
|
|
|
|
return nil
|
2023-08-20 05:20:33 +02:00
|
|
|
case localbreach.FieldContainsPasswords:
|
|
|
|
m.ResetContainsPasswords()
|
2023-08-19 04:52:15 +02:00
|
|
|
return nil
|
|
|
|
case localbreach.FieldContainsHashes:
|
|
|
|
m.ResetContainsHashes()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldContainsEmails:
|
|
|
|
m.ResetContainsEmails()
|
|
|
|
return nil
|
2023-08-20 05:20:33 +02:00
|
|
|
case localbreach.FieldContainsUsernames:
|
|
|
|
m.ResetContainsUsernames()
|
|
|
|
return nil
|
2023-08-19 04:52:15 +02:00
|
|
|
case localbreach.FieldHashType:
|
|
|
|
m.ResetHashType()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldHashSalted:
|
|
|
|
m.ResetHashSalted()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldHashPeppered:
|
|
|
|
m.ResetHashPeppered()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldData:
|
|
|
|
m.ResetData()
|
|
|
|
return nil
|
|
|
|
case localbreach.FieldCreatedAt:
|
|
|
|
m.ResetCreatedAt()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown LocalBreach field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
|
func (m *LocalBreachMutation) AddedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.tracked_breaches != nil {
|
|
|
|
edges = append(edges, localbreach.EdgeTrackedBreaches)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
|
|
|
func (m *LocalBreachMutation) AddedIDs(name string) []ent.Value {
|
|
|
|
switch name {
|
|
|
|
case localbreach.EdgeTrackedBreaches:
|
|
|
|
ids := make([]ent.Value, 0, len(m.tracked_breaches))
|
|
|
|
for id := range m.tracked_breaches {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
|
func (m *LocalBreachMutation) RemovedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.removedtracked_breaches != nil {
|
|
|
|
edges = append(edges, localbreach.EdgeTrackedBreaches)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
|
// the given name in this mutation.
|
|
|
|
func (m *LocalBreachMutation) RemovedIDs(name string) []ent.Value {
|
|
|
|
switch name {
|
|
|
|
case localbreach.EdgeTrackedBreaches:
|
|
|
|
ids := make([]ent.Value, 0, len(m.removedtracked_breaches))
|
|
|
|
for id := range m.removedtracked_breaches {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
|
func (m *LocalBreachMutation) ClearedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.clearedtracked_breaches {
|
|
|
|
edges = append(edges, localbreach.EdgeTrackedBreaches)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
|
|
|
func (m *LocalBreachMutation) EdgeCleared(name string) bool {
|
|
|
|
switch name {
|
|
|
|
case localbreach.EdgeTrackedBreaches:
|
|
|
|
return m.clearedtracked_breaches
|
|
|
|
}
|
|
|
|
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 *LocalBreachMutation) ClearEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown LocalBreach 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 *LocalBreachMutation) ResetEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case localbreach.EdgeTrackedBreaches:
|
|
|
|
m.ResetTrackedBreaches()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown LocalBreach edge %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SearchQueryMutation represents an operation that mutates the SearchQuery nodes in the graph.
|
|
|
|
type SearchQueryMutation struct {
|
|
|
|
config
|
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *uuid.UUID
|
|
|
|
query *string
|
|
|
|
created *time.Time
|
|
|
|
clearedFields map[string]struct{}
|
|
|
|
user *uuid.UUID
|
|
|
|
cleareduser bool
|
|
|
|
done bool
|
|
|
|
oldValue func(context.Context) (*SearchQuery, error)
|
|
|
|
predicates []predicate.SearchQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ ent.Mutation = (*SearchQueryMutation)(nil)
|
|
|
|
|
|
|
|
// searchqueryOption allows management of the mutation configuration using functional options.
|
|
|
|
type searchqueryOption func(*SearchQueryMutation)
|
|
|
|
|
|
|
|
// newSearchQueryMutation creates new mutation for the SearchQuery entity.
|
|
|
|
func newSearchQueryMutation(c config, op Op, opts ...searchqueryOption) *SearchQueryMutation {
|
|
|
|
m := &SearchQueryMutation{
|
|
|
|
config: c,
|
|
|
|
op: op,
|
|
|
|
typ: TypeSearchQuery,
|
|
|
|
clearedFields: make(map[string]struct{}),
|
|
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(m)
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// withSearchQueryID sets the ID field of the mutation.
|
|
|
|
func withSearchQueryID(id uuid.UUID) searchqueryOption {
|
|
|
|
return func(m *SearchQueryMutation) {
|
|
|
|
var (
|
|
|
|
err error
|
|
|
|
once sync.Once
|
|
|
|
value *SearchQuery
|
|
|
|
)
|
|
|
|
m.oldValue = func(ctx context.Context) (*SearchQuery, error) {
|
|
|
|
once.Do(func() {
|
|
|
|
if m.done {
|
|
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
|
|
} else {
|
|
|
|
value, err = m.Client().SearchQuery.Get(ctx, id)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return value, err
|
|
|
|
}
|
|
|
|
m.id = &id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// withSearchQuery sets the old SearchQuery of the mutation.
|
|
|
|
func withSearchQuery(node *SearchQuery) searchqueryOption {
|
|
|
|
return func(m *SearchQueryMutation) {
|
|
|
|
m.oldValue = func(context.Context) (*SearchQuery, 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 SearchQueryMutation) 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 SearchQueryMutation) 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 SearchQuery entities.
|
|
|
|
func (m *SearchQueryMutation) 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 *SearchQueryMutation) 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 *SearchQueryMutation) 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().SearchQuery.Query().Where(m.predicates...).IDs(ctx)
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetQuery sets the "query" field.
|
|
|
|
func (m *SearchQueryMutation) SetQuery(s string) {
|
|
|
|
m.query = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Query returns the value of the "query" field in the mutation.
|
|
|
|
func (m *SearchQueryMutation) Query() (r string, exists bool) {
|
|
|
|
v := m.query
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldQuery returns the old "query" field's value of the SearchQuery entity.
|
|
|
|
// If the SearchQuery 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 *SearchQueryMutation) OldQuery(ctx context.Context) (v string, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldQuery is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldQuery requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldQuery: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Query, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetQuery resets all changes to the "query" field.
|
|
|
|
func (m *SearchQueryMutation) ResetQuery() {
|
|
|
|
m.query = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCreated sets the "created" field.
|
|
|
|
func (m *SearchQueryMutation) SetCreated(t time.Time) {
|
|
|
|
m.created = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// Created returns the value of the "created" field in the mutation.
|
|
|
|
func (m *SearchQueryMutation) Created() (r time.Time, exists bool) {
|
|
|
|
v := m.created
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldCreated returns the old "created" field's value of the SearchQuery entity.
|
|
|
|
// If the SearchQuery 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 *SearchQueryMutation) OldCreated(ctx context.Context) (v time.Time, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldCreated is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldCreated requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldCreated: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Created, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetCreated resets all changes to the "created" field.
|
|
|
|
func (m *SearchQueryMutation) ResetCreated() {
|
|
|
|
m.created = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOwner sets the "owner" field.
|
|
|
|
func (m *SearchQueryMutation) SetOwner(u uuid.UUID) {
|
|
|
|
m.user = &u
|
|
|
|
}
|
|
|
|
|
|
|
|
// Owner returns the value of the "owner" field in the mutation.
|
|
|
|
func (m *SearchQueryMutation) Owner() (r uuid.UUID, exists bool) {
|
|
|
|
v := m.user
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldOwner returns the old "owner" field's value of the SearchQuery entity.
|
|
|
|
// If the SearchQuery 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 *SearchQueryMutation) OldOwner(ctx context.Context) (v uuid.UUID, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldOwner is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldOwner requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldOwner: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Owner, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetOwner resets all changes to the "owner" field.
|
|
|
|
func (m *SearchQueryMutation) ResetOwner() {
|
|
|
|
m.user = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUserID sets the "user" edge to the User entity by id.
|
|
|
|
func (m *SearchQueryMutation) SetUserID(id uuid.UUID) {
|
|
|
|
m.user = &id
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
|
|
func (m *SearchQueryMutation) ClearUser() {
|
|
|
|
m.cleareduser = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserCleared reports if the "user" edge to the User entity was cleared.
|
|
|
|
func (m *SearchQueryMutation) UserCleared() bool {
|
|
|
|
return m.cleareduser
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserID returns the "user" edge ID in the mutation.
|
|
|
|
func (m *SearchQueryMutation) UserID() (id uuid.UUID, exists bool) {
|
|
|
|
if m.user != nil {
|
|
|
|
return *m.user, true
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserIDs returns the "user" edge IDs in the mutation.
|
|
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
|
|
// UserID instead. It exists only for internal usage by the builders.
|
|
|
|
func (m *SearchQueryMutation) UserIDs() (ids []uuid.UUID) {
|
|
|
|
if id := m.user; id != nil {
|
|
|
|
ids = append(ids, *id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetUser resets all changes to the "user" edge.
|
|
|
|
func (m *SearchQueryMutation) ResetUser() {
|
|
|
|
m.user = nil
|
|
|
|
m.cleareduser = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the SearchQueryMutation builder.
|
|
|
|
func (m *SearchQueryMutation) Where(ps ...predicate.SearchQuery) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// WhereP appends storage-level predicates to the SearchQueryMutation builder. Using this method,
|
|
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
|
func (m *SearchQueryMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
|
p := make([]predicate.SearchQuery, len(ps))
|
|
|
|
for i := range ps {
|
|
|
|
p[i] = ps[i]
|
|
|
|
}
|
|
|
|
m.Where(p...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Op returns the operation name.
|
|
|
|
func (m *SearchQueryMutation) Op() Op {
|
|
|
|
return m.op
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
|
|
func (m *SearchQueryMutation) SetOp(op Op) {
|
|
|
|
m.op = op
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type returns the node type of this mutation (SearchQuery).
|
|
|
|
func (m *SearchQueryMutation) 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 *SearchQueryMutation) Fields() []string {
|
|
|
|
fields := make([]string, 0, 3)
|
|
|
|
if m.query != nil {
|
|
|
|
fields = append(fields, searchquery.FieldQuery)
|
|
|
|
}
|
|
|
|
if m.created != nil {
|
|
|
|
fields = append(fields, searchquery.FieldCreated)
|
|
|
|
}
|
|
|
|
if m.user != nil {
|
|
|
|
fields = append(fields, searchquery.FieldOwner)
|
|
|
|
}
|
|
|
|
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 *SearchQueryMutation) Field(name string) (ent.Value, bool) {
|
|
|
|
switch name {
|
|
|
|
case searchquery.FieldQuery:
|
|
|
|
return m.Query()
|
|
|
|
case searchquery.FieldCreated:
|
|
|
|
return m.Created()
|
|
|
|
case searchquery.FieldOwner:
|
|
|
|
return m.Owner()
|
|
|
|
}
|
|
|
|
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 *SearchQueryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
|
switch name {
|
|
|
|
case searchquery.FieldQuery:
|
|
|
|
return m.OldQuery(ctx)
|
|
|
|
case searchquery.FieldCreated:
|
|
|
|
return m.OldCreated(ctx)
|
|
|
|
case searchquery.FieldOwner:
|
|
|
|
return m.OldOwner(ctx)
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown SearchQuery 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 *SearchQueryMutation) SetField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
case searchquery.FieldQuery:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetQuery(v)
|
|
|
|
return nil
|
|
|
|
case searchquery.FieldCreated:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetCreated(v)
|
|
|
|
return nil
|
|
|
|
case searchquery.FieldOwner:
|
|
|
|
v, ok := value.(uuid.UUID)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetOwner(v)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown SearchQuery field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
|
|
|
func (m *SearchQueryMutation) 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 *SearchQueryMutation) 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 *SearchQueryMutation) AddField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown SearchQuery numeric field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
|
|
|
func (m *SearchQueryMutation) ClearedFields() []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
|
|
|
func (m *SearchQueryMutation) 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 *SearchQueryMutation) ClearField(name string) error {
|
|
|
|
return fmt.Errorf("unknown SearchQuery 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 *SearchQueryMutation) ResetField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case searchquery.FieldQuery:
|
|
|
|
m.ResetQuery()
|
|
|
|
return nil
|
|
|
|
case searchquery.FieldCreated:
|
|
|
|
m.ResetCreated()
|
|
|
|
return nil
|
|
|
|
case searchquery.FieldOwner:
|
|
|
|
m.ResetOwner()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown SearchQuery field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
|
func (m *SearchQueryMutation) AddedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.user != nil {
|
|
|
|
edges = append(edges, searchquery.EdgeUser)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
|
|
|
func (m *SearchQueryMutation) AddedIDs(name string) []ent.Value {
|
|
|
|
switch name {
|
|
|
|
case searchquery.EdgeUser:
|
|
|
|
if id := m.user; id != nil {
|
|
|
|
return []ent.Value{*id}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
|
func (m *SearchQueryMutation) 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 *SearchQueryMutation) RemovedIDs(name string) []ent.Value {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
|
func (m *SearchQueryMutation) ClearedEdges() []string {
|
|
|
|
edges := make([]string, 0, 1)
|
|
|
|
if m.cleareduser {
|
|
|
|
edges = append(edges, searchquery.EdgeUser)
|
|
|
|
}
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
|
|
|
func (m *SearchQueryMutation) EdgeCleared(name string) bool {
|
|
|
|
switch name {
|
|
|
|
case searchquery.EdgeUser:
|
|
|
|
return m.cleareduser
|
|
|
|
}
|
|
|
|
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 *SearchQueryMutation) ClearEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case searchquery.EdgeUser:
|
|
|
|
m.ClearUser()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown SearchQuery 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 *SearchQueryMutation) ResetEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case searchquery.EdgeUser:
|
|
|
|
m.ResetUser()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown SearchQuery edge %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SettingsMutation represents an operation that mutates the Settings nodes in the graph.
|
|
|
|
type SettingsMutation struct {
|
|
|
|
config
|
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *uuid.UUID
|
|
|
|
hibp_api_key *string
|
|
|
|
dehashed_api_key *string
|
|
|
|
searches *uint64
|
|
|
|
addsearches *int64
|
|
|
|
clearedFields map[string]struct{}
|
|
|
|
done bool
|
|
|
|
oldValue func(context.Context) (*Settings, error)
|
|
|
|
predicates []predicate.Settings
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ ent.Mutation = (*SettingsMutation)(nil)
|
|
|
|
|
|
|
|
// settingsOption allows management of the mutation configuration using functional options.
|
|
|
|
type settingsOption func(*SettingsMutation)
|
|
|
|
|
|
|
|
// newSettingsMutation creates new mutation for the Settings entity.
|
|
|
|
func newSettingsMutation(c config, op Op, opts ...settingsOption) *SettingsMutation {
|
|
|
|
m := &SettingsMutation{
|
|
|
|
config: c,
|
|
|
|
op: op,
|
|
|
|
typ: TypeSettings,
|
|
|
|
clearedFields: make(map[string]struct{}),
|
|
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(m)
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// withSettingsID sets the ID field of the mutation.
|
|
|
|
func withSettingsID(id uuid.UUID) settingsOption {
|
|
|
|
return func(m *SettingsMutation) {
|
|
|
|
var (
|
|
|
|
err error
|
|
|
|
once sync.Once
|
|
|
|
value *Settings
|
|
|
|
)
|
|
|
|
m.oldValue = func(ctx context.Context) (*Settings, error) {
|
|
|
|
once.Do(func() {
|
|
|
|
if m.done {
|
|
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
|
|
} else {
|
|
|
|
value, err = m.Client().Settings.Get(ctx, id)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return value, err
|
|
|
|
}
|
|
|
|
m.id = &id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// withSettings sets the old Settings of the mutation.
|
|
|
|
func withSettings(node *Settings) settingsOption {
|
|
|
|
return func(m *SettingsMutation) {
|
|
|
|
m.oldValue = func(context.Context) (*Settings, error) {
|
|
|
|
return node, nil
|
|
|
|
}
|
|
|
|
m.id = &node.ID
|
|
|
|
}
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// 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 SettingsMutation) 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 SettingsMutation) 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 Settings entities.
|
|
|
|
func (m *SettingsMutation) 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 *SettingsMutation) 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 *SettingsMutation) 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().Settings.Query().Where(m.predicates...).IDs(ctx)
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetHibpAPIKey sets the "hibp_api_key" field.
|
|
|
|
func (m *SettingsMutation) SetHibpAPIKey(s string) {
|
|
|
|
m.hibp_api_key = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// HibpAPIKey returns the value of the "hibp_api_key" field in the mutation.
|
|
|
|
func (m *SettingsMutation) HibpAPIKey() (r string, exists bool) {
|
|
|
|
v := m.hibp_api_key
|
2023-04-21 13:57:32 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// OldHibpAPIKey returns the old "hibp_api_key" field's value of the Settings entity.
|
|
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
2023-04-21 13:57:32 +02:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SettingsMutation) OldHibpAPIKey(ctx context.Context) (v string, err error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldHibpAPIKey is only allowed on UpdateOne operations")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldHibpAPIKey requires an ID field in the mutation")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldHibpAPIKey: %w", err)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return oldValue.HibpAPIKey, nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ClearHibpAPIKey clears the value of the "hibp_api_key" field.
|
|
|
|
func (m *SettingsMutation) ClearHibpAPIKey() {
|
|
|
|
m.hibp_api_key = nil
|
|
|
|
m.clearedFields[settings.FieldHibpAPIKey] = struct{}{}
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// HibpAPIKeyCleared returns if the "hibp_api_key" field was cleared in this mutation.
|
|
|
|
func (m *SettingsMutation) HibpAPIKeyCleared() bool {
|
|
|
|
_, ok := m.clearedFields[settings.FieldHibpAPIKey]
|
|
|
|
return ok
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetHibpAPIKey resets all changes to the "hibp_api_key" field.
|
|
|
|
func (m *SettingsMutation) ResetHibpAPIKey() {
|
|
|
|
m.hibp_api_key = nil
|
|
|
|
delete(m.clearedFields, settings.FieldHibpAPIKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDehashedAPIKey sets the "dehashed_api_key" field.
|
|
|
|
func (m *SettingsMutation) SetDehashedAPIKey(s string) {
|
|
|
|
m.dehashed_api_key = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// DehashedAPIKey returns the value of the "dehashed_api_key" field in the mutation.
|
|
|
|
func (m *SettingsMutation) DehashedAPIKey() (r string, exists bool) {
|
|
|
|
v := m.dehashed_api_key
|
2023-04-21 13:57:32 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// OldDehashedAPIKey returns the old "dehashed_api_key" field's value of the Settings entity.
|
|
|
|
// If the Settings object wasn't provided to the builder, the object is fetched from the database.
|
2023-04-21 13:57:32 +02:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SettingsMutation) OldDehashedAPIKey(ctx context.Context) (v string, err error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldDehashedAPIKey is only allowed on UpdateOne operations")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldDehashedAPIKey requires an ID field in the mutation")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldDehashedAPIKey: %w", err)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return oldValue.DehashedAPIKey, nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ClearDehashedAPIKey clears the value of the "dehashed_api_key" field.
|
|
|
|
func (m *SettingsMutation) ClearDehashedAPIKey() {
|
|
|
|
m.dehashed_api_key = nil
|
|
|
|
m.clearedFields[settings.FieldDehashedAPIKey] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// DehashedAPIKeyCleared returns if the "dehashed_api_key" field was cleared in this mutation.
|
|
|
|
func (m *SettingsMutation) DehashedAPIKeyCleared() bool {
|
|
|
|
_, ok := m.clearedFields[settings.FieldDehashedAPIKey]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetDehashedAPIKey resets all changes to the "dehashed_api_key" field.
|
|
|
|
func (m *SettingsMutation) ResetDehashedAPIKey() {
|
|
|
|
m.dehashed_api_key = nil
|
|
|
|
delete(m.clearedFields, settings.FieldDehashedAPIKey)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetSearches sets the "searches" field.
|
|
|
|
func (m *SettingsMutation) SetSearches(u uint64) {
|
|
|
|
m.searches = &u
|
|
|
|
m.addsearches = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Searches returns the value of the "searches" field in the mutation.
|
|
|
|
func (m *SettingsMutation) Searches() (r uint64, exists bool) {
|
|
|
|
v := m.searches
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldSearches returns the old "searches" field's value of the Settings entity.
|
|
|
|
// If the Settings 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 *SettingsMutation) OldSearches(ctx context.Context) (v uint64, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldSearches is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldSearches requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldSearches: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Searches, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddSearches adds u to the "searches" field.
|
|
|
|
func (m *SettingsMutation) AddSearches(u int64) {
|
|
|
|
if m.addsearches != nil {
|
|
|
|
*m.addsearches += u
|
|
|
|
} else {
|
|
|
|
m.addsearches = &u
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedSearches returns the value that was added to the "searches" field in this mutation.
|
|
|
|
func (m *SettingsMutation) AddedSearches() (r int64, exists bool) {
|
|
|
|
v := m.addsearches
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetSearches resets all changes to the "searches" field.
|
|
|
|
func (m *SettingsMutation) ResetSearches() {
|
|
|
|
m.searches = nil
|
|
|
|
m.addsearches = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the SettingsMutation builder.
|
|
|
|
func (m *SettingsMutation) Where(ps ...predicate.Settings) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// WhereP appends storage-level predicates to the SettingsMutation builder. Using this method,
|
|
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
|
func (m *SettingsMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
|
p := make([]predicate.Settings, len(ps))
|
|
|
|
for i := range ps {
|
|
|
|
p[i] = ps[i]
|
|
|
|
}
|
|
|
|
m.Where(p...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Op returns the operation name.
|
|
|
|
func (m *SettingsMutation) Op() Op {
|
|
|
|
return m.op
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
|
|
func (m *SettingsMutation) SetOp(op Op) {
|
|
|
|
m.op = op
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type returns the node type of this mutation (Settings).
|
|
|
|
func (m *SettingsMutation) 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 *SettingsMutation) Fields() []string {
|
|
|
|
fields := make([]string, 0, 3)
|
|
|
|
if m.hibp_api_key != nil {
|
|
|
|
fields = append(fields, settings.FieldHibpAPIKey)
|
|
|
|
}
|
|
|
|
if m.dehashed_api_key != nil {
|
|
|
|
fields = append(fields, settings.FieldDehashedAPIKey)
|
|
|
|
}
|
|
|
|
if m.searches != nil {
|
|
|
|
fields = append(fields, settings.FieldSearches)
|
|
|
|
}
|
|
|
|
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 *SettingsMutation) Field(name string) (ent.Value, bool) {
|
|
|
|
switch name {
|
|
|
|
case settings.FieldHibpAPIKey:
|
|
|
|
return m.HibpAPIKey()
|
|
|
|
case settings.FieldDehashedAPIKey:
|
|
|
|
return m.DehashedAPIKey()
|
|
|
|
case settings.FieldSearches:
|
|
|
|
return m.Searches()
|
|
|
|
}
|
|
|
|
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 *SettingsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
|
switch name {
|
|
|
|
case settings.FieldHibpAPIKey:
|
|
|
|
return m.OldHibpAPIKey(ctx)
|
|
|
|
case settings.FieldDehashedAPIKey:
|
|
|
|
return m.OldDehashedAPIKey(ctx)
|
|
|
|
case settings.FieldSearches:
|
|
|
|
return m.OldSearches(ctx)
|
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown Settings 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 *SettingsMutation) SetField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
case settings.FieldHibpAPIKey:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetHibpAPIKey(v)
|
|
|
|
return nil
|
|
|
|
case settings.FieldDehashedAPIKey:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetDehashedAPIKey(v)
|
|
|
|
return nil
|
|
|
|
case settings.FieldSearches:
|
|
|
|
v, ok := value.(uint64)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetSearches(v)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown Settings field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
|
|
|
func (m *SettingsMutation) AddedFields() []string {
|
|
|
|
var fields []string
|
|
|
|
if m.addsearches != nil {
|
|
|
|
fields = append(fields, settings.FieldSearches)
|
|
|
|
}
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedField returns the numeric value that was incremented/decremented on a field
|
|
|
|
// with the given name. The second boolean return value indicates that this field
|
|
|
|
// was not set, or was not defined in the schema.
|
|
|
|
func (m *SettingsMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
|
switch name {
|
|
|
|
case settings.FieldSearches:
|
|
|
|
return m.AddedSearches()
|
|
|
|
}
|
|
|
|
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 *SettingsMutation) AddField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
case settings.FieldSearches:
|
|
|
|
v, ok := value.(int64)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.AddSearches(v)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown Settings numeric field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
|
|
|
func (m *SettingsMutation) ClearedFields() []string {
|
|
|
|
var fields []string
|
|
|
|
if m.FieldCleared(settings.FieldHibpAPIKey) {
|
|
|
|
fields = append(fields, settings.FieldHibpAPIKey)
|
|
|
|
}
|
|
|
|
if m.FieldCleared(settings.FieldDehashedAPIKey) {
|
|
|
|
fields = append(fields, settings.FieldDehashedAPIKey)
|
|
|
|
}
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
|
|
|
func (m *SettingsMutation) 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 *SettingsMutation) ClearField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case settings.FieldHibpAPIKey:
|
|
|
|
m.ClearHibpAPIKey()
|
|
|
|
return nil
|
|
|
|
case settings.FieldDehashedAPIKey:
|
|
|
|
m.ClearDehashedAPIKey()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown Settings 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 *SettingsMutation) ResetField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case settings.FieldHibpAPIKey:
|
|
|
|
m.ResetHibpAPIKey()
|
|
|
|
return nil
|
|
|
|
case settings.FieldDehashedAPIKey:
|
|
|
|
m.ResetDehashedAPIKey()
|
|
|
|
return nil
|
|
|
|
case settings.FieldSearches:
|
|
|
|
m.ResetSearches()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown Settings field %s", name)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
|
func (m *SettingsMutation) AddedEdges() []string {
|
|
|
|
edges := make([]string, 0, 0)
|
|
|
|
return edges
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
|
|
|
func (m *SettingsMutation) AddedIDs(name string) []ent.Value {
|
|
|
|
return nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
|
func (m *SettingsMutation) RemovedEdges() []string {
|
|
|
|
edges := make([]string, 0, 0)
|
|
|
|
return edges
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
|
// the given name in this mutation.
|
|
|
|
func (m *SettingsMutation) RemovedIDs(name string) []ent.Value {
|
|
|
|
return nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
|
func (m *SettingsMutation) ClearedEdges() []string {
|
|
|
|
edges := make([]string, 0, 0)
|
|
|
|
return edges
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
|
|
|
func (m *SettingsMutation) EdgeCleared(name string) bool {
|
|
|
|
return false
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02: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 *SettingsMutation) ClearEdge(name string) error {
|
|
|
|
return fmt.Errorf("unknown Settings unique edge %s", name)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02: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 *SettingsMutation) ResetEdge(name string) error {
|
|
|
|
return fmt.Errorf("unknown Settings edge %s", name)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetupMutation represents an operation that mutates the Setup nodes in the graph.
|
|
|
|
type SetupMutation struct {
|
|
|
|
config
|
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *uuid.UUID
|
|
|
|
set_up_at *time.Time
|
|
|
|
clearedFields map[string]struct{}
|
|
|
|
done bool
|
|
|
|
oldValue func(context.Context) (*Setup, error)
|
|
|
|
predicates []predicate.Setup
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
var _ ent.Mutation = (*SetupMutation)(nil)
|
2023-04-21 13:57:32 +02:00
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// setupOption allows management of the mutation configuration using functional options.
|
|
|
|
type setupOption func(*SetupMutation)
|
|
|
|
|
|
|
|
// newSetupMutation creates new mutation for the Setup entity.
|
|
|
|
func newSetupMutation(c config, op Op, opts ...setupOption) *SetupMutation {
|
|
|
|
m := &SetupMutation{
|
|
|
|
config: c,
|
|
|
|
op: op,
|
|
|
|
typ: TypeSetup,
|
|
|
|
clearedFields: make(map[string]struct{}),
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
for _, opt := range opts {
|
|
|
|
opt(m)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
// withSetupID sets the ID field of the mutation.
|
|
|
|
func withSetupID(id uuid.UUID) setupOption {
|
|
|
|
return func(m *SetupMutation) {
|
|
|
|
var (
|
|
|
|
err error
|
|
|
|
once sync.Once
|
|
|
|
value *Setup
|
|
|
|
)
|
|
|
|
m.oldValue = func(ctx context.Context) (*Setup, error) {
|
|
|
|
once.Do(func() {
|
|
|
|
if m.done {
|
|
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
|
|
} else {
|
|
|
|
value, err = m.Client().Setup.Get(ctx, id)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return value, err
|
|
|
|
}
|
|
|
|
m.id = &id
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// withSetup sets the old Setup of the mutation.
|
|
|
|
func withSetup(node *Setup) setupOption {
|
|
|
|
return func(m *SetupMutation) {
|
|
|
|
m.oldValue = func(context.Context) (*Setup, error) {
|
|
|
|
return node, nil
|
|
|
|
}
|
|
|
|
m.id = &node.ID
|
|
|
|
}
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// 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 SetupMutation) Client() *Client {
|
|
|
|
client := &Client{config: m.config}
|
|
|
|
client.init()
|
|
|
|
return client
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
|
|
// it returns an error otherwise.
|
|
|
|
func (m SetupMutation) Tx() (*Tx, error) {
|
|
|
|
if _, ok := m.driver.(*txDriver); !ok {
|
|
|
|
return nil, errors.New("ent: mutation is not running in a transaction")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
tx := &Tx{config: m.config}
|
|
|
|
tx.init()
|
|
|
|
return tx, nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetID sets the value of the id field. Note that this
|
|
|
|
// operation is only accepted on creation of Setup entities.
|
|
|
|
func (m *SetupMutation) 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 *SetupMutation) ID() (id uuid.UUID, exists bool) {
|
|
|
|
if m.id == nil {
|
|
|
|
return
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return *m.id, true
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02: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 *SetupMutation) 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().Setup.Query().Where(m.predicates...).IDs(ctx)
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetSetUpAt sets the "set_up_at" field.
|
|
|
|
func (m *SetupMutation) SetSetUpAt(t time.Time) {
|
|
|
|
m.set_up_at = &t
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetUpAt returns the value of the "set_up_at" field in the mutation.
|
|
|
|
func (m *SetupMutation) SetUpAt() (r time.Time, exists bool) {
|
|
|
|
v := m.set_up_at
|
2023-04-21 13:57:32 +02:00
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// OldSetUpAt returns the old "set_up_at" field's value of the Setup entity.
|
|
|
|
// If the Setup object wasn't provided to the builder, the object is fetched from the database.
|
2023-04-21 13:57:32 +02:00
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) OldSetUpAt(ctx context.Context) (v time.Time, err error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
if !m.op.Is(OpUpdateOne) {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldSetUpAt is only allowed on UpdateOne operations")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, errors.New("OldSetUpAt requires an ID field in the mutation")
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
2023-08-19 04:52:15 +02:00
|
|
|
return v, fmt.Errorf("querying old value for OldSetUpAt: %w", err)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return oldValue.SetUpAt, nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetSetUpAt resets all changes to the "set_up_at" field.
|
|
|
|
func (m *SetupMutation) ResetSetUpAt() {
|
|
|
|
m.set_up_at = nil
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Where appends a list predicates to the SetupMutation builder.
|
|
|
|
func (m *SetupMutation) Where(ps ...predicate.Setup) {
|
2023-04-21 13:57:32 +02:00
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// WhereP appends storage-level predicates to the SetupMutation builder. Using this method,
|
2023-04-21 13:57:32 +02:00
|
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
|
p := make([]predicate.Setup, len(ps))
|
2023-04-21 13:57:32 +02:00
|
|
|
for i := range ps {
|
|
|
|
p[i] = ps[i]
|
|
|
|
}
|
|
|
|
m.Where(p...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Op returns the operation name.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) Op() Op {
|
2023-04-21 13:57:32 +02:00
|
|
|
return m.op
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOp allows setting the mutation operation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) SetOp(op Op) {
|
2023-04-21 13:57:32 +02:00
|
|
|
m.op = op
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Type returns the node type of this mutation (Setup).
|
|
|
|
func (m *SetupMutation) Type() string {
|
2023-04-21 13:57:32 +02: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().
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) Fields() []string {
|
|
|
|
fields := make([]string, 0, 1)
|
|
|
|
if m.set_up_at != nil {
|
|
|
|
fields = append(fields, setup.FieldSetUpAt)
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) Field(name string) (ent.Value, bool) {
|
2023-04-21 13:57:32 +02:00
|
|
|
switch name {
|
2023-08-19 04:52:15 +02:00
|
|
|
case setup.FieldSetUpAt:
|
|
|
|
return m.SetUpAt()
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
2023-04-21 13:57:32 +02:00
|
|
|
switch name {
|
2023-08-19 04:52:15 +02:00
|
|
|
case setup.FieldSetUpAt:
|
|
|
|
return m.OldSetUpAt(ctx)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return nil, fmt.Errorf("unknown Setup field %s", name)
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) SetField(name string, value ent.Value) error {
|
2023-04-21 13:57:32 +02:00
|
|
|
switch name {
|
2023-08-19 04:52:15 +02:00
|
|
|
case setup.FieldSetUpAt:
|
2023-04-21 13:57:32 +02:00
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
m.SetSetUpAt(v)
|
2023-04-21 13:57:32 +02:00
|
|
|
return nil
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return fmt.Errorf("unknown Setup field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
|
|
|
func (m *SetupMutation) AddedFields() []string {
|
|
|
|
return nil
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) AddedField(name string) (ent.Value, bool) {
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) AddField(name string, value ent.Value) error {
|
2023-04-21 13:57:32 +02:00
|
|
|
switch name {
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return fmt.Errorf("unknown Setup numeric field %s", name)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) ClearedFields() []string {
|
2023-04-21 13:57:32 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) FieldCleared(name string) bool {
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) ClearField(name string) error {
|
|
|
|
return fmt.Errorf("unknown Setup nullable field %s", name)
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) ResetField(name string) error {
|
2023-04-21 13:57:32 +02:00
|
|
|
switch name {
|
2023-08-19 04:52:15 +02:00
|
|
|
case setup.FieldSetUpAt:
|
|
|
|
m.ResetSetUpAt()
|
2023-04-21 13:57:32 +02:00
|
|
|
return nil
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return fmt.Errorf("unknown Setup field %s", name)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) AddedEdges() []string {
|
2023-04-21 13:57:32 +02:00
|
|
|
edges := make([]string, 0, 0)
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) AddedIDs(name string) []ent.Value {
|
2023-04-21 13:57:32 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) RemovedEdges() []string {
|
2023-04-21 13:57:32 +02:00
|
|
|
edges := make([]string, 0, 0)
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
|
// the given name in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) RemovedIDs(name string) []ent.Value {
|
2023-04-21 13:57:32 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) ClearedEdges() []string {
|
2023-04-21 13:57:32 +02:00
|
|
|
edges := make([]string, 0, 0)
|
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) EdgeCleared(name string) bool {
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) ClearEdge(name string) error {
|
|
|
|
return fmt.Errorf("unknown Setup unique edge %s", name)
|
2023-04-21 13:57:32 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *SetupMutation) ResetEdge(name string) error {
|
|
|
|
return fmt.Errorf("unknown Setup edge %s", name)
|
2023-04-21 13:57:32 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// TrackedBreachesMutation represents an operation that mutates the TrackedBreaches nodes in the graph.
|
|
|
|
type TrackedBreachesMutation struct {
|
2023-05-05 22:52:59 +02:00
|
|
|
config
|
2023-08-19 04:52:15 +02:00
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *uuid.UUID
|
|
|
|
breach *uuid.UUID
|
|
|
|
online *bool
|
|
|
|
clearedFields map[string]struct{}
|
|
|
|
user *uuid.UUID
|
|
|
|
cleareduser bool
|
|
|
|
localbreach map[uuid.UUID]struct{}
|
|
|
|
removedlocalbreach map[uuid.UUID]struct{}
|
|
|
|
clearedlocalbreach bool
|
|
|
|
hibp map[uuid.UUID]struct{}
|
|
|
|
removedhibp map[uuid.UUID]struct{}
|
|
|
|
clearedhibp bool
|
|
|
|
done bool
|
|
|
|
oldValue func(context.Context) (*TrackedBreaches, error)
|
|
|
|
predicates []predicate.TrackedBreaches
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ ent.Mutation = (*TrackedBreachesMutation)(nil)
|
|
|
|
|
|
|
|
// trackedbreachesOption allows management of the mutation configuration using functional options.
|
|
|
|
type trackedbreachesOption func(*TrackedBreachesMutation)
|
|
|
|
|
|
|
|
// newTrackedBreachesMutation creates new mutation for the TrackedBreaches entity.
|
|
|
|
func newTrackedBreachesMutation(c config, op Op, opts ...trackedbreachesOption) *TrackedBreachesMutation {
|
|
|
|
m := &TrackedBreachesMutation{
|
2023-05-05 22:52:59 +02:00
|
|
|
config: c,
|
|
|
|
op: op,
|
2023-08-19 04:52:15 +02:00
|
|
|
typ: TypeTrackedBreaches,
|
2023-05-05 22:52:59 +02:00
|
|
|
clearedFields: make(map[string]struct{}),
|
|
|
|
}
|
|
|
|
for _, opt := range opts {
|
|
|
|
opt(m)
|
|
|
|
}
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// withTrackedBreachesID sets the ID field of the mutation.
|
|
|
|
func withTrackedBreachesID(id uuid.UUID) trackedbreachesOption {
|
|
|
|
return func(m *TrackedBreachesMutation) {
|
2023-05-05 22:52:59 +02:00
|
|
|
var (
|
|
|
|
err error
|
|
|
|
once sync.Once
|
2023-08-19 04:52:15 +02:00
|
|
|
value *TrackedBreaches
|
2023-05-05 22:52:59 +02:00
|
|
|
)
|
2023-08-19 04:52:15 +02:00
|
|
|
m.oldValue = func(ctx context.Context) (*TrackedBreaches, error) {
|
2023-05-05 22:52:59 +02:00
|
|
|
once.Do(func() {
|
|
|
|
if m.done {
|
|
|
|
err = errors.New("querying old values post mutation is not allowed")
|
|
|
|
} else {
|
2023-08-19 04:52:15 +02:00
|
|
|
value, err = m.Client().TrackedBreaches.Get(ctx, id)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
return value, err
|
|
|
|
}
|
|
|
|
m.id = &id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// withTrackedBreaches sets the old TrackedBreaches of the mutation.
|
|
|
|
func withTrackedBreaches(node *TrackedBreaches) trackedbreachesOption {
|
|
|
|
return func(m *TrackedBreachesMutation) {
|
|
|
|
m.oldValue = func(context.Context) (*TrackedBreaches, error) {
|
2023-05-05 22:52:59 +02:00
|
|
|
return node, nil
|
|
|
|
}
|
|
|
|
m.id = &node.ID
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// 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 TrackedBreachesMutation) 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 TrackedBreachesMutation) 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 TrackedBreaches entities.
|
|
|
|
func (m *TrackedBreachesMutation) 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 *TrackedBreachesMutation) 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 *TrackedBreachesMutation) 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().TrackedBreaches.Query().Where(m.predicates...).IDs(ctx)
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetBreach sets the "breach" field.
|
|
|
|
func (m *TrackedBreachesMutation) SetBreach(u uuid.UUID) {
|
|
|
|
m.breach = &u
|
|
|
|
}
|
|
|
|
|
|
|
|
// Breach returns the value of the "breach" field in the mutation.
|
|
|
|
func (m *TrackedBreachesMutation) Breach() (r uuid.UUID, exists bool) {
|
|
|
|
v := m.breach
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldBreach returns the old "breach" field's value of the TrackedBreaches entity.
|
|
|
|
// If the TrackedBreaches 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 *TrackedBreachesMutation) OldBreach(ctx context.Context) (v uuid.UUID, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldBreach is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldBreach requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldBreach: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Breach, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetBreach resets all changes to the "breach" field.
|
|
|
|
func (m *TrackedBreachesMutation) ResetBreach() {
|
|
|
|
m.breach = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOnline sets the "online" field.
|
|
|
|
func (m *TrackedBreachesMutation) SetOnline(b bool) {
|
|
|
|
m.online = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// Online returns the value of the "online" field in the mutation.
|
|
|
|
func (m *TrackedBreachesMutation) Online() (r bool, exists bool) {
|
|
|
|
v := m.online
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldOnline returns the old "online" field's value of the TrackedBreaches entity.
|
|
|
|
// If the TrackedBreaches 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 *TrackedBreachesMutation) OldOnline(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldOnline is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldOnline requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldOnline: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Online, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetOnline resets all changes to the "online" field.
|
|
|
|
func (m *TrackedBreachesMutation) ResetOnline() {
|
|
|
|
m.online = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOwner sets the "owner" field.
|
|
|
|
func (m *TrackedBreachesMutation) SetOwner(u uuid.UUID) {
|
|
|
|
m.user = &u
|
|
|
|
}
|
|
|
|
|
|
|
|
// Owner returns the value of the "owner" field in the mutation.
|
|
|
|
func (m *TrackedBreachesMutation) Owner() (r uuid.UUID, exists bool) {
|
|
|
|
v := m.user
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldOwner returns the old "owner" field's value of the TrackedBreaches entity.
|
|
|
|
// If the TrackedBreaches 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 *TrackedBreachesMutation) OldOwner(ctx context.Context) (v uuid.UUID, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldOwner is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldOwner requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldOwner: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Owner, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetOwner resets all changes to the "owner" field.
|
|
|
|
func (m *TrackedBreachesMutation) ResetOwner() {
|
|
|
|
m.user = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUserID sets the "user" edge to the User entity by id.
|
|
|
|
func (m *TrackedBreachesMutation) SetUserID(id uuid.UUID) {
|
|
|
|
m.user = &id
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
|
|
func (m *TrackedBreachesMutation) ClearUser() {
|
|
|
|
m.cleareduser = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserCleared reports if the "user" edge to the User entity was cleared.
|
|
|
|
func (m *TrackedBreachesMutation) UserCleared() bool {
|
|
|
|
return m.cleareduser
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserID returns the "user" edge ID in the mutation.
|
|
|
|
func (m *TrackedBreachesMutation) UserID() (id uuid.UUID, exists bool) {
|
|
|
|
if m.user != nil {
|
|
|
|
return *m.user, true
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// UserIDs returns the "user" edge IDs in the mutation.
|
|
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
|
|
// UserID instead. It exists only for internal usage by the builders.
|
|
|
|
func (m *TrackedBreachesMutation) UserIDs() (ids []uuid.UUID) {
|
|
|
|
if id := m.user; id != nil {
|
|
|
|
ids = append(ids, *id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetUser resets all changes to the "user" edge.
|
|
|
|
func (m *TrackedBreachesMutation) ResetUser() {
|
|
|
|
m.user = nil
|
|
|
|
m.cleareduser = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddLocalbreachIDs adds the "localbreach" edge to the LocalBreach entity by ids.
|
|
|
|
func (m *TrackedBreachesMutation) AddLocalbreachIDs(ids ...uuid.UUID) {
|
|
|
|
if m.localbreach == nil {
|
|
|
|
m.localbreach = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
m.localbreach[ids[i]] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearLocalbreach clears the "localbreach" edge to the LocalBreach entity.
|
|
|
|
func (m *TrackedBreachesMutation) ClearLocalbreach() {
|
|
|
|
m.clearedlocalbreach = true
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// LocalbreachCleared reports if the "localbreach" edge to the LocalBreach entity was cleared.
|
|
|
|
func (m *TrackedBreachesMutation) LocalbreachCleared() bool {
|
|
|
|
return m.clearedlocalbreach
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// RemoveLocalbreachIDs removes the "localbreach" edge to the LocalBreach entity by IDs.
|
|
|
|
func (m *TrackedBreachesMutation) RemoveLocalbreachIDs(ids ...uuid.UUID) {
|
|
|
|
if m.removedlocalbreach == nil {
|
|
|
|
m.removedlocalbreach = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
delete(m.localbreach, ids[i])
|
|
|
|
m.removedlocalbreach[ids[i]] = struct{}{}
|
|
|
|
}
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// RemovedLocalbreach returns the removed IDs of the "localbreach" edge to the LocalBreach entity.
|
|
|
|
func (m *TrackedBreachesMutation) RemovedLocalbreachIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.removedlocalbreach {
|
|
|
|
ids = append(ids, id)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// LocalbreachIDs returns the "localbreach" edge IDs in the mutation.
|
|
|
|
func (m *TrackedBreachesMutation) LocalbreachIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.localbreach {
|
|
|
|
ids = append(ids, id)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetLocalbreach resets all changes to the "localbreach" edge.
|
|
|
|
func (m *TrackedBreachesMutation) ResetLocalbreach() {
|
|
|
|
m.localbreach = nil
|
|
|
|
m.clearedlocalbreach = false
|
|
|
|
m.removedlocalbreach = nil
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// AddHibpIDs adds the "hibp" edge to the HIBP entity by ids.
|
|
|
|
func (m *TrackedBreachesMutation) AddHibpIDs(ids ...uuid.UUID) {
|
|
|
|
if m.hibp == nil {
|
|
|
|
m.hibp = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
m.hibp[ids[i]] = struct{}{}
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ClearHibp clears the "hibp" edge to the HIBP entity.
|
|
|
|
func (m *TrackedBreachesMutation) ClearHibp() {
|
|
|
|
m.clearedhibp = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// HibpCleared reports if the "hibp" edge to the HIBP entity was cleared.
|
|
|
|
func (m *TrackedBreachesMutation) HibpCleared() bool {
|
|
|
|
return m.clearedhibp
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveHibpIDs removes the "hibp" edge to the HIBP entity by IDs.
|
|
|
|
func (m *TrackedBreachesMutation) RemoveHibpIDs(ids ...uuid.UUID) {
|
|
|
|
if m.removedhibp == nil {
|
|
|
|
m.removedhibp = make(map[uuid.UUID]struct{})
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
for i := range ids {
|
|
|
|
delete(m.hibp, ids[i])
|
|
|
|
m.removedhibp[ids[i]] = struct{}{}
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedHibp returns the removed IDs of the "hibp" edge to the HIBP entity.
|
|
|
|
func (m *TrackedBreachesMutation) RemovedHibpIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.removedhibp {
|
|
|
|
ids = append(ids, id)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// HibpIDs returns the "hibp" edge IDs in the mutation.
|
|
|
|
func (m *TrackedBreachesMutation) HibpIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.hibp {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// ResetHibp resets all changes to the "hibp" edge.
|
|
|
|
func (m *TrackedBreachesMutation) ResetHibp() {
|
|
|
|
m.hibp = nil
|
|
|
|
m.clearedhibp = false
|
|
|
|
m.removedhibp = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the TrackedBreachesMutation builder.
|
|
|
|
func (m *TrackedBreachesMutation) Where(ps ...predicate.TrackedBreaches) {
|
2023-05-05 22:52:59 +02:00
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// WhereP appends storage-level predicates to the TrackedBreachesMutation builder. Using this method,
|
2023-05-05 22:52:59 +02:00
|
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
|
p := make([]predicate.TrackedBreaches, len(ps))
|
2023-05-05 22:52:59 +02:00
|
|
|
for i := range ps {
|
|
|
|
p[i] = ps[i]
|
|
|
|
}
|
|
|
|
m.Where(p...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Op returns the operation name.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) Op() Op {
|
2023-05-05 22:52:59 +02:00
|
|
|
return m.op
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOp allows setting the mutation operation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) SetOp(op Op) {
|
2023-05-05 22:52:59 +02:00
|
|
|
m.op = op
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// Type returns the node type of this mutation (TrackedBreaches).
|
|
|
|
func (m *TrackedBreachesMutation) Type() string {
|
2023-05-05 22:52:59 +02: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().
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) Fields() []string {
|
|
|
|
fields := make([]string, 0, 3)
|
|
|
|
if m.breach != nil {
|
|
|
|
fields = append(fields, trackedbreaches.FieldBreach)
|
|
|
|
}
|
|
|
|
if m.online != nil {
|
|
|
|
fields = append(fields, trackedbreaches.FieldOnline)
|
|
|
|
}
|
|
|
|
if m.user != nil {
|
|
|
|
fields = append(fields, trackedbreaches.FieldOwner)
|
2023-05-05 22:52:59 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) Field(name string) (ent.Value, bool) {
|
2023-05-05 22:52:59 +02:00
|
|
|
switch name {
|
2023-08-19 04:52:15 +02:00
|
|
|
case trackedbreaches.FieldBreach:
|
|
|
|
return m.Breach()
|
|
|
|
case trackedbreaches.FieldOnline:
|
|
|
|
return m.Online()
|
|
|
|
case trackedbreaches.FieldOwner:
|
|
|
|
return m.Owner()
|
2023-05-05 22:52:59 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
2023-05-05 22:52:59 +02:00
|
|
|
switch name {
|
2023-08-19 04:52:15 +02:00
|
|
|
case trackedbreaches.FieldBreach:
|
|
|
|
return m.OldBreach(ctx)
|
|
|
|
case trackedbreaches.FieldOnline:
|
|
|
|
return m.OldOnline(ctx)
|
|
|
|
case trackedbreaches.FieldOwner:
|
|
|
|
return m.OldOwner(ctx)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return nil, fmt.Errorf("unknown TrackedBreaches field %s", name)
|
2023-05-05 22:52:59 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) SetField(name string, value ent.Value) error {
|
2023-05-05 22:52:59 +02:00
|
|
|
switch name {
|
2023-08-19 04:52:15 +02:00
|
|
|
case trackedbreaches.FieldBreach:
|
|
|
|
v, ok := value.(uuid.UUID)
|
2023-05-05 22:52:59 +02:00
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
m.SetBreach(v)
|
|
|
|
return nil
|
|
|
|
case trackedbreaches.FieldOnline:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetOnline(v)
|
|
|
|
return nil
|
|
|
|
case trackedbreaches.FieldOwner:
|
|
|
|
v, ok := value.(uuid.UUID)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetOwner(v)
|
2023-05-05 22:52:59 +02:00
|
|
|
return nil
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return fmt.Errorf("unknown TrackedBreaches field %s", name)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) AddedFields() []string {
|
2023-05-05 22:52:59 +02:00
|
|
|
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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) AddedField(name string) (ent.Value, bool) {
|
2023-05-05 22:52:59 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) AddField(name string, value ent.Value) error {
|
2023-05-05 22:52:59 +02:00
|
|
|
switch name {
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return fmt.Errorf("unknown TrackedBreaches numeric field %s", name)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) ClearedFields() []string {
|
2023-05-05 22:52:59 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) FieldCleared(name string) bool {
|
2023-05-05 22:52:59 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) ClearField(name string) error {
|
|
|
|
return fmt.Errorf("unknown TrackedBreaches nullable field %s", name)
|
2023-05-05 22:52:59 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) ResetField(name string) error {
|
2023-05-05 22:52:59 +02:00
|
|
|
switch name {
|
2023-08-19 04:52:15 +02:00
|
|
|
case trackedbreaches.FieldBreach:
|
|
|
|
m.ResetBreach()
|
|
|
|
return nil
|
|
|
|
case trackedbreaches.FieldOnline:
|
|
|
|
m.ResetOnline()
|
|
|
|
return nil
|
|
|
|
case trackedbreaches.FieldOwner:
|
|
|
|
m.ResetOwner()
|
2023-05-05 22:52:59 +02:00
|
|
|
return nil
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
return fmt.Errorf("unknown TrackedBreaches field %s", name)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) AddedEdges() []string {
|
|
|
|
edges := make([]string, 0, 3)
|
|
|
|
if m.user != nil {
|
|
|
|
edges = append(edges, trackedbreaches.EdgeUser)
|
|
|
|
}
|
|
|
|
if m.localbreach != nil {
|
|
|
|
edges = append(edges, trackedbreaches.EdgeLocalbreach)
|
|
|
|
}
|
|
|
|
if m.hibp != nil {
|
|
|
|
edges = append(edges, trackedbreaches.EdgeHibp)
|
|
|
|
}
|
2023-05-05 22:52:59 +02:00
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) AddedIDs(name string) []ent.Value {
|
|
|
|
switch name {
|
|
|
|
case trackedbreaches.EdgeUser:
|
|
|
|
if id := m.user; id != nil {
|
|
|
|
return []ent.Value{*id}
|
|
|
|
}
|
|
|
|
case trackedbreaches.EdgeLocalbreach:
|
|
|
|
ids := make([]ent.Value, 0, len(m.localbreach))
|
|
|
|
for id := range m.localbreach {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
case trackedbreaches.EdgeHibp:
|
|
|
|
ids := make([]ent.Value, 0, len(m.hibp))
|
|
|
|
for id := range m.hibp {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
}
|
2023-05-05 22:52:59 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) RemovedEdges() []string {
|
|
|
|
edges := make([]string, 0, 3)
|
|
|
|
if m.removedlocalbreach != nil {
|
|
|
|
edges = append(edges, trackedbreaches.EdgeLocalbreach)
|
|
|
|
}
|
|
|
|
if m.removedhibp != nil {
|
|
|
|
edges = append(edges, trackedbreaches.EdgeHibp)
|
|
|
|
}
|
2023-05-05 22:52:59 +02:00
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
|
// the given name in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) RemovedIDs(name string) []ent.Value {
|
|
|
|
switch name {
|
|
|
|
case trackedbreaches.EdgeLocalbreach:
|
|
|
|
ids := make([]ent.Value, 0, len(m.removedlocalbreach))
|
|
|
|
for id := range m.removedlocalbreach {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
case trackedbreaches.EdgeHibp:
|
|
|
|
ids := make([]ent.Value, 0, len(m.removedhibp))
|
|
|
|
for id := range m.removedhibp {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
}
|
2023-05-05 22:52:59 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) ClearedEdges() []string {
|
|
|
|
edges := make([]string, 0, 3)
|
|
|
|
if m.cleareduser {
|
|
|
|
edges = append(edges, trackedbreaches.EdgeUser)
|
|
|
|
}
|
|
|
|
if m.clearedlocalbreach {
|
|
|
|
edges = append(edges, trackedbreaches.EdgeLocalbreach)
|
|
|
|
}
|
|
|
|
if m.clearedhibp {
|
|
|
|
edges = append(edges, trackedbreaches.EdgeHibp)
|
|
|
|
}
|
2023-05-05 22:52:59 +02:00
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) EdgeCleared(name string) bool {
|
|
|
|
switch name {
|
|
|
|
case trackedbreaches.EdgeUser:
|
|
|
|
return m.cleareduser
|
|
|
|
case trackedbreaches.EdgeLocalbreach:
|
|
|
|
return m.clearedlocalbreach
|
|
|
|
case trackedbreaches.EdgeHibp:
|
|
|
|
return m.clearedhibp
|
|
|
|
}
|
2023-05-05 22:52:59 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) ClearEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case trackedbreaches.EdgeUser:
|
|
|
|
m.ClearUser()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown TrackedBreaches unique edge %s", name)
|
2023-05-05 22:52:59 +02: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.
|
2023-08-19 04:52:15 +02:00
|
|
|
func (m *TrackedBreachesMutation) ResetEdge(name string) error {
|
|
|
|
switch name {
|
|
|
|
case trackedbreaches.EdgeUser:
|
|
|
|
m.ResetUser()
|
|
|
|
return nil
|
|
|
|
case trackedbreaches.EdgeLocalbreach:
|
|
|
|
m.ResetLocalbreach()
|
|
|
|
return nil
|
|
|
|
case trackedbreaches.EdgeHibp:
|
|
|
|
m.ResetHibp()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown TrackedBreaches edge %s", name)
|
2023-05-05 22:52:59 +02:00
|
|
|
}
|
|
|
|
|
2023-04-13 00:07:08 +02:00
|
|
|
// UserMutation represents an operation that mutates the User nodes in the graph.
|
|
|
|
type UserMutation struct {
|
|
|
|
config
|
2023-08-19 04:52:15 +02:00
|
|
|
op Op
|
|
|
|
typ string
|
|
|
|
id *uuid.UUID
|
|
|
|
username *string
|
|
|
|
email *string
|
|
|
|
password *[]byte
|
|
|
|
is_admin *bool
|
|
|
|
is_active *bool
|
|
|
|
created_at *time.Time
|
|
|
|
updated_at *time.Time
|
|
|
|
last_login *time.Time
|
|
|
|
clearedFields map[string]struct{}
|
|
|
|
agekey *uuid.UUID
|
|
|
|
clearedagekey bool
|
|
|
|
tracked_breaches map[uuid.UUID]struct{}
|
|
|
|
removedtracked_breaches map[uuid.UUID]struct{}
|
|
|
|
clearedtracked_breaches bool
|
|
|
|
search_queries map[uuid.UUID]struct{}
|
|
|
|
removedsearch_queries map[uuid.UUID]struct{}
|
|
|
|
clearedsearch_queries bool
|
|
|
|
done bool
|
|
|
|
oldValue func(context.Context) (*User, error)
|
|
|
|
predicates []predicate.User
|
2023-04-13 00:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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 uuid.UUID) 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
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetID sets the value of the id field. Note that this
|
|
|
|
// operation is only accepted on creation of User entities.
|
|
|
|
func (m *UserMutation) 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 *UserMutation) 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 *UserMutation) 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().User.Query().Where(m.predicates...).IDs(ctx)
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUsername sets the "username" field.
|
|
|
|
func (m *UserMutation) SetUsername(s string) {
|
|
|
|
m.username = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Username returns the value of the "username" field in the mutation.
|
|
|
|
func (m *UserMutation) Username() (r string, exists bool) {
|
|
|
|
v := m.username
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldUsername returns the old "username" field's value of the User entity.
|
|
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
|
func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldUsername is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldUsername requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldUsername: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.Username, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetUsername resets all changes to the "username" field.
|
|
|
|
func (m *UserMutation) ResetUsername() {
|
|
|
|
m.username = nil
|
|
|
|
}
|
|
|
|
|
2023-05-01 22:48:11 +02:00
|
|
|
// SetEmail sets the "email" field.
|
|
|
|
func (m *UserMutation) SetEmail(s string) {
|
|
|
|
m.email = &s
|
|
|
|
}
|
|
|
|
|
|
|
|
// Email returns the value of the "email" field in the mutation.
|
|
|
|
func (m *UserMutation) 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 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) 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 *UserMutation) ResetEmail() {
|
|
|
|
m.email = nil
|
|
|
|
}
|
|
|
|
|
2023-04-13 00:07:08 +02:00
|
|
|
// SetPassword sets the "password" field.
|
2023-05-03 06:30:12 +02:00
|
|
|
func (m *UserMutation) SetPassword(b []byte) {
|
|
|
|
m.password = &b
|
2023-04-13 00:07:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Password returns the value of the "password" field in the mutation.
|
2023-05-03 06:30:12 +02:00
|
|
|
func (m *UserMutation) Password() (r []byte, exists bool) {
|
2023-04-13 00:07:08 +02:00
|
|
|
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.
|
2023-05-03 06:30:12 +02:00
|
|
|
func (m *UserMutation) OldPassword(ctx context.Context) (v []byte, err error) {
|
2023-04-13 00:07:08 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsAdmin sets the "is_admin" field.
|
|
|
|
func (m *UserMutation) SetIsAdmin(b bool) {
|
|
|
|
m.is_admin = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsAdmin returns the value of the "is_admin" field in the mutation.
|
|
|
|
func (m *UserMutation) IsAdmin() (r bool, exists bool) {
|
|
|
|
v := m.is_admin
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsAdmin returns the old "is_admin" 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) OldIsAdmin(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsAdmin is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsAdmin requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsAdmin: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsAdmin, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsAdmin resets all changes to the "is_admin" field.
|
|
|
|
func (m *UserMutation) ResetIsAdmin() {
|
|
|
|
m.is_admin = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsActive sets the "is_active" field.
|
|
|
|
func (m *UserMutation) SetIsActive(b bool) {
|
|
|
|
m.is_active = &b
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsActive returns the value of the "is_active" field in the mutation.
|
|
|
|
func (m *UserMutation) IsActive() (r bool, exists bool) {
|
|
|
|
v := m.is_active
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldIsActive returns the old "is_active" 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) OldIsActive(ctx context.Context) (v bool, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldIsActive is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldIsActive requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldIsActive: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.IsActive, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetIsActive resets all changes to the "is_active" field.
|
|
|
|
func (m *UserMutation) ResetIsActive() {
|
|
|
|
m.is_active = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
|
|
func (m *UserMutation) SetCreatedAt(t time.Time) {
|
|
|
|
m.created_at = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
|
func (m *UserMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
|
v := m.created_at
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldCreatedAt returns the old "created_at" field's value of the User entity.
|
|
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
|
func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.CreatedAt, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetCreatedAt resets all changes to the "created_at" field.
|
|
|
|
func (m *UserMutation) ResetCreatedAt() {
|
|
|
|
m.created_at = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
|
|
func (m *UserMutation) SetUpdatedAt(t time.Time) {
|
|
|
|
m.updated_at = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
|
func (m *UserMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
|
v := m.updated_at
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldUpdatedAt returns the old "updated_at" field's value of the User entity.
|
|
|
|
// If the User object wasn't provided to the builder, the object is fetched from the database.
|
|
|
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
|
func (m *UserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.UpdatedAt, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
|
|
func (m *UserMutation) ResetUpdatedAt() {
|
|
|
|
m.updated_at = nil
|
|
|
|
}
|
|
|
|
|
2023-08-10 19:27:14 +02:00
|
|
|
// SetLastLogin sets the "last_login" field.
|
|
|
|
func (m *UserMutation) SetLastLogin(t time.Time) {
|
|
|
|
m.last_login = &t
|
|
|
|
}
|
|
|
|
|
|
|
|
// LastLogin returns the value of the "last_login" field in the mutation.
|
|
|
|
func (m *UserMutation) LastLogin() (r time.Time, exists bool) {
|
|
|
|
v := m.last_login
|
|
|
|
if v == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
return *v, true
|
|
|
|
}
|
|
|
|
|
|
|
|
// OldLastLogin returns the old "last_login" 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) OldLastLogin(ctx context.Context) (v time.Time, err error) {
|
|
|
|
if !m.op.Is(OpUpdateOne) {
|
|
|
|
return v, errors.New("OldLastLogin is only allowed on UpdateOne operations")
|
|
|
|
}
|
|
|
|
if m.id == nil || m.oldValue == nil {
|
|
|
|
return v, errors.New("OldLastLogin requires an ID field in the mutation")
|
|
|
|
}
|
|
|
|
oldValue, err := m.oldValue(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return v, fmt.Errorf("querying old value for OldLastLogin: %w", err)
|
|
|
|
}
|
|
|
|
return oldValue.LastLogin, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetLastLogin resets all changes to the "last_login" field.
|
|
|
|
func (m *UserMutation) ResetLastLogin() {
|
|
|
|
m.last_login = nil
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetAgekeyID sets the "agekey" edge to the AgeKey entity by id.
|
|
|
|
func (m *UserMutation) SetAgekeyID(id uuid.UUID) {
|
|
|
|
m.agekey = &id
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearAgekey clears the "agekey" edge to the AgeKey entity.
|
|
|
|
func (m *UserMutation) ClearAgekey() {
|
|
|
|
m.clearedagekey = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// AgekeyCleared reports if the "agekey" edge to the AgeKey entity was cleared.
|
|
|
|
func (m *UserMutation) AgekeyCleared() bool {
|
|
|
|
return m.clearedagekey
|
|
|
|
}
|
|
|
|
|
|
|
|
// AgekeyID returns the "agekey" edge ID in the mutation.
|
|
|
|
func (m *UserMutation) AgekeyID() (id uuid.UUID, exists bool) {
|
|
|
|
if m.agekey != nil {
|
|
|
|
return *m.agekey, true
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// AgekeyIDs returns the "agekey" edge IDs in the mutation.
|
|
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
|
|
// AgekeyID instead. It exists only for internal usage by the builders.
|
|
|
|
func (m *UserMutation) AgekeyIDs() (ids []uuid.UUID) {
|
|
|
|
if id := m.agekey; id != nil {
|
|
|
|
ids = append(ids, *id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetAgekey resets all changes to the "agekey" edge.
|
|
|
|
func (m *UserMutation) ResetAgekey() {
|
|
|
|
m.agekey = nil
|
|
|
|
m.clearedagekey = false
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddTrackedBreachIDs adds the "tracked_breaches" edge to the TrackedBreaches entity by ids.
|
|
|
|
func (m *UserMutation) AddTrackedBreachIDs(ids ...uuid.UUID) {
|
|
|
|
if m.tracked_breaches == nil {
|
|
|
|
m.tracked_breaches = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
m.tracked_breaches[ids[i]] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearTrackedBreaches clears the "tracked_breaches" edge to the TrackedBreaches entity.
|
|
|
|
func (m *UserMutation) ClearTrackedBreaches() {
|
|
|
|
m.clearedtracked_breaches = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackedBreachesCleared reports if the "tracked_breaches" edge to the TrackedBreaches entity was cleared.
|
|
|
|
func (m *UserMutation) TrackedBreachesCleared() bool {
|
|
|
|
return m.clearedtracked_breaches
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveTrackedBreachIDs removes the "tracked_breaches" edge to the TrackedBreaches entity by IDs.
|
|
|
|
func (m *UserMutation) RemoveTrackedBreachIDs(ids ...uuid.UUID) {
|
|
|
|
if m.removedtracked_breaches == nil {
|
|
|
|
m.removedtracked_breaches = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
delete(m.tracked_breaches, ids[i])
|
|
|
|
m.removedtracked_breaches[ids[i]] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedTrackedBreaches returns the removed IDs of the "tracked_breaches" edge to the TrackedBreaches entity.
|
|
|
|
func (m *UserMutation) RemovedTrackedBreachesIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.removedtracked_breaches {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// TrackedBreachesIDs returns the "tracked_breaches" edge IDs in the mutation.
|
|
|
|
func (m *UserMutation) TrackedBreachesIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.tracked_breaches {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetTrackedBreaches resets all changes to the "tracked_breaches" edge.
|
|
|
|
func (m *UserMutation) ResetTrackedBreaches() {
|
|
|
|
m.tracked_breaches = nil
|
|
|
|
m.clearedtracked_breaches = false
|
|
|
|
m.removedtracked_breaches = nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddSearchQueryIDs adds the "search_queries" edge to the SearchQuery entity by ids.
|
|
|
|
func (m *UserMutation) AddSearchQueryIDs(ids ...uuid.UUID) {
|
|
|
|
if m.search_queries == nil {
|
|
|
|
m.search_queries = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
m.search_queries[ids[i]] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearSearchQueries clears the "search_queries" edge to the SearchQuery entity.
|
|
|
|
func (m *UserMutation) ClearSearchQueries() {
|
|
|
|
m.clearedsearch_queries = true
|
|
|
|
}
|
|
|
|
|
|
|
|
// SearchQueriesCleared reports if the "search_queries" edge to the SearchQuery entity was cleared.
|
|
|
|
func (m *UserMutation) SearchQueriesCleared() bool {
|
|
|
|
return m.clearedsearch_queries
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveSearchQueryIDs removes the "search_queries" edge to the SearchQuery entity by IDs.
|
|
|
|
func (m *UserMutation) RemoveSearchQueryIDs(ids ...uuid.UUID) {
|
|
|
|
if m.removedsearch_queries == nil {
|
|
|
|
m.removedsearch_queries = make(map[uuid.UUID]struct{})
|
|
|
|
}
|
|
|
|
for i := range ids {
|
|
|
|
delete(m.search_queries, ids[i])
|
|
|
|
m.removedsearch_queries[ids[i]] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedSearchQueries returns the removed IDs of the "search_queries" edge to the SearchQuery entity.
|
|
|
|
func (m *UserMutation) RemovedSearchQueriesIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.removedsearch_queries {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// SearchQueriesIDs returns the "search_queries" edge IDs in the mutation.
|
|
|
|
func (m *UserMutation) SearchQueriesIDs() (ids []uuid.UUID) {
|
|
|
|
for id := range m.search_queries {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetSearchQueries resets all changes to the "search_queries" edge.
|
|
|
|
func (m *UserMutation) ResetSearchQueries() {
|
|
|
|
m.search_queries = nil
|
|
|
|
m.clearedsearch_queries = false
|
|
|
|
m.removedsearch_queries = nil
|
|
|
|
}
|
|
|
|
|
2023-04-13 00:07:08 +02:00
|
|
|
// Where appends a list predicates to the UserMutation builder.
|
|
|
|
func (m *UserMutation) Where(ps ...predicate.User) {
|
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// WhereP appends storage-level predicates to the UserMutation builder. Using this method,
|
|
|
|
// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
|
func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
|
p := make([]predicate.User, len(ps))
|
|
|
|
for i := range ps {
|
|
|
|
p[i] = ps[i]
|
|
|
|
}
|
|
|
|
m.Where(p...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Op returns the operation name.
|
|
|
|
func (m *UserMutation) Op() Op {
|
|
|
|
return m.op
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetOp allows setting the mutation operation.
|
|
|
|
func (m *UserMutation) SetOp(op Op) {
|
|
|
|
m.op = op
|
|
|
|
}
|
|
|
|
|
|
|
|
// Type returns the node type of this mutation (User).
|
|
|
|
func (m *UserMutation) Type() string {
|
|
|
|
return m.typ
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fields returns all fields that were changed during this mutation. Note that in
|
|
|
|
// order to get all numeric fields that were incremented/decremented, call
|
|
|
|
// AddedFields().
|
|
|
|
func (m *UserMutation) Fields() []string {
|
2023-08-10 19:27:14 +02:00
|
|
|
fields := make([]string, 0, 8)
|
2023-04-13 00:07:08 +02:00
|
|
|
if m.username != nil {
|
|
|
|
fields = append(fields, user.FieldUsername)
|
|
|
|
}
|
2023-05-01 22:48:11 +02:00
|
|
|
if m.email != nil {
|
|
|
|
fields = append(fields, user.FieldEmail)
|
|
|
|
}
|
2023-04-13 00:07:08 +02:00
|
|
|
if m.password != nil {
|
|
|
|
fields = append(fields, user.FieldPassword)
|
|
|
|
}
|
|
|
|
if m.is_admin != nil {
|
|
|
|
fields = append(fields, user.FieldIsAdmin)
|
|
|
|
}
|
|
|
|
if m.is_active != nil {
|
|
|
|
fields = append(fields, user.FieldIsActive)
|
|
|
|
}
|
|
|
|
if m.created_at != nil {
|
|
|
|
fields = append(fields, user.FieldCreatedAt)
|
|
|
|
}
|
|
|
|
if m.updated_at != nil {
|
|
|
|
fields = append(fields, user.FieldUpdatedAt)
|
|
|
|
}
|
2023-08-10 19:27:14 +02:00
|
|
|
if m.last_login != nil {
|
|
|
|
fields = append(fields, user.FieldLastLogin)
|
|
|
|
}
|
2023-04-13 00:07:08 +02: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 *UserMutation) Field(name string) (ent.Value, bool) {
|
|
|
|
switch name {
|
|
|
|
case user.FieldUsername:
|
|
|
|
return m.Username()
|
2023-05-01 22:48:11 +02:00
|
|
|
case user.FieldEmail:
|
|
|
|
return m.Email()
|
2023-04-13 00:07:08 +02:00
|
|
|
case user.FieldPassword:
|
|
|
|
return m.Password()
|
|
|
|
case user.FieldIsAdmin:
|
|
|
|
return m.IsAdmin()
|
|
|
|
case user.FieldIsActive:
|
|
|
|
return m.IsActive()
|
|
|
|
case user.FieldCreatedAt:
|
|
|
|
return m.CreatedAt()
|
|
|
|
case user.FieldUpdatedAt:
|
|
|
|
return m.UpdatedAt()
|
2023-08-10 19:27:14 +02:00
|
|
|
case user.FieldLastLogin:
|
|
|
|
return m.LastLogin()
|
2023-04-13 00:07:08 +02: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 *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
|
switch name {
|
|
|
|
case user.FieldUsername:
|
|
|
|
return m.OldUsername(ctx)
|
2023-05-01 22:48:11 +02:00
|
|
|
case user.FieldEmail:
|
|
|
|
return m.OldEmail(ctx)
|
2023-04-13 00:07:08 +02:00
|
|
|
case user.FieldPassword:
|
|
|
|
return m.OldPassword(ctx)
|
|
|
|
case user.FieldIsAdmin:
|
|
|
|
return m.OldIsAdmin(ctx)
|
|
|
|
case user.FieldIsActive:
|
|
|
|
return m.OldIsActive(ctx)
|
|
|
|
case user.FieldCreatedAt:
|
|
|
|
return m.OldCreatedAt(ctx)
|
|
|
|
case user.FieldUpdatedAt:
|
|
|
|
return m.OldUpdatedAt(ctx)
|
2023-08-10 19:27:14 +02:00
|
|
|
case user.FieldLastLogin:
|
|
|
|
return m.OldLastLogin(ctx)
|
2023-04-13 00:07:08 +02:00
|
|
|
}
|
|
|
|
return nil, fmt.Errorf("unknown User field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetField sets the value of a field with the given name. It returns an error if
|
|
|
|
// the field is not defined in the schema, or if the type mismatched the field
|
|
|
|
// type.
|
|
|
|
func (m *UserMutation) SetField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
case user.FieldUsername:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetUsername(v)
|
|
|
|
return nil
|
2023-05-01 22:48:11 +02:00
|
|
|
case user.FieldEmail:
|
|
|
|
v, ok := value.(string)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetEmail(v)
|
|
|
|
return nil
|
2023-04-13 00:07:08 +02:00
|
|
|
case user.FieldPassword:
|
2023-05-03 06:30:12 +02:00
|
|
|
v, ok := value.([]byte)
|
2023-04-13 00:07:08 +02:00
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetPassword(v)
|
|
|
|
return nil
|
|
|
|
case user.FieldIsAdmin:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsAdmin(v)
|
|
|
|
return nil
|
|
|
|
case user.FieldIsActive:
|
|
|
|
v, ok := value.(bool)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetIsActive(v)
|
|
|
|
return nil
|
|
|
|
case user.FieldCreatedAt:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetCreatedAt(v)
|
|
|
|
return nil
|
|
|
|
case user.FieldUpdatedAt:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetUpdatedAt(v)
|
|
|
|
return nil
|
2023-08-10 19:27:14 +02:00
|
|
|
case user.FieldLastLogin:
|
|
|
|
v, ok := value.(time.Time)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
|
}
|
|
|
|
m.SetLastLogin(v)
|
|
|
|
return nil
|
2023-04-13 00:07:08 +02:00
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown User field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
|
// this mutation.
|
|
|
|
func (m *UserMutation) AddedFields() []string {
|
|
|
|
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 *UserMutation) 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 *UserMutation) AddField(name string, value ent.Value) error {
|
|
|
|
switch name {
|
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown User numeric field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedFields returns all nullable fields that were cleared during this
|
|
|
|
// mutation.
|
|
|
|
func (m *UserMutation) ClearedFields() []string {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
|
// cleared in this mutation.
|
|
|
|
func (m *UserMutation) FieldCleared(name string) bool {
|
|
|
|
_, ok := m.clearedFields[name]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearField clears the value of the field with the given name. It returns an
|
|
|
|
// error if the field is not defined in the schema.
|
|
|
|
func (m *UserMutation) ClearField(name string) error {
|
|
|
|
return fmt.Errorf("unknown User nullable field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetField resets all changes in the mutation for the field with the given name.
|
|
|
|
// It returns an error if the field is not defined in the schema.
|
|
|
|
func (m *UserMutation) ResetField(name string) error {
|
|
|
|
switch name {
|
|
|
|
case user.FieldUsername:
|
|
|
|
m.ResetUsername()
|
|
|
|
return nil
|
2023-05-01 22:48:11 +02:00
|
|
|
case user.FieldEmail:
|
|
|
|
m.ResetEmail()
|
|
|
|
return nil
|
2023-04-13 00:07:08 +02:00
|
|
|
case user.FieldPassword:
|
|
|
|
m.ResetPassword()
|
|
|
|
return nil
|
|
|
|
case user.FieldIsAdmin:
|
|
|
|
m.ResetIsAdmin()
|
|
|
|
return nil
|
|
|
|
case user.FieldIsActive:
|
|
|
|
m.ResetIsActive()
|
|
|
|
return nil
|
|
|
|
case user.FieldCreatedAt:
|
|
|
|
m.ResetCreatedAt()
|
|
|
|
return nil
|
|
|
|
case user.FieldUpdatedAt:
|
|
|
|
m.ResetUpdatedAt()
|
|
|
|
return nil
|
2023-08-10 19:27:14 +02:00
|
|
|
case user.FieldLastLogin:
|
|
|
|
m.ResetLastLogin()
|
|
|
|
return nil
|
2023-04-13 00:07:08 +02:00
|
|
|
}
|
|
|
|
return fmt.Errorf("unknown User field %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
|
func (m *UserMutation) AddedEdges() []string {
|
2023-08-19 04:52:15 +02:00
|
|
|
edges := make([]string, 0, 3)
|
|
|
|
if m.agekey != nil {
|
|
|
|
edges = append(edges, user.EdgeAgekey)
|
|
|
|
}
|
|
|
|
if m.tracked_breaches != nil {
|
|
|
|
edges = append(edges, user.EdgeTrackedBreaches)
|
|
|
|
}
|
|
|
|
if m.search_queries != nil {
|
|
|
|
edges = append(edges, user.EdgeSearchQueries)
|
|
|
|
}
|
2023-04-13 00:07:08 +02:00
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
|
// name in this mutation.
|
|
|
|
func (m *UserMutation) AddedIDs(name string) []ent.Value {
|
2023-08-19 04:52:15 +02:00
|
|
|
switch name {
|
|
|
|
case user.EdgeAgekey:
|
|
|
|
if id := m.agekey; id != nil {
|
|
|
|
return []ent.Value{*id}
|
|
|
|
}
|
|
|
|
case user.EdgeTrackedBreaches:
|
|
|
|
ids := make([]ent.Value, 0, len(m.tracked_breaches))
|
|
|
|
for id := range m.tracked_breaches {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
case user.EdgeSearchQueries:
|
|
|
|
ids := make([]ent.Value, 0, len(m.search_queries))
|
|
|
|
for id := range m.search_queries {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
}
|
2023-04-13 00:07:08 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
|
func (m *UserMutation) RemovedEdges() []string {
|
2023-08-19 04:52:15 +02:00
|
|
|
edges := make([]string, 0, 3)
|
|
|
|
if m.removedtracked_breaches != nil {
|
|
|
|
edges = append(edges, user.EdgeTrackedBreaches)
|
|
|
|
}
|
|
|
|
if m.removedsearch_queries != nil {
|
|
|
|
edges = append(edges, user.EdgeSearchQueries)
|
|
|
|
}
|
2023-04-13 00:07:08 +02: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 *UserMutation) RemovedIDs(name string) []ent.Value {
|
2023-08-19 04:52:15 +02:00
|
|
|
switch name {
|
|
|
|
case user.EdgeTrackedBreaches:
|
|
|
|
ids := make([]ent.Value, 0, len(m.removedtracked_breaches))
|
|
|
|
for id := range m.removedtracked_breaches {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
case user.EdgeSearchQueries:
|
|
|
|
ids := make([]ent.Value, 0, len(m.removedsearch_queries))
|
|
|
|
for id := range m.removedsearch_queries {
|
|
|
|
ids = append(ids, id)
|
|
|
|
}
|
|
|
|
return ids
|
|
|
|
}
|
2023-04-13 00:07:08 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
|
func (m *UserMutation) ClearedEdges() []string {
|
2023-08-19 04:52:15 +02:00
|
|
|
edges := make([]string, 0, 3)
|
|
|
|
if m.clearedagekey {
|
|
|
|
edges = append(edges, user.EdgeAgekey)
|
|
|
|
}
|
|
|
|
if m.clearedtracked_breaches {
|
|
|
|
edges = append(edges, user.EdgeTrackedBreaches)
|
|
|
|
}
|
|
|
|
if m.clearedsearch_queries {
|
|
|
|
edges = append(edges, user.EdgeSearchQueries)
|
|
|
|
}
|
2023-04-13 00:07:08 +02:00
|
|
|
return edges
|
|
|
|
}
|
|
|
|
|
|
|
|
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
|
// was cleared in this mutation.
|
|
|
|
func (m *UserMutation) EdgeCleared(name string) bool {
|
2023-08-19 04:52:15 +02:00
|
|
|
switch name {
|
|
|
|
case user.EdgeAgekey:
|
|
|
|
return m.clearedagekey
|
|
|
|
case user.EdgeTrackedBreaches:
|
|
|
|
return m.clearedtracked_breaches
|
|
|
|
case user.EdgeSearchQueries:
|
|
|
|
return m.clearedsearch_queries
|
|
|
|
}
|
2023-04-13 00:07:08 +02: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.
|
|
|
|
func (m *UserMutation) ClearEdge(name string) error {
|
2023-08-19 04:52:15 +02:00
|
|
|
switch name {
|
|
|
|
case user.EdgeAgekey:
|
|
|
|
m.ClearAgekey()
|
|
|
|
return nil
|
|
|
|
}
|
2023-04-13 00:07:08 +02:00
|
|
|
return fmt.Errorf("unknown User unique edge %s", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
|
|
// It returns an error if the edge is not defined in the schema.
|
|
|
|
func (m *UserMutation) ResetEdge(name string) error {
|
2023-08-19 04:52:15 +02:00
|
|
|
switch name {
|
|
|
|
case user.EdgeAgekey:
|
|
|
|
m.ResetAgekey()
|
|
|
|
return nil
|
|
|
|
case user.EdgeTrackedBreaches:
|
|
|
|
m.ResetTrackedBreaches()
|
|
|
|
return nil
|
|
|
|
case user.EdgeSearchQueries:
|
|
|
|
m.ResetSearchQueries()
|
|
|
|
return nil
|
|
|
|
}
|
2023-04-13 00:07:08 +02:00
|
|
|
return fmt.Errorf("unknown User edge %s", name)
|
|
|
|
}
|