771 lines
18 KiB
Go
771 lines
18 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 group
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/gremlin/graph/dsl"
|
|
"entgo.io/ent/entc/integration/gremlin/ent/predicate"
|
|
)
|
|
|
|
// Mutation represents an operation that mutates the Group nodes in the graph.
|
|
type Mutation struct {
|
|
op ent.Op
|
|
typ string
|
|
active *bool
|
|
expire *time.Time
|
|
_type *string
|
|
max_users *int
|
|
addmax_users *int
|
|
name *string
|
|
clearedFields map[string]struct{}
|
|
files map[string]struct{}
|
|
removedfiles map[string]struct{}
|
|
clearedfiles bool
|
|
blocked map[string]struct{}
|
|
removedblocked map[string]struct{}
|
|
clearedblocked bool
|
|
users map[string]struct{}
|
|
removedusers map[string]struct{}
|
|
clearedusers bool
|
|
info *string
|
|
clearedinfo bool
|
|
predicates []predicate.Group
|
|
}
|
|
|
|
// NewMutation creates a new Mutation for the Group entity.
|
|
func NewMutation(op ent.Op) *Mutation {
|
|
return &Mutation{
|
|
op: op,
|
|
typ: "Group",
|
|
clearedFields: make(map[string]struct{}),
|
|
}
|
|
}
|
|
|
|
// Predicates returns the list of predicates set on the mutation.
|
|
func (m *Mutation) Predicates() []predicate.Group {
|
|
return m.predicates
|
|
}
|
|
|
|
// SetActive sets the "active" field.
|
|
func (m *Mutation) SetActive(b bool) {
|
|
m.active = &b
|
|
}
|
|
|
|
// Active returns the value of the "active" field in the mutation.
|
|
func (m *Mutation) Active() (r bool, exists bool) {
|
|
v := m.active
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetActive resets all changes to the "active" field.
|
|
func (m *Mutation) ResetActive() {
|
|
m.active = nil
|
|
}
|
|
|
|
// SetExpire sets the "expire" field.
|
|
func (m *Mutation) SetExpire(t time.Time) {
|
|
m.expire = &t
|
|
}
|
|
|
|
// Expire returns the value of the "expire" field in the mutation.
|
|
func (m *Mutation) Expire() (r time.Time, exists bool) {
|
|
v := m.expire
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ResetExpire resets all changes to the "expire" field.
|
|
func (m *Mutation) ResetExpire() {
|
|
m.expire = nil
|
|
}
|
|
|
|
// SetType sets the "type" field.
|
|
func (m *Mutation) SetType(s string) {
|
|
m._type = &s
|
|
}
|
|
|
|
// GetType returns the value of the "type" field in the mutation.
|
|
func (m *Mutation) GetType() (r string, exists bool) {
|
|
v := m._type
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearType clears the value of the "type" field.
|
|
func (m *Mutation) ClearType() {
|
|
m._type = nil
|
|
m.clearedFields[FieldType] = struct{}{}
|
|
}
|
|
|
|
// TypeCleared returns if the "type" field was cleared in this mutation.
|
|
func (m *Mutation) TypeCleared() bool {
|
|
_, ok := m.clearedFields[FieldType]
|
|
return ok
|
|
}
|
|
|
|
// ResetType resets all changes to the "type" field.
|
|
func (m *Mutation) ResetType() {
|
|
m._type = nil
|
|
delete(m.clearedFields, FieldType)
|
|
}
|
|
|
|
// SetMaxUsers sets the "max_users" field.
|
|
func (m *Mutation) SetMaxUsers(i int) {
|
|
m.max_users = &i
|
|
m.addmax_users = nil
|
|
}
|
|
|
|
// MaxUsers returns the value of the "max_users" field in the mutation.
|
|
func (m *Mutation) MaxUsers() (r int, exists bool) {
|
|
v := m.max_users
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// AddMaxUsers adds i to the "max_users" field.
|
|
func (m *Mutation) AddMaxUsers(i int) {
|
|
if m.addmax_users != nil {
|
|
*m.addmax_users += i
|
|
} else {
|
|
m.addmax_users = &i
|
|
}
|
|
}
|
|
|
|
// AddedMaxUsers returns the value that was added to the "max_users" field in this mutation.
|
|
func (m *Mutation) AddedMaxUsers() (r int, exists bool) {
|
|
v := m.addmax_users
|
|
if v == nil {
|
|
return
|
|
}
|
|
return *v, true
|
|
}
|
|
|
|
// ClearMaxUsers clears the value of the "max_users" field.
|
|
func (m *Mutation) ClearMaxUsers() {
|
|
m.max_users = nil
|
|
m.addmax_users = nil
|
|
m.clearedFields[FieldMaxUsers] = struct{}{}
|
|
}
|
|
|
|
// MaxUsersCleared returns if the "max_users" field was cleared in this mutation.
|
|
func (m *Mutation) MaxUsersCleared() bool {
|
|
_, ok := m.clearedFields[FieldMaxUsers]
|
|
return ok
|
|
}
|
|
|
|
// ResetMaxUsers resets all changes to the "max_users" field.
|
|
func (m *Mutation) ResetMaxUsers() {
|
|
m.max_users = nil
|
|
m.addmax_users = nil
|
|
delete(m.clearedFields, FieldMaxUsers)
|
|
}
|
|
|
|
// 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
|
|
}
|
|
|
|
// AddFileIDs adds the "files" edge to the File entity by ids.
|
|
func (m *Mutation) AddFileIDs(ids ...string) {
|
|
if m.files == nil {
|
|
m.files = make(map[string]struct{})
|
|
}
|
|
for i := range ids {
|
|
m.files[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// ClearFiles clears the "files" edge to the File entity.
|
|
func (m *Mutation) ClearFiles() {
|
|
m.clearedfiles = true
|
|
}
|
|
|
|
// FilesCleared reports if the "files" edge to the File entity was cleared.
|
|
func (m *Mutation) FilesCleared() bool {
|
|
return m.clearedfiles
|
|
}
|
|
|
|
// RemoveFileIDs removes the "files" edge to the File entity by IDs.
|
|
func (m *Mutation) RemoveFileIDs(ids ...string) {
|
|
if m.removedfiles == nil {
|
|
m.removedfiles = make(map[string]struct{})
|
|
}
|
|
for i := range ids {
|
|
delete(m.files, ids[i])
|
|
m.removedfiles[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// RemovedFiles returns the removed IDs of the "files" edge to the File entity.
|
|
func (m *Mutation) RemovedFilesIDs() (ids []string) {
|
|
for id := range m.removedfiles {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// FilesIDs returns the "files" edge IDs in the mutation.
|
|
func (m *Mutation) FilesIDs() (ids []string) {
|
|
for id := range m.files {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetFiles resets all changes to the "files" edge.
|
|
func (m *Mutation) ResetFiles() {
|
|
m.files = nil
|
|
m.clearedfiles = false
|
|
m.removedfiles = nil
|
|
}
|
|
|
|
// AddBlockedIDs adds the "blocked" edge to the User entity by ids.
|
|
func (m *Mutation) AddBlockedIDs(ids ...string) {
|
|
if m.blocked == nil {
|
|
m.blocked = make(map[string]struct{})
|
|
}
|
|
for i := range ids {
|
|
m.blocked[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// ClearBlocked clears the "blocked" edge to the User entity.
|
|
func (m *Mutation) ClearBlocked() {
|
|
m.clearedblocked = true
|
|
}
|
|
|
|
// BlockedCleared reports if the "blocked" edge to the User entity was cleared.
|
|
func (m *Mutation) BlockedCleared() bool {
|
|
return m.clearedblocked
|
|
}
|
|
|
|
// RemoveBlockedIDs removes the "blocked" edge to the User entity by IDs.
|
|
func (m *Mutation) RemoveBlockedIDs(ids ...string) {
|
|
if m.removedblocked == nil {
|
|
m.removedblocked = make(map[string]struct{})
|
|
}
|
|
for i := range ids {
|
|
delete(m.blocked, ids[i])
|
|
m.removedblocked[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// RemovedBlocked returns the removed IDs of the "blocked" edge to the User entity.
|
|
func (m *Mutation) RemovedBlockedIDs() (ids []string) {
|
|
for id := range m.removedblocked {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// BlockedIDs returns the "blocked" edge IDs in the mutation.
|
|
func (m *Mutation) BlockedIDs() (ids []string) {
|
|
for id := range m.blocked {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetBlocked resets all changes to the "blocked" edge.
|
|
func (m *Mutation) ResetBlocked() {
|
|
m.blocked = nil
|
|
m.clearedblocked = false
|
|
m.removedblocked = nil
|
|
}
|
|
|
|
// AddUserIDs adds the "users" edge to the User entity by ids.
|
|
func (m *Mutation) AddUserIDs(ids ...string) {
|
|
if m.users == nil {
|
|
m.users = make(map[string]struct{})
|
|
}
|
|
for i := range ids {
|
|
m.users[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// ClearUsers clears the "users" edge to the User entity.
|
|
func (m *Mutation) ClearUsers() {
|
|
m.clearedusers = true
|
|
}
|
|
|
|
// UsersCleared reports if the "users" edge to the User entity was cleared.
|
|
func (m *Mutation) UsersCleared() bool {
|
|
return m.clearedusers
|
|
}
|
|
|
|
// RemoveUserIDs removes the "users" edge to the User entity by IDs.
|
|
func (m *Mutation) RemoveUserIDs(ids ...string) {
|
|
if m.removedusers == nil {
|
|
m.removedusers = make(map[string]struct{})
|
|
}
|
|
for i := range ids {
|
|
delete(m.users, ids[i])
|
|
m.removedusers[ids[i]] = struct{}{}
|
|
}
|
|
}
|
|
|
|
// RemovedUsers returns the removed IDs of the "users" edge to the User entity.
|
|
func (m *Mutation) RemovedUsersIDs() (ids []string) {
|
|
for id := range m.removedusers {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// UsersIDs returns the "users" edge IDs in the mutation.
|
|
func (m *Mutation) UsersIDs() (ids []string) {
|
|
for id := range m.users {
|
|
ids = append(ids, id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetUsers resets all changes to the "users" edge.
|
|
func (m *Mutation) ResetUsers() {
|
|
m.users = nil
|
|
m.clearedusers = false
|
|
m.removedusers = nil
|
|
}
|
|
|
|
// SetInfoID sets the "info" edge to the GroupInfo entity by id.
|
|
func (m *Mutation) SetInfoID(id string) {
|
|
m.info = &id
|
|
}
|
|
|
|
// ClearInfo clears the "info" edge to the GroupInfo entity.
|
|
func (m *Mutation) ClearInfo() {
|
|
m.clearedinfo = true
|
|
}
|
|
|
|
// InfoCleared reports if the "info" edge to the GroupInfo entity was cleared.
|
|
func (m *Mutation) InfoCleared() bool {
|
|
return m.clearedinfo
|
|
}
|
|
|
|
// InfoID returns the "info" edge ID in the mutation.
|
|
func (m *Mutation) InfoID() (id string, exists bool) {
|
|
if m.info != nil {
|
|
return *m.info, true
|
|
}
|
|
return
|
|
}
|
|
|
|
// InfoIDs returns the "info" edge IDs in the mutation.
|
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
// InfoID instead. It exists only for internal usage by the builders.
|
|
func (m *Mutation) InfoIDs() (ids []string) {
|
|
if id := m.info; id != nil {
|
|
ids = append(ids, *id)
|
|
}
|
|
return
|
|
}
|
|
|
|
// ResetInfo resets all changes to the "info" edge.
|
|
func (m *Mutation) ResetInfo() {
|
|
m.info = nil
|
|
m.clearedinfo = false
|
|
}
|
|
|
|
// Where appends a list predicates to the Mutation builder.
|
|
func (m *Mutation) Where(ps ...predicate.Group) {
|
|
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(*dsl.Traversal)) {
|
|
p := make([]predicate.Group, 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 (Group).
|
|
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, 5)
|
|
if m.active != nil {
|
|
fields = append(fields, FieldActive)
|
|
}
|
|
if m.expire != nil {
|
|
fields = append(fields, FieldExpire)
|
|
}
|
|
if m._type != nil {
|
|
fields = append(fields, FieldType)
|
|
}
|
|
if m.max_users != nil {
|
|
fields = append(fields, FieldMaxUsers)
|
|
}
|
|
if m.name != nil {
|
|
fields = append(fields, FieldName)
|
|
}
|
|
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 FieldActive:
|
|
return m.Active()
|
|
case FieldExpire:
|
|
return m.Expire()
|
|
case FieldType:
|
|
return m.GetType()
|
|
case FieldMaxUsers:
|
|
return m.MaxUsers()
|
|
case FieldName:
|
|
return m.Name()
|
|
}
|
|
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 Group 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 FieldActive:
|
|
v, ok := value.(bool)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetActive(v)
|
|
return nil
|
|
case FieldExpire:
|
|
v, ok := value.(time.Time)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetExpire(v)
|
|
return nil
|
|
case FieldType:
|
|
v, ok := value.(string)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetType(v)
|
|
return nil
|
|
case FieldMaxUsers:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.SetMaxUsers(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
|
|
}
|
|
return fmt.Errorf("unknown Group 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.addmax_users != nil {
|
|
fields = append(fields, FieldMaxUsers)
|
|
}
|
|
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 FieldMaxUsers:
|
|
return m.AddedMaxUsers()
|
|
}
|
|
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 FieldMaxUsers:
|
|
v, ok := value.(int)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
}
|
|
m.AddMaxUsers(v)
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Group 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(FieldType) {
|
|
fields = append(fields, FieldType)
|
|
}
|
|
if m.FieldCleared(FieldMaxUsers) {
|
|
fields = append(fields, FieldMaxUsers)
|
|
}
|
|
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 FieldType:
|
|
m.ClearType()
|
|
return nil
|
|
case FieldMaxUsers:
|
|
m.ClearMaxUsers()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Group 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 FieldActive:
|
|
m.ResetActive()
|
|
return nil
|
|
case FieldExpire:
|
|
m.ResetExpire()
|
|
return nil
|
|
case FieldType:
|
|
m.ResetType()
|
|
return nil
|
|
case FieldMaxUsers:
|
|
m.ResetMaxUsers()
|
|
return nil
|
|
case FieldName:
|
|
m.ResetName()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Group 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.files != nil {
|
|
edges = append(edges, EdgeFiles)
|
|
}
|
|
if m.blocked != nil {
|
|
edges = append(edges, EdgeBlocked)
|
|
}
|
|
if m.users != nil {
|
|
edges = append(edges, EdgeUsers)
|
|
}
|
|
if m.info != nil {
|
|
edges = append(edges, EdgeInfo)
|
|
}
|
|
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 EdgeFiles:
|
|
ids := make([]ent.Value, 0, len(m.files))
|
|
for id := range m.files {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
case EdgeBlocked:
|
|
ids := make([]ent.Value, 0, len(m.blocked))
|
|
for id := range m.blocked {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
case EdgeUsers:
|
|
ids := make([]ent.Value, 0, len(m.users))
|
|
for id := range m.users {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
case EdgeInfo:
|
|
if id := m.info; 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.removedfiles != nil {
|
|
edges = append(edges, EdgeFiles)
|
|
}
|
|
if m.removedblocked != nil {
|
|
edges = append(edges, EdgeBlocked)
|
|
}
|
|
if m.removedusers != nil {
|
|
edges = append(edges, EdgeUsers)
|
|
}
|
|
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 EdgeFiles:
|
|
ids := make([]ent.Value, 0, len(m.removedfiles))
|
|
for id := range m.removedfiles {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
case EdgeBlocked:
|
|
ids := make([]ent.Value, 0, len(m.removedblocked))
|
|
for id := range m.removedblocked {
|
|
ids = append(ids, id)
|
|
}
|
|
return ids
|
|
case EdgeUsers:
|
|
ids := make([]ent.Value, 0, len(m.removedusers))
|
|
for id := range m.removedusers {
|
|
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.clearedfiles {
|
|
edges = append(edges, EdgeFiles)
|
|
}
|
|
if m.clearedblocked {
|
|
edges = append(edges, EdgeBlocked)
|
|
}
|
|
if m.clearedusers {
|
|
edges = append(edges, EdgeUsers)
|
|
}
|
|
if m.clearedinfo {
|
|
edges = append(edges, EdgeInfo)
|
|
}
|
|
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 EdgeFiles:
|
|
return m.clearedfiles
|
|
case EdgeBlocked:
|
|
return m.clearedblocked
|
|
case EdgeUsers:
|
|
return m.clearedusers
|
|
case EdgeInfo:
|
|
return m.clearedinfo
|
|
}
|
|
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 EdgeInfo:
|
|
m.ClearInfo()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Group 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 EdgeFiles:
|
|
m.ResetFiles()
|
|
return nil
|
|
case EdgeBlocked:
|
|
m.ResetBlocked()
|
|
return nil
|
|
case EdgeUsers:
|
|
m.ResetUsers()
|
|
return nil
|
|
case EdgeInfo:
|
|
m.ResetInfo()
|
|
return nil
|
|
}
|
|
return fmt.Errorf("unknown Group edge %s", name)
|
|
}
|