pcmt/ent/mutation.go
surtur 3077eb80c6
All checks were successful
continuous-integration/drone/push Build is passing
go: add HIBPSchema + adjust ent model fields
2023-08-20 23:16:12 +02:00

6052 lines
180 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"sync"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"git.dotya.ml/mirre-mt/pcmt/ent/agekey"
"git.dotya.ml/mirre-mt/pcmt/ent/hibp"
"git.dotya.ml/mirre-mt/pcmt/ent/localbreach"
"git.dotya.ml/mirre-mt/pcmt/ent/predicate"
"git.dotya.ml/mirre-mt/pcmt/ent/schema"
"git.dotya.ml/mirre-mt/pcmt/ent/searchquery"
"git.dotya.ml/mirre-mt/pcmt/ent/settings"
"git.dotya.ml/mirre-mt/pcmt/ent/setup"
"git.dotya.ml/mirre-mt/pcmt/ent/trackedbreaches"
"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.
TypeAgeKey = "AgeKey"
TypeHIBP = "HIBP"
TypeLocalBreach = "LocalBreach"
TypeSearchQuery = "SearchQuery"
TypeSettings = "Settings"
TypeSetup = "Setup"
TypeTrackedBreaches = "TrackedBreaches"
TypeUser = "User"
)
// AgeKeyMutation represents an operation that mutates the AgeKey nodes in the graph.
type AgeKeyMutation struct {
config
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
}
var _ ent.Mutation = (*AgeKeyMutation)(nil)
// agekeyOption allows management of the mutation configuration using functional options.
type agekeyOption func(*AgeKeyMutation)
// newAgeKeyMutation creates new mutation for the AgeKey entity.
func newAgeKeyMutation(c config, op Op, opts ...agekeyOption) *AgeKeyMutation {
m := &AgeKeyMutation{
config: c,
op: op,
typ: TypeAgeKey,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withAgeKeyID sets the ID field of the mutation.
func withAgeKeyID(id uuid.UUID) agekeyOption {
return func(m *AgeKeyMutation) {
var (
err error
once sync.Once
value *AgeKey
)
m.oldValue = func(ctx context.Context) (*AgeKey, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().AgeKey.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withAgeKey sets the old AgeKey of the mutation.
func withAgeKey(node *AgeKey) agekeyOption {
return func(m *AgeKeyMutation) {
m.oldValue = func(context.Context) (*AgeKey, 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 AgeKeyMutation) 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 AgeKeyMutation) 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 AgeKey entities.
func (m *AgeKeyMutation) 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 *AgeKeyMutation) 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 *AgeKeyMutation) 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().AgeKey.Query().Where(m.predicates...).IDs(ctx)
default:
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
}
}
// SetKey sets the "key" field.
func (m *AgeKeyMutation) SetKey(b []byte) {
m.key = &b
}
// Key returns the value of the "key" field in the mutation.
func (m *AgeKeyMutation) Key() (r []byte, exists bool) {
v := m.key
if v == nil {
return
}
return *v, true
}
// 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.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AgeKeyMutation) OldKey(ctx context.Context) (v *[]byte, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldKey is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldKey requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldKey: %w", err)
}
return oldValue.Key, nil
}
// ResetKey resets all changes to the "key" field.
func (m *AgeKeyMutation) ResetKey() {
m.key = nil
}
// SetCreated sets the "created" field.
func (m *AgeKeyMutation) SetCreated(t time.Time) {
m.created = &t
}
// Created returns the value of the "created" field in the mutation.
func (m *AgeKeyMutation) 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 AgeKey entity.
// If the AgeKey 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 *AgeKeyMutation) 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 *AgeKeyMutation) ResetCreated() {
m.created = nil
}
// SetUpdated sets the "updated" field.
func (m *AgeKeyMutation) SetUpdated(t time.Time) {
m.updated = &t
}
// Updated returns the value of the "updated" field in the mutation.
func (m *AgeKeyMutation) Updated() (r time.Time, exists bool) {
v := m.updated
if v == nil {
return
}
return *v, true
}
// 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.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *AgeKeyMutation) OldUpdated(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldUpdated is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldUpdated requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldUpdated: %w", err)
}
return oldValue.Updated, nil
}
// ResetUpdated resets all changes to the "updated" field.
func (m *AgeKeyMutation) ResetUpdated() {
m.updated = nil
}
// SetOwner sets the "owner" field.
func (m *AgeKeyMutation) SetOwner(u uuid.UUID) {
m.user = &u
}
// Owner returns the value of the "owner" field in the mutation.
func (m *AgeKeyMutation) 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 AgeKey entity.
// If the AgeKey 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 *AgeKeyMutation) 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 *AgeKeyMutation) ResetOwner() {
m.user = nil
}
// SetUserID sets the "user" edge to the User entity by id.
func (m *AgeKeyMutation) SetUserID(id uuid.UUID) {
m.user = &id
}
// ClearUser clears the "user" edge to the User entity.
func (m *AgeKeyMutation) ClearUser() {
m.cleareduser = true
}
// UserCleared reports if the "user" edge to the User entity was cleared.
func (m *AgeKeyMutation) UserCleared() bool {
return m.cleareduser
}
// 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
}
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 *AgeKeyMutation) 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 *AgeKeyMutation) ResetUser() {
m.user = nil
m.cleareduser = false
}
// Where appends a list predicates to the AgeKeyMutation builder.
func (m *AgeKeyMutation) Where(ps ...predicate.AgeKey) {
m.predicates = append(m.predicates, ps...)
}
// 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]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *AgeKeyMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *AgeKeyMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (AgeKey).
func (m *AgeKeyMutation) 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 *AgeKeyMutation) Fields() []string {
fields := make([]string, 0, 4)
if m.key != nil {
fields = append(fields, agekey.FieldKey)
}
if m.created != nil {
fields = append(fields, agekey.FieldCreated)
}
if m.updated != nil {
fields = append(fields, agekey.FieldUpdated)
}
if m.user != nil {
fields = append(fields, agekey.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 *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
}
// 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)
}
return nil, fmt.Errorf("unknown AgeKey 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 *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
title *string
domain *string
breach_date *time.Time
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
logo_path *string
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
}
// 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
}
// 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.
func (m *HIBPMutation) SetBreachDate(t time.Time) {
m.breach_date = &t
}
// BreachDate returns the value of the "breach_date" field in the mutation.
func (m *HIBPMutation) BreachDate() (r time.Time, exists bool) {
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.
func (m *HIBPMutation) OldBreachDate(ctx context.Context) (v time.Time, err error) {
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.
func (m *HIBPMutation) ResetDataclasses() {
m.dataclasses = nil
m.appenddataclasses = nil
}
// 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
}
// SetLogoPath sets the "logo_path" field.
func (m *HIBPMutation) SetLogoPath(s string) {
m.logo_path = &s
}
// LogoPath returns the value of the "logo_path" field in the mutation.
func (m *HIBPMutation) LogoPath() (r string, exists bool) {
v := m.logo_path
if v == nil {
return
}
return *v, true
}
// OldLogoPath returns the old "logo_path" 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) OldLogoPath(ctx context.Context) (v *string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldLogoPath is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldLogoPath requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldLogoPath: %w", err)
}
return oldValue.LogoPath, nil
}
// ClearLogoPath clears the value of the "logo_path" field.
func (m *HIBPMutation) ClearLogoPath() {
m.logo_path = nil
m.clearedFields[hibp.FieldLogoPath] = struct{}{}
}
// LogoPathCleared returns if the "logo_path" field was cleared in this mutation.
func (m *HIBPMutation) LogoPathCleared() bool {
_, ok := m.clearedFields[hibp.FieldLogoPath]
return ok
}
// ResetLogoPath resets all changes to the "logo_path" field.
func (m *HIBPMutation) ResetLogoPath() {
m.logo_path = nil
delete(m.clearedFields, hibp.FieldLogoPath)
}
// 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 {
fields := make([]string, 0, 16)
if m.name != nil {
fields = append(fields, hibp.FieldName)
}
if m.title != nil {
fields = append(fields, hibp.FieldTitle)
}
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)
}
if m.logo_path != nil {
fields = append(fields, hibp.FieldLogoPath)
}
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()
case hibp.FieldTitle:
return m.Title()
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()
case hibp.FieldLogoPath:
return m.LogoPath()
}
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)
case hibp.FieldTitle:
return m.OldTitle(ctx)
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)
case hibp.FieldLogoPath:
return m.OldLogoPath(ctx)
}
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
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
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:
v, ok := value.(time.Time)
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
case hibp.FieldLogoPath:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetLogoPath(v)
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)
}
if m.FieldCleared(hibp.FieldLogoPath) {
fields = append(fields, hibp.FieldLogoPath)
}
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
case hibp.FieldLogoPath:
m.ClearLogoPath()
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
case hibp.FieldTitle:
m.ResetTitle()
return nil
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
case hibp.FieldLogoPath:
m.ResetLogoPath()
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
contains_passwords *bool
contains_hashes *bool
contains_emails *bool
contains_usernames *bool
hash_type *string
hash_salted *bool
hash_peppered *bool
data **schema.Data
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
}
// SetContainsPasswords sets the "contains_passwords" field.
func (m *LocalBreachMutation) SetContainsPasswords(b bool) {
m.contains_passwords = &b
}
// ContainsPasswords returns the value of the "contains_passwords" field in the mutation.
func (m *LocalBreachMutation) ContainsPasswords() (r bool, exists bool) {
v := m.contains_passwords
if v == nil {
return
}
return *v, true
}
// OldContainsPasswords returns the old "contains_passwords" 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) OldContainsPasswords(ctx context.Context) (v bool, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldContainsPasswords is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldContainsPasswords requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldContainsPasswords: %w", err)
}
return oldValue.ContainsPasswords, nil
}
// ResetContainsPasswords resets all changes to the "contains_passwords" field.
func (m *LocalBreachMutation) ResetContainsPasswords() {
m.contains_passwords = nil
}
// 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
}
// 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
}
// 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.
func (m *LocalBreachMutation) SetData(s *schema.Data) {
m.data = &s
}
// Data returns the value of the "data" field in the mutation.
func (m *LocalBreachMutation) Data() (r *schema.Data, exists bool) {
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.
func (m *LocalBreachMutation) OldData(ctx context.Context) (v *schema.Data, err error) {
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 {
fields := make([]string, 0, 13)
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)
}
if m.contains_passwords != nil {
fields = append(fields, localbreach.FieldContainsPasswords)
}
if m.contains_hashes != nil {
fields = append(fields, localbreach.FieldContainsHashes)
}
if m.contains_emails != nil {
fields = append(fields, localbreach.FieldContainsEmails)
}
if m.contains_usernames != nil {
fields = append(fields, localbreach.FieldContainsUsernames)
}
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()
case localbreach.FieldContainsPasswords:
return m.ContainsPasswords()
case localbreach.FieldContainsHashes:
return m.ContainsHashes()
case localbreach.FieldContainsEmails:
return m.ContainsEmails()
case localbreach.FieldContainsUsernames:
return m.ContainsUsernames()
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)
case localbreach.FieldContainsPasswords:
return m.OldContainsPasswords(ctx)
case localbreach.FieldContainsHashes:
return m.OldContainsHashes(ctx)
case localbreach.FieldContainsEmails:
return m.OldContainsEmails(ctx)
case localbreach.FieldContainsUsernames:
return m.OldContainsUsernames(ctx)
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
case localbreach.FieldContainsPasswords:
v, ok := value.(bool)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetContainsPasswords(v)
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
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
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:
v, ok := value.(*schema.Data)
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
case localbreach.FieldContainsPasswords:
m.ResetContainsPasswords()
return nil
case localbreach.FieldContainsHashes:
m.ResetContainsHashes()
return nil
case localbreach.FieldContainsEmails:
m.ResetContainsEmails()
return nil
case localbreach.FieldContainsUsernames:
m.ResetContainsUsernames()
return nil
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
}
}
// 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
if v == nil {
return
}
return *v, true
}
// 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.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SettingsMutation) OldHibpAPIKey(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldHibpAPIKey is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldHibpAPIKey requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldHibpAPIKey: %w", err)
}
return oldValue.HibpAPIKey, nil
}
// ClearHibpAPIKey clears the value of the "hibp_api_key" field.
func (m *SettingsMutation) ClearHibpAPIKey() {
m.hibp_api_key = nil
m.clearedFields[settings.FieldHibpAPIKey] = struct{}{}
}
// 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
}
// 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
if v == nil {
return
}
return *v, true
}
// 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.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SettingsMutation) OldDehashedAPIKey(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldDehashedAPIKey is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldDehashedAPIKey requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldDehashedAPIKey: %w", err)
}
return oldValue.DehashedAPIKey, nil
}
// 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)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *SettingsMutation) AddedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *SettingsMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *SettingsMutation) RemovedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *SettingsMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *SettingsMutation) ClearedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *SettingsMutation) EdgeCleared(name string) bool {
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *SettingsMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown Settings 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 *SettingsMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown Settings edge %s", name)
}
// 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
}
var _ ent.Mutation = (*SetupMutation)(nil)
// 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{}),
}
for _, opt := range opts {
opt(m)
}
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
}
}
// 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
}
}
// 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
}
// 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")
}
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 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
}
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 *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)
}
}
// SetSetUpAt sets the "set_up_at" field.
func (m *SetupMutation) SetSetUpAt(t time.Time) {
m.set_up_at = &t
}
// 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
if v == nil {
return
}
return *v, true
}
// 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.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *SetupMutation) OldSetUpAt(ctx context.Context) (v time.Time, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldSetUpAt is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldSetUpAt requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldSetUpAt: %w", err)
}
return oldValue.SetUpAt, nil
}
// ResetSetUpAt resets all changes to the "set_up_at" field.
func (m *SetupMutation) ResetSetUpAt() {
m.set_up_at = nil
}
// Where appends a list predicates to the SetupMutation builder.
func (m *SetupMutation) Where(ps ...predicate.Setup) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the SetupMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *SetupMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Setup, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *SetupMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *SetupMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (Setup).
func (m *SetupMutation) 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 *SetupMutation) Fields() []string {
fields := make([]string, 0, 1)
if m.set_up_at != nil {
fields = append(fields, setup.FieldSetUpAt)
}
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 *SetupMutation) Field(name string) (ent.Value, bool) {
switch name {
case setup.FieldSetUpAt:
return m.SetUpAt()
}
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 *SetupMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case setup.FieldSetUpAt:
return m.OldSetUpAt(ctx)
}
return nil, fmt.Errorf("unknown Setup 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 *SetupMutation) SetField(name string, value ent.Value) error {
switch name {
case setup.FieldSetUpAt:
v, ok := value.(time.Time)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetSetUpAt(v)
return nil
}
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
}
// 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 *SetupMutation) 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 *SetupMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown Setup numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *SetupMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *SetupMutation) 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 *SetupMutation) ClearField(name string) error {
return fmt.Errorf("unknown Setup 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 *SetupMutation) ResetField(name string) error {
switch name {
case setup.FieldSetUpAt:
m.ResetSetUpAt()
return nil
}
return fmt.Errorf("unknown Setup field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *SetupMutation) AddedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *SetupMutation) AddedIDs(name string) []ent.Value {
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *SetupMutation) RemovedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *SetupMutation) RemovedIDs(name string) []ent.Value {
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *SetupMutation) ClearedEdges() []string {
edges := make([]string, 0, 0)
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *SetupMutation) EdgeCleared(name string) bool {
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *SetupMutation) ClearEdge(name string) error {
return fmt.Errorf("unknown Setup 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 *SetupMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown Setup edge %s", name)
}
// TrackedBreachesMutation represents an operation that mutates the TrackedBreaches nodes in the graph.
type TrackedBreachesMutation struct {
config
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{
config: c,
op: op,
typ: TypeTrackedBreaches,
clearedFields: make(map[string]struct{}),
}
for _, opt := range opts {
opt(m)
}
return m
}
// withTrackedBreachesID sets the ID field of the mutation.
func withTrackedBreachesID(id uuid.UUID) trackedbreachesOption {
return func(m *TrackedBreachesMutation) {
var (
err error
once sync.Once
value *TrackedBreaches
)
m.oldValue = func(ctx context.Context) (*TrackedBreaches, error) {
once.Do(func() {
if m.done {
err = errors.New("querying old values post mutation is not allowed")
} else {
value, err = m.Client().TrackedBreaches.Get(ctx, id)
}
})
return value, err
}
m.id = &id
}
}
// withTrackedBreaches sets the old TrackedBreaches of the mutation.
func withTrackedBreaches(node *TrackedBreaches) trackedbreachesOption {
return func(m *TrackedBreachesMutation) {
m.oldValue = func(context.Context) (*TrackedBreaches, 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 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
}
// LocalbreachCleared reports if the "localbreach" edge to the LocalBreach entity was cleared.
func (m *TrackedBreachesMutation) LocalbreachCleared() bool {
return m.clearedlocalbreach
}
// 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{}{}
}
}
// 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)
}
return
}
// 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)
}
return
}
// ResetLocalbreach resets all changes to the "localbreach" edge.
func (m *TrackedBreachesMutation) ResetLocalbreach() {
m.localbreach = nil
m.clearedlocalbreach = false
m.removedlocalbreach = nil
}
// 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{}{}
}
}
// 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{})
}
for i := range ids {
delete(m.hibp, ids[i])
m.removedhibp[ids[i]] = struct{}{}
}
}
// 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)
}
return
}
// 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
}
// 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) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the TrackedBreachesMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *TrackedBreachesMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.TrackedBreaches, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *TrackedBreachesMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *TrackedBreachesMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (TrackedBreaches).
func (m *TrackedBreachesMutation) 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 *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)
}
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 *TrackedBreachesMutation) Field(name string) (ent.Value, bool) {
switch name {
case trackedbreaches.FieldBreach:
return m.Breach()
case trackedbreaches.FieldOnline:
return m.Online()
case trackedbreaches.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 *TrackedBreachesMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case trackedbreaches.FieldBreach:
return m.OldBreach(ctx)
case trackedbreaches.FieldOnline:
return m.OldOnline(ctx)
case trackedbreaches.FieldOwner:
return m.OldOwner(ctx)
}
return nil, fmt.Errorf("unknown TrackedBreaches 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 *TrackedBreachesMutation) SetField(name string, value ent.Value) error {
switch name {
case trackedbreaches.FieldBreach:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
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)
return nil
}
return fmt.Errorf("unknown TrackedBreaches field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *TrackedBreachesMutation) 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 *TrackedBreachesMutation) 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 *TrackedBreachesMutation) AddField(name string, value ent.Value) error {
switch name {
}
return fmt.Errorf("unknown TrackedBreaches numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *TrackedBreachesMutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *TrackedBreachesMutation) 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 *TrackedBreachesMutation) ClearField(name string) error {
return fmt.Errorf("unknown TrackedBreaches 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 *TrackedBreachesMutation) ResetField(name string) error {
switch name {
case trackedbreaches.FieldBreach:
m.ResetBreach()
return nil
case trackedbreaches.FieldOnline:
m.ResetOnline()
return nil
case trackedbreaches.FieldOwner:
m.ResetOwner()
return nil
}
return fmt.Errorf("unknown TrackedBreaches field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
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)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
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
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
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)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
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
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
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)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
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
}
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 *TrackedBreachesMutation) ClearEdge(name string) error {
switch name {
case trackedbreaches.EdgeUser:
m.ClearUser()
return nil
}
return fmt.Errorf("unknown TrackedBreaches 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 *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)
}
// UserMutation represents an operation that mutates the User nodes in the graph.
type UserMutation struct {
config
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
}
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
}
// 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
}
// SetPassword sets the "password" field.
func (m *UserMutation) SetPassword(b []byte) {
m.password = &b
}
// Password returns the value of the "password" field in the mutation.
func (m *UserMutation) Password() (r []byte, exists bool) {
v := m.password
if v == nil {
return
}
return *v, true
}
// OldPassword returns the old "password" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldPassword(ctx context.Context) (v []byte, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPassword requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPassword: %w", err)
}
return oldValue.Password, nil
}
// ResetPassword resets all changes to the "password" field.
func (m *UserMutation) ResetPassword() {
m.password = nil
}
// 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
}
// 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
}
// 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
}
// Where appends a list predicates to the UserMutation builder.
func (m *UserMutation) Where(ps ...predicate.User) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the UserMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.User, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *UserMutation) Op() Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *UserMutation) SetOp(op Op) {
m.op = op
}
// Type returns the node type of this mutation (User).
func (m *UserMutation) Type() string {
return m.typ
}
// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *UserMutation) Fields() []string {
fields := make([]string, 0, 8)
if m.username != nil {
fields = append(fields, user.FieldUsername)
}
if m.email != nil {
fields = append(fields, user.FieldEmail)
}
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)
}
if m.last_login != nil {
fields = append(fields, user.FieldLastLogin)
}
return fields
}
// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *UserMutation) Field(name string) (ent.Value, bool) {
switch name {
case user.FieldUsername:
return m.Username()
case user.FieldEmail:
return m.Email()
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()
case user.FieldLastLogin:
return m.LastLogin()
}
return nil, false
}
// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
switch name {
case user.FieldUsername:
return m.OldUsername(ctx)
case user.FieldEmail:
return m.OldEmail(ctx)
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)
case user.FieldLastLogin:
return m.OldLastLogin(ctx)
}
return nil, fmt.Errorf("unknown User field %s", name)
}
// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *UserMutation) SetField(name string, value ent.Value) error {
switch name {
case user.FieldUsername:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUsername(v)
return nil
case user.FieldEmail:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetEmail(v)
return nil
case user.FieldPassword:
v, ok := value.([]byte)
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
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
}
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
case user.FieldEmail:
m.ResetEmail()
return nil
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
case user.FieldLastLogin:
m.ResetLastLogin()
return nil
}
return fmt.Errorf("unknown User field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *UserMutation) AddedEdges() []string {
edges := make([]string, 0, 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)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *UserMutation) AddedIDs(name string) []ent.Value {
switch name {
case user.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
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *UserMutation) RemovedEdges() []string {
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)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *UserMutation) RemovedIDs(name string) []ent.Value {
switch name {
case user.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
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *UserMutation) ClearedEdges() []string {
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)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *UserMutation) EdgeCleared(name string) bool {
switch name {
case user.EdgeAgekey:
return m.clearedagekey
case user.EdgeTrackedBreaches:
return m.clearedtracked_breaches
case user.EdgeSearchQueries:
return m.clearedsearch_queries
}
return false
}
// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *UserMutation) ClearEdge(name string) error {
switch name {
case user.EdgeAgekey:
m.ClearAgekey()
return nil
}
return fmt.Errorf("unknown User unique edge %s", name)
}
// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *UserMutation) ResetEdge(name string) error {
switch name {
case user.EdgeAgekey:
m.ResetAgekey()
return nil
case user.EdgeTrackedBreaches:
m.ResetTrackedBreaches()
return nil
case user.EdgeSearchQueries:
m.ResetSearchQueries()
return nil
}
return fmt.Errorf("unknown User edge %s", name)
}