2023-08-19 04:52:15 +02:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
|
|
"entgo.io/ent/schema/field"
|
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/localbreach"
|
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/predicate"
|
2023-08-20 05:20:33 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/schema"
|
2023-08-19 04:52:15 +02:00
|
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/trackedbreaches"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
// LocalBreachUpdate is the builder for updating LocalBreach entities.
|
|
|
|
type LocalBreachUpdate struct {
|
|
|
|
config
|
|
|
|
hooks []Hook
|
|
|
|
mutation *LocalBreachMutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the LocalBreachUpdate builder.
|
|
|
|
func (lbu *LocalBreachUpdate) Where(ps ...predicate.LocalBreach) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.Where(ps...)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetName sets the "name" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetName(s string) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetName(s)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDate sets the "date" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetDate(t time.Time) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetDate(t)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableDate sets the "date" field if the given value is not nil.
|
|
|
|
func (lbu *LocalBreachUpdate) SetNillableDate(t *time.Time) *LocalBreachUpdate {
|
|
|
|
if t != nil {
|
|
|
|
lbu.SetDate(*t)
|
|
|
|
}
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDescription sets the "description" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetDescription(s string) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetDescription(s)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
|
|
func (lbu *LocalBreachUpdate) SetNillableDescription(s *string) *LocalBreachUpdate {
|
|
|
|
if s != nil {
|
|
|
|
lbu.SetDescription(*s)
|
|
|
|
}
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
|
|
func (lbu *LocalBreachUpdate) ClearDescription() *LocalBreachUpdate {
|
|
|
|
lbu.mutation.ClearDescription()
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsVerified sets the "is_verified" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetIsVerified(b bool) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetIsVerified(b)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// SetContainsPasswords sets the "contains_passwords" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetContainsPasswords(b bool) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetContainsPasswords(b)
|
2023-08-19 04:52:15 +02:00
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetContainsHashes sets the "contains_hashes" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetContainsHashes(b bool) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetContainsHashes(b)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetContainsEmails sets the "contains_emails" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetContainsEmails(b bool) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetContainsEmails(b)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// SetContainsUsernames sets the "contains_usernames" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetContainsUsernames(b bool) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetContainsUsernames(b)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetHashType sets the "hash_type" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetHashType(s string) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetHashType(s)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableHashType sets the "hash_type" field if the given value is not nil.
|
|
|
|
func (lbu *LocalBreachUpdate) SetNillableHashType(s *string) *LocalBreachUpdate {
|
|
|
|
if s != nil {
|
|
|
|
lbu.SetHashType(*s)
|
|
|
|
}
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashType clears the value of the "hash_type" field.
|
|
|
|
func (lbu *LocalBreachUpdate) ClearHashType() *LocalBreachUpdate {
|
|
|
|
lbu.mutation.ClearHashType()
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetHashSalted sets the "hash_salted" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetHashSalted(b bool) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetHashSalted(b)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableHashSalted sets the "hash_salted" field if the given value is not nil.
|
|
|
|
func (lbu *LocalBreachUpdate) SetNillableHashSalted(b *bool) *LocalBreachUpdate {
|
|
|
|
if b != nil {
|
|
|
|
lbu.SetHashSalted(*b)
|
|
|
|
}
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashSalted clears the value of the "hash_salted" field.
|
|
|
|
func (lbu *LocalBreachUpdate) ClearHashSalted() *LocalBreachUpdate {
|
|
|
|
lbu.mutation.ClearHashSalted()
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetHashPeppered sets the "hash_peppered" field.
|
|
|
|
func (lbu *LocalBreachUpdate) SetHashPeppered(b bool) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.SetHashPeppered(b)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableHashPeppered sets the "hash_peppered" field if the given value is not nil.
|
|
|
|
func (lbu *LocalBreachUpdate) SetNillableHashPeppered(b *bool) *LocalBreachUpdate {
|
|
|
|
if b != nil {
|
|
|
|
lbu.SetHashPeppered(*b)
|
|
|
|
}
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashPeppered clears the value of the "hash_peppered" field.
|
|
|
|
func (lbu *LocalBreachUpdate) ClearHashPeppered() *LocalBreachUpdate {
|
|
|
|
lbu.mutation.ClearHashPeppered()
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetData sets the "data" field.
|
2023-08-20 05:20:33 +02:00
|
|
|
func (lbu *LocalBreachUpdate) SetData(s *schema.Data) *LocalBreachUpdate {
|
2023-08-19 04:52:15 +02:00
|
|
|
lbu.mutation.SetData(s)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearData clears the value of the "data" field.
|
|
|
|
func (lbu *LocalBreachUpdate) ClearData() *LocalBreachUpdate {
|
|
|
|
lbu.mutation.ClearData()
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddTrackedBreachIDs adds the "tracked_breaches" edge to the TrackedBreaches entity by IDs.
|
|
|
|
func (lbu *LocalBreachUpdate) AddTrackedBreachIDs(ids ...uuid.UUID) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.AddTrackedBreachIDs(ids...)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddTrackedBreaches adds the "tracked_breaches" edges to the TrackedBreaches entity.
|
|
|
|
func (lbu *LocalBreachUpdate) AddTrackedBreaches(t ...*TrackedBreaches) *LocalBreachUpdate {
|
|
|
|
ids := make([]uuid.UUID, len(t))
|
|
|
|
for i := range t {
|
|
|
|
ids[i] = t[i].ID
|
|
|
|
}
|
|
|
|
return lbu.AddTrackedBreachIDs(ids...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mutation returns the LocalBreachMutation object of the builder.
|
|
|
|
func (lbu *LocalBreachUpdate) Mutation() *LocalBreachMutation {
|
|
|
|
return lbu.mutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearTrackedBreaches clears all "tracked_breaches" edges to the TrackedBreaches entity.
|
|
|
|
func (lbu *LocalBreachUpdate) ClearTrackedBreaches() *LocalBreachUpdate {
|
|
|
|
lbu.mutation.ClearTrackedBreaches()
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveTrackedBreachIDs removes the "tracked_breaches" edge to TrackedBreaches entities by IDs.
|
|
|
|
func (lbu *LocalBreachUpdate) RemoveTrackedBreachIDs(ids ...uuid.UUID) *LocalBreachUpdate {
|
|
|
|
lbu.mutation.RemoveTrackedBreachIDs(ids...)
|
|
|
|
return lbu
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveTrackedBreaches removes "tracked_breaches" edges to TrackedBreaches entities.
|
|
|
|
func (lbu *LocalBreachUpdate) RemoveTrackedBreaches(t ...*TrackedBreaches) *LocalBreachUpdate {
|
|
|
|
ids := make([]uuid.UUID, len(t))
|
|
|
|
for i := range t {
|
|
|
|
ids[i] = t[i].ID
|
|
|
|
}
|
|
|
|
return lbu.RemoveTrackedBreachIDs(ids...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
|
|
func (lbu *LocalBreachUpdate) Save(ctx context.Context) (int, error) {
|
|
|
|
return withHooks(ctx, lbu.sqlSave, lbu.mutation, lbu.hooks)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
|
|
func (lbu *LocalBreachUpdate) SaveX(ctx context.Context) int {
|
|
|
|
affected, err := lbu.Save(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return affected
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the query.
|
|
|
|
func (lbu *LocalBreachUpdate) Exec(ctx context.Context) error {
|
|
|
|
_, err := lbu.Save(ctx)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (lbu *LocalBreachUpdate) ExecX(ctx context.Context) {
|
|
|
|
if err := lbu.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
|
|
func (lbu *LocalBreachUpdate) check() error {
|
|
|
|
if v, ok := lbu.mutation.Name(); ok {
|
|
|
|
if err := localbreach.NameValidator(v); err != nil {
|
|
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "LocalBreach.name": %w`, err)}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (lbu *LocalBreachUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
|
|
if err := lbu.check(); err != nil {
|
|
|
|
return n, err
|
|
|
|
}
|
|
|
|
_spec := sqlgraph.NewUpdateSpec(localbreach.Table, localbreach.Columns, sqlgraph.NewFieldSpec(localbreach.FieldID, field.TypeUUID))
|
|
|
|
if ps := lbu.mutation.predicates; len(ps) > 0 {
|
|
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
|
|
for i := range ps {
|
|
|
|
ps[i](selector)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.Name(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldName, field.TypeString, value)
|
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.Date(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldDate, field.TypeTime, value)
|
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.Description(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldDescription, field.TypeString, value)
|
|
|
|
}
|
|
|
|
if lbu.mutation.DescriptionCleared() {
|
|
|
|
_spec.ClearField(localbreach.FieldDescription, field.TypeString)
|
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.IsVerified(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldIsVerified, field.TypeBool, value)
|
|
|
|
}
|
2023-08-20 05:20:33 +02:00
|
|
|
if value, ok := lbu.mutation.ContainsPasswords(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldContainsPasswords, field.TypeBool, value)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.ContainsHashes(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldContainsHashes, field.TypeBool, value)
|
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.ContainsEmails(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldContainsEmails, field.TypeBool, value)
|
|
|
|
}
|
2023-08-20 05:20:33 +02:00
|
|
|
if value, ok := lbu.mutation.ContainsUsernames(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldContainsUsernames, field.TypeBool, value)
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
if value, ok := lbu.mutation.HashType(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldHashType, field.TypeString, value)
|
|
|
|
}
|
|
|
|
if lbu.mutation.HashTypeCleared() {
|
|
|
|
_spec.ClearField(localbreach.FieldHashType, field.TypeString)
|
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.HashSalted(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldHashSalted, field.TypeBool, value)
|
|
|
|
}
|
|
|
|
if lbu.mutation.HashSaltedCleared() {
|
|
|
|
_spec.ClearField(localbreach.FieldHashSalted, field.TypeBool)
|
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.HashPeppered(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldHashPeppered, field.TypeBool, value)
|
|
|
|
}
|
|
|
|
if lbu.mutation.HashPepperedCleared() {
|
|
|
|
_spec.ClearField(localbreach.FieldHashPeppered, field.TypeBool)
|
|
|
|
}
|
|
|
|
if value, ok := lbu.mutation.Data(); ok {
|
2023-08-20 05:20:33 +02:00
|
|
|
_spec.SetField(localbreach.FieldData, field.TypeJSON, value)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if lbu.mutation.DataCleared() {
|
2023-08-20 05:20:33 +02:00
|
|
|
_spec.ClearField(localbreach.FieldData, field.TypeJSON)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if lbu.mutation.TrackedBreachesCleared() {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2M,
|
|
|
|
Inverse: true,
|
|
|
|
Table: localbreach.TrackedBreachesTable,
|
|
|
|
Columns: localbreach.TrackedBreachesPrimaryKey,
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
|
|
|
IDSpec: sqlgraph.NewFieldSpec(trackedbreaches.FieldID, field.TypeUUID),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
|
}
|
|
|
|
if nodes := lbu.mutation.RemovedTrackedBreachesIDs(); len(nodes) > 0 && !lbu.mutation.TrackedBreachesCleared() {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2M,
|
|
|
|
Inverse: true,
|
|
|
|
Table: localbreach.TrackedBreachesTable,
|
|
|
|
Columns: localbreach.TrackedBreachesPrimaryKey,
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
|
|
|
IDSpec: sqlgraph.NewFieldSpec(trackedbreaches.FieldID, field.TypeUUID),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
|
}
|
|
|
|
if nodes := lbu.mutation.TrackedBreachesIDs(); len(nodes) > 0 {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2M,
|
|
|
|
Inverse: true,
|
|
|
|
Table: localbreach.TrackedBreachesTable,
|
|
|
|
Columns: localbreach.TrackedBreachesPrimaryKey,
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
|
|
|
IDSpec: sqlgraph.NewFieldSpec(trackedbreaches.FieldID, field.TypeUUID),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
|
}
|
|
|
|
if n, err = sqlgraph.UpdateNodes(ctx, lbu.driver, _spec); err != nil {
|
|
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
|
|
err = &NotFoundError{localbreach.Label}
|
|
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
|
|
}
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
lbu.mutation.done = true
|
|
|
|
return n, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// LocalBreachUpdateOne is the builder for updating a single LocalBreach entity.
|
|
|
|
type LocalBreachUpdateOne struct {
|
|
|
|
config
|
|
|
|
fields []string
|
|
|
|
hooks []Hook
|
|
|
|
mutation *LocalBreachMutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetName sets the "name" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetName(s string) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetName(s)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDate sets the "date" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetDate(t time.Time) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetDate(t)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableDate sets the "date" field if the given value is not nil.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetNillableDate(t *time.Time) *LocalBreachUpdateOne {
|
|
|
|
if t != nil {
|
|
|
|
lbuo.SetDate(*t)
|
|
|
|
}
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetDescription sets the "description" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetDescription(s string) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetDescription(s)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetNillableDescription(s *string) *LocalBreachUpdateOne {
|
|
|
|
if s != nil {
|
|
|
|
lbuo.SetDescription(*s)
|
|
|
|
}
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearDescription clears the value of the "description" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) ClearDescription() *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.ClearDescription()
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetIsVerified sets the "is_verified" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetIsVerified(b bool) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetIsVerified(b)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// SetContainsPasswords sets the "contains_passwords" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetContainsPasswords(b bool) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetContainsPasswords(b)
|
2023-08-19 04:52:15 +02:00
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetContainsHashes sets the "contains_hashes" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetContainsHashes(b bool) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetContainsHashes(b)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetContainsEmails sets the "contains_emails" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetContainsEmails(b bool) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetContainsEmails(b)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
2023-08-20 05:20:33 +02:00
|
|
|
// SetContainsUsernames sets the "contains_usernames" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetContainsUsernames(b bool) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetContainsUsernames(b)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
2023-08-19 04:52:15 +02:00
|
|
|
// SetHashType sets the "hash_type" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetHashType(s string) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetHashType(s)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableHashType sets the "hash_type" field if the given value is not nil.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetNillableHashType(s *string) *LocalBreachUpdateOne {
|
|
|
|
if s != nil {
|
|
|
|
lbuo.SetHashType(*s)
|
|
|
|
}
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashType clears the value of the "hash_type" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) ClearHashType() *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.ClearHashType()
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetHashSalted sets the "hash_salted" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetHashSalted(b bool) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetHashSalted(b)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableHashSalted sets the "hash_salted" field if the given value is not nil.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetNillableHashSalted(b *bool) *LocalBreachUpdateOne {
|
|
|
|
if b != nil {
|
|
|
|
lbuo.SetHashSalted(*b)
|
|
|
|
}
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashSalted clears the value of the "hash_salted" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) ClearHashSalted() *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.ClearHashSalted()
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetHashPeppered sets the "hash_peppered" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetHashPeppered(b bool) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.SetHashPeppered(b)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableHashPeppered sets the "hash_peppered" field if the given value is not nil.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SetNillableHashPeppered(b *bool) *LocalBreachUpdateOne {
|
|
|
|
if b != nil {
|
|
|
|
lbuo.SetHashPeppered(*b)
|
|
|
|
}
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearHashPeppered clears the value of the "hash_peppered" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) ClearHashPeppered() *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.ClearHashPeppered()
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetData sets the "data" field.
|
2023-08-20 05:20:33 +02:00
|
|
|
func (lbuo *LocalBreachUpdateOne) SetData(s *schema.Data) *LocalBreachUpdateOne {
|
2023-08-19 04:52:15 +02:00
|
|
|
lbuo.mutation.SetData(s)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearData clears the value of the "data" field.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) ClearData() *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.ClearData()
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddTrackedBreachIDs adds the "tracked_breaches" edge to the TrackedBreaches entity by IDs.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) AddTrackedBreachIDs(ids ...uuid.UUID) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.AddTrackedBreachIDs(ids...)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddTrackedBreaches adds the "tracked_breaches" edges to the TrackedBreaches entity.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) AddTrackedBreaches(t ...*TrackedBreaches) *LocalBreachUpdateOne {
|
|
|
|
ids := make([]uuid.UUID, len(t))
|
|
|
|
for i := range t {
|
|
|
|
ids[i] = t[i].ID
|
|
|
|
}
|
|
|
|
return lbuo.AddTrackedBreachIDs(ids...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mutation returns the LocalBreachMutation object of the builder.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) Mutation() *LocalBreachMutation {
|
|
|
|
return lbuo.mutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearTrackedBreaches clears all "tracked_breaches" edges to the TrackedBreaches entity.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) ClearTrackedBreaches() *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.ClearTrackedBreaches()
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveTrackedBreachIDs removes the "tracked_breaches" edge to TrackedBreaches entities by IDs.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) RemoveTrackedBreachIDs(ids ...uuid.UUID) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.RemoveTrackedBreachIDs(ids...)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoveTrackedBreaches removes "tracked_breaches" edges to TrackedBreaches entities.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) RemoveTrackedBreaches(t ...*TrackedBreaches) *LocalBreachUpdateOne {
|
|
|
|
ids := make([]uuid.UUID, len(t))
|
|
|
|
for i := range t {
|
|
|
|
ids[i] = t[i].ID
|
|
|
|
}
|
|
|
|
return lbuo.RemoveTrackedBreachIDs(ids...)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the LocalBreachUpdate builder.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) Where(ps ...predicate.LocalBreach) *LocalBreachUpdateOne {
|
|
|
|
lbuo.mutation.Where(ps...)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
|
|
// The default is selecting all fields defined in the entity schema.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) Select(field string, fields ...string) *LocalBreachUpdateOne {
|
|
|
|
lbuo.fields = append([]string{field}, fields...)
|
|
|
|
return lbuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save executes the query and returns the updated LocalBreach entity.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) Save(ctx context.Context) (*LocalBreach, error) {
|
|
|
|
return withHooks(ctx, lbuo.sqlSave, lbuo.mutation, lbuo.hooks)
|
|
|
|
}
|
|
|
|
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) SaveX(ctx context.Context) *LocalBreach {
|
|
|
|
node, err := lbuo.Save(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return node
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the query on the entity.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) Exec(ctx context.Context) error {
|
|
|
|
_, err := lbuo.Save(ctx)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) ExecX(ctx context.Context) {
|
|
|
|
if err := lbuo.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
|
|
func (lbuo *LocalBreachUpdateOne) check() error {
|
|
|
|
if v, ok := lbuo.mutation.Name(); ok {
|
|
|
|
if err := localbreach.NameValidator(v); err != nil {
|
|
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "LocalBreach.name": %w`, err)}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (lbuo *LocalBreachUpdateOne) sqlSave(ctx context.Context) (_node *LocalBreach, err error) {
|
|
|
|
if err := lbuo.check(); err != nil {
|
|
|
|
return _node, err
|
|
|
|
}
|
|
|
|
_spec := sqlgraph.NewUpdateSpec(localbreach.Table, localbreach.Columns, sqlgraph.NewFieldSpec(localbreach.FieldID, field.TypeUUID))
|
|
|
|
id, ok := lbuo.mutation.ID()
|
|
|
|
if !ok {
|
|
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "LocalBreach.id" for update`)}
|
|
|
|
}
|
|
|
|
_spec.Node.ID.Value = id
|
|
|
|
if fields := lbuo.fields; len(fields) > 0 {
|
|
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
|
|
_spec.Node.Columns = append(_spec.Node.Columns, localbreach.FieldID)
|
|
|
|
for _, f := range fields {
|
|
|
|
if !localbreach.ValidColumn(f) {
|
|
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
|
|
}
|
|
|
|
if f != localbreach.FieldID {
|
|
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ps := lbuo.mutation.predicates; len(ps) > 0 {
|
|
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
|
|
for i := range ps {
|
|
|
|
ps[i](selector)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.Name(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldName, field.TypeString, value)
|
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.Date(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldDate, field.TypeTime, value)
|
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.Description(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldDescription, field.TypeString, value)
|
|
|
|
}
|
|
|
|
if lbuo.mutation.DescriptionCleared() {
|
|
|
|
_spec.ClearField(localbreach.FieldDescription, field.TypeString)
|
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.IsVerified(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldIsVerified, field.TypeBool, value)
|
|
|
|
}
|
2023-08-20 05:20:33 +02:00
|
|
|
if value, ok := lbuo.mutation.ContainsPasswords(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldContainsPasswords, field.TypeBool, value)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.ContainsHashes(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldContainsHashes, field.TypeBool, value)
|
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.ContainsEmails(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldContainsEmails, field.TypeBool, value)
|
|
|
|
}
|
2023-08-20 05:20:33 +02:00
|
|
|
if value, ok := lbuo.mutation.ContainsUsernames(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldContainsUsernames, field.TypeBool, value)
|
|
|
|
}
|
2023-08-19 04:52:15 +02:00
|
|
|
if value, ok := lbuo.mutation.HashType(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldHashType, field.TypeString, value)
|
|
|
|
}
|
|
|
|
if lbuo.mutation.HashTypeCleared() {
|
|
|
|
_spec.ClearField(localbreach.FieldHashType, field.TypeString)
|
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.HashSalted(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldHashSalted, field.TypeBool, value)
|
|
|
|
}
|
|
|
|
if lbuo.mutation.HashSaltedCleared() {
|
|
|
|
_spec.ClearField(localbreach.FieldHashSalted, field.TypeBool)
|
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.HashPeppered(); ok {
|
|
|
|
_spec.SetField(localbreach.FieldHashPeppered, field.TypeBool, value)
|
|
|
|
}
|
|
|
|
if lbuo.mutation.HashPepperedCleared() {
|
|
|
|
_spec.ClearField(localbreach.FieldHashPeppered, field.TypeBool)
|
|
|
|
}
|
|
|
|
if value, ok := lbuo.mutation.Data(); ok {
|
2023-08-20 05:20:33 +02:00
|
|
|
_spec.SetField(localbreach.FieldData, field.TypeJSON, value)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if lbuo.mutation.DataCleared() {
|
2023-08-20 05:20:33 +02:00
|
|
|
_spec.ClearField(localbreach.FieldData, field.TypeJSON)
|
2023-08-19 04:52:15 +02:00
|
|
|
}
|
|
|
|
if lbuo.mutation.TrackedBreachesCleared() {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2M,
|
|
|
|
Inverse: true,
|
|
|
|
Table: localbreach.TrackedBreachesTable,
|
|
|
|
Columns: localbreach.TrackedBreachesPrimaryKey,
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
|
|
|
IDSpec: sqlgraph.NewFieldSpec(trackedbreaches.FieldID, field.TypeUUID),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
|
}
|
|
|
|
if nodes := lbuo.mutation.RemovedTrackedBreachesIDs(); len(nodes) > 0 && !lbuo.mutation.TrackedBreachesCleared() {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2M,
|
|
|
|
Inverse: true,
|
|
|
|
Table: localbreach.TrackedBreachesTable,
|
|
|
|
Columns: localbreach.TrackedBreachesPrimaryKey,
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
|
|
|
IDSpec: sqlgraph.NewFieldSpec(trackedbreaches.FieldID, field.TypeUUID),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
|
}
|
|
|
|
if nodes := lbuo.mutation.TrackedBreachesIDs(); len(nodes) > 0 {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2M,
|
|
|
|
Inverse: true,
|
|
|
|
Table: localbreach.TrackedBreachesTable,
|
|
|
|
Columns: localbreach.TrackedBreachesPrimaryKey,
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
|
|
|
IDSpec: sqlgraph.NewFieldSpec(trackedbreaches.FieldID, field.TypeUUID),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
|
}
|
|
|
|
_node = &LocalBreach{config: lbuo.config}
|
|
|
|
_spec.Assign = _node.assignValues
|
|
|
|
_spec.ScanValues = _node.scanValues
|
|
|
|
if err = sqlgraph.UpdateNode(ctx, lbuo.driver, _spec); err != nil {
|
|
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
|
|
err = &NotFoundError{localbreach.Label}
|
|
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
lbuo.mutation.done = true
|
|
|
|
return _node, nil
|
|
|
|
}
|