|
@@ -31,6 +31,8 @@ import (
|
|
|
"wechat-api/ent/soptask"
|
|
|
"wechat-api/ent/token"
|
|
|
"wechat-api/ent/tutorial"
|
|
|
+ "wechat-api/ent/usagedetail"
|
|
|
+ "wechat-api/ent/usagetotal"
|
|
|
"wechat-api/ent/workexperience"
|
|
|
"wechat-api/ent/wx"
|
|
|
"wechat-api/ent/wxcard"
|
|
@@ -71,6 +73,8 @@ const (
|
|
|
TypeSopTask = "SopTask"
|
|
|
TypeToken = "Token"
|
|
|
TypeTutorial = "Tutorial"
|
|
|
+ TypeUsageDetail = "UsageDetail"
|
|
|
+ TypeUsageTotal = "UsageTotal"
|
|
|
TypeWorkExperience = "WorkExperience"
|
|
|
TypeWx = "Wx"
|
|
|
TypeWxCard = "WxCard"
|
|
@@ -24451,6 +24455,2558 @@ func (m *TutorialMutation) ResetEdge(name string) error {
|
|
|
return fmt.Errorf("unknown Tutorial edge %s", name)
|
|
|
}
|
|
|
|
|
|
+// UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
|
|
|
+type UsageDetailMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ status *uint8
|
|
|
+ addstatus *int8
|
|
|
+ _type *int
|
|
|
+ add_type *int
|
|
|
+ bot_id *string
|
|
|
+ receiver_id *string
|
|
|
+ app *int
|
|
|
+ addapp *int
|
|
|
+ session_id *uint64
|
|
|
+ addsession_id *int64
|
|
|
+ request *string
|
|
|
+ response *string
|
|
|
+ total_tokens *uint64
|
|
|
+ addtotal_tokens *int64
|
|
|
+ prompt_tokens *uint64
|
|
|
+ addprompt_tokens *int64
|
|
|
+ completion_tokens *uint64
|
|
|
+ addcompletion_tokens *int64
|
|
|
+ organization_id *uint64
|
|
|
+ addorganization_id *int64
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*UsageDetail, error)
|
|
|
+ predicates []predicate.UsageDetail
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*UsageDetailMutation)(nil)
|
|
|
+
|
|
|
+// usagedetailOption allows management of the mutation configuration using functional options.
|
|
|
+type usagedetailOption func(*UsageDetailMutation)
|
|
|
+
|
|
|
+// newUsageDetailMutation creates new mutation for the UsageDetail entity.
|
|
|
+func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
|
|
|
+ m := &UsageDetailMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeUsageDetail,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withUsageDetailID sets the ID field of the mutation.
|
|
|
+func withUsageDetailID(id uint64) usagedetailOption {
|
|
|
+ return func(m *UsageDetailMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *UsageDetail
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().UsageDetail.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withUsageDetail sets the old UsageDetail of the mutation.
|
|
|
+func withUsageDetail(node *UsageDetail) usagedetailOption {
|
|
|
+ return func(m *UsageDetailMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*UsageDetail, 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 UsageDetailMutation) 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 UsageDetailMutation) 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 UsageDetail entities.
|
|
|
+func (m *UsageDetailMutation) SetID(id uint64) {
|
|
|
+ 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 *UsageDetailMutation) ID() (id uint64, 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 *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
|
|
|
+ switch {
|
|
|
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
|
+ id, exists := m.ID()
|
|
|
+ if exists {
|
|
|
+ return []uint64{id}, nil
|
|
|
+ }
|
|
|
+ fallthrough
|
|
|
+ case m.op.Is(OpUpdate | OpDelete):
|
|
|
+ return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// SetCreatedAt sets the "created_at" field.
|
|
|
+func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.created_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CreatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCreatedAt resets all changes to the "created_at" field.
|
|
|
+func (m *UsageDetailMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.updated_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.UpdatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
|
+func (m *UsageDetailMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (m *UsageDetailMutation) SetStatus(u uint8) {
|
|
|
+ m.status = &u
|
|
|
+ m.addstatus = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Status returns the value of the "status" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
|
|
|
+ v := m.status
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldStatus returns the old "status" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldStatus is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldStatus requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldStatus: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Status, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds u to the "status" field.
|
|
|
+func (m *UsageDetailMutation) AddStatus(u int8) {
|
|
|
+ if m.addstatus != nil {
|
|
|
+ *m.addstatus += u
|
|
|
+ } else {
|
|
|
+ m.addstatus = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedStatus returns the value that was added to the "status" field in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
|
|
|
+ v := m.addstatus
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (m *UsageDetailMutation) ClearStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ m.clearedFields[usagedetail.FieldStatus] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// StatusCleared returns if the "status" field was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) StatusCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagedetail.FieldStatus]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetStatus resets all changes to the "status" field.
|
|
|
+func (m *UsageDetailMutation) ResetStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ delete(m.clearedFields, usagedetail.FieldStatus)
|
|
|
+}
|
|
|
+
|
|
|
+// SetType sets the "type" field.
|
|
|
+func (m *UsageDetailMutation) SetType(i int) {
|
|
|
+ m._type = &i
|
|
|
+ m.add_type = nil
|
|
|
+}
|
|
|
+
|
|
|
+// GetType returns the value of the "type" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) GetType() (r int, exists bool) {
|
|
|
+ v := m._type
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldType returns the old "type" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldType is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldType requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldType: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Type, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddType adds i to the "type" field.
|
|
|
+func (m *UsageDetailMutation) AddType(i int) {
|
|
|
+ if m.add_type != nil {
|
|
|
+ *m.add_type += i
|
|
|
+ } else {
|
|
|
+ m.add_type = &i
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedType returns the value that was added to the "type" field in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
|
|
|
+ v := m.add_type
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearType clears the value of the "type" field.
|
|
|
+func (m *UsageDetailMutation) ClearType() {
|
|
|
+ m._type = nil
|
|
|
+ m.add_type = nil
|
|
|
+ m.clearedFields[usagedetail.FieldType] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// TypeCleared returns if the "type" field was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) TypeCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagedetail.FieldType]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetType resets all changes to the "type" field.
|
|
|
+func (m *UsageDetailMutation) ResetType() {
|
|
|
+ m._type = nil
|
|
|
+ m.add_type = nil
|
|
|
+ delete(m.clearedFields, usagedetail.FieldType)
|
|
|
+}
|
|
|
+
|
|
|
+// SetBotID sets the "bot_id" field.
|
|
|
+func (m *UsageDetailMutation) SetBotID(s string) {
|
|
|
+ m.bot_id = &s
|
|
|
+}
|
|
|
+
|
|
|
+// BotID returns the value of the "bot_id" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) BotID() (r string, exists bool) {
|
|
|
+ v := m.bot_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldBotID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldBotID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldBotID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.BotID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetBotID resets all changes to the "bot_id" field.
|
|
|
+func (m *UsageDetailMutation) ResetBotID() {
|
|
|
+ m.bot_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetReceiverID sets the "receiver_id" field.
|
|
|
+func (m *UsageDetailMutation) SetReceiverID(s string) {
|
|
|
+ m.receiver_id = &s
|
|
|
+}
|
|
|
+
|
|
|
+// ReceiverID returns the value of the "receiver_id" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
|
|
|
+ v := m.receiver_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldReceiverID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.ReceiverID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetReceiverID resets all changes to the "receiver_id" field.
|
|
|
+func (m *UsageDetailMutation) ResetReceiverID() {
|
|
|
+ m.receiver_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetApp sets the "app" field.
|
|
|
+func (m *UsageDetailMutation) SetApp(i int) {
|
|
|
+ m.app = &i
|
|
|
+ m.addapp = nil
|
|
|
+}
|
|
|
+
|
|
|
+// App returns the value of the "app" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) App() (r int, exists bool) {
|
|
|
+ v := m.app
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldApp returns the old "app" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldApp is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldApp requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldApp: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.App, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddApp adds i to the "app" field.
|
|
|
+func (m *UsageDetailMutation) AddApp(i int) {
|
|
|
+ if m.addapp != nil {
|
|
|
+ *m.addapp += i
|
|
|
+ } else {
|
|
|
+ m.addapp = &i
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedApp returns the value that was added to the "app" field in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
|
|
|
+ v := m.addapp
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearApp clears the value of the "app" field.
|
|
|
+func (m *UsageDetailMutation) ClearApp() {
|
|
|
+ m.app = nil
|
|
|
+ m.addapp = nil
|
|
|
+ m.clearedFields[usagedetail.FieldApp] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// AppCleared returns if the "app" field was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) AppCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagedetail.FieldApp]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetApp resets all changes to the "app" field.
|
|
|
+func (m *UsageDetailMutation) ResetApp() {
|
|
|
+ m.app = nil
|
|
|
+ m.addapp = nil
|
|
|
+ delete(m.clearedFields, usagedetail.FieldApp)
|
|
|
+}
|
|
|
+
|
|
|
+// SetSessionID sets the "session_id" field.
|
|
|
+func (m *UsageDetailMutation) SetSessionID(u uint64) {
|
|
|
+ m.session_id = &u
|
|
|
+ m.addsession_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SessionID returns the value of the "session_id" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
|
|
|
+ v := m.session_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldSessionID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.SessionID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddSessionID adds u to the "session_id" field.
|
|
|
+func (m *UsageDetailMutation) AddSessionID(u int64) {
|
|
|
+ if m.addsession_id != nil {
|
|
|
+ *m.addsession_id += u
|
|
|
+ } else {
|
|
|
+ m.addsession_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedSessionID returns the value that was added to the "session_id" field in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
|
|
|
+ v := m.addsession_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSessionID clears the value of the "session_id" field.
|
|
|
+func (m *UsageDetailMutation) ClearSessionID() {
|
|
|
+ m.session_id = nil
|
|
|
+ m.addsession_id = nil
|
|
|
+ m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// SessionIDCleared returns if the "session_id" field was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) SessionIDCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagedetail.FieldSessionID]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetSessionID resets all changes to the "session_id" field.
|
|
|
+func (m *UsageDetailMutation) ResetSessionID() {
|
|
|
+ m.session_id = nil
|
|
|
+ m.addsession_id = nil
|
|
|
+ delete(m.clearedFields, usagedetail.FieldSessionID)
|
|
|
+}
|
|
|
+
|
|
|
+// SetRequest sets the "request" field.
|
|
|
+func (m *UsageDetailMutation) SetRequest(s string) {
|
|
|
+ m.request = &s
|
|
|
+}
|
|
|
+
|
|
|
+// Request returns the value of the "request" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) Request() (r string, exists bool) {
|
|
|
+ v := m.request
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldRequest returns the old "request" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldRequest is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldRequest requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldRequest: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Request, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetRequest resets all changes to the "request" field.
|
|
|
+func (m *UsageDetailMutation) ResetRequest() {
|
|
|
+ m.request = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetResponse sets the "response" field.
|
|
|
+func (m *UsageDetailMutation) SetResponse(s string) {
|
|
|
+ m.response = &s
|
|
|
+}
|
|
|
+
|
|
|
+// Response returns the value of the "response" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) Response() (r string, exists bool) {
|
|
|
+ v := m.response
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldResponse returns the old "response" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldResponse is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldResponse requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldResponse: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Response, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetResponse resets all changes to the "response" field.
|
|
|
+func (m *UsageDetailMutation) ResetResponse() {
|
|
|
+ m.response = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetTotalTokens sets the "total_tokens" field.
|
|
|
+func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
|
|
|
+ m.total_tokens = &u
|
|
|
+ m.addtotal_tokens = nil
|
|
|
+}
|
|
|
+
|
|
|
+// TotalTokens returns the value of the "total_tokens" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
|
|
|
+ v := m.total_tokens
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldTotalTokens requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.TotalTokens, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddTotalTokens adds u to the "total_tokens" field.
|
|
|
+func (m *UsageDetailMutation) AddTotalTokens(u int64) {
|
|
|
+ if m.addtotal_tokens != nil {
|
|
|
+ *m.addtotal_tokens += u
|
|
|
+ } else {
|
|
|
+ m.addtotal_tokens = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
|
|
|
+ v := m.addtotal_tokens
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearTotalTokens clears the value of the "total_tokens" field.
|
|
|
+func (m *UsageDetailMutation) ClearTotalTokens() {
|
|
|
+ m.total_tokens = nil
|
|
|
+ m.addtotal_tokens = nil
|
|
|
+ m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) TotalTokensCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetTotalTokens resets all changes to the "total_tokens" field.
|
|
|
+func (m *UsageDetailMutation) ResetTotalTokens() {
|
|
|
+ m.total_tokens = nil
|
|
|
+ m.addtotal_tokens = nil
|
|
|
+ delete(m.clearedFields, usagedetail.FieldTotalTokens)
|
|
|
+}
|
|
|
+
|
|
|
+// SetPromptTokens sets the "prompt_tokens" field.
|
|
|
+func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
|
|
|
+ m.prompt_tokens = &u
|
|
|
+ m.addprompt_tokens = nil
|
|
|
+}
|
|
|
+
|
|
|
+// PromptTokens returns the value of the "prompt_tokens" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
|
|
|
+ v := m.prompt_tokens
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldPromptTokens requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.PromptTokens, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddPromptTokens adds u to the "prompt_tokens" field.
|
|
|
+func (m *UsageDetailMutation) AddPromptTokens(u int64) {
|
|
|
+ if m.addprompt_tokens != nil {
|
|
|
+ *m.addprompt_tokens += u
|
|
|
+ } else {
|
|
|
+ m.addprompt_tokens = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
|
|
|
+ v := m.addprompt_tokens
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearPromptTokens clears the value of the "prompt_tokens" field.
|
|
|
+func (m *UsageDetailMutation) ClearPromptTokens() {
|
|
|
+ m.prompt_tokens = nil
|
|
|
+ m.addprompt_tokens = nil
|
|
|
+ m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) PromptTokensCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetPromptTokens resets all changes to the "prompt_tokens" field.
|
|
|
+func (m *UsageDetailMutation) ResetPromptTokens() {
|
|
|
+ m.prompt_tokens = nil
|
|
|
+ m.addprompt_tokens = nil
|
|
|
+ delete(m.clearedFields, usagedetail.FieldPromptTokens)
|
|
|
+}
|
|
|
+
|
|
|
+// SetCompletionTokens sets the "completion_tokens" field.
|
|
|
+func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
|
|
|
+ m.completion_tokens = &u
|
|
|
+ m.addcompletion_tokens = nil
|
|
|
+}
|
|
|
+
|
|
|
+// CompletionTokens returns the value of the "completion_tokens" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
|
|
|
+ v := m.completion_tokens
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CompletionTokens, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddCompletionTokens adds u to the "completion_tokens" field.
|
|
|
+func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
|
|
|
+ if m.addcompletion_tokens != nil {
|
|
|
+ *m.addcompletion_tokens += u
|
|
|
+ } else {
|
|
|
+ m.addcompletion_tokens = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
|
|
|
+ v := m.addcompletion_tokens
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearCompletionTokens clears the value of the "completion_tokens" field.
|
|
|
+func (m *UsageDetailMutation) ClearCompletionTokens() {
|
|
|
+ m.completion_tokens = nil
|
|
|
+ m.addcompletion_tokens = nil
|
|
|
+ m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) CompletionTokensCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCompletionTokens resets all changes to the "completion_tokens" field.
|
|
|
+func (m *UsageDetailMutation) ResetCompletionTokens() {
|
|
|
+ m.completion_tokens = nil
|
|
|
+ m.addcompletion_tokens = nil
|
|
|
+ delete(m.clearedFields, usagedetail.FieldCompletionTokens)
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
|
|
|
+ m.organization_id = &u
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// OrganizationID returns the value of the "organization_id" field in the mutation.
|
|
|
+func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
|
|
|
+ v := m.organization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
|
|
|
+// If the UsageDetail 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 *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldOrganizationID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.OrganizationID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddOrganizationID adds u to the "organization_id" field.
|
|
|
+func (m *UsageDetailMutation) AddOrganizationID(u int64) {
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ *m.addorganization_id += u
|
|
|
+ } else {
|
|
|
+ m.addorganization_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
|
|
|
+ v := m.addorganization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearOrganizationID clears the value of the "organization_id" field.
|
|
|
+func (m *UsageDetailMutation) ClearOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+ m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) OrganizationIDCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetOrganizationID resets all changes to the "organization_id" field.
|
|
|
+func (m *UsageDetailMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+ delete(m.clearedFields, usagedetail.FieldOrganizationID)
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the UsageDetailMutation builder.
|
|
|
+func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.UsageDetail, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *UsageDetailMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *UsageDetailMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (UsageDetail).
|
|
|
+func (m *UsageDetailMutation) 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 *UsageDetailMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 14)
|
|
|
+ if m.created_at != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ if m.updated_at != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldUpdatedAt)
|
|
|
+ }
|
|
|
+ if m.status != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldStatus)
|
|
|
+ }
|
|
|
+ if m._type != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldType)
|
|
|
+ }
|
|
|
+ if m.bot_id != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldBotID)
|
|
|
+ }
|
|
|
+ if m.receiver_id != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldReceiverID)
|
|
|
+ }
|
|
|
+ if m.app != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldApp)
|
|
|
+ }
|
|
|
+ if m.session_id != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldSessionID)
|
|
|
+ }
|
|
|
+ if m.request != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldRequest)
|
|
|
+ }
|
|
|
+ if m.response != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldResponse)
|
|
|
+ }
|
|
|
+ if m.total_tokens != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldTotalTokens)
|
|
|
+ }
|
|
|
+ if m.prompt_tokens != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldPromptTokens)
|
|
|
+ }
|
|
|
+ if m.completion_tokens != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldCompletionTokens)
|
|
|
+ }
|
|
|
+ if m.organization_id != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ 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 *UsageDetailMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case usagedetail.FieldCreatedAt:
|
|
|
+ return m.CreatedAt()
|
|
|
+ case usagedetail.FieldUpdatedAt:
|
|
|
+ return m.UpdatedAt()
|
|
|
+ case usagedetail.FieldStatus:
|
|
|
+ return m.Status()
|
|
|
+ case usagedetail.FieldType:
|
|
|
+ return m.GetType()
|
|
|
+ case usagedetail.FieldBotID:
|
|
|
+ return m.BotID()
|
|
|
+ case usagedetail.FieldReceiverID:
|
|
|
+ return m.ReceiverID()
|
|
|
+ case usagedetail.FieldApp:
|
|
|
+ return m.App()
|
|
|
+ case usagedetail.FieldSessionID:
|
|
|
+ return m.SessionID()
|
|
|
+ case usagedetail.FieldRequest:
|
|
|
+ return m.Request()
|
|
|
+ case usagedetail.FieldResponse:
|
|
|
+ return m.Response()
|
|
|
+ case usagedetail.FieldTotalTokens:
|
|
|
+ return m.TotalTokens()
|
|
|
+ case usagedetail.FieldPromptTokens:
|
|
|
+ return m.PromptTokens()
|
|
|
+ case usagedetail.FieldCompletionTokens:
|
|
|
+ return m.CompletionTokens()
|
|
|
+ case usagedetail.FieldOrganizationID:
|
|
|
+ return m.OrganizationID()
|
|
|
+ }
|
|
|
+ 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 *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case usagedetail.FieldCreatedAt:
|
|
|
+ return m.OldCreatedAt(ctx)
|
|
|
+ case usagedetail.FieldUpdatedAt:
|
|
|
+ return m.OldUpdatedAt(ctx)
|
|
|
+ case usagedetail.FieldStatus:
|
|
|
+ return m.OldStatus(ctx)
|
|
|
+ case usagedetail.FieldType:
|
|
|
+ return m.OldType(ctx)
|
|
|
+ case usagedetail.FieldBotID:
|
|
|
+ return m.OldBotID(ctx)
|
|
|
+ case usagedetail.FieldReceiverID:
|
|
|
+ return m.OldReceiverID(ctx)
|
|
|
+ case usagedetail.FieldApp:
|
|
|
+ return m.OldApp(ctx)
|
|
|
+ case usagedetail.FieldSessionID:
|
|
|
+ return m.OldSessionID(ctx)
|
|
|
+ case usagedetail.FieldRequest:
|
|
|
+ return m.OldRequest(ctx)
|
|
|
+ case usagedetail.FieldResponse:
|
|
|
+ return m.OldResponse(ctx)
|
|
|
+ case usagedetail.FieldTotalTokens:
|
|
|
+ return m.OldTotalTokens(ctx)
|
|
|
+ case usagedetail.FieldPromptTokens:
|
|
|
+ return m.OldPromptTokens(ctx)
|
|
|
+ case usagedetail.FieldCompletionTokens:
|
|
|
+ return m.OldCompletionTokens(ctx)
|
|
|
+ case usagedetail.FieldOrganizationID:
|
|
|
+ return m.OldOrganizationID(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown UsageDetail 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 *UsageDetailMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case usagedetail.FieldCreatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCreatedAt(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldUpdatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetUpdatedAt(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldStatus:
|
|
|
+ v, ok := value.(uint8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetStatus(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldType:
|
|
|
+ v, ok := value.(int)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetType(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldBotID:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetBotID(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldReceiverID:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetReceiverID(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldApp:
|
|
|
+ v, ok := value.(int)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetApp(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldSessionID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetSessionID(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldRequest:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetRequest(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldResponse:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetResponse(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldTotalTokens:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetTotalTokens(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldPromptTokens:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetPromptTokens(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldCompletionTokens:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCompletionTokens(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldOrganizationID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown UsageDetail field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addstatus != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.add_type != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldType)
|
|
|
+ }
|
|
|
+ if m.addapp != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldApp)
|
|
|
+ }
|
|
|
+ if m.addsession_id != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldSessionID)
|
|
|
+ }
|
|
|
+ if m.addtotal_tokens != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldTotalTokens)
|
|
|
+ }
|
|
|
+ if m.addprompt_tokens != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldPromptTokens)
|
|
|
+ }
|
|
|
+ if m.addcompletion_tokens != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldCompletionTokens)
|
|
|
+ }
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, usagedetail.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ 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 *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case usagedetail.FieldStatus:
|
|
|
+ return m.AddedStatus()
|
|
|
+ case usagedetail.FieldType:
|
|
|
+ return m.AddedType()
|
|
|
+ case usagedetail.FieldApp:
|
|
|
+ return m.AddedApp()
|
|
|
+ case usagedetail.FieldSessionID:
|
|
|
+ return m.AddedSessionID()
|
|
|
+ case usagedetail.FieldTotalTokens:
|
|
|
+ return m.AddedTotalTokens()
|
|
|
+ case usagedetail.FieldPromptTokens:
|
|
|
+ return m.AddedPromptTokens()
|
|
|
+ case usagedetail.FieldCompletionTokens:
|
|
|
+ return m.AddedCompletionTokens()
|
|
|
+ case usagedetail.FieldOrganizationID:
|
|
|
+ return m.AddedOrganizationID()
|
|
|
+ }
|
|
|
+ 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 *UsageDetailMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case usagedetail.FieldStatus:
|
|
|
+ v, ok := value.(int8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddStatus(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldType:
|
|
|
+ v, ok := value.(int)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddType(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldApp:
|
|
|
+ v, ok := value.(int)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddApp(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldSessionID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddSessionID(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldTotalTokens:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddTotalTokens(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldPromptTokens:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddPromptTokens(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldCompletionTokens:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddCompletionTokens(v)
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldOrganizationID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown UsageDetail numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *UsageDetailMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(usagedetail.FieldStatus) {
|
|
|
+ fields = append(fields, usagedetail.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagedetail.FieldType) {
|
|
|
+ fields = append(fields, usagedetail.FieldType)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagedetail.FieldApp) {
|
|
|
+ fields = append(fields, usagedetail.FieldApp)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagedetail.FieldSessionID) {
|
|
|
+ fields = append(fields, usagedetail.FieldSessionID)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagedetail.FieldTotalTokens) {
|
|
|
+ fields = append(fields, usagedetail.FieldTotalTokens)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagedetail.FieldPromptTokens) {
|
|
|
+ fields = append(fields, usagedetail.FieldPromptTokens)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagedetail.FieldCompletionTokens) {
|
|
|
+ fields = append(fields, usagedetail.FieldCompletionTokens)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagedetail.FieldOrganizationID) {
|
|
|
+ fields = append(fields, usagedetail.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) 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 *UsageDetailMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case usagedetail.FieldStatus:
|
|
|
+ m.ClearStatus()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldType:
|
|
|
+ m.ClearType()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldApp:
|
|
|
+ m.ClearApp()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldSessionID:
|
|
|
+ m.ClearSessionID()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldTotalTokens:
|
|
|
+ m.ClearTotalTokens()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldPromptTokens:
|
|
|
+ m.ClearPromptTokens()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldCompletionTokens:
|
|
|
+ m.ClearCompletionTokens()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldOrganizationID:
|
|
|
+ m.ClearOrganizationID()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown UsageDetail 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 *UsageDetailMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case usagedetail.FieldCreatedAt:
|
|
|
+ m.ResetCreatedAt()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldUpdatedAt:
|
|
|
+ m.ResetUpdatedAt()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldStatus:
|
|
|
+ m.ResetStatus()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldType:
|
|
|
+ m.ResetType()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldBotID:
|
|
|
+ m.ResetBotID()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldReceiverID:
|
|
|
+ m.ResetReceiverID()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldApp:
|
|
|
+ m.ResetApp()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldSessionID:
|
|
|
+ m.ResetSessionID()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldRequest:
|
|
|
+ m.ResetRequest()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldResponse:
|
|
|
+ m.ResetResponse()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldTotalTokens:
|
|
|
+ m.ResetTotalTokens()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldPromptTokens:
|
|
|
+ m.ResetPromptTokens()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldCompletionTokens:
|
|
|
+ m.ResetCompletionTokens()
|
|
|
+ return nil
|
|
|
+ case usagedetail.FieldOrganizationID:
|
|
|
+ m.ResetOrganizationID()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown UsageDetail field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
+// name in this mutation.
|
|
|
+func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *UsageDetailMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
+// the given name in this mutation.
|
|
|
+func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
+// was cleared in this mutation.
|
|
|
+func (m *UsageDetailMutation) EdgeCleared(name string) bool {
|
|
|
+ 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 *UsageDetailMutation) ClearEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown UsageDetail 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 *UsageDetailMutation) ResetEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown UsageDetail edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
|
|
|
+type UsageTotalMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ status *uint8
|
|
|
+ addstatus *int8
|
|
|
+ _type *int
|
|
|
+ add_type *int
|
|
|
+ bot_id *string
|
|
|
+ total_tokens *uint64
|
|
|
+ addtotal_tokens *int64
|
|
|
+ start_index *uint64
|
|
|
+ addstart_index *int64
|
|
|
+ end_index *uint64
|
|
|
+ addend_index *int64
|
|
|
+ organization_id *uint64
|
|
|
+ addorganization_id *int64
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*UsageTotal, error)
|
|
|
+ predicates []predicate.UsageTotal
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*UsageTotalMutation)(nil)
|
|
|
+
|
|
|
+// usagetotalOption allows management of the mutation configuration using functional options.
|
|
|
+type usagetotalOption func(*UsageTotalMutation)
|
|
|
+
|
|
|
+// newUsageTotalMutation creates new mutation for the UsageTotal entity.
|
|
|
+func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
|
|
|
+ m := &UsageTotalMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeUsageTotal,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withUsageTotalID sets the ID field of the mutation.
|
|
|
+func withUsageTotalID(id uint64) usagetotalOption {
|
|
|
+ return func(m *UsageTotalMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *UsageTotal
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().UsageTotal.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withUsageTotal sets the old UsageTotal of the mutation.
|
|
|
+func withUsageTotal(node *UsageTotal) usagetotalOption {
|
|
|
+ return func(m *UsageTotalMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*UsageTotal, 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 UsageTotalMutation) 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 UsageTotalMutation) 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 UsageTotal entities.
|
|
|
+func (m *UsageTotalMutation) SetID(id uint64) {
|
|
|
+ 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 *UsageTotalMutation) ID() (id uint64, 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 *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
|
|
|
+ switch {
|
|
|
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
|
+ id, exists := m.ID()
|
|
|
+ if exists {
|
|
|
+ return []uint64{id}, nil
|
|
|
+ }
|
|
|
+ fallthrough
|
|
|
+ case m.op.Is(OpUpdate | OpDelete):
|
|
|
+ return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// SetCreatedAt sets the "created_at" field.
|
|
|
+func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.created_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CreatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCreatedAt resets all changes to the "created_at" field.
|
|
|
+func (m *UsageTotalMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.updated_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.UpdatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
|
+func (m *UsageTotalMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (m *UsageTotalMutation) SetStatus(u uint8) {
|
|
|
+ m.status = &u
|
|
|
+ m.addstatus = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Status returns the value of the "status" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
|
|
|
+ v := m.status
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldStatus returns the old "status" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldStatus is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldStatus requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldStatus: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Status, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds u to the "status" field.
|
|
|
+func (m *UsageTotalMutation) AddStatus(u int8) {
|
|
|
+ if m.addstatus != nil {
|
|
|
+ *m.addstatus += u
|
|
|
+ } else {
|
|
|
+ m.addstatus = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedStatus returns the value that was added to the "status" field in this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
|
|
|
+ v := m.addstatus
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (m *UsageTotalMutation) ClearStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ m.clearedFields[usagetotal.FieldStatus] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// StatusCleared returns if the "status" field was cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) StatusCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagetotal.FieldStatus]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetStatus resets all changes to the "status" field.
|
|
|
+func (m *UsageTotalMutation) ResetStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ delete(m.clearedFields, usagetotal.FieldStatus)
|
|
|
+}
|
|
|
+
|
|
|
+// SetType sets the "type" field.
|
|
|
+func (m *UsageTotalMutation) SetType(i int) {
|
|
|
+ m._type = &i
|
|
|
+ m.add_type = nil
|
|
|
+}
|
|
|
+
|
|
|
+// GetType returns the value of the "type" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) GetType() (r int, exists bool) {
|
|
|
+ v := m._type
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldType returns the old "type" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldType is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldType requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldType: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Type, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddType adds i to the "type" field.
|
|
|
+func (m *UsageTotalMutation) AddType(i int) {
|
|
|
+ if m.add_type != nil {
|
|
|
+ *m.add_type += i
|
|
|
+ } else {
|
|
|
+ m.add_type = &i
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedType returns the value that was added to the "type" field in this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
|
|
|
+ v := m.add_type
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearType clears the value of the "type" field.
|
|
|
+func (m *UsageTotalMutation) ClearType() {
|
|
|
+ m._type = nil
|
|
|
+ m.add_type = nil
|
|
|
+ m.clearedFields[usagetotal.FieldType] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// TypeCleared returns if the "type" field was cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) TypeCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagetotal.FieldType]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetType resets all changes to the "type" field.
|
|
|
+func (m *UsageTotalMutation) ResetType() {
|
|
|
+ m._type = nil
|
|
|
+ m.add_type = nil
|
|
|
+ delete(m.clearedFields, usagetotal.FieldType)
|
|
|
+}
|
|
|
+
|
|
|
+// SetBotID sets the "bot_id" field.
|
|
|
+func (m *UsageTotalMutation) SetBotID(s string) {
|
|
|
+ m.bot_id = &s
|
|
|
+}
|
|
|
+
|
|
|
+// BotID returns the value of the "bot_id" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) BotID() (r string, exists bool) {
|
|
|
+ v := m.bot_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldBotID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldBotID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldBotID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.BotID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetBotID resets all changes to the "bot_id" field.
|
|
|
+func (m *UsageTotalMutation) ResetBotID() {
|
|
|
+ m.bot_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetTotalTokens sets the "total_tokens" field.
|
|
|
+func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
|
|
|
+ m.total_tokens = &u
|
|
|
+ m.addtotal_tokens = nil
|
|
|
+}
|
|
|
+
|
|
|
+// TotalTokens returns the value of the "total_tokens" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
|
|
|
+ v := m.total_tokens
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldTotalTokens requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.TotalTokens, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddTotalTokens adds u to the "total_tokens" field.
|
|
|
+func (m *UsageTotalMutation) AddTotalTokens(u int64) {
|
|
|
+ if m.addtotal_tokens != nil {
|
|
|
+ *m.addtotal_tokens += u
|
|
|
+ } else {
|
|
|
+ m.addtotal_tokens = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
|
|
|
+ v := m.addtotal_tokens
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearTotalTokens clears the value of the "total_tokens" field.
|
|
|
+func (m *UsageTotalMutation) ClearTotalTokens() {
|
|
|
+ m.total_tokens = nil
|
|
|
+ m.addtotal_tokens = nil
|
|
|
+ m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) TotalTokensCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetTotalTokens resets all changes to the "total_tokens" field.
|
|
|
+func (m *UsageTotalMutation) ResetTotalTokens() {
|
|
|
+ m.total_tokens = nil
|
|
|
+ m.addtotal_tokens = nil
|
|
|
+ delete(m.clearedFields, usagetotal.FieldTotalTokens)
|
|
|
+}
|
|
|
+
|
|
|
+// SetStartIndex sets the "start_index" field.
|
|
|
+func (m *UsageTotalMutation) SetStartIndex(u uint64) {
|
|
|
+ m.start_index = &u
|
|
|
+ m.addstart_index = nil
|
|
|
+}
|
|
|
+
|
|
|
+// StartIndex returns the value of the "start_index" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
|
|
|
+ v := m.start_index
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldStartIndex requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.StartIndex, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddStartIndex adds u to the "start_index" field.
|
|
|
+func (m *UsageTotalMutation) AddStartIndex(u int64) {
|
|
|
+ if m.addstart_index != nil {
|
|
|
+ *m.addstart_index += u
|
|
|
+ } else {
|
|
|
+ m.addstart_index = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
|
|
|
+ v := m.addstart_index
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStartIndex clears the value of the "start_index" field.
|
|
|
+func (m *UsageTotalMutation) ClearStartIndex() {
|
|
|
+ m.start_index = nil
|
|
|
+ m.addstart_index = nil
|
|
|
+ m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// StartIndexCleared returns if the "start_index" field was cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) StartIndexCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagetotal.FieldStartIndex]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetStartIndex resets all changes to the "start_index" field.
|
|
|
+func (m *UsageTotalMutation) ResetStartIndex() {
|
|
|
+ m.start_index = nil
|
|
|
+ m.addstart_index = nil
|
|
|
+ delete(m.clearedFields, usagetotal.FieldStartIndex)
|
|
|
+}
|
|
|
+
|
|
|
+// SetEndIndex sets the "end_index" field.
|
|
|
+func (m *UsageTotalMutation) SetEndIndex(u uint64) {
|
|
|
+ m.end_index = &u
|
|
|
+ m.addend_index = nil
|
|
|
+}
|
|
|
+
|
|
|
+// EndIndex returns the value of the "end_index" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
|
|
|
+ v := m.end_index
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldEndIndex requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.EndIndex, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddEndIndex adds u to the "end_index" field.
|
|
|
+func (m *UsageTotalMutation) AddEndIndex(u int64) {
|
|
|
+ if m.addend_index != nil {
|
|
|
+ *m.addend_index += u
|
|
|
+ } else {
|
|
|
+ m.addend_index = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
|
|
|
+ v := m.addend_index
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearEndIndex clears the value of the "end_index" field.
|
|
|
+func (m *UsageTotalMutation) ClearEndIndex() {
|
|
|
+ m.end_index = nil
|
|
|
+ m.addend_index = nil
|
|
|
+ m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// EndIndexCleared returns if the "end_index" field was cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) EndIndexCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagetotal.FieldEndIndex]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetEndIndex resets all changes to the "end_index" field.
|
|
|
+func (m *UsageTotalMutation) ResetEndIndex() {
|
|
|
+ m.end_index = nil
|
|
|
+ m.addend_index = nil
|
|
|
+ delete(m.clearedFields, usagetotal.FieldEndIndex)
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
|
|
|
+ m.organization_id = &u
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// OrganizationID returns the value of the "organization_id" field in the mutation.
|
|
|
+func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
|
|
|
+ v := m.organization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
|
|
|
+// If the UsageTotal 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 *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldOrganizationID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.OrganizationID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddOrganizationID adds u to the "organization_id" field.
|
|
|
+func (m *UsageTotalMutation) AddOrganizationID(u int64) {
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ *m.addorganization_id += u
|
|
|
+ } else {
|
|
|
+ m.addorganization_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
|
|
|
+ v := m.addorganization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearOrganizationID clears the value of the "organization_id" field.
|
|
|
+func (m *UsageTotalMutation) ClearOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+ m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) OrganizationIDCleared() bool {
|
|
|
+ _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetOrganizationID resets all changes to the "organization_id" field.
|
|
|
+func (m *UsageTotalMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+ delete(m.clearedFields, usagetotal.FieldOrganizationID)
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the UsageTotalMutation builder.
|
|
|
+func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.UsageTotal, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *UsageTotalMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *UsageTotalMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (UsageTotal).
|
|
|
+func (m *UsageTotalMutation) 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 *UsageTotalMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 9)
|
|
|
+ if m.created_at != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ if m.updated_at != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldUpdatedAt)
|
|
|
+ }
|
|
|
+ if m.status != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldStatus)
|
|
|
+ }
|
|
|
+ if m._type != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldType)
|
|
|
+ }
|
|
|
+ if m.bot_id != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldBotID)
|
|
|
+ }
|
|
|
+ if m.total_tokens != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldTotalTokens)
|
|
|
+ }
|
|
|
+ if m.start_index != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldStartIndex)
|
|
|
+ }
|
|
|
+ if m.end_index != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldEndIndex)
|
|
|
+ }
|
|
|
+ if m.organization_id != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ 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 *UsageTotalMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case usagetotal.FieldCreatedAt:
|
|
|
+ return m.CreatedAt()
|
|
|
+ case usagetotal.FieldUpdatedAt:
|
|
|
+ return m.UpdatedAt()
|
|
|
+ case usagetotal.FieldStatus:
|
|
|
+ return m.Status()
|
|
|
+ case usagetotal.FieldType:
|
|
|
+ return m.GetType()
|
|
|
+ case usagetotal.FieldBotID:
|
|
|
+ return m.BotID()
|
|
|
+ case usagetotal.FieldTotalTokens:
|
|
|
+ return m.TotalTokens()
|
|
|
+ case usagetotal.FieldStartIndex:
|
|
|
+ return m.StartIndex()
|
|
|
+ case usagetotal.FieldEndIndex:
|
|
|
+ return m.EndIndex()
|
|
|
+ case usagetotal.FieldOrganizationID:
|
|
|
+ return m.OrganizationID()
|
|
|
+ }
|
|
|
+ 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 *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case usagetotal.FieldCreatedAt:
|
|
|
+ return m.OldCreatedAt(ctx)
|
|
|
+ case usagetotal.FieldUpdatedAt:
|
|
|
+ return m.OldUpdatedAt(ctx)
|
|
|
+ case usagetotal.FieldStatus:
|
|
|
+ return m.OldStatus(ctx)
|
|
|
+ case usagetotal.FieldType:
|
|
|
+ return m.OldType(ctx)
|
|
|
+ case usagetotal.FieldBotID:
|
|
|
+ return m.OldBotID(ctx)
|
|
|
+ case usagetotal.FieldTotalTokens:
|
|
|
+ return m.OldTotalTokens(ctx)
|
|
|
+ case usagetotal.FieldStartIndex:
|
|
|
+ return m.OldStartIndex(ctx)
|
|
|
+ case usagetotal.FieldEndIndex:
|
|
|
+ return m.OldEndIndex(ctx)
|
|
|
+ case usagetotal.FieldOrganizationID:
|
|
|
+ return m.OldOrganizationID(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown UsageTotal 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 *UsageTotalMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case usagetotal.FieldCreatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCreatedAt(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldUpdatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetUpdatedAt(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldStatus:
|
|
|
+ v, ok := value.(uint8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetStatus(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldType:
|
|
|
+ v, ok := value.(int)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetType(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldBotID:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetBotID(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldTotalTokens:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetTotalTokens(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldStartIndex:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetStartIndex(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldEndIndex:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetEndIndex(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldOrganizationID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown UsageTotal field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addstatus != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.add_type != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldType)
|
|
|
+ }
|
|
|
+ if m.addtotal_tokens != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldTotalTokens)
|
|
|
+ }
|
|
|
+ if m.addstart_index != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldStartIndex)
|
|
|
+ }
|
|
|
+ if m.addend_index != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldEndIndex)
|
|
|
+ }
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, usagetotal.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ 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 *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case usagetotal.FieldStatus:
|
|
|
+ return m.AddedStatus()
|
|
|
+ case usagetotal.FieldType:
|
|
|
+ return m.AddedType()
|
|
|
+ case usagetotal.FieldTotalTokens:
|
|
|
+ return m.AddedTotalTokens()
|
|
|
+ case usagetotal.FieldStartIndex:
|
|
|
+ return m.AddedStartIndex()
|
|
|
+ case usagetotal.FieldEndIndex:
|
|
|
+ return m.AddedEndIndex()
|
|
|
+ case usagetotal.FieldOrganizationID:
|
|
|
+ return m.AddedOrganizationID()
|
|
|
+ }
|
|
|
+ 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 *UsageTotalMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case usagetotal.FieldStatus:
|
|
|
+ v, ok := value.(int8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddStatus(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldType:
|
|
|
+ v, ok := value.(int)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddType(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldTotalTokens:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddTotalTokens(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldStartIndex:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddStartIndex(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldEndIndex:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddEndIndex(v)
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldOrganizationID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown UsageTotal numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *UsageTotalMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(usagetotal.FieldStatus) {
|
|
|
+ fields = append(fields, usagetotal.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagetotal.FieldType) {
|
|
|
+ fields = append(fields, usagetotal.FieldType)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagetotal.FieldTotalTokens) {
|
|
|
+ fields = append(fields, usagetotal.FieldTotalTokens)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagetotal.FieldStartIndex) {
|
|
|
+ fields = append(fields, usagetotal.FieldStartIndex)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagetotal.FieldEndIndex) {
|
|
|
+ fields = append(fields, usagetotal.FieldEndIndex)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(usagetotal.FieldOrganizationID) {
|
|
|
+ fields = append(fields, usagetotal.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) 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 *UsageTotalMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case usagetotal.FieldStatus:
|
|
|
+ m.ClearStatus()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldType:
|
|
|
+ m.ClearType()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldTotalTokens:
|
|
|
+ m.ClearTotalTokens()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldStartIndex:
|
|
|
+ m.ClearStartIndex()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldEndIndex:
|
|
|
+ m.ClearEndIndex()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldOrganizationID:
|
|
|
+ m.ClearOrganizationID()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown UsageTotal 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 *UsageTotalMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case usagetotal.FieldCreatedAt:
|
|
|
+ m.ResetCreatedAt()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldUpdatedAt:
|
|
|
+ m.ResetUpdatedAt()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldStatus:
|
|
|
+ m.ResetStatus()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldType:
|
|
|
+ m.ResetType()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldBotID:
|
|
|
+ m.ResetBotID()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldTotalTokens:
|
|
|
+ m.ResetTotalTokens()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldStartIndex:
|
|
|
+ m.ResetStartIndex()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldEndIndex:
|
|
|
+ m.ResetEndIndex()
|
|
|
+ return nil
|
|
|
+ case usagetotal.FieldOrganizationID:
|
|
|
+ m.ResetOrganizationID()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown UsageTotal field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
+// name in this mutation.
|
|
|
+func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *UsageTotalMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
+// the given name in this mutation.
|
|
|
+func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
+// was cleared in this mutation.
|
|
|
+func (m *UsageTotalMutation) EdgeCleared(name string) bool {
|
|
|
+ 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 *UsageTotalMutation) ClearEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown UsageTotal 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 *UsageTotalMutation) ResetEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown UsageTotal edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
// WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
|
|
|
type WorkExperienceMutation struct {
|
|
|
config
|