|
@@ -9,6 +9,7 @@ import (
|
|
|
"sync"
|
|
|
"time"
|
|
|
"wechat-api/ent/agent"
|
|
|
+ "wechat-api/ent/agentbase"
|
|
|
"wechat-api/ent/batchmsg"
|
|
|
"wechat-api/ent/category"
|
|
|
"wechat-api/ent/contact"
|
|
@@ -44,6 +45,7 @@ const (
|
|
|
|
|
|
// Node types.
|
|
|
TypeAgent = "Agent"
|
|
|
+ TypeAgentBase = "AgentBase"
|
|
|
TypeBatchMsg = "BatchMsg"
|
|
|
TypeCategory = "Category"
|
|
|
TypeContact = "Contact"
|
|
@@ -1178,6 +1180,1105 @@ func (m *AgentMutation) ResetEdge(name string) error {
|
|
|
return fmt.Errorf("unknown Agent edge %s", name)
|
|
|
}
|
|
|
|
|
|
+// AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
|
|
|
+type AgentBaseMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *string
|
|
|
+ q *string
|
|
|
+ a *string
|
|
|
+ chunk_index *uint64
|
|
|
+ addchunk_index *int64
|
|
|
+ indexes *[]string
|
|
|
+ appendindexes []string
|
|
|
+ dataset_id *string
|
|
|
+ collection_id *string
|
|
|
+ source_name *string
|
|
|
+ can_write *[]bool
|
|
|
+ appendcan_write []bool
|
|
|
+ is_owner *[]bool
|
|
|
+ appendis_owner []bool
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ wx_agent map[uint64]struct{}
|
|
|
+ removedwx_agent map[uint64]struct{}
|
|
|
+ clearedwx_agent bool
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*AgentBase, error)
|
|
|
+ predicates []predicate.AgentBase
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*AgentBaseMutation)(nil)
|
|
|
+
|
|
|
+// agentbaseOption allows management of the mutation configuration using functional options.
|
|
|
+type agentbaseOption func(*AgentBaseMutation)
|
|
|
+
|
|
|
+// newAgentBaseMutation creates new mutation for the AgentBase entity.
|
|
|
+func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
|
|
|
+ m := &AgentBaseMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeAgentBase,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withAgentBaseID sets the ID field of the mutation.
|
|
|
+func withAgentBaseID(id string) agentbaseOption {
|
|
|
+ return func(m *AgentBaseMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *AgentBase
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*AgentBase, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().AgentBase.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withAgentBase sets the old AgentBase of the mutation.
|
|
|
+func withAgentBase(node *AgentBase) agentbaseOption {
|
|
|
+ return func(m *AgentBaseMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*AgentBase, error) {
|
|
|
+ return node, nil
|
|
|
+ }
|
|
|
+ m.id = &node.ID
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
|
+// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
|
+func (m AgentBaseMutation) Client() *Client {
|
|
|
+ client := &Client{config: m.config}
|
|
|
+ client.init()
|
|
|
+ return client
|
|
|
+}
|
|
|
+
|
|
|
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
|
+// it returns an error otherwise.
|
|
|
+func (m AgentBaseMutation) Tx() (*Tx, error) {
|
|
|
+ if _, ok := m.driver.(*txDriver); !ok {
|
|
|
+ return nil, errors.New("ent: mutation is not running in a transaction")
|
|
|
+ }
|
|
|
+ tx := &Tx{config: m.config}
|
|
|
+ tx.init()
|
|
|
+ return tx, nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetID sets the value of the id field. Note that this
|
|
|
+// operation is only accepted on creation of AgentBase entities.
|
|
|
+func (m *AgentBaseMutation) SetID(id string) {
|
|
|
+ m.id = &id
|
|
|
+}
|
|
|
+
|
|
|
+// ID returns the ID value in the mutation. Note that the ID is only available
|
|
|
+// if it was provided to the builder or after it was returned from the database.
|
|
|
+func (m *AgentBaseMutation) ID() (id string, exists bool) {
|
|
|
+ if m.id == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *m.id, true
|
|
|
+}
|
|
|
+
|
|
|
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
|
+// That means, if the mutation is applied within a transaction with an isolation level such
|
|
|
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
|
+// or updated by the mutation.
|
|
|
+func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
|
|
|
+ switch {
|
|
|
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
|
+ id, exists := m.ID()
|
|
|
+ if exists {
|
|
|
+ return []string{id}, nil
|
|
|
+ }
|
|
|
+ fallthrough
|
|
|
+ case m.op.Is(OpUpdate | OpDelete):
|
|
|
+ return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// SetQ sets the "q" field.
|
|
|
+func (m *AgentBaseMutation) SetQ(s string) {
|
|
|
+ m.q = &s
|
|
|
+}
|
|
|
+
|
|
|
+// Q returns the value of the "q" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) Q() (r string, exists bool) {
|
|
|
+ v := m.q
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldQ returns the old "q" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldQ is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldQ requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldQ: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Q, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearQ clears the value of the "q" field.
|
|
|
+func (m *AgentBaseMutation) ClearQ() {
|
|
|
+ m.q = nil
|
|
|
+ m.clearedFields[agentbase.FieldQ] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// QCleared returns if the "q" field was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) QCleared() bool {
|
|
|
+ _, ok := m.clearedFields[agentbase.FieldQ]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetQ resets all changes to the "q" field.
|
|
|
+func (m *AgentBaseMutation) ResetQ() {
|
|
|
+ m.q = nil
|
|
|
+ delete(m.clearedFields, agentbase.FieldQ)
|
|
|
+}
|
|
|
+
|
|
|
+// SetA sets the "a" field.
|
|
|
+func (m *AgentBaseMutation) SetA(s string) {
|
|
|
+ m.a = &s
|
|
|
+}
|
|
|
+
|
|
|
+// A returns the value of the "a" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) A() (r string, exists bool) {
|
|
|
+ v := m.a
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldA returns the old "a" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldA is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldA requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldA: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.A, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearA clears the value of the "a" field.
|
|
|
+func (m *AgentBaseMutation) ClearA() {
|
|
|
+ m.a = nil
|
|
|
+ m.clearedFields[agentbase.FieldA] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// ACleared returns if the "a" field was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) ACleared() bool {
|
|
|
+ _, ok := m.clearedFields[agentbase.FieldA]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetA resets all changes to the "a" field.
|
|
|
+func (m *AgentBaseMutation) ResetA() {
|
|
|
+ m.a = nil
|
|
|
+ delete(m.clearedFields, agentbase.FieldA)
|
|
|
+}
|
|
|
+
|
|
|
+// SetChunkIndex sets the "chunk_index" field.
|
|
|
+func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
|
|
|
+ m.chunk_index = &u
|
|
|
+ m.addchunk_index = nil
|
|
|
+}
|
|
|
+
|
|
|
+// ChunkIndex returns the value of the "chunk_index" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
|
|
|
+ v := m.chunk_index
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldChunkIndex requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.ChunkIndex, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddChunkIndex adds u to the "chunk_index" field.
|
|
|
+func (m *AgentBaseMutation) AddChunkIndex(u int64) {
|
|
|
+ if m.addchunk_index != nil {
|
|
|
+ *m.addchunk_index += u
|
|
|
+ } else {
|
|
|
+ m.addchunk_index = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
|
|
|
+func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
|
|
|
+ v := m.addchunk_index
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetChunkIndex resets all changes to the "chunk_index" field.
|
|
|
+func (m *AgentBaseMutation) ResetChunkIndex() {
|
|
|
+ m.chunk_index = nil
|
|
|
+ m.addchunk_index = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetIndexes sets the "indexes" field.
|
|
|
+func (m *AgentBaseMutation) SetIndexes(s []string) {
|
|
|
+ m.indexes = &s
|
|
|
+ m.appendindexes = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Indexes returns the value of the "indexes" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
|
|
|
+ v := m.indexes
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldIndexes returns the old "indexes" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldIndexes requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Indexes, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AppendIndexes adds s to the "indexes" field.
|
|
|
+func (m *AgentBaseMutation) AppendIndexes(s []string) {
|
|
|
+ m.appendindexes = append(m.appendindexes, s...)
|
|
|
+}
|
|
|
+
|
|
|
+// AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
|
|
|
+func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
|
|
|
+ if len(m.appendindexes) == 0 {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
+ return m.appendindexes, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearIndexes clears the value of the "indexes" field.
|
|
|
+func (m *AgentBaseMutation) ClearIndexes() {
|
|
|
+ m.indexes = nil
|
|
|
+ m.appendindexes = nil
|
|
|
+ m.clearedFields[agentbase.FieldIndexes] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// IndexesCleared returns if the "indexes" field was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) IndexesCleared() bool {
|
|
|
+ _, ok := m.clearedFields[agentbase.FieldIndexes]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetIndexes resets all changes to the "indexes" field.
|
|
|
+func (m *AgentBaseMutation) ResetIndexes() {
|
|
|
+ m.indexes = nil
|
|
|
+ m.appendindexes = nil
|
|
|
+ delete(m.clearedFields, agentbase.FieldIndexes)
|
|
|
+}
|
|
|
+
|
|
|
+// SetDatasetID sets the "dataset_id" field.
|
|
|
+func (m *AgentBaseMutation) SetDatasetID(s string) {
|
|
|
+ m.dataset_id = &s
|
|
|
+}
|
|
|
+
|
|
|
+// DatasetID returns the value of the "dataset_id" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
|
|
|
+ v := m.dataset_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldDatasetID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.DatasetID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDatasetID clears the value of the "dataset_id" field.
|
|
|
+func (m *AgentBaseMutation) ClearDatasetID() {
|
|
|
+ m.dataset_id = nil
|
|
|
+ m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) DatasetIDCleared() bool {
|
|
|
+ _, ok := m.clearedFields[agentbase.FieldDatasetID]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetDatasetID resets all changes to the "dataset_id" field.
|
|
|
+func (m *AgentBaseMutation) ResetDatasetID() {
|
|
|
+ m.dataset_id = nil
|
|
|
+ delete(m.clearedFields, agentbase.FieldDatasetID)
|
|
|
+}
|
|
|
+
|
|
|
+// SetCollectionID sets the "collection_id" field.
|
|
|
+func (m *AgentBaseMutation) SetCollectionID(s string) {
|
|
|
+ m.collection_id = &s
|
|
|
+}
|
|
|
+
|
|
|
+// CollectionID returns the value of the "collection_id" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
|
|
|
+ v := m.collection_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCollectionID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CollectionID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearCollectionID clears the value of the "collection_id" field.
|
|
|
+func (m *AgentBaseMutation) ClearCollectionID() {
|
|
|
+ m.collection_id = nil
|
|
|
+ m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) CollectionIDCleared() bool {
|
|
|
+ _, ok := m.clearedFields[agentbase.FieldCollectionID]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCollectionID resets all changes to the "collection_id" field.
|
|
|
+func (m *AgentBaseMutation) ResetCollectionID() {
|
|
|
+ m.collection_id = nil
|
|
|
+ delete(m.clearedFields, agentbase.FieldCollectionID)
|
|
|
+}
|
|
|
+
|
|
|
+// SetSourceName sets the "source_name" field.
|
|
|
+func (m *AgentBaseMutation) SetSourceName(s string) {
|
|
|
+ m.source_name = &s
|
|
|
+}
|
|
|
+
|
|
|
+// SourceName returns the value of the "source_name" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
|
|
|
+ v := m.source_name
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldSourceName returns the old "source_name" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldSourceName requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.SourceName, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSourceName clears the value of the "source_name" field.
|
|
|
+func (m *AgentBaseMutation) ClearSourceName() {
|
|
|
+ m.source_name = nil
|
|
|
+ m.clearedFields[agentbase.FieldSourceName] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// SourceNameCleared returns if the "source_name" field was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) SourceNameCleared() bool {
|
|
|
+ _, ok := m.clearedFields[agentbase.FieldSourceName]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetSourceName resets all changes to the "source_name" field.
|
|
|
+func (m *AgentBaseMutation) ResetSourceName() {
|
|
|
+ m.source_name = nil
|
|
|
+ delete(m.clearedFields, agentbase.FieldSourceName)
|
|
|
+}
|
|
|
+
|
|
|
+// SetCanWrite sets the "can_write" field.
|
|
|
+func (m *AgentBaseMutation) SetCanWrite(b []bool) {
|
|
|
+ m.can_write = &b
|
|
|
+ m.appendcan_write = nil
|
|
|
+}
|
|
|
+
|
|
|
+// CanWrite returns the value of the "can_write" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
|
|
|
+ v := m.can_write
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCanWrite requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CanWrite, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AppendCanWrite adds b to the "can_write" field.
|
|
|
+func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
|
|
|
+ m.appendcan_write = append(m.appendcan_write, b...)
|
|
|
+}
|
|
|
+
|
|
|
+// AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
|
|
|
+func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
|
|
|
+ if len(m.appendcan_write) == 0 {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
+ return m.appendcan_write, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearCanWrite clears the value of the "can_write" field.
|
|
|
+func (m *AgentBaseMutation) ClearCanWrite() {
|
|
|
+ m.can_write = nil
|
|
|
+ m.appendcan_write = nil
|
|
|
+ m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// CanWriteCleared returns if the "can_write" field was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) CanWriteCleared() bool {
|
|
|
+ _, ok := m.clearedFields[agentbase.FieldCanWrite]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCanWrite resets all changes to the "can_write" field.
|
|
|
+func (m *AgentBaseMutation) ResetCanWrite() {
|
|
|
+ m.can_write = nil
|
|
|
+ m.appendcan_write = nil
|
|
|
+ delete(m.clearedFields, agentbase.FieldCanWrite)
|
|
|
+}
|
|
|
+
|
|
|
+// SetIsOwner sets the "is_owner" field.
|
|
|
+func (m *AgentBaseMutation) SetIsOwner(b []bool) {
|
|
|
+ m.is_owner = &b
|
|
|
+ m.appendis_owner = nil
|
|
|
+}
|
|
|
+
|
|
|
+// IsOwner returns the value of the "is_owner" field in the mutation.
|
|
|
+func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
|
|
|
+ v := m.is_owner
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
|
|
|
+// If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldIsOwner requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.IsOwner, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AppendIsOwner adds b to the "is_owner" field.
|
|
|
+func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
|
|
|
+ m.appendis_owner = append(m.appendis_owner, b...)
|
|
|
+}
|
|
|
+
|
|
|
+// AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
|
|
|
+func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
|
|
|
+ if len(m.appendis_owner) == 0 {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
+ return m.appendis_owner, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearIsOwner clears the value of the "is_owner" field.
|
|
|
+func (m *AgentBaseMutation) ClearIsOwner() {
|
|
|
+ m.is_owner = nil
|
|
|
+ m.appendis_owner = nil
|
|
|
+ m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) IsOwnerCleared() bool {
|
|
|
+ _, ok := m.clearedFields[agentbase.FieldIsOwner]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetIsOwner resets all changes to the "is_owner" field.
|
|
|
+func (m *AgentBaseMutation) ResetIsOwner() {
|
|
|
+ m.is_owner = nil
|
|
|
+ m.appendis_owner = nil
|
|
|
+ delete(m.clearedFields, agentbase.FieldIsOwner)
|
|
|
+}
|
|
|
+
|
|
|
+// AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
|
|
|
+func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
|
|
|
+ if m.wx_agent == nil {
|
|
|
+ m.wx_agent = make(map[uint64]struct{})
|
|
|
+ }
|
|
|
+ for i := range ids {
|
|
|
+ m.wx_agent[ids[i]] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ClearWxAgent clears the "wx_agent" edge to the Wx entity.
|
|
|
+func (m *AgentBaseMutation) ClearWxAgent() {
|
|
|
+ m.clearedwx_agent = true
|
|
|
+}
|
|
|
+
|
|
|
+// WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
|
|
|
+func (m *AgentBaseMutation) WxAgentCleared() bool {
|
|
|
+ return m.clearedwx_agent
|
|
|
+}
|
|
|
+
|
|
|
+// RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
|
|
|
+func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
|
|
|
+ if m.removedwx_agent == nil {
|
|
|
+ m.removedwx_agent = make(map[uint64]struct{})
|
|
|
+ }
|
|
|
+ for i := range ids {
|
|
|
+ delete(m.wx_agent, ids[i])
|
|
|
+ m.removedwx_agent[ids[i]] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
|
|
|
+func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
|
|
|
+ for id := range m.removedwx_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
|
|
|
+func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
|
|
|
+ for id := range m.wx_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ResetWxAgent resets all changes to the "wx_agent" edge.
|
|
|
+func (m *AgentBaseMutation) ResetWxAgent() {
|
|
|
+ m.wx_agent = nil
|
|
|
+ m.clearedwx_agent = false
|
|
|
+ m.removedwx_agent = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the AgentBaseMutation builder.
|
|
|
+func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.AgentBase, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *AgentBaseMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *AgentBaseMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (AgentBase).
|
|
|
+func (m *AgentBaseMutation) 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 *AgentBaseMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 9)
|
|
|
+ if m.q != nil {
|
|
|
+ fields = append(fields, agentbase.FieldQ)
|
|
|
+ }
|
|
|
+ if m.a != nil {
|
|
|
+ fields = append(fields, agentbase.FieldA)
|
|
|
+ }
|
|
|
+ if m.chunk_index != nil {
|
|
|
+ fields = append(fields, agentbase.FieldChunkIndex)
|
|
|
+ }
|
|
|
+ if m.indexes != nil {
|
|
|
+ fields = append(fields, agentbase.FieldIndexes)
|
|
|
+ }
|
|
|
+ if m.dataset_id != nil {
|
|
|
+ fields = append(fields, agentbase.FieldDatasetID)
|
|
|
+ }
|
|
|
+ if m.collection_id != nil {
|
|
|
+ fields = append(fields, agentbase.FieldCollectionID)
|
|
|
+ }
|
|
|
+ if m.source_name != nil {
|
|
|
+ fields = append(fields, agentbase.FieldSourceName)
|
|
|
+ }
|
|
|
+ if m.can_write != nil {
|
|
|
+ fields = append(fields, agentbase.FieldCanWrite)
|
|
|
+ }
|
|
|
+ if m.is_owner != nil {
|
|
|
+ fields = append(fields, agentbase.FieldIsOwner)
|
|
|
+ }
|
|
|
+ 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 *AgentBaseMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case agentbase.FieldQ:
|
|
|
+ return m.Q()
|
|
|
+ case agentbase.FieldA:
|
|
|
+ return m.A()
|
|
|
+ case agentbase.FieldChunkIndex:
|
|
|
+ return m.ChunkIndex()
|
|
|
+ case agentbase.FieldIndexes:
|
|
|
+ return m.Indexes()
|
|
|
+ case agentbase.FieldDatasetID:
|
|
|
+ return m.DatasetID()
|
|
|
+ case agentbase.FieldCollectionID:
|
|
|
+ return m.CollectionID()
|
|
|
+ case agentbase.FieldSourceName:
|
|
|
+ return m.SourceName()
|
|
|
+ case agentbase.FieldCanWrite:
|
|
|
+ return m.CanWrite()
|
|
|
+ case agentbase.FieldIsOwner:
|
|
|
+ return m.IsOwner()
|
|
|
+ }
|
|
|
+ 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 *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case agentbase.FieldQ:
|
|
|
+ return m.OldQ(ctx)
|
|
|
+ case agentbase.FieldA:
|
|
|
+ return m.OldA(ctx)
|
|
|
+ case agentbase.FieldChunkIndex:
|
|
|
+ return m.OldChunkIndex(ctx)
|
|
|
+ case agentbase.FieldIndexes:
|
|
|
+ return m.OldIndexes(ctx)
|
|
|
+ case agentbase.FieldDatasetID:
|
|
|
+ return m.OldDatasetID(ctx)
|
|
|
+ case agentbase.FieldCollectionID:
|
|
|
+ return m.OldCollectionID(ctx)
|
|
|
+ case agentbase.FieldSourceName:
|
|
|
+ return m.OldSourceName(ctx)
|
|
|
+ case agentbase.FieldCanWrite:
|
|
|
+ return m.OldCanWrite(ctx)
|
|
|
+ case agentbase.FieldIsOwner:
|
|
|
+ return m.OldIsOwner(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown AgentBase 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 *AgentBaseMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case agentbase.FieldQ:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetQ(v)
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldA:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetA(v)
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldChunkIndex:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetChunkIndex(v)
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldIndexes:
|
|
|
+ v, ok := value.([]string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetIndexes(v)
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldDatasetID:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetDatasetID(v)
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldCollectionID:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCollectionID(v)
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldSourceName:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetSourceName(v)
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldCanWrite:
|
|
|
+ v, ok := value.([]bool)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCanWrite(v)
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldIsOwner:
|
|
|
+ v, ok := value.([]bool)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetIsOwner(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown AgentBase field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *AgentBaseMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addchunk_index != nil {
|
|
|
+ fields = append(fields, agentbase.FieldChunkIndex)
|
|
|
+ }
|
|
|
+ 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 *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case agentbase.FieldChunkIndex:
|
|
|
+ return m.AddedChunkIndex()
|
|
|
+ }
|
|
|
+ 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 *AgentBaseMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case agentbase.FieldChunkIndex:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddChunkIndex(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown AgentBase numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *AgentBaseMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(agentbase.FieldQ) {
|
|
|
+ fields = append(fields, agentbase.FieldQ)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(agentbase.FieldA) {
|
|
|
+ fields = append(fields, agentbase.FieldA)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(agentbase.FieldIndexes) {
|
|
|
+ fields = append(fields, agentbase.FieldIndexes)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(agentbase.FieldDatasetID) {
|
|
|
+ fields = append(fields, agentbase.FieldDatasetID)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(agentbase.FieldCollectionID) {
|
|
|
+ fields = append(fields, agentbase.FieldCollectionID)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(agentbase.FieldSourceName) {
|
|
|
+ fields = append(fields, agentbase.FieldSourceName)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(agentbase.FieldCanWrite) {
|
|
|
+ fields = append(fields, agentbase.FieldCanWrite)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(agentbase.FieldIsOwner) {
|
|
|
+ fields = append(fields, agentbase.FieldIsOwner)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) 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 *AgentBaseMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case agentbase.FieldQ:
|
|
|
+ m.ClearQ()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldA:
|
|
|
+ m.ClearA()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldIndexes:
|
|
|
+ m.ClearIndexes()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldDatasetID:
|
|
|
+ m.ClearDatasetID()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldCollectionID:
|
|
|
+ m.ClearCollectionID()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldSourceName:
|
|
|
+ m.ClearSourceName()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldCanWrite:
|
|
|
+ m.ClearCanWrite()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldIsOwner:
|
|
|
+ m.ClearIsOwner()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown AgentBase 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 *AgentBaseMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case agentbase.FieldQ:
|
|
|
+ m.ResetQ()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldA:
|
|
|
+ m.ResetA()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldChunkIndex:
|
|
|
+ m.ResetChunkIndex()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldIndexes:
|
|
|
+ m.ResetIndexes()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldDatasetID:
|
|
|
+ m.ResetDatasetID()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldCollectionID:
|
|
|
+ m.ResetCollectionID()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldSourceName:
|
|
|
+ m.ResetSourceName()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldCanWrite:
|
|
|
+ m.ResetCanWrite()
|
|
|
+ return nil
|
|
|
+ case agentbase.FieldIsOwner:
|
|
|
+ m.ResetIsOwner()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown AgentBase field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *AgentBaseMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.wx_agent != nil {
|
|
|
+ edges = append(edges, agentbase.EdgeWxAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
+// name in this mutation.
|
|
|
+func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ switch name {
|
|
|
+ case agentbase.EdgeWxAgent:
|
|
|
+ ids := make([]ent.Value, 0, len(m.wx_agent))
|
|
|
+ for id := range m.wx_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return ids
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *AgentBaseMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.removedwx_agent != nil {
|
|
|
+ edges = append(edges, agentbase.EdgeWxAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
+// the given name in this mutation.
|
|
|
+func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ switch name {
|
|
|
+ case agentbase.EdgeWxAgent:
|
|
|
+ ids := make([]ent.Value, 0, len(m.removedwx_agent))
|
|
|
+ for id := range m.removedwx_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return ids
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.clearedwx_agent {
|
|
|
+ edges = append(edges, agentbase.EdgeWxAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
+// was cleared in this mutation.
|
|
|
+func (m *AgentBaseMutation) EdgeCleared(name string) bool {
|
|
|
+ switch name {
|
|
|
+ case agentbase.EdgeWxAgent:
|
|
|
+ return m.clearedwx_agent
|
|
|
+ }
|
|
|
+ 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 *AgentBaseMutation) ClearEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown AgentBase 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 *AgentBaseMutation) ResetEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ case agentbase.EdgeWxAgent:
|
|
|
+ m.ResetWxAgent()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown AgentBase edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
// BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
|
|
|
type BatchMsgMutation struct {
|
|
|
config
|