Files
upstream-mirror 4b3ad0b611
Some checks failed
Atlas CI Public / lint (push) Failing after 13s
Atlas CI Public / sync (push) Has been skipped
snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 22:12:36 +05:00

458 lines
11 KiB
Go

// Copyright 2019-present Facebook Inc. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by ent, DO NOT EDIT.
package blob
import (
"context"
"fmt"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/entc/integration/customid/ent/predicate"
"github.com/google/uuid"
)
// Mutation represents an operation that mutates the Blob nodes in the graph.
type Mutation struct {
op ent.Op
typ string
uuid *uuid.UUID
count *int
addcount *int
clearedFields map[string]struct{}
parent *uuid.UUID
clearedparent bool
links map[uuid.UUID]struct{}
removedlinks map[uuid.UUID]struct{}
clearedlinks bool
predicates []predicate.Blob
}
// NewMutation creates a new Mutation for the Blob entity.
func NewMutation(op ent.Op) *Mutation {
return &Mutation{
op: op,
typ: "Blob",
clearedFields: make(map[string]struct{}),
}
}
// Predicates returns the list of predicates set on the mutation.
func (m *Mutation) Predicates() []predicate.Blob {
return m.predicates
}
// SetUUID sets the "uuid" field.
func (m *Mutation) SetUUID(u uuid.UUID) {
m.uuid = &u
}
// UUID returns the value of the "uuid" field in the mutation.
func (m *Mutation) UUID() (r uuid.UUID, exists bool) {
v := m.uuid
if v == nil {
return
}
return *v, true
}
// ResetUUID resets all changes to the "uuid" field.
func (m *Mutation) ResetUUID() {
m.uuid = nil
}
// SetCount sets the "count" field.
func (m *Mutation) SetCount(i int) {
m.count = &i
m.addcount = nil
}
// Count returns the value of the "count" field in the mutation.
func (m *Mutation) Count() (r int, exists bool) {
v := m.count
if v == nil {
return
}
return *v, true
}
// AddCount adds i to the "count" field.
func (m *Mutation) AddCount(i int) {
if m.addcount != nil {
*m.addcount += i
} else {
m.addcount = &i
}
}
// AddedCount returns the value that was added to the "count" field in this mutation.
func (m *Mutation) AddedCount() (r int, exists bool) {
v := m.addcount
if v == nil {
return
}
return *v, true
}
// ResetCount resets all changes to the "count" field.
func (m *Mutation) ResetCount() {
m.count = nil
m.addcount = nil
}
// SetParentID sets the "parent" edge to the Blob entity by id.
func (m *Mutation) SetParentID(id uuid.UUID) {
m.parent = &id
}
// ClearParent clears the "parent" edge to the Blob entity.
func (m *Mutation) ClearParent() {
m.clearedparent = true
}
// ParentCleared reports if the "parent" edge to the Blob entity was cleared.
func (m *Mutation) ParentCleared() bool {
return m.clearedparent
}
// ParentID returns the "parent" edge ID in the mutation.
func (m *Mutation) ParentID() (id uuid.UUID, exists bool) {
if m.parent != nil {
return *m.parent, true
}
return
}
// ParentIDs returns the "parent" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// ParentID instead. It exists only for internal usage by the builders.
func (m *Mutation) ParentIDs() (ids []uuid.UUID) {
if id := m.parent; id != nil {
ids = append(ids, *id)
}
return
}
// ResetParent resets all changes to the "parent" edge.
func (m *Mutation) ResetParent() {
m.parent = nil
m.clearedparent = false
}
// AddLinkIDs adds the "links" edge to the Blob entity by ids.
func (m *Mutation) AddLinkIDs(ids ...uuid.UUID) {
if m.links == nil {
m.links = make(map[uuid.UUID]struct{})
}
for i := range ids {
m.links[ids[i]] = struct{}{}
}
}
// ClearLinks clears the "links" edge to the Blob entity.
func (m *Mutation) ClearLinks() {
m.clearedlinks = true
}
// LinksCleared reports if the "links" edge to the Blob entity was cleared.
func (m *Mutation) LinksCleared() bool {
return m.clearedlinks
}
// RemoveLinkIDs removes the "links" edge to the Blob entity by IDs.
func (m *Mutation) RemoveLinkIDs(ids ...uuid.UUID) {
if m.removedlinks == nil {
m.removedlinks = make(map[uuid.UUID]struct{})
}
for i := range ids {
delete(m.links, ids[i])
m.removedlinks[ids[i]] = struct{}{}
}
}
// RemovedLinks returns the removed IDs of the "links" edge to the Blob entity.
func (m *Mutation) RemovedLinksIDs() (ids []uuid.UUID) {
for id := range m.removedlinks {
ids = append(ids, id)
}
return
}
// LinksIDs returns the "links" edge IDs in the mutation.
func (m *Mutation) LinksIDs() (ids []uuid.UUID) {
for id := range m.links {
ids = append(ids, id)
}
return
}
// ResetLinks resets all changes to the "links" edge.
func (m *Mutation) ResetLinks() {
m.links = nil
m.clearedlinks = false
m.removedlinks = nil
}
// Where appends a list predicates to the Mutation builder.
func (m *Mutation) Where(ps ...predicate.Blob) {
m.predicates = append(m.predicates, ps...)
}
// WhereP appends storage-level predicates to the Mutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *Mutation) WhereP(ps ...func(*sql.Selector)) {
p := make([]predicate.Blob, len(ps))
for i := range ps {
p[i] = ps[i]
}
m.Where(p...)
}
// Op returns the operation name.
func (m *Mutation) Op() ent.Op {
return m.op
}
// SetOp allows setting the mutation operation.
func (m *Mutation) SetOp(op ent.Op) {
m.op = op
}
// Type returns the node type of this mutation (Blob).
func (m *Mutation) 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 *Mutation) Fields() []string {
fields := make([]string, 0, 2)
if m.uuid != nil {
fields = append(fields, FieldUUID)
}
if m.count != nil {
fields = append(fields, FieldCount)
}
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 *Mutation) Field(name string) (ent.Value, bool) {
switch name {
case FieldUUID:
return m.UUID()
case FieldCount:
return m.Count()
}
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 *Mutation) OldField(ctx context.Context, name string) (ent.Value, error) {
return nil, fmt.Errorf("unknown Blob 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 *Mutation) SetField(name string, value ent.Value) error {
switch name {
case FieldUUID:
v, ok := value.(uuid.UUID)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetUUID(v)
return nil
case FieldCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetCount(v)
return nil
}
return fmt.Errorf("unknown Blob field %s", name)
}
// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *Mutation) AddedFields() []string {
var fields []string
if m.addcount != nil {
fields = append(fields, FieldCount)
}
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 *Mutation) AddedField(name string) (ent.Value, bool) {
switch name {
case FieldCount:
return m.AddedCount()
}
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 *Mutation) AddField(name string, value ent.Value) error {
switch name {
case FieldCount:
v, ok := value.(int)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddCount(v)
return nil
}
return fmt.Errorf("unknown Blob numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *Mutation) ClearedFields() []string {
return nil
}
// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *Mutation) 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 *Mutation) ClearField(name string) error {
return fmt.Errorf("unknown Blob 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 *Mutation) ResetField(name string) error {
switch name {
case FieldUUID:
m.ResetUUID()
return nil
case FieldCount:
m.ResetCount()
return nil
}
return fmt.Errorf("unknown Blob field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *Mutation) AddedEdges() []string {
edges := make([]string, 0, 2)
if m.parent != nil {
edges = append(edges, EdgeParent)
}
if m.links != nil {
edges = append(edges, EdgeLinks)
}
return edges
}
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *Mutation) AddedIDs(name string) []ent.Value {
switch name {
case EdgeParent:
if id := m.parent; id != nil {
return []ent.Value{*id}
}
case EdgeLinks:
ids := make([]ent.Value, 0, len(m.links))
for id := range m.links {
ids = append(ids, id)
}
return ids
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *Mutation) RemovedEdges() []string {
edges := make([]string, 0, 2)
if m.removedlinks != nil {
edges = append(edges, EdgeLinks)
}
return edges
}
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *Mutation) RemovedIDs(name string) []ent.Value {
switch name {
case EdgeLinks:
ids := make([]ent.Value, 0, len(m.removedlinks))
for id := range m.removedlinks {
ids = append(ids, id)
}
return ids
}
return nil
}
// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *Mutation) ClearedEdges() []string {
edges := make([]string, 0, 2)
if m.clearedparent {
edges = append(edges, EdgeParent)
}
if m.clearedlinks {
edges = append(edges, EdgeLinks)
}
return edges
}
// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *Mutation) EdgeCleared(name string) bool {
switch name {
case EdgeParent:
return m.clearedparent
case EdgeLinks:
return m.clearedlinks
}
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 *Mutation) ClearEdge(name string) error {
switch name {
case EdgeParent:
m.ClearParent()
return nil
}
return fmt.Errorf("unknown Blob 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 *Mutation) ResetEdge(name string) error {
switch name {
case EdgeParent:
m.ResetParent()
return nil
case EdgeLinks:
m.ResetLinks()
return nil
}
return fmt.Errorf("unknown Blob edge %s", name)
}