272 lines
9.7 KiB
Go
272 lines
9.7 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"git.dotya.ml/mirre-mt/pcmt/ent/localbreach"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// LocalBreach is the model entity for the LocalBreach schema.
|
|
type LocalBreach struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// Name holds the value of the "name" field.
|
|
Name string `json:"name,omitempty"`
|
|
// Date holds the value of the "date" field.
|
|
Date time.Time `json:"date,omitempty"`
|
|
// Description holds the value of the "description" field.
|
|
Description *string `json:"description,omitempty"`
|
|
// IsVerified holds the value of the "is_verified" field.
|
|
IsVerified bool `json:"is_verified,omitempty"`
|
|
// ContainsPasswds holds the value of the "contains_passwds" field.
|
|
ContainsPasswds bool `json:"contains_passwds,omitempty"`
|
|
// ContainsHashes holds the value of the "contains_hashes" field.
|
|
ContainsHashes bool `json:"contains_hashes,omitempty"`
|
|
// ContainsEmails holds the value of the "contains_emails" field.
|
|
ContainsEmails bool `json:"contains_emails,omitempty"`
|
|
// MD5, SHA1, Argon2id...
|
|
HashType *string `json:"hash_type,omitempty"`
|
|
// HashSalted holds the value of the "hash_salted" field.
|
|
HashSalted *bool `json:"hash_salted,omitempty"`
|
|
// HashPeppered holds the value of the "hash_peppered" field.
|
|
HashPeppered *bool `json:"hash_peppered,omitempty"`
|
|
// Data holds the value of the "data" field.
|
|
Data *string `json:"data,omitempty"`
|
|
// CreatedAt holds the value of the "created_at" field.
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the LocalBreachQuery when eager-loading is set.
|
|
Edges LocalBreachEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// LocalBreachEdges holds the relations/edges for other nodes in the graph.
|
|
type LocalBreachEdges struct {
|
|
// TrackedBreaches holds the value of the tracked_breaches edge.
|
|
TrackedBreaches []*TrackedBreaches `json:"tracked_breaches,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// TrackedBreachesOrErr returns the TrackedBreaches value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e LocalBreachEdges) TrackedBreachesOrErr() ([]*TrackedBreaches, error) {
|
|
if e.loadedTypes[0] {
|
|
return e.TrackedBreaches, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "tracked_breaches"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*LocalBreach) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case localbreach.FieldIsVerified, localbreach.FieldContainsPasswds, localbreach.FieldContainsHashes, localbreach.FieldContainsEmails, localbreach.FieldHashSalted, localbreach.FieldHashPeppered:
|
|
values[i] = new(sql.NullBool)
|
|
case localbreach.FieldName, localbreach.FieldDescription, localbreach.FieldHashType, localbreach.FieldData:
|
|
values[i] = new(sql.NullString)
|
|
case localbreach.FieldDate, localbreach.FieldCreatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case localbreach.FieldID:
|
|
values[i] = new(uuid.UUID)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the LocalBreach fields.
|
|
func (lb *LocalBreach) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case localbreach.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
lb.ID = *value
|
|
}
|
|
case localbreach.FieldName:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
|
} else if value.Valid {
|
|
lb.Name = value.String
|
|
}
|
|
case localbreach.FieldDate:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field date", values[i])
|
|
} else if value.Valid {
|
|
lb.Date = value.Time
|
|
}
|
|
case localbreach.FieldDescription:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
} else if value.Valid {
|
|
lb.Description = new(string)
|
|
*lb.Description = value.String
|
|
}
|
|
case localbreach.FieldIsVerified:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_verified", values[i])
|
|
} else if value.Valid {
|
|
lb.IsVerified = value.Bool
|
|
}
|
|
case localbreach.FieldContainsPasswds:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field contains_passwds", values[i])
|
|
} else if value.Valid {
|
|
lb.ContainsPasswds = value.Bool
|
|
}
|
|
case localbreach.FieldContainsHashes:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field contains_hashes", values[i])
|
|
} else if value.Valid {
|
|
lb.ContainsHashes = value.Bool
|
|
}
|
|
case localbreach.FieldContainsEmails:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field contains_emails", values[i])
|
|
} else if value.Valid {
|
|
lb.ContainsEmails = value.Bool
|
|
}
|
|
case localbreach.FieldHashType:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field hash_type", values[i])
|
|
} else if value.Valid {
|
|
lb.HashType = new(string)
|
|
*lb.HashType = value.String
|
|
}
|
|
case localbreach.FieldHashSalted:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field hash_salted", values[i])
|
|
} else if value.Valid {
|
|
lb.HashSalted = new(bool)
|
|
*lb.HashSalted = value.Bool
|
|
}
|
|
case localbreach.FieldHashPeppered:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field hash_peppered", values[i])
|
|
} else if value.Valid {
|
|
lb.HashPeppered = new(bool)
|
|
*lb.HashPeppered = value.Bool
|
|
}
|
|
case localbreach.FieldData:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field data", values[i])
|
|
} else if value.Valid {
|
|
lb.Data = new(string)
|
|
*lb.Data = value.String
|
|
}
|
|
case localbreach.FieldCreatedAt:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
|
} else if value.Valid {
|
|
lb.CreatedAt = value.Time
|
|
}
|
|
default:
|
|
lb.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the LocalBreach.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (lb *LocalBreach) Value(name string) (ent.Value, error) {
|
|
return lb.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryTrackedBreaches queries the "tracked_breaches" edge of the LocalBreach entity.
|
|
func (lb *LocalBreach) QueryTrackedBreaches() *TrackedBreachesQuery {
|
|
return NewLocalBreachClient(lb.config).QueryTrackedBreaches(lb)
|
|
}
|
|
|
|
// Update returns a builder for updating this LocalBreach.
|
|
// Note that you need to call LocalBreach.Unwrap() before calling this method if this LocalBreach
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (lb *LocalBreach) Update() *LocalBreachUpdateOne {
|
|
return NewLocalBreachClient(lb.config).UpdateOne(lb)
|
|
}
|
|
|
|
// Unwrap unwraps the LocalBreach entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (lb *LocalBreach) Unwrap() *LocalBreach {
|
|
_tx, ok := lb.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: LocalBreach is not a transactional entity")
|
|
}
|
|
lb.config.driver = _tx.drv
|
|
return lb
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (lb *LocalBreach) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("LocalBreach(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", lb.ID))
|
|
builder.WriteString("name=")
|
|
builder.WriteString(lb.Name)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("date=")
|
|
builder.WriteString(lb.Date.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
if v := lb.Description; v != nil {
|
|
builder.WriteString("description=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_verified=")
|
|
builder.WriteString(fmt.Sprintf("%v", lb.IsVerified))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("contains_passwds=")
|
|
builder.WriteString(fmt.Sprintf("%v", lb.ContainsPasswds))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("contains_hashes=")
|
|
builder.WriteString(fmt.Sprintf("%v", lb.ContainsHashes))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("contains_emails=")
|
|
builder.WriteString(fmt.Sprintf("%v", lb.ContainsEmails))
|
|
builder.WriteString(", ")
|
|
if v := lb.HashType; v != nil {
|
|
builder.WriteString("hash_type=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := lb.HashSalted; v != nil {
|
|
builder.WriteString("hash_salted=")
|
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := lb.HashPeppered; v != nil {
|
|
builder.WriteString("hash_peppered=")
|
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
|
}
|
|
builder.WriteString(", ")
|
|
if v := lb.Data; v != nil {
|
|
builder.WriteString("data=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", ")
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(lb.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// LocalBreaches is a parsable slice of LocalBreach.
|
|
type LocalBreaches []*LocalBreach
|