| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- "github.com/Wei-Shaw/sub2api/ent/user"
- )
- // User is the model entity for the User schema.
- type User struct {
- config `json:"-"`
- // ID of the ent.
- ID int64 `json:"id,omitempty"`
- // CreatedAt holds the value of the "created_at" field.
- CreatedAt time.Time `json:"created_at,omitempty"`
- // UpdatedAt holds the value of the "updated_at" field.
- UpdatedAt time.Time `json:"updated_at,omitempty"`
- // DeletedAt holds the value of the "deleted_at" field.
- DeletedAt *time.Time `json:"deleted_at,omitempty"`
- // Email holds the value of the "email" field.
- Email string `json:"email,omitempty"`
- // PasswordHash holds the value of the "password_hash" field.
- PasswordHash string `json:"password_hash,omitempty"`
- // Role holds the value of the "role" field.
- Role string `json:"role,omitempty"`
- // Balance holds the value of the "balance" field.
- Balance float64 `json:"balance,omitempty"`
- // FrozenBalance holds the value of the "frozen_balance" field.
- FrozenBalance float64 `json:"frozen_balance,omitempty"`
- // Concurrency holds the value of the "concurrency" field.
- Concurrency int `json:"concurrency,omitempty"`
- // Status holds the value of the "status" field.
- Status string `json:"status,omitempty"`
- // Username holds the value of the "username" field.
- Username string `json:"username,omitempty"`
- // Notes holds the value of the "notes" field.
- Notes string `json:"notes,omitempty"`
- // TotpSecretEncrypted holds the value of the "totp_secret_encrypted" field.
- TotpSecretEncrypted *string `json:"totp_secret_encrypted,omitempty"`
- // TotpEnabled holds the value of the "totp_enabled" field.
- TotpEnabled bool `json:"totp_enabled,omitempty"`
- // TotpEnabledAt holds the value of the "totp_enabled_at" field.
- TotpEnabledAt *time.Time `json:"totp_enabled_at,omitempty"`
- // SignupSource holds the value of the "signup_source" field.
- SignupSource string `json:"signup_source,omitempty"`
- // LastLoginAt holds the value of the "last_login_at" field.
- LastLoginAt *time.Time `json:"last_login_at,omitempty"`
- // LastActiveAt holds the value of the "last_active_at" field.
- LastActiveAt *time.Time `json:"last_active_at,omitempty"`
- // RestrictPublicGroups holds the value of the "restrict_public_groups" field.
- RestrictPublicGroups bool `json:"restrict_public_groups,omitempty"`
- // BalanceNotifyEnabled holds the value of the "balance_notify_enabled" field.
- BalanceNotifyEnabled bool `json:"balance_notify_enabled,omitempty"`
- // BalanceNotifyThresholdType holds the value of the "balance_notify_threshold_type" field.
- BalanceNotifyThresholdType string `json:"balance_notify_threshold_type,omitempty"`
- // BalanceNotifyThreshold holds the value of the "balance_notify_threshold" field.
- BalanceNotifyThreshold *float64 `json:"balance_notify_threshold,omitempty"`
- // BalanceNotifyExtraEmails holds the value of the "balance_notify_extra_emails" field.
- BalanceNotifyExtraEmails string `json:"balance_notify_extra_emails,omitempty"`
- // TotalRecharged holds the value of the "total_recharged" field.
- TotalRecharged float64 `json:"total_recharged,omitempty"`
- // RpmLimit holds the value of the "rpm_limit" field.
- RpmLimit int `json:"rpm_limit,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the UserQuery when eager-loading is set.
- Edges UserEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- // UserEdges holds the relations/edges for other nodes in the graph.
- type UserEdges struct {
- // APIKeys holds the value of the api_keys edge.
- APIKeys []*APIKey `json:"api_keys,omitempty"`
- // RedeemCodes holds the value of the redeem_codes edge.
- RedeemCodes []*RedeemCode `json:"redeem_codes,omitempty"`
- // Subscriptions holds the value of the subscriptions edge.
- Subscriptions []*UserSubscription `json:"subscriptions,omitempty"`
- // AssignedSubscriptions holds the value of the assigned_subscriptions edge.
- AssignedSubscriptions []*UserSubscription `json:"assigned_subscriptions,omitempty"`
- // AnnouncementReads holds the value of the announcement_reads edge.
- AnnouncementReads []*AnnouncementRead `json:"announcement_reads,omitempty"`
- // AllowedGroups holds the value of the allowed_groups edge.
- AllowedGroups []*Group `json:"allowed_groups,omitempty"`
- // UsageLogs holds the value of the usage_logs edge.
- UsageLogs []*UsageLog `json:"usage_logs,omitempty"`
- // AttributeValues holds the value of the attribute_values edge.
- AttributeValues []*UserAttributeValue `json:"attribute_values,omitempty"`
- // PromoCodeUsages holds the value of the promo_code_usages edge.
- PromoCodeUsages []*PromoCodeUsage `json:"promo_code_usages,omitempty"`
- // PaymentOrders holds the value of the payment_orders edge.
- PaymentOrders []*PaymentOrder `json:"payment_orders,omitempty"`
- // AuthIdentities holds the value of the auth_identities edge.
- AuthIdentities []*AuthIdentity `json:"auth_identities,omitempty"`
- // PendingAuthSessions holds the value of the pending_auth_sessions edge.
- PendingAuthSessions []*PendingAuthSession `json:"pending_auth_sessions,omitempty"`
- // PlatformQuotas holds the value of the platform_quotas edge.
- PlatformQuotas []*UserPlatformQuota `json:"platform_quotas,omitempty"`
- // UserAllowedGroups holds the value of the user_allowed_groups edge.
- UserAllowedGroups []*UserAllowedGroup `json:"user_allowed_groups,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [14]bool
- }
- // APIKeysOrErr returns the APIKeys value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) APIKeysOrErr() ([]*APIKey, error) {
- if e.loadedTypes[0] {
- return e.APIKeys, nil
- }
- return nil, &NotLoadedError{edge: "api_keys"}
- }
- // RedeemCodesOrErr returns the RedeemCodes value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) RedeemCodesOrErr() ([]*RedeemCode, error) {
- if e.loadedTypes[1] {
- return e.RedeemCodes, nil
- }
- return nil, &NotLoadedError{edge: "redeem_codes"}
- }
- // SubscriptionsOrErr returns the Subscriptions value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) SubscriptionsOrErr() ([]*UserSubscription, error) {
- if e.loadedTypes[2] {
- return e.Subscriptions, nil
- }
- return nil, &NotLoadedError{edge: "subscriptions"}
- }
- // AssignedSubscriptionsOrErr returns the AssignedSubscriptions value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) AssignedSubscriptionsOrErr() ([]*UserSubscription, error) {
- if e.loadedTypes[3] {
- return e.AssignedSubscriptions, nil
- }
- return nil, &NotLoadedError{edge: "assigned_subscriptions"}
- }
- // AnnouncementReadsOrErr returns the AnnouncementReads value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) AnnouncementReadsOrErr() ([]*AnnouncementRead, error) {
- if e.loadedTypes[4] {
- return e.AnnouncementReads, nil
- }
- return nil, &NotLoadedError{edge: "announcement_reads"}
- }
- // AllowedGroupsOrErr returns the AllowedGroups value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) AllowedGroupsOrErr() ([]*Group, error) {
- if e.loadedTypes[5] {
- return e.AllowedGroups, nil
- }
- return nil, &NotLoadedError{edge: "allowed_groups"}
- }
- // UsageLogsOrErr returns the UsageLogs value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) UsageLogsOrErr() ([]*UsageLog, error) {
- if e.loadedTypes[6] {
- return e.UsageLogs, nil
- }
- return nil, &NotLoadedError{edge: "usage_logs"}
- }
- // AttributeValuesOrErr returns the AttributeValues value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) AttributeValuesOrErr() ([]*UserAttributeValue, error) {
- if e.loadedTypes[7] {
- return e.AttributeValues, nil
- }
- return nil, &NotLoadedError{edge: "attribute_values"}
- }
- // PromoCodeUsagesOrErr returns the PromoCodeUsages value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) PromoCodeUsagesOrErr() ([]*PromoCodeUsage, error) {
- if e.loadedTypes[8] {
- return e.PromoCodeUsages, nil
- }
- return nil, &NotLoadedError{edge: "promo_code_usages"}
- }
- // PaymentOrdersOrErr returns the PaymentOrders value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) PaymentOrdersOrErr() ([]*PaymentOrder, error) {
- if e.loadedTypes[9] {
- return e.PaymentOrders, nil
- }
- return nil, &NotLoadedError{edge: "payment_orders"}
- }
- // AuthIdentitiesOrErr returns the AuthIdentities value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) AuthIdentitiesOrErr() ([]*AuthIdentity, error) {
- if e.loadedTypes[10] {
- return e.AuthIdentities, nil
- }
- return nil, &NotLoadedError{edge: "auth_identities"}
- }
- // PendingAuthSessionsOrErr returns the PendingAuthSessions value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) PendingAuthSessionsOrErr() ([]*PendingAuthSession, error) {
- if e.loadedTypes[11] {
- return e.PendingAuthSessions, nil
- }
- return nil, &NotLoadedError{edge: "pending_auth_sessions"}
- }
- // PlatformQuotasOrErr returns the PlatformQuotas value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) PlatformQuotasOrErr() ([]*UserPlatformQuota, error) {
- if e.loadedTypes[12] {
- return e.PlatformQuotas, nil
- }
- return nil, &NotLoadedError{edge: "platform_quotas"}
- }
- // UserAllowedGroupsOrErr returns the UserAllowedGroups value or an error if the edge
- // was not loaded in eager-loading.
- func (e UserEdges) UserAllowedGroupsOrErr() ([]*UserAllowedGroup, error) {
- if e.loadedTypes[13] {
- return e.UserAllowedGroups, nil
- }
- return nil, &NotLoadedError{edge: "user_allowed_groups"}
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*User) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case user.FieldTotpEnabled, user.FieldRestrictPublicGroups, user.FieldBalanceNotifyEnabled:
- values[i] = new(sql.NullBool)
- case user.FieldBalance, user.FieldFrozenBalance, user.FieldBalanceNotifyThreshold, user.FieldTotalRecharged:
- values[i] = new(sql.NullFloat64)
- case user.FieldID, user.FieldConcurrency, user.FieldRpmLimit:
- values[i] = new(sql.NullInt64)
- case user.FieldEmail, user.FieldPasswordHash, user.FieldRole, user.FieldStatus, user.FieldUsername, user.FieldNotes, user.FieldTotpSecretEncrypted, user.FieldSignupSource, user.FieldBalanceNotifyThresholdType, user.FieldBalanceNotifyExtraEmails:
- values[i] = new(sql.NullString)
- case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldDeletedAt, user.FieldTotpEnabledAt, user.FieldLastLoginAt, user.FieldLastActiveAt:
- values[i] = new(sql.NullTime)
- default:
- values[i] = new(sql.UnknownType)
- }
- }
- return values, nil
- }
- // assignValues assigns the values that were returned from sql.Rows (after scanning)
- // to the User fields.
- func (_m *User) assignValues(columns []string, values []any) error {
- if m, n := len(values), len(columns); m < n {
- return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
- }
- for i := range columns {
- switch columns[i] {
- case user.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- _m.ID = int64(value.Int64)
- case user.FieldCreatedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field created_at", values[i])
- } else if value.Valid {
- _m.CreatedAt = value.Time
- }
- case user.FieldUpdatedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field updated_at", values[i])
- } else if value.Valid {
- _m.UpdatedAt = value.Time
- }
- case user.FieldDeletedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
- } else if value.Valid {
- _m.DeletedAt = new(time.Time)
- *_m.DeletedAt = value.Time
- }
- case user.FieldEmail:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field email", values[i])
- } else if value.Valid {
- _m.Email = value.String
- }
- case user.FieldPasswordHash:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field password_hash", values[i])
- } else if value.Valid {
- _m.PasswordHash = value.String
- }
- case user.FieldRole:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field role", values[i])
- } else if value.Valid {
- _m.Role = value.String
- }
- case user.FieldBalance:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field balance", values[i])
- } else if value.Valid {
- _m.Balance = value.Float64
- }
- case user.FieldFrozenBalance:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field frozen_balance", values[i])
- } else if value.Valid {
- _m.FrozenBalance = value.Float64
- }
- case user.FieldConcurrency:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field concurrency", values[i])
- } else if value.Valid {
- _m.Concurrency = int(value.Int64)
- }
- case user.FieldStatus:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field status", values[i])
- } else if value.Valid {
- _m.Status = value.String
- }
- case user.FieldUsername:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field username", values[i])
- } else if value.Valid {
- _m.Username = value.String
- }
- case user.FieldNotes:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field notes", values[i])
- } else if value.Valid {
- _m.Notes = value.String
- }
- case user.FieldTotpSecretEncrypted:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field totp_secret_encrypted", values[i])
- } else if value.Valid {
- _m.TotpSecretEncrypted = new(string)
- *_m.TotpSecretEncrypted = value.String
- }
- case user.FieldTotpEnabled:
- if value, ok := values[i].(*sql.NullBool); !ok {
- return fmt.Errorf("unexpected type %T for field totp_enabled", values[i])
- } else if value.Valid {
- _m.TotpEnabled = value.Bool
- }
- case user.FieldTotpEnabledAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field totp_enabled_at", values[i])
- } else if value.Valid {
- _m.TotpEnabledAt = new(time.Time)
- *_m.TotpEnabledAt = value.Time
- }
- case user.FieldSignupSource:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field signup_source", values[i])
- } else if value.Valid {
- _m.SignupSource = value.String
- }
- case user.FieldLastLoginAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field last_login_at", values[i])
- } else if value.Valid {
- _m.LastLoginAt = new(time.Time)
- *_m.LastLoginAt = value.Time
- }
- case user.FieldLastActiveAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field last_active_at", values[i])
- } else if value.Valid {
- _m.LastActiveAt = new(time.Time)
- *_m.LastActiveAt = value.Time
- }
- case user.FieldRestrictPublicGroups:
- if value, ok := values[i].(*sql.NullBool); !ok {
- return fmt.Errorf("unexpected type %T for field restrict_public_groups", values[i])
- } else if value.Valid {
- _m.RestrictPublicGroups = value.Bool
- }
- case user.FieldBalanceNotifyEnabled:
- if value, ok := values[i].(*sql.NullBool); !ok {
- return fmt.Errorf("unexpected type %T for field balance_notify_enabled", values[i])
- } else if value.Valid {
- _m.BalanceNotifyEnabled = value.Bool
- }
- case user.FieldBalanceNotifyThresholdType:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field balance_notify_threshold_type", values[i])
- } else if value.Valid {
- _m.BalanceNotifyThresholdType = value.String
- }
- case user.FieldBalanceNotifyThreshold:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field balance_notify_threshold", values[i])
- } else if value.Valid {
- _m.BalanceNotifyThreshold = new(float64)
- *_m.BalanceNotifyThreshold = value.Float64
- }
- case user.FieldBalanceNotifyExtraEmails:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field balance_notify_extra_emails", values[i])
- } else if value.Valid {
- _m.BalanceNotifyExtraEmails = value.String
- }
- case user.FieldTotalRecharged:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field total_recharged", values[i])
- } else if value.Valid {
- _m.TotalRecharged = value.Float64
- }
- case user.FieldRpmLimit:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field rpm_limit", values[i])
- } else if value.Valid {
- _m.RpmLimit = int(value.Int64)
- }
- default:
- _m.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the User.
- // This includes values selected through modifiers, order, etc.
- func (_m *User) Value(name string) (ent.Value, error) {
- return _m.selectValues.Get(name)
- }
- // QueryAPIKeys queries the "api_keys" edge of the User entity.
- func (_m *User) QueryAPIKeys() *APIKeyQuery {
- return NewUserClient(_m.config).QueryAPIKeys(_m)
- }
- // QueryRedeemCodes queries the "redeem_codes" edge of the User entity.
- func (_m *User) QueryRedeemCodes() *RedeemCodeQuery {
- return NewUserClient(_m.config).QueryRedeemCodes(_m)
- }
- // QuerySubscriptions queries the "subscriptions" edge of the User entity.
- func (_m *User) QuerySubscriptions() *UserSubscriptionQuery {
- return NewUserClient(_m.config).QuerySubscriptions(_m)
- }
- // QueryAssignedSubscriptions queries the "assigned_subscriptions" edge of the User entity.
- func (_m *User) QueryAssignedSubscriptions() *UserSubscriptionQuery {
- return NewUserClient(_m.config).QueryAssignedSubscriptions(_m)
- }
- // QueryAnnouncementReads queries the "announcement_reads" edge of the User entity.
- func (_m *User) QueryAnnouncementReads() *AnnouncementReadQuery {
- return NewUserClient(_m.config).QueryAnnouncementReads(_m)
- }
- // QueryAllowedGroups queries the "allowed_groups" edge of the User entity.
- func (_m *User) QueryAllowedGroups() *GroupQuery {
- return NewUserClient(_m.config).QueryAllowedGroups(_m)
- }
- // QueryUsageLogs queries the "usage_logs" edge of the User entity.
- func (_m *User) QueryUsageLogs() *UsageLogQuery {
- return NewUserClient(_m.config).QueryUsageLogs(_m)
- }
- // QueryAttributeValues queries the "attribute_values" edge of the User entity.
- func (_m *User) QueryAttributeValues() *UserAttributeValueQuery {
- return NewUserClient(_m.config).QueryAttributeValues(_m)
- }
- // QueryPromoCodeUsages queries the "promo_code_usages" edge of the User entity.
- func (_m *User) QueryPromoCodeUsages() *PromoCodeUsageQuery {
- return NewUserClient(_m.config).QueryPromoCodeUsages(_m)
- }
- // QueryPaymentOrders queries the "payment_orders" edge of the User entity.
- func (_m *User) QueryPaymentOrders() *PaymentOrderQuery {
- return NewUserClient(_m.config).QueryPaymentOrders(_m)
- }
- // QueryAuthIdentities queries the "auth_identities" edge of the User entity.
- func (_m *User) QueryAuthIdentities() *AuthIdentityQuery {
- return NewUserClient(_m.config).QueryAuthIdentities(_m)
- }
- // QueryPendingAuthSessions queries the "pending_auth_sessions" edge of the User entity.
- func (_m *User) QueryPendingAuthSessions() *PendingAuthSessionQuery {
- return NewUserClient(_m.config).QueryPendingAuthSessions(_m)
- }
- // QueryPlatformQuotas queries the "platform_quotas" edge of the User entity.
- func (_m *User) QueryPlatformQuotas() *UserPlatformQuotaQuery {
- return NewUserClient(_m.config).QueryPlatformQuotas(_m)
- }
- // QueryUserAllowedGroups queries the "user_allowed_groups" edge of the User entity.
- func (_m *User) QueryUserAllowedGroups() *UserAllowedGroupQuery {
- return NewUserClient(_m.config).QueryUserAllowedGroups(_m)
- }
- // Update returns a builder for updating this User.
- // Note that you need to call User.Unwrap() before calling this method if this User
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (_m *User) Update() *UserUpdateOne {
- return NewUserClient(_m.config).UpdateOne(_m)
- }
- // Unwrap unwraps the User entity that was returned from a transaction after it was closed,
- // so that all future queries will be executed through the driver which created the transaction.
- func (_m *User) Unwrap() *User {
- _tx, ok := _m.config.driver.(*txDriver)
- if !ok {
- panic("ent: User is not a transactional entity")
- }
- _m.config.driver = _tx.drv
- return _m
- }
- // String implements the fmt.Stringer.
- func (_m *User) String() string {
- var builder strings.Builder
- builder.WriteString("User(")
- builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
- builder.WriteString("created_at=")
- builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- if v := _m.DeletedAt; v != nil {
- builder.WriteString("deleted_at=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- builder.WriteString("email=")
- builder.WriteString(_m.Email)
- builder.WriteString(", ")
- builder.WriteString("password_hash=")
- builder.WriteString(_m.PasswordHash)
- builder.WriteString(", ")
- builder.WriteString("role=")
- builder.WriteString(_m.Role)
- builder.WriteString(", ")
- builder.WriteString("balance=")
- builder.WriteString(fmt.Sprintf("%v", _m.Balance))
- builder.WriteString(", ")
- builder.WriteString("frozen_balance=")
- builder.WriteString(fmt.Sprintf("%v", _m.FrozenBalance))
- builder.WriteString(", ")
- builder.WriteString("concurrency=")
- builder.WriteString(fmt.Sprintf("%v", _m.Concurrency))
- builder.WriteString(", ")
- builder.WriteString("status=")
- builder.WriteString(_m.Status)
- builder.WriteString(", ")
- builder.WriteString("username=")
- builder.WriteString(_m.Username)
- builder.WriteString(", ")
- builder.WriteString("notes=")
- builder.WriteString(_m.Notes)
- builder.WriteString(", ")
- if v := _m.TotpSecretEncrypted; v != nil {
- builder.WriteString("totp_secret_encrypted=")
- builder.WriteString(*v)
- }
- builder.WriteString(", ")
- builder.WriteString("totp_enabled=")
- builder.WriteString(fmt.Sprintf("%v", _m.TotpEnabled))
- builder.WriteString(", ")
- if v := _m.TotpEnabledAt; v != nil {
- builder.WriteString("totp_enabled_at=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- builder.WriteString("signup_source=")
- builder.WriteString(_m.SignupSource)
- builder.WriteString(", ")
- if v := _m.LastLoginAt; v != nil {
- builder.WriteString("last_login_at=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- if v := _m.LastActiveAt; v != nil {
- builder.WriteString("last_active_at=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- builder.WriteString("restrict_public_groups=")
- builder.WriteString(fmt.Sprintf("%v", _m.RestrictPublicGroups))
- builder.WriteString(", ")
- builder.WriteString("balance_notify_enabled=")
- builder.WriteString(fmt.Sprintf("%v", _m.BalanceNotifyEnabled))
- builder.WriteString(", ")
- builder.WriteString("balance_notify_threshold_type=")
- builder.WriteString(_m.BalanceNotifyThresholdType)
- builder.WriteString(", ")
- if v := _m.BalanceNotifyThreshold; v != nil {
- builder.WriteString("balance_notify_threshold=")
- builder.WriteString(fmt.Sprintf("%v", *v))
- }
- builder.WriteString(", ")
- builder.WriteString("balance_notify_extra_emails=")
- builder.WriteString(_m.BalanceNotifyExtraEmails)
- builder.WriteString(", ")
- builder.WriteString("total_recharged=")
- builder.WriteString(fmt.Sprintf("%v", _m.TotalRecharged))
- builder.WriteString(", ")
- builder.WriteString("rpm_limit=")
- builder.WriteString(fmt.Sprintf("%v", _m.RpmLimit))
- builder.WriteByte(')')
- return builder.String()
- }
- // Users is a parsable slice of User.
- type Users []*User
|