Files
ent/entc/integration/migrate/entv1/user/mutation.go

1080 lines
26 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 user
import (
"context"
"fmt"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/entc/integration/migrate/entv1/predicate"
)
// Mutation represents an operation that mutates the User nodes in the graph.
type Mutation struct {
op ent.Op
typ string
age *int32
addage *int32
name *string
description *string
nickname *string
address *string
renamed *string
old_token *string
blob *[]byte
state *State
status *string
workplace *string
drop_optional *string
clearedFields map[string]struct{}
parent *int
clearedparent bool
children map[int]struct{}
removedchildren map[int]struct{}
clearedchildren bool
spouse *int
clearedspouse bool
car *int
clearedcar bool
predicates []predicate.User
}
// NewMutation creates a new Mutation for the User entity.
func NewMutation(op ent.Op) *Mutation {
return &Mutation{
op: op,
typ: "User",
clearedFields: make(map[string]struct{}),
}
}
// Predicates returns the list of predicates set on the mutation.
func (m *Mutation) Predicates() []predicate.User {
return m.predicates
}
// SetAge sets the "age" field.
func (m *Mutation) SetAge(i int32) {
m.age = &i
m.addage = nil
}
// Age returns the value of the "age" field in the mutation.
func (m *Mutation) Age() (r int32, exists bool) {
v := m.age
if v == nil {
return
}
return *v, true
}
// AddAge adds i to the "age" field.
func (m *Mutation) AddAge(i int32) {
if m.addage != nil {
*m.addage += i
} else {
m.addage = &i
}
}
// AddedAge returns the value that was added to the "age" field in this mutation.
func (m *Mutation) AddedAge() (r int32, exists bool) {
v := m.addage
if v == nil {
return
}
return *v, true
}
// ResetAge resets all changes to the "age" field.
func (m *Mutation) ResetAge() {
m.age = nil
m.addage = nil
}
// SetName sets the "name" field.
func (m *Mutation) SetName(s string) {
m.name = &s
}
// Name returns the value of the "name" field in the mutation.
func (m *Mutation) Name() (r string, exists bool) {
v := m.name
if v == nil {
return
}
return *v, true
}
// ResetName resets all changes to the "name" field.
func (m *Mutation) ResetName() {
m.name = nil
}
// SetDescription sets the "description" field.
func (m *Mutation) SetDescription(s string) {
m.description = &s
}
// Description returns the value of the "description" field in the mutation.
func (m *Mutation) Description() (r string, exists bool) {
v := m.description
if v == nil {
return
}
return *v, true
}
// ClearDescription clears the value of the "description" field.
func (m *Mutation) ClearDescription() {
m.description = nil
m.clearedFields[FieldDescription] = struct{}{}
}
// DescriptionCleared returns if the "description" field was cleared in this mutation.
func (m *Mutation) DescriptionCleared() bool {
_, ok := m.clearedFields[FieldDescription]
return ok
}
// ResetDescription resets all changes to the "description" field.
func (m *Mutation) ResetDescription() {
m.description = nil
delete(m.clearedFields, FieldDescription)
}
// SetNickname sets the "nickname" field.
func (m *Mutation) SetNickname(s string) {
m.nickname = &s
}
// Nickname returns the value of the "nickname" field in the mutation.
func (m *Mutation) Nickname() (r string, exists bool) {
v := m.nickname
if v == nil {
return
}
return *v, true
}
// ResetNickname resets all changes to the "nickname" field.
func (m *Mutation) ResetNickname() {
m.nickname = nil
}
// SetAddress sets the "address" field.
func (m *Mutation) SetAddress(s string) {
m.address = &s
}
// Address returns the value of the "address" field in the mutation.
func (m *Mutation) Address() (r string, exists bool) {
v := m.address
if v == nil {
return
}
return *v, true
}
// ClearAddress clears the value of the "address" field.
func (m *Mutation) ClearAddress() {
m.address = nil
m.clearedFields[FieldAddress] = struct{}{}
}
// AddressCleared returns if the "address" field was cleared in this mutation.
func (m *Mutation) AddressCleared() bool {
_, ok := m.clearedFields[FieldAddress]
return ok
}
// ResetAddress resets all changes to the "address" field.
func (m *Mutation) ResetAddress() {
m.address = nil
delete(m.clearedFields, FieldAddress)
}
// SetRenamed sets the "renamed" field.
func (m *Mutation) SetRenamed(s string) {
m.renamed = &s
}
// Renamed returns the value of the "renamed" field in the mutation.
func (m *Mutation) Renamed() (r string, exists bool) {
v := m.renamed
if v == nil {
return
}
return *v, true
}
// ClearRenamed clears the value of the "renamed" field.
func (m *Mutation) ClearRenamed() {
m.renamed = nil
m.clearedFields[FieldRenamed] = struct{}{}
}
// RenamedCleared returns if the "renamed" field was cleared in this mutation.
func (m *Mutation) RenamedCleared() bool {
_, ok := m.clearedFields[FieldRenamed]
return ok
}
// ResetRenamed resets all changes to the "renamed" field.
func (m *Mutation) ResetRenamed() {
m.renamed = nil
delete(m.clearedFields, FieldRenamed)
}
// SetOldToken sets the "old_token" field.
func (m *Mutation) SetOldToken(s string) {
m.old_token = &s
}
// OldToken returns the value of the "old_token" field in the mutation.
func (m *Mutation) OldToken() (r string, exists bool) {
v := m.old_token
if v == nil {
return
}
return *v, true
}
// ResetOldToken resets all changes to the "old_token" field.
func (m *Mutation) ResetOldToken() {
m.old_token = nil
}
// SetBlob sets the "blob" field.
func (m *Mutation) SetBlob(b []byte) {
m.blob = &b
}
// Blob returns the value of the "blob" field in the mutation.
func (m *Mutation) Blob() (r []byte, exists bool) {
v := m.blob
if v == nil {
return
}
return *v, true
}
// ClearBlob clears the value of the "blob" field.
func (m *Mutation) ClearBlob() {
m.blob = nil
m.clearedFields[FieldBlob] = struct{}{}
}
// BlobCleared returns if the "blob" field was cleared in this mutation.
func (m *Mutation) BlobCleared() bool {
_, ok := m.clearedFields[FieldBlob]
return ok
}
// ResetBlob resets all changes to the "blob" field.
func (m *Mutation) ResetBlob() {
m.blob = nil
delete(m.clearedFields, FieldBlob)
}
// SetState sets the "state" field.
func (m *Mutation) SetState(u State) {
m.state = &u
}
// State returns the value of the "state" field in the mutation.
func (m *Mutation) State() (r State, exists bool) {
v := m.state
if v == nil {
return
}
return *v, true
}
// ClearState clears the value of the "state" field.
func (m *Mutation) ClearState() {
m.state = nil
m.clearedFields[FieldState] = struct{}{}
}
// StateCleared returns if the "state" field was cleared in this mutation.
func (m *Mutation) StateCleared() bool {
_, ok := m.clearedFields[FieldState]
return ok
}
// ResetState resets all changes to the "state" field.
func (m *Mutation) ResetState() {
m.state = nil
delete(m.clearedFields, FieldState)
}
// SetStatus sets the "status" field.
func (m *Mutation) SetStatus(s string) {
m.status = &s
}
// Status returns the value of the "status" field in the mutation.
func (m *Mutation) Status() (r string, exists bool) {
v := m.status
if v == nil {
return
}
return *v, true
}
// ClearStatus clears the value of the "status" field.
func (m *Mutation) ClearStatus() {
m.status = nil
m.clearedFields[FieldStatus] = struct{}{}
}
// StatusCleared returns if the "status" field was cleared in this mutation.
func (m *Mutation) StatusCleared() bool {
_, ok := m.clearedFields[FieldStatus]
return ok
}
// ResetStatus resets all changes to the "status" field.
func (m *Mutation) ResetStatus() {
m.status = nil
delete(m.clearedFields, FieldStatus)
}
// SetWorkplace sets the "workplace" field.
func (m *Mutation) SetWorkplace(s string) {
m.workplace = &s
}
// Workplace returns the value of the "workplace" field in the mutation.
func (m *Mutation) Workplace() (r string, exists bool) {
v := m.workplace
if v == nil {
return
}
return *v, true
}
// ClearWorkplace clears the value of the "workplace" field.
func (m *Mutation) ClearWorkplace() {
m.workplace = nil
m.clearedFields[FieldWorkplace] = struct{}{}
}
// WorkplaceCleared returns if the "workplace" field was cleared in this mutation.
func (m *Mutation) WorkplaceCleared() bool {
_, ok := m.clearedFields[FieldWorkplace]
return ok
}
// ResetWorkplace resets all changes to the "workplace" field.
func (m *Mutation) ResetWorkplace() {
m.workplace = nil
delete(m.clearedFields, FieldWorkplace)
}
// SetDropOptional sets the "drop_optional" field.
func (m *Mutation) SetDropOptional(s string) {
m.drop_optional = &s
}
// DropOptional returns the value of the "drop_optional" field in the mutation.
func (m *Mutation) DropOptional() (r string, exists bool) {
v := m.drop_optional
if v == nil {
return
}
return *v, true
}
// ClearDropOptional clears the value of the "drop_optional" field.
func (m *Mutation) ClearDropOptional() {
m.drop_optional = nil
m.clearedFields[FieldDropOptional] = struct{}{}
}
// DropOptionalCleared returns if the "drop_optional" field was cleared in this mutation.
func (m *Mutation) DropOptionalCleared() bool {
_, ok := m.clearedFields[FieldDropOptional]
return ok
}
// ResetDropOptional resets all changes to the "drop_optional" field.
func (m *Mutation) ResetDropOptional() {
m.drop_optional = nil
delete(m.clearedFields, FieldDropOptional)
}
// SetParentID sets the "parent" edge to the User entity by id.
func (m *Mutation) SetParentID(id int) {
m.parent = &id
}
// ClearParent clears the "parent" edge to the User entity.
func (m *Mutation) ClearParent() {
m.clearedparent = true
}
// ParentCleared reports if the "parent" edge to the User 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 int, 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 []int) {
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
}
// AddChildIDs adds the "children" edge to the User entity by ids.
func (m *Mutation) AddChildIDs(ids ...int) {
if m.children == nil {
m.children = make(map[int]struct{})
}
for i := range ids {
m.children[ids[i]] = struct{}{}
}
}
// ClearChildren clears the "children" edge to the User entity.
func (m *Mutation) ClearChildren() {
m.clearedchildren = true
}
// ChildrenCleared reports if the "children" edge to the User entity was cleared.
func (m *Mutation) ChildrenCleared() bool {
return m.clearedchildren
}
// RemoveChildIDs removes the "children" edge to the User entity by IDs.
func (m *Mutation) RemoveChildIDs(ids ...int) {
if m.removedchildren == nil {
m.removedchildren = make(map[int]struct{})
}
for i := range ids {
delete(m.children, ids[i])
m.removedchildren[ids[i]] = struct{}{}
}
}
// RemovedChildren returns the removed IDs of the "children" edge to the User entity.
func (m *Mutation) RemovedChildrenIDs() (ids []int) {
for id := range m.removedchildren {
ids = append(ids, id)
}
return
}
// ChildrenIDs returns the "children" edge IDs in the mutation.
func (m *Mutation) ChildrenIDs() (ids []int) {
for id := range m.children {
ids = append(ids, id)
}
return
}
// ResetChildren resets all changes to the "children" edge.
func (m *Mutation) ResetChildren() {
m.children = nil
m.clearedchildren = false
m.removedchildren = nil
}
// SetSpouseID sets the "spouse" edge to the User entity by id.
func (m *Mutation) SetSpouseID(id int) {
m.spouse = &id
}
// ClearSpouse clears the "spouse" edge to the User entity.
func (m *Mutation) ClearSpouse() {
m.clearedspouse = true
}
// SpouseCleared reports if the "spouse" edge to the User entity was cleared.
func (m *Mutation) SpouseCleared() bool {
return m.clearedspouse
}
// SpouseID returns the "spouse" edge ID in the mutation.
func (m *Mutation) SpouseID() (id int, exists bool) {
if m.spouse != nil {
return *m.spouse, true
}
return
}
// SpouseIDs returns the "spouse" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// SpouseID instead. It exists only for internal usage by the builders.
func (m *Mutation) SpouseIDs() (ids []int) {
if id := m.spouse; id != nil {
ids = append(ids, *id)
}
return
}
// ResetSpouse resets all changes to the "spouse" edge.
func (m *Mutation) ResetSpouse() {
m.spouse = nil
m.clearedspouse = false
}
// SetCarID sets the "car" edge to the Car entity by id.
func (m *Mutation) SetCarID(id int) {
m.car = &id
}
// ClearCar clears the "car" edge to the Car entity.
func (m *Mutation) ClearCar() {
m.clearedcar = true
}
// CarCleared reports if the "car" edge to the Car entity was cleared.
func (m *Mutation) CarCleared() bool {
return m.clearedcar
}
// CarID returns the "car" edge ID in the mutation.
func (m *Mutation) CarID() (id int, exists bool) {
if m.car != nil {
return *m.car, true
}
return
}
// CarIDs returns the "car" edge IDs in the mutation.
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
// CarID instead. It exists only for internal usage by the builders.
func (m *Mutation) CarIDs() (ids []int) {
if id := m.car; id != nil {
ids = append(ids, *id)
}
return
}
// ResetCar resets all changes to the "car" edge.
func (m *Mutation) ResetCar() {
m.car = nil
m.clearedcar = false
}
// Where appends a list predicates to the Mutation builder.
func (m *Mutation) Where(ps ...predicate.User) {
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.User, 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 (User).
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, 12)
if m.age != nil {
fields = append(fields, FieldAge)
}
if m.name != nil {
fields = append(fields, FieldName)
}
if m.description != nil {
fields = append(fields, FieldDescription)
}
if m.nickname != nil {
fields = append(fields, FieldNickname)
}
if m.address != nil {
fields = append(fields, FieldAddress)
}
if m.renamed != nil {
fields = append(fields, FieldRenamed)
}
if m.old_token != nil {
fields = append(fields, FieldOldToken)
}
if m.blob != nil {
fields = append(fields, FieldBlob)
}
if m.state != nil {
fields = append(fields, FieldState)
}
if m.status != nil {
fields = append(fields, FieldStatus)
}
if m.workplace != nil {
fields = append(fields, FieldWorkplace)
}
if m.drop_optional != nil {
fields = append(fields, FieldDropOptional)
}
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 FieldAge:
return m.Age()
case FieldName:
return m.Name()
case FieldDescription:
return m.Description()
case FieldNickname:
return m.Nickname()
case FieldAddress:
return m.Address()
case FieldRenamed:
return m.Renamed()
case FieldOldToken:
return m.OldToken()
case FieldBlob:
return m.Blob()
case FieldState:
return m.State()
case FieldStatus:
return m.Status()
case FieldWorkplace:
return m.Workplace()
case FieldDropOptional:
return m.DropOptional()
}
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 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 *Mutation) SetField(name string, value ent.Value) error {
switch name {
case FieldAge:
v, ok := value.(int32)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAge(v)
return nil
case FieldName:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetName(v)
return nil
case FieldDescription:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDescription(v)
return nil
case FieldNickname:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetNickname(v)
return nil
case FieldAddress:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetAddress(v)
return nil
case FieldRenamed:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetRenamed(v)
return nil
case FieldOldToken:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetOldToken(v)
return nil
case FieldBlob:
v, ok := value.([]byte)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetBlob(v)
return nil
case FieldState:
v, ok := value.(State)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetState(v)
return nil
case FieldStatus:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetStatus(v)
return nil
case FieldWorkplace:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetWorkplace(v)
return nil
case FieldDropOptional:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetDropOptional(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 *Mutation) AddedFields() []string {
var fields []string
if m.addage != nil {
fields = append(fields, FieldAge)
}
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 FieldAge:
return m.AddedAge()
}
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 FieldAge:
v, ok := value.(int32)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.AddAge(v)
return nil
}
return fmt.Errorf("unknown User numeric field %s", name)
}
// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *Mutation) ClearedFields() []string {
var fields []string
if m.FieldCleared(FieldDescription) {
fields = append(fields, FieldDescription)
}
if m.FieldCleared(FieldAddress) {
fields = append(fields, FieldAddress)
}
if m.FieldCleared(FieldRenamed) {
fields = append(fields, FieldRenamed)
}
if m.FieldCleared(FieldBlob) {
fields = append(fields, FieldBlob)
}
if m.FieldCleared(FieldState) {
fields = append(fields, FieldState)
}
if m.FieldCleared(FieldStatus) {
fields = append(fields, FieldStatus)
}
if m.FieldCleared(FieldWorkplace) {
fields = append(fields, FieldWorkplace)
}
if m.FieldCleared(FieldDropOptional) {
fields = append(fields, FieldDropOptional)
}
return fields
}
// 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 {
switch name {
case FieldDescription:
m.ClearDescription()
return nil
case FieldAddress:
m.ClearAddress()
return nil
case FieldRenamed:
m.ClearRenamed()
return nil
case FieldBlob:
m.ClearBlob()
return nil
case FieldState:
m.ClearState()
return nil
case FieldStatus:
m.ClearStatus()
return nil
case FieldWorkplace:
m.ClearWorkplace()
return nil
case FieldDropOptional:
m.ClearDropOptional()
return nil
}
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 *Mutation) ResetField(name string) error {
switch name {
case FieldAge:
m.ResetAge()
return nil
case FieldName:
m.ResetName()
return nil
case FieldDescription:
m.ResetDescription()
return nil
case FieldNickname:
m.ResetNickname()
return nil
case FieldAddress:
m.ResetAddress()
return nil
case FieldRenamed:
m.ResetRenamed()
return nil
case FieldOldToken:
m.ResetOldToken()
return nil
case FieldBlob:
m.ResetBlob()
return nil
case FieldState:
m.ResetState()
return nil
case FieldStatus:
m.ResetStatus()
return nil
case FieldWorkplace:
m.ResetWorkplace()
return nil
case FieldDropOptional:
m.ResetDropOptional()
return nil
}
return fmt.Errorf("unknown User field %s", name)
}
// AddedEdges returns all edge names that were set/added in this mutation.
func (m *Mutation) AddedEdges() []string {
edges := make([]string, 0, 4)
if m.parent != nil {
edges = append(edges, EdgeParent)
}
if m.children != nil {
edges = append(edges, EdgeChildren)
}
if m.spouse != nil {
edges = append(edges, EdgeSpouse)
}
if m.car != nil {
edges = append(edges, EdgeCar)
}
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 EdgeChildren:
ids := make([]ent.Value, 0, len(m.children))
for id := range m.children {
ids = append(ids, id)
}
return ids
case EdgeSpouse:
if id := m.spouse; id != nil {
return []ent.Value{*id}
}
case EdgeCar:
if id := m.car; id != nil {
return []ent.Value{*id}
}
}
return nil
}
// RemovedEdges returns all edge names that were removed in this mutation.
func (m *Mutation) RemovedEdges() []string {
edges := make([]string, 0, 4)
if m.removedchildren != nil {
edges = append(edges, EdgeChildren)
}
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 EdgeChildren:
ids := make([]ent.Value, 0, len(m.removedchildren))
for id := range m.removedchildren {
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, 4)
if m.clearedparent {
edges = append(edges, EdgeParent)
}
if m.clearedchildren {
edges = append(edges, EdgeChildren)
}
if m.clearedspouse {
edges = append(edges, EdgeSpouse)
}
if m.clearedcar {
edges = append(edges, EdgeCar)
}
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 EdgeChildren:
return m.clearedchildren
case EdgeSpouse:
return m.clearedspouse
case EdgeCar:
return m.clearedcar
}
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
case EdgeSpouse:
m.ClearSpouse()
return nil
case EdgeCar:
m.ClearCar()
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 *Mutation) ResetEdge(name string) error {
switch name {
case EdgeParent:
m.ResetParent()
return nil
case EdgeChildren:
m.ResetChildren()
return nil
case EdgeSpouse:
m.ResetSpouse()
return nil
case EdgeCar:
m.ResetCar()
return nil
}
return fmt.Errorf("unknown User edge %s", name)
}