Commit 3d617de5 authored by yangjianbo's avatar yangjianbo
Browse files

refactor(数据库): 迁移持久层到 Ent 并清理 GORM

将仓储层/基础设施改为 Ent + 原生 SQL 执行路径,并移除 AutoMigrate 与 GORM 依赖。
重构内容包括:
- 仓储层改用 Ent/SQL(含 usage_log/account 等复杂查询),统一错误映射
- 基础设施与 setup 初始化切换为 Ent + SQL migrations
- 集成测试与 fixtures 迁移到 Ent 事务模型
- 清理遗留 GORM 模型/依赖,补充迁移与文档说明
- 增加根目录 Makefile 便于前后端编译

测试:
- go test -tags unit ./...
- go test -tags integration ./...
parent fd51ff69
<!-- OPENSPEC:START -->
# OpenSpec Instructions
These instructions are for AI assistants working in this project.
Always open `@/openspec/AGENTS.md` when the request:
- Mentions planning or proposals (words like proposal, spec, change, plan)
- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
- Sounds ambiguous and you need the authoritative spec before coding
Use `@/openspec/AGENTS.md` to learn:
- How to create and apply change proposals
- Spec format and conventions
- Project structure and guidelines
Keep this managed block so 'openspec update' can refresh the instructions.
<!-- OPENSPEC:END -->
\ No newline at end of file
.PHONY: build build-backend build-frontend
# 一键编译前后端
build: build-backend build-frontend
# 编译后端(复用 backend/Makefile)
build-backend:
@$(MAKE) -C backend build
# 编译前端(需要已安装依赖)
build-frontend:
@npm --prefix frontend run build
......@@ -20,6 +20,8 @@ English | [中文](README_CN.md)
Try Sub2API online: **https://v2.pincc.ai/**
Demo credentials (shared demo environment; **not** created automatically for self-hosted installs):
| Email | Password |
|-------|----------|
| admin@sub2api.com | admin123 |
......@@ -260,8 +262,10 @@ jwt:
expire_hour: 24
default:
admin_email: "admin@example.com"
admin_password: "admin123"
user_concurrency: 5
user_balance: 0
api_key_prefix: "sk-"
rate_multiplier: 1.0
```
```bash
......@@ -281,6 +285,16 @@ cd frontend
npm run dev
```
#### Code Generation
When editing `backend/ent/schema`, regenerate Ent + Wire:
```bash
cd backend
go generate ./ent
go generate ./cmd/server
```
---
## Project Structure
......
......@@ -20,6 +20,8 @@
体验地址:**https://v2.pincc.ai/**
演示账号(共享演示环境;自建部署不会自动创建该账号):
| 邮箱 | 密码 |
|------|------|
| admin@sub2api.com | admin123 |
......@@ -260,8 +262,10 @@ jwt:
expire_hour: 24
default:
admin_email: "admin@example.com"
admin_password: "admin123"
user_concurrency: 5
user_balance: 0
api_key_prefix: "sk-"
rate_multiplier: 1.0
```
```bash
......@@ -281,6 +285,16 @@ cd frontend
npm run dev
```
#### 代码生成
修改 `backend/ent/schema` 后,需要重新生成 Ent + Wire:
```bash
cd backend
go generate ./ent
go generate ./cmd/server
```
---
## 项目结构
......
......@@ -15,6 +15,7 @@ import (
"syscall"
"time"
_ "github.com/Wei-Shaw/sub2api/ent/runtime"
"github.com/Wei-Shaw/sub2api/internal/config"
"github.com/Wei-Shaw/sub2api/internal/handler"
"github.com/Wei-Shaw/sub2api/internal/server/middleware"
......
......@@ -9,6 +9,7 @@ import (
"net/http"
"time"
"github.com/Wei-Shaw/sub2api/ent"
"github.com/Wei-Shaw/sub2api/internal/config"
"github.com/Wei-Shaw/sub2api/internal/handler"
"github.com/Wei-Shaw/sub2api/internal/infrastructure"
......@@ -19,7 +20,6 @@ import (
"github.com/google/wire"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
type Application struct {
......@@ -62,7 +62,7 @@ func provideServiceBuildInfo(buildInfo handler.BuildInfo) service.BuildInfo {
}
func provideCleanup(
db *gorm.DB,
entClient *ent.Client,
rdb *redis.Client,
tokenRefresh *service.TokenRefreshService,
pricing *service.PricingService,
......@@ -107,12 +107,8 @@ func provideCleanup(
{"Redis", func() error {
return rdb.Close()
}},
{"Database", func() error {
sqlDB, err := db.DB()
if err != nil {
return err
}
return sqlDB.Close()
{"Ent", func() error {
return entClient.Close()
}},
}
......
......@@ -8,6 +8,7 @@ package main
import (
"context"
"github.com/Wei-Shaw/sub2api/ent"
"github.com/Wei-Shaw/sub2api/internal/config"
"github.com/Wei-Shaw/sub2api/internal/handler"
"github.com/Wei-Shaw/sub2api/internal/handler/admin"
......@@ -17,7 +18,6 @@ import (
"github.com/Wei-Shaw/sub2api/internal/server/middleware"
"github.com/Wei-Shaw/sub2api/internal/service"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
"log"
"net/http"
"time"
......@@ -25,6 +25,7 @@ import (
import (
_ "embed"
_ "github.com/Wei-Shaw/sub2api/ent/runtime"
)
// Injectors from wire.go:
......@@ -34,15 +35,19 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
if err != nil {
return nil, err
}
db, err := infrastructure.ProvideDB(configConfig)
client, err := infrastructure.ProvideEnt(configConfig)
if err != nil {
return nil, err
}
userRepository := repository.NewUserRepository(db)
settingRepository := repository.NewSettingRepository(db)
sqlDB, err := infrastructure.ProvideSQLDB(client)
if err != nil {
return nil, err
}
userRepository := repository.NewUserRepository(client, sqlDB)
settingRepository := repository.NewSettingRepository(client)
settingService := service.NewSettingService(settingRepository, configConfig)
client := infrastructure.ProvideRedis(configConfig)
emailCache := repository.NewEmailCache(client)
redisClient := infrastructure.ProvideRedis(configConfig)
emailCache := repository.NewEmailCache(redisClient)
emailService := service.NewEmailService(settingRepository, emailCache)
turnstileVerifier := repository.NewTurnstileVerifier()
turnstileService := service.NewTurnstileService(settingService, turnstileVerifier)
......@@ -51,27 +56,27 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
userService := service.NewUserService(userRepository)
authHandler := handler.NewAuthHandler(authService, userService)
userHandler := handler.NewUserHandler(userService)
apiKeyRepository := repository.NewApiKeyRepository(db)
groupRepository := repository.NewGroupRepository(db)
userSubscriptionRepository := repository.NewUserSubscriptionRepository(db)
apiKeyCache := repository.NewApiKeyCache(client)
apiKeyRepository := repository.NewApiKeyRepository(client)
groupRepository := repository.NewGroupRepository(client, sqlDB)
userSubscriptionRepository := repository.NewUserSubscriptionRepository(client)
apiKeyCache := repository.NewApiKeyCache(redisClient)
apiKeyService := service.NewApiKeyService(apiKeyRepository, userRepository, groupRepository, userSubscriptionRepository, apiKeyCache, configConfig)
apiKeyHandler := handler.NewAPIKeyHandler(apiKeyService)
usageLogRepository := repository.NewUsageLogRepository(db)
usageLogRepository := repository.NewUsageLogRepository(client, sqlDB)
usageService := service.NewUsageService(usageLogRepository, userRepository)
usageHandler := handler.NewUsageHandler(usageService, apiKeyService)
redeemCodeRepository := repository.NewRedeemCodeRepository(db)
billingCache := repository.NewBillingCache(client)
redeemCodeRepository := repository.NewRedeemCodeRepository(client)
billingCache := repository.NewBillingCache(redisClient)
billingCacheService := service.NewBillingCacheService(billingCache, userRepository, userSubscriptionRepository)
subscriptionService := service.NewSubscriptionService(groupRepository, userSubscriptionRepository, billingCacheService)
redeemCache := repository.NewRedeemCache(client)
redeemCache := repository.NewRedeemCache(redisClient)
redeemService := service.NewRedeemService(redeemCodeRepository, userRepository, subscriptionService, redeemCache, billingCacheService)
redeemHandler := handler.NewRedeemHandler(redeemService)
subscriptionHandler := handler.NewSubscriptionHandler(subscriptionService)
dashboardService := service.NewDashboardService(usageLogRepository)
dashboardHandler := admin.NewDashboardHandler(dashboardService)
accountRepository := repository.NewAccountRepository(db)
proxyRepository := repository.NewProxyRepository(db)
accountRepository := repository.NewAccountRepository(client, sqlDB)
proxyRepository := repository.NewProxyRepository(client, sqlDB)
proxyExitInfoProber := repository.NewProxyExitInfoProber()
adminService := service.NewAdminService(userRepository, groupRepository, accountRepository, proxyRepository, apiKeyRepository, redeemCodeRepository, billingCacheService, proxyExitInfoProber)
adminUserHandler := admin.NewUserHandler(adminService)
......@@ -86,11 +91,11 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
rateLimitService := service.NewRateLimitService(accountRepository, configConfig)
claudeUsageFetcher := repository.NewClaudeUsageFetcher()
accountUsageService := service.NewAccountUsageService(accountRepository, usageLogRepository, claudeUsageFetcher)
geminiTokenCache := repository.NewGeminiTokenCache(client)
geminiTokenCache := repository.NewGeminiTokenCache(redisClient)
geminiTokenProvider := service.NewGeminiTokenProvider(accountRepository, geminiTokenCache, geminiOAuthService)
httpUpstream := repository.NewHTTPUpstream(configConfig)
accountTestService := service.NewAccountTestService(accountRepository, oAuthService, openAIOAuthService, geminiTokenProvider, httpUpstream)
concurrencyCache := repository.NewConcurrencyCache(client)
concurrencyCache := repository.NewConcurrencyCache(redisClient)
concurrencyService := service.NewConcurrencyService(concurrencyCache)
crsSyncService := service.NewCRSSyncService(accountRepository, proxyRepository, oAuthService, openAIOAuthService, geminiOAuthService)
accountHandler := admin.NewAccountHandler(adminService, oAuthService, openAIOAuthService, geminiOAuthService, rateLimitService, accountUsageService, accountTestService, concurrencyService, crsSyncService)
......@@ -100,7 +105,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
proxyHandler := admin.NewProxyHandler(adminService)
adminRedeemHandler := admin.NewRedeemHandler(adminService)
settingHandler := admin.NewSettingHandler(settingService, emailService)
updateCache := repository.NewUpdateCache(client)
updateCache := repository.NewUpdateCache(redisClient)
gitHubReleaseClient := repository.NewGitHubReleaseClient()
serviceBuildInfo := provideServiceBuildInfo(buildInfo)
updateService := service.ProvideUpdateService(updateCache, gitHubReleaseClient, serviceBuildInfo)
......@@ -108,14 +113,14 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
adminSubscriptionHandler := admin.NewSubscriptionHandler(subscriptionService)
adminUsageHandler := admin.NewUsageHandler(usageService, apiKeyService, adminService)
adminHandlers := handler.ProvideAdminHandlers(dashboardHandler, adminUserHandler, groupHandler, accountHandler, oAuthHandler, openAIOAuthHandler, geminiOAuthHandler, proxyHandler, adminRedeemHandler, settingHandler, systemHandler, adminSubscriptionHandler, adminUsageHandler)
gatewayCache := repository.NewGatewayCache(client)
gatewayCache := repository.NewGatewayCache(redisClient)
pricingRemoteClient := repository.NewPricingRemoteClient()
pricingService, err := service.ProvidePricingService(configConfig, pricingRemoteClient)
if err != nil {
return nil, err
}
billingService := service.NewBillingService(configConfig, pricingService)
identityCache := repository.NewIdentityCache(client)
identityCache := repository.NewIdentityCache(redisClient)
identityService := service.NewIdentityService(identityCache)
timingWheelService := service.ProvideTimingWheelService()
deferredService := service.ProvideDeferredService(accountRepository, timingWheelService)
......@@ -132,7 +137,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
engine := server.ProvideRouter(configConfig, handlers, jwtAuthMiddleware, adminAuthMiddleware, apiKeyAuthMiddleware, apiKeyService, subscriptionService)
httpServer := server.ProvideHTTPServer(configConfig, engine)
tokenRefreshService := service.ProvideTokenRefreshService(accountRepository, oAuthService, openAIOAuthService, geminiOAuthService, configConfig)
v := provideCleanup(db, client, tokenRefreshService, pricingService, emailQueueService, oAuthService, openAIOAuthService, geminiOAuthService)
v := provideCleanup(client, redisClient, tokenRefreshService, pricingService, emailQueueService, oAuthService, openAIOAuthService, geminiOAuthService)
application := &Application{
Server: httpServer,
Cleanup: v,
......@@ -155,7 +160,7 @@ func provideServiceBuildInfo(buildInfo handler.BuildInfo) service.BuildInfo {
}
func provideCleanup(
db *gorm.DB,
entClient *ent.Client,
rdb *redis.Client,
tokenRefresh *service.TokenRefreshService,
pricing *service.PricingService,
......@@ -199,12 +204,8 @@ func provideCleanup(
{"Redis", func() error {
return rdb.Close()
}},
{"Database", func() error {
sqlDB, err := db.DB()
if err != nil {
return err
}
return sqlDB.Close()
{"Ent", func() error {
return entClient.Close()
}},
}
......
// Code generated by ent, DO NOT EDIT.
package ent
import (
"encoding/json"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/account"
)
// Account is the model entity for the Account schema.
type Account 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"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Platform holds the value of the "platform" field.
Platform string `json:"platform,omitempty"`
// Type holds the value of the "type" field.
Type string `json:"type,omitempty"`
// Credentials holds the value of the "credentials" field.
Credentials map[string]interface{} `json:"credentials,omitempty"`
// Extra holds the value of the "extra" field.
Extra map[string]interface{} `json:"extra,omitempty"`
// ProxyID holds the value of the "proxy_id" field.
ProxyID *int64 `json:"proxy_id,omitempty"`
// Concurrency holds the value of the "concurrency" field.
Concurrency int `json:"concurrency,omitempty"`
// Priority holds the value of the "priority" field.
Priority int `json:"priority,omitempty"`
// Status holds the value of the "status" field.
Status string `json:"status,omitempty"`
// ErrorMessage holds the value of the "error_message" field.
ErrorMessage *string `json:"error_message,omitempty"`
// LastUsedAt holds the value of the "last_used_at" field.
LastUsedAt *time.Time `json:"last_used_at,omitempty"`
// Schedulable holds the value of the "schedulable" field.
Schedulable bool `json:"schedulable,omitempty"`
// RateLimitedAt holds the value of the "rate_limited_at" field.
RateLimitedAt *time.Time `json:"rate_limited_at,omitempty"`
// RateLimitResetAt holds the value of the "rate_limit_reset_at" field.
RateLimitResetAt *time.Time `json:"rate_limit_reset_at,omitempty"`
// OverloadUntil holds the value of the "overload_until" field.
OverloadUntil *time.Time `json:"overload_until,omitempty"`
// SessionWindowStart holds the value of the "session_window_start" field.
SessionWindowStart *time.Time `json:"session_window_start,omitempty"`
// SessionWindowEnd holds the value of the "session_window_end" field.
SessionWindowEnd *time.Time `json:"session_window_end,omitempty"`
// SessionWindowStatus holds the value of the "session_window_status" field.
SessionWindowStatus *string `json:"session_window_status,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the AccountQuery when eager-loading is set.
Edges AccountEdges `json:"edges"`
selectValues sql.SelectValues
}
// AccountEdges holds the relations/edges for other nodes in the graph.
type AccountEdges struct {
// Groups holds the value of the groups edge.
Groups []*Group `json:"groups,omitempty"`
// AccountGroups holds the value of the account_groups edge.
AccountGroups []*AccountGroup `json:"account_groups,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
}
// GroupsOrErr returns the Groups value or an error if the edge
// was not loaded in eager-loading.
func (e AccountEdges) GroupsOrErr() ([]*Group, error) {
if e.loadedTypes[0] {
return e.Groups, nil
}
return nil, &NotLoadedError{edge: "groups"}
}
// AccountGroupsOrErr returns the AccountGroups value or an error if the edge
// was not loaded in eager-loading.
func (e AccountEdges) AccountGroupsOrErr() ([]*AccountGroup, error) {
if e.loadedTypes[1] {
return e.AccountGroups, nil
}
return nil, &NotLoadedError{edge: "account_groups"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Account) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case account.FieldCredentials, account.FieldExtra:
values[i] = new([]byte)
case account.FieldSchedulable:
values[i] = new(sql.NullBool)
case account.FieldID, account.FieldProxyID, account.FieldConcurrency, account.FieldPriority:
values[i] = new(sql.NullInt64)
case account.FieldName, account.FieldPlatform, account.FieldType, account.FieldStatus, account.FieldErrorMessage, account.FieldSessionWindowStatus:
values[i] = new(sql.NullString)
case account.FieldCreatedAt, account.FieldUpdatedAt, account.FieldDeletedAt, account.FieldLastUsedAt, account.FieldRateLimitedAt, account.FieldRateLimitResetAt, account.FieldOverloadUntil, account.FieldSessionWindowStart, account.FieldSessionWindowEnd:
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 Account fields.
func (_m *Account) 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 account.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 account.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 account.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 account.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 account.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case account.FieldPlatform:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field platform", values[i])
} else if value.Valid {
_m.Platform = value.String
}
case account.FieldType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field type", values[i])
} else if value.Valid {
_m.Type = value.String
}
case account.FieldCredentials:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field credentials", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Credentials); err != nil {
return fmt.Errorf("unmarshal field credentials: %w", err)
}
}
case account.FieldExtra:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field extra", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Extra); err != nil {
return fmt.Errorf("unmarshal field extra: %w", err)
}
}
case account.FieldProxyID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field proxy_id", values[i])
} else if value.Valid {
_m.ProxyID = new(int64)
*_m.ProxyID = value.Int64
}
case account.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 account.FieldPriority:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field priority", values[i])
} else if value.Valid {
_m.Priority = int(value.Int64)
}
case account.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 account.FieldErrorMessage:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field error_message", values[i])
} else if value.Valid {
_m.ErrorMessage = new(string)
*_m.ErrorMessage = value.String
}
case account.FieldLastUsedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field last_used_at", values[i])
} else if value.Valid {
_m.LastUsedAt = new(time.Time)
*_m.LastUsedAt = value.Time
}
case account.FieldSchedulable:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field schedulable", values[i])
} else if value.Valid {
_m.Schedulable = value.Bool
}
case account.FieldRateLimitedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field rate_limited_at", values[i])
} else if value.Valid {
_m.RateLimitedAt = new(time.Time)
*_m.RateLimitedAt = value.Time
}
case account.FieldRateLimitResetAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field rate_limit_reset_at", values[i])
} else if value.Valid {
_m.RateLimitResetAt = new(time.Time)
*_m.RateLimitResetAt = value.Time
}
case account.FieldOverloadUntil:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field overload_until", values[i])
} else if value.Valid {
_m.OverloadUntil = new(time.Time)
*_m.OverloadUntil = value.Time
}
case account.FieldSessionWindowStart:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field session_window_start", values[i])
} else if value.Valid {
_m.SessionWindowStart = new(time.Time)
*_m.SessionWindowStart = value.Time
}
case account.FieldSessionWindowEnd:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field session_window_end", values[i])
} else if value.Valid {
_m.SessionWindowEnd = new(time.Time)
*_m.SessionWindowEnd = value.Time
}
case account.FieldSessionWindowStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field session_window_status", values[i])
} else if value.Valid {
_m.SessionWindowStatus = new(string)
*_m.SessionWindowStatus = value.String
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Account.
// This includes values selected through modifiers, order, etc.
func (_m *Account) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryGroups queries the "groups" edge of the Account entity.
func (_m *Account) QueryGroups() *GroupQuery {
return NewAccountClient(_m.config).QueryGroups(_m)
}
// QueryAccountGroups queries the "account_groups" edge of the Account entity.
func (_m *Account) QueryAccountGroups() *AccountGroupQuery {
return NewAccountClient(_m.config).QueryAccountGroups(_m)
}
// Update returns a builder for updating this Account.
// Note that you need to call Account.Unwrap() before calling this method if this Account
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *Account) Update() *AccountUpdateOne {
return NewAccountClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the Account 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 *Account) Unwrap() *Account {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: Account is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *Account) String() string {
var builder strings.Builder
builder.WriteString("Account(")
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("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("platform=")
builder.WriteString(_m.Platform)
builder.WriteString(", ")
builder.WriteString("type=")
builder.WriteString(_m.Type)
builder.WriteString(", ")
builder.WriteString("credentials=")
builder.WriteString(fmt.Sprintf("%v", _m.Credentials))
builder.WriteString(", ")
builder.WriteString("extra=")
builder.WriteString(fmt.Sprintf("%v", _m.Extra))
builder.WriteString(", ")
if v := _m.ProxyID; v != nil {
builder.WriteString("proxy_id=")
builder.WriteString(fmt.Sprintf("%v", *v))
}
builder.WriteString(", ")
builder.WriteString("concurrency=")
builder.WriteString(fmt.Sprintf("%v", _m.Concurrency))
builder.WriteString(", ")
builder.WriteString("priority=")
builder.WriteString(fmt.Sprintf("%v", _m.Priority))
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(_m.Status)
builder.WriteString(", ")
if v := _m.ErrorMessage; v != nil {
builder.WriteString("error_message=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.LastUsedAt; v != nil {
builder.WriteString("last_used_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
builder.WriteString("schedulable=")
builder.WriteString(fmt.Sprintf("%v", _m.Schedulable))
builder.WriteString(", ")
if v := _m.RateLimitedAt; v != nil {
builder.WriteString("rate_limited_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
if v := _m.RateLimitResetAt; v != nil {
builder.WriteString("rate_limit_reset_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
if v := _m.OverloadUntil; v != nil {
builder.WriteString("overload_until=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
if v := _m.SessionWindowStart; v != nil {
builder.WriteString("session_window_start=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
if v := _m.SessionWindowEnd; v != nil {
builder.WriteString("session_window_end=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
if v := _m.SessionWindowStatus; v != nil {
builder.WriteString("session_window_status=")
builder.WriteString(*v)
}
builder.WriteByte(')')
return builder.String()
}
// Accounts is a parsable slice of Account.
type Accounts []*Account
// Code generated by ent, DO NOT EDIT.
package account
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the account type in the database.
Label = "account"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldPlatform holds the string denoting the platform field in the database.
FieldPlatform = "platform"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldCredentials holds the string denoting the credentials field in the database.
FieldCredentials = "credentials"
// FieldExtra holds the string denoting the extra field in the database.
FieldExtra = "extra"
// FieldProxyID holds the string denoting the proxy_id field in the database.
FieldProxyID = "proxy_id"
// FieldConcurrency holds the string denoting the concurrency field in the database.
FieldConcurrency = "concurrency"
// FieldPriority holds the string denoting the priority field in the database.
FieldPriority = "priority"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldErrorMessage holds the string denoting the error_message field in the database.
FieldErrorMessage = "error_message"
// FieldLastUsedAt holds the string denoting the last_used_at field in the database.
FieldLastUsedAt = "last_used_at"
// FieldSchedulable holds the string denoting the schedulable field in the database.
FieldSchedulable = "schedulable"
// FieldRateLimitedAt holds the string denoting the rate_limited_at field in the database.
FieldRateLimitedAt = "rate_limited_at"
// FieldRateLimitResetAt holds the string denoting the rate_limit_reset_at field in the database.
FieldRateLimitResetAt = "rate_limit_reset_at"
// FieldOverloadUntil holds the string denoting the overload_until field in the database.
FieldOverloadUntil = "overload_until"
// FieldSessionWindowStart holds the string denoting the session_window_start field in the database.
FieldSessionWindowStart = "session_window_start"
// FieldSessionWindowEnd holds the string denoting the session_window_end field in the database.
FieldSessionWindowEnd = "session_window_end"
// FieldSessionWindowStatus holds the string denoting the session_window_status field in the database.
FieldSessionWindowStatus = "session_window_status"
// EdgeGroups holds the string denoting the groups edge name in mutations.
EdgeGroups = "groups"
// EdgeAccountGroups holds the string denoting the account_groups edge name in mutations.
EdgeAccountGroups = "account_groups"
// Table holds the table name of the account in the database.
Table = "accounts"
// GroupsTable is the table that holds the groups relation/edge. The primary key declared below.
GroupsTable = "account_groups"
// GroupsInverseTable is the table name for the Group entity.
// It exists in this package in order to avoid circular dependency with the "group" package.
GroupsInverseTable = "groups"
// AccountGroupsTable is the table that holds the account_groups relation/edge.
AccountGroupsTable = "account_groups"
// AccountGroupsInverseTable is the table name for the AccountGroup entity.
// It exists in this package in order to avoid circular dependency with the "accountgroup" package.
AccountGroupsInverseTable = "account_groups"
// AccountGroupsColumn is the table column denoting the account_groups relation/edge.
AccountGroupsColumn = "account_id"
)
// Columns holds all SQL columns for account fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldDeletedAt,
FieldName,
FieldPlatform,
FieldType,
FieldCredentials,
FieldExtra,
FieldProxyID,
FieldConcurrency,
FieldPriority,
FieldStatus,
FieldErrorMessage,
FieldLastUsedAt,
FieldSchedulable,
FieldRateLimitedAt,
FieldRateLimitResetAt,
FieldOverloadUntil,
FieldSessionWindowStart,
FieldSessionWindowEnd,
FieldSessionWindowStatus,
}
var (
// GroupsPrimaryKey and GroupsColumn2 are the table columns denoting the
// primary key for the groups relation (M2M).
GroupsPrimaryKey = []string{"account_id", "group_id"}
)
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
// import _ "github.com/Wei-Shaw/sub2api/ent/runtime"
var (
Hooks [1]ent.Hook
Interceptors [1]ent.Interceptor
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator func(string) error
// PlatformValidator is a validator for the "platform" field. It is called by the builders before save.
PlatformValidator func(string) error
// TypeValidator is a validator for the "type" field. It is called by the builders before save.
TypeValidator func(string) error
// DefaultCredentials holds the default value on creation for the "credentials" field.
DefaultCredentials func() map[string]interface{}
// DefaultExtra holds the default value on creation for the "extra" field.
DefaultExtra func() map[string]interface{}
// DefaultConcurrency holds the default value on creation for the "concurrency" field.
DefaultConcurrency int
// DefaultPriority holds the default value on creation for the "priority" field.
DefaultPriority int
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus string
// StatusValidator is a validator for the "status" field. It is called by the builders before save.
StatusValidator func(string) error
// DefaultSchedulable holds the default value on creation for the "schedulable" field.
DefaultSchedulable bool
// SessionWindowStatusValidator is a validator for the "session_window_status" field. It is called by the builders before save.
SessionWindowStatusValidator func(string) error
)
// OrderOption defines the ordering options for the Account queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByPlatform orders the results by the platform field.
func ByPlatform(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPlatform, opts...).ToFunc()
}
// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByProxyID orders the results by the proxy_id field.
func ByProxyID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProxyID, opts...).ToFunc()
}
// ByConcurrency orders the results by the concurrency field.
func ByConcurrency(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldConcurrency, opts...).ToFunc()
}
// ByPriority orders the results by the priority field.
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPriority, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByErrorMessage orders the results by the error_message field.
func ByErrorMessage(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldErrorMessage, opts...).ToFunc()
}
// ByLastUsedAt orders the results by the last_used_at field.
func ByLastUsedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLastUsedAt, opts...).ToFunc()
}
// BySchedulable orders the results by the schedulable field.
func BySchedulable(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSchedulable, opts...).ToFunc()
}
// ByRateLimitedAt orders the results by the rate_limited_at field.
func ByRateLimitedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRateLimitedAt, opts...).ToFunc()
}
// ByRateLimitResetAt orders the results by the rate_limit_reset_at field.
func ByRateLimitResetAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRateLimitResetAt, opts...).ToFunc()
}
// ByOverloadUntil orders the results by the overload_until field.
func ByOverloadUntil(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOverloadUntil, opts...).ToFunc()
}
// BySessionWindowStart orders the results by the session_window_start field.
func BySessionWindowStart(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSessionWindowStart, opts...).ToFunc()
}
// BySessionWindowEnd orders the results by the session_window_end field.
func BySessionWindowEnd(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSessionWindowEnd, opts...).ToFunc()
}
// BySessionWindowStatus orders the results by the session_window_status field.
func BySessionWindowStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSessionWindowStatus, opts...).ToFunc()
}
// ByGroupsCount orders the results by groups count.
func ByGroupsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newGroupsStep(), opts...)
}
}
// ByGroups orders the results by groups terms.
func ByGroups(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newGroupsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByAccountGroupsCount orders the results by account_groups count.
func ByAccountGroupsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newAccountGroupsStep(), opts...)
}
}
// ByAccountGroups orders the results by account_groups terms.
func ByAccountGroups(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAccountGroupsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newGroupsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(GroupsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, GroupsTable, GroupsPrimaryKey...),
)
}
func newAccountGroupsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(AccountGroupsInverseTable, AccountGroupsColumn),
sqlgraph.Edge(sqlgraph.O2M, true, AccountGroupsTable, AccountGroupsColumn),
)
}
// Code generated by ent, DO NOT EDIT.
package account
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.Account {
return predicate.Account(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.Account {
return predicate.Account(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.Account {
return predicate.Account(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldUpdatedAt, v))
}
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
func DeletedAt(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldDeletedAt, v))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldName, v))
}
// Platform applies equality check predicate on the "platform" field. It's identical to PlatformEQ.
func Platform(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldPlatform, v))
}
// Type applies equality check predicate on the "type" field. It's identical to TypeEQ.
func Type(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldType, v))
}
// ProxyID applies equality check predicate on the "proxy_id" field. It's identical to ProxyIDEQ.
func ProxyID(v int64) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldProxyID, v))
}
// Concurrency applies equality check predicate on the "concurrency" field. It's identical to ConcurrencyEQ.
func Concurrency(v int) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldConcurrency, v))
}
// Priority applies equality check predicate on the "priority" field. It's identical to PriorityEQ.
func Priority(v int) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldPriority, v))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func Status(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldStatus, v))
}
// ErrorMessage applies equality check predicate on the "error_message" field. It's identical to ErrorMessageEQ.
func ErrorMessage(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldErrorMessage, v))
}
// LastUsedAt applies equality check predicate on the "last_used_at" field. It's identical to LastUsedAtEQ.
func LastUsedAt(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldLastUsedAt, v))
}
// Schedulable applies equality check predicate on the "schedulable" field. It's identical to SchedulableEQ.
func Schedulable(v bool) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldSchedulable, v))
}
// RateLimitedAt applies equality check predicate on the "rate_limited_at" field. It's identical to RateLimitedAtEQ.
func RateLimitedAt(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldRateLimitedAt, v))
}
// RateLimitResetAt applies equality check predicate on the "rate_limit_reset_at" field. It's identical to RateLimitResetAtEQ.
func RateLimitResetAt(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldRateLimitResetAt, v))
}
// OverloadUntil applies equality check predicate on the "overload_until" field. It's identical to OverloadUntilEQ.
func OverloadUntil(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldOverloadUntil, v))
}
// SessionWindowStart applies equality check predicate on the "session_window_start" field. It's identical to SessionWindowStartEQ.
func SessionWindowStart(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldSessionWindowStart, v))
}
// SessionWindowEnd applies equality check predicate on the "session_window_end" field. It's identical to SessionWindowEndEQ.
func SessionWindowEnd(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldSessionWindowEnd, v))
}
// SessionWindowStatus applies equality check predicate on the "session_window_status" field. It's identical to SessionWindowStatusEQ.
func SessionWindowStatus(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldSessionWindowStatus, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldUpdatedAt, v))
}
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
func DeletedAtEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldDeletedAt, v))
}
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
func DeletedAtNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldDeletedAt, v))
}
// DeletedAtIn applies the In predicate on the "deleted_at" field.
func DeletedAtIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldDeletedAt, vs...))
}
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
func DeletedAtNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldDeletedAt, vs...))
}
// DeletedAtGT applies the GT predicate on the "deleted_at" field.
func DeletedAtGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldDeletedAt, v))
}
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
func DeletedAtGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldDeletedAt, v))
}
// DeletedAtLT applies the LT predicate on the "deleted_at" field.
func DeletedAtLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldDeletedAt, v))
}
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
func DeletedAtLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldDeletedAt, v))
}
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
func DeletedAtIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldDeletedAt))
}
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
func DeletedAtNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldDeletedAt))
}
// NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldName, v))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldName, v))
}
// NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldIn(FieldName, vs...))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldName, vs...))
}
// NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.Account {
return predicate.Account(sql.FieldGT(FieldName, v))
}
// NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldName, v))
}
// NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.Account {
return predicate.Account(sql.FieldLT(FieldName, v))
}
// NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldName, v))
}
// NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.Account {
return predicate.Account(sql.FieldContains(FieldName, v))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.Account {
return predicate.Account(sql.FieldHasPrefix(FieldName, v))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.Account {
return predicate.Account(sql.FieldHasSuffix(FieldName, v))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.Account {
return predicate.Account(sql.FieldEqualFold(FieldName, v))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.Account {
return predicate.Account(sql.FieldContainsFold(FieldName, v))
}
// PlatformEQ applies the EQ predicate on the "platform" field.
func PlatformEQ(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldPlatform, v))
}
// PlatformNEQ applies the NEQ predicate on the "platform" field.
func PlatformNEQ(v string) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldPlatform, v))
}
// PlatformIn applies the In predicate on the "platform" field.
func PlatformIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldIn(FieldPlatform, vs...))
}
// PlatformNotIn applies the NotIn predicate on the "platform" field.
func PlatformNotIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldPlatform, vs...))
}
// PlatformGT applies the GT predicate on the "platform" field.
func PlatformGT(v string) predicate.Account {
return predicate.Account(sql.FieldGT(FieldPlatform, v))
}
// PlatformGTE applies the GTE predicate on the "platform" field.
func PlatformGTE(v string) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldPlatform, v))
}
// PlatformLT applies the LT predicate on the "platform" field.
func PlatformLT(v string) predicate.Account {
return predicate.Account(sql.FieldLT(FieldPlatform, v))
}
// PlatformLTE applies the LTE predicate on the "platform" field.
func PlatformLTE(v string) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldPlatform, v))
}
// PlatformContains applies the Contains predicate on the "platform" field.
func PlatformContains(v string) predicate.Account {
return predicate.Account(sql.FieldContains(FieldPlatform, v))
}
// PlatformHasPrefix applies the HasPrefix predicate on the "platform" field.
func PlatformHasPrefix(v string) predicate.Account {
return predicate.Account(sql.FieldHasPrefix(FieldPlatform, v))
}
// PlatformHasSuffix applies the HasSuffix predicate on the "platform" field.
func PlatformHasSuffix(v string) predicate.Account {
return predicate.Account(sql.FieldHasSuffix(FieldPlatform, v))
}
// PlatformEqualFold applies the EqualFold predicate on the "platform" field.
func PlatformEqualFold(v string) predicate.Account {
return predicate.Account(sql.FieldEqualFold(FieldPlatform, v))
}
// PlatformContainsFold applies the ContainsFold predicate on the "platform" field.
func PlatformContainsFold(v string) predicate.Account {
return predicate.Account(sql.FieldContainsFold(FieldPlatform, v))
}
// TypeEQ applies the EQ predicate on the "type" field.
func TypeEQ(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldType, v))
}
// TypeNEQ applies the NEQ predicate on the "type" field.
func TypeNEQ(v string) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldType, v))
}
// TypeIn applies the In predicate on the "type" field.
func TypeIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldIn(FieldType, vs...))
}
// TypeNotIn applies the NotIn predicate on the "type" field.
func TypeNotIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldType, vs...))
}
// TypeGT applies the GT predicate on the "type" field.
func TypeGT(v string) predicate.Account {
return predicate.Account(sql.FieldGT(FieldType, v))
}
// TypeGTE applies the GTE predicate on the "type" field.
func TypeGTE(v string) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldType, v))
}
// TypeLT applies the LT predicate on the "type" field.
func TypeLT(v string) predicate.Account {
return predicate.Account(sql.FieldLT(FieldType, v))
}
// TypeLTE applies the LTE predicate on the "type" field.
func TypeLTE(v string) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldType, v))
}
// TypeContains applies the Contains predicate on the "type" field.
func TypeContains(v string) predicate.Account {
return predicate.Account(sql.FieldContains(FieldType, v))
}
// TypeHasPrefix applies the HasPrefix predicate on the "type" field.
func TypeHasPrefix(v string) predicate.Account {
return predicate.Account(sql.FieldHasPrefix(FieldType, v))
}
// TypeHasSuffix applies the HasSuffix predicate on the "type" field.
func TypeHasSuffix(v string) predicate.Account {
return predicate.Account(sql.FieldHasSuffix(FieldType, v))
}
// TypeEqualFold applies the EqualFold predicate on the "type" field.
func TypeEqualFold(v string) predicate.Account {
return predicate.Account(sql.FieldEqualFold(FieldType, v))
}
// TypeContainsFold applies the ContainsFold predicate on the "type" field.
func TypeContainsFold(v string) predicate.Account {
return predicate.Account(sql.FieldContainsFold(FieldType, v))
}
// ProxyIDEQ applies the EQ predicate on the "proxy_id" field.
func ProxyIDEQ(v int64) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldProxyID, v))
}
// ProxyIDNEQ applies the NEQ predicate on the "proxy_id" field.
func ProxyIDNEQ(v int64) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldProxyID, v))
}
// ProxyIDIn applies the In predicate on the "proxy_id" field.
func ProxyIDIn(vs ...int64) predicate.Account {
return predicate.Account(sql.FieldIn(FieldProxyID, vs...))
}
// ProxyIDNotIn applies the NotIn predicate on the "proxy_id" field.
func ProxyIDNotIn(vs ...int64) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldProxyID, vs...))
}
// ProxyIDGT applies the GT predicate on the "proxy_id" field.
func ProxyIDGT(v int64) predicate.Account {
return predicate.Account(sql.FieldGT(FieldProxyID, v))
}
// ProxyIDGTE applies the GTE predicate on the "proxy_id" field.
func ProxyIDGTE(v int64) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldProxyID, v))
}
// ProxyIDLT applies the LT predicate on the "proxy_id" field.
func ProxyIDLT(v int64) predicate.Account {
return predicate.Account(sql.FieldLT(FieldProxyID, v))
}
// ProxyIDLTE applies the LTE predicate on the "proxy_id" field.
func ProxyIDLTE(v int64) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldProxyID, v))
}
// ProxyIDIsNil applies the IsNil predicate on the "proxy_id" field.
func ProxyIDIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldProxyID))
}
// ProxyIDNotNil applies the NotNil predicate on the "proxy_id" field.
func ProxyIDNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldProxyID))
}
// ConcurrencyEQ applies the EQ predicate on the "concurrency" field.
func ConcurrencyEQ(v int) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldConcurrency, v))
}
// ConcurrencyNEQ applies the NEQ predicate on the "concurrency" field.
func ConcurrencyNEQ(v int) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldConcurrency, v))
}
// ConcurrencyIn applies the In predicate on the "concurrency" field.
func ConcurrencyIn(vs ...int) predicate.Account {
return predicate.Account(sql.FieldIn(FieldConcurrency, vs...))
}
// ConcurrencyNotIn applies the NotIn predicate on the "concurrency" field.
func ConcurrencyNotIn(vs ...int) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldConcurrency, vs...))
}
// ConcurrencyGT applies the GT predicate on the "concurrency" field.
func ConcurrencyGT(v int) predicate.Account {
return predicate.Account(sql.FieldGT(FieldConcurrency, v))
}
// ConcurrencyGTE applies the GTE predicate on the "concurrency" field.
func ConcurrencyGTE(v int) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldConcurrency, v))
}
// ConcurrencyLT applies the LT predicate on the "concurrency" field.
func ConcurrencyLT(v int) predicate.Account {
return predicate.Account(sql.FieldLT(FieldConcurrency, v))
}
// ConcurrencyLTE applies the LTE predicate on the "concurrency" field.
func ConcurrencyLTE(v int) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldConcurrency, v))
}
// PriorityEQ applies the EQ predicate on the "priority" field.
func PriorityEQ(v int) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldPriority, v))
}
// PriorityNEQ applies the NEQ predicate on the "priority" field.
func PriorityNEQ(v int) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldPriority, v))
}
// PriorityIn applies the In predicate on the "priority" field.
func PriorityIn(vs ...int) predicate.Account {
return predicate.Account(sql.FieldIn(FieldPriority, vs...))
}
// PriorityNotIn applies the NotIn predicate on the "priority" field.
func PriorityNotIn(vs ...int) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldPriority, vs...))
}
// PriorityGT applies the GT predicate on the "priority" field.
func PriorityGT(v int) predicate.Account {
return predicate.Account(sql.FieldGT(FieldPriority, v))
}
// PriorityGTE applies the GTE predicate on the "priority" field.
func PriorityGTE(v int) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldPriority, v))
}
// PriorityLT applies the LT predicate on the "priority" field.
func PriorityLT(v int) predicate.Account {
return predicate.Account(sql.FieldLT(FieldPriority, v))
}
// PriorityLTE applies the LTE predicate on the "priority" field.
func PriorityLTE(v int) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldPriority, v))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldStatus, v))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func StatusNEQ(v string) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldStatus, v))
}
// StatusIn applies the In predicate on the "status" field.
func StatusIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldIn(FieldStatus, vs...))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func StatusNotIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldStatus, vs...))
}
// StatusGT applies the GT predicate on the "status" field.
func StatusGT(v string) predicate.Account {
return predicate.Account(sql.FieldGT(FieldStatus, v))
}
// StatusGTE applies the GTE predicate on the "status" field.
func StatusGTE(v string) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldStatus, v))
}
// StatusLT applies the LT predicate on the "status" field.
func StatusLT(v string) predicate.Account {
return predicate.Account(sql.FieldLT(FieldStatus, v))
}
// StatusLTE applies the LTE predicate on the "status" field.
func StatusLTE(v string) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldStatus, v))
}
// StatusContains applies the Contains predicate on the "status" field.
func StatusContains(v string) predicate.Account {
return predicate.Account(sql.FieldContains(FieldStatus, v))
}
// StatusHasPrefix applies the HasPrefix predicate on the "status" field.
func StatusHasPrefix(v string) predicate.Account {
return predicate.Account(sql.FieldHasPrefix(FieldStatus, v))
}
// StatusHasSuffix applies the HasSuffix predicate on the "status" field.
func StatusHasSuffix(v string) predicate.Account {
return predicate.Account(sql.FieldHasSuffix(FieldStatus, v))
}
// StatusEqualFold applies the EqualFold predicate on the "status" field.
func StatusEqualFold(v string) predicate.Account {
return predicate.Account(sql.FieldEqualFold(FieldStatus, v))
}
// StatusContainsFold applies the ContainsFold predicate on the "status" field.
func StatusContainsFold(v string) predicate.Account {
return predicate.Account(sql.FieldContainsFold(FieldStatus, v))
}
// ErrorMessageEQ applies the EQ predicate on the "error_message" field.
func ErrorMessageEQ(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldErrorMessage, v))
}
// ErrorMessageNEQ applies the NEQ predicate on the "error_message" field.
func ErrorMessageNEQ(v string) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldErrorMessage, v))
}
// ErrorMessageIn applies the In predicate on the "error_message" field.
func ErrorMessageIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldIn(FieldErrorMessage, vs...))
}
// ErrorMessageNotIn applies the NotIn predicate on the "error_message" field.
func ErrorMessageNotIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldErrorMessage, vs...))
}
// ErrorMessageGT applies the GT predicate on the "error_message" field.
func ErrorMessageGT(v string) predicate.Account {
return predicate.Account(sql.FieldGT(FieldErrorMessage, v))
}
// ErrorMessageGTE applies the GTE predicate on the "error_message" field.
func ErrorMessageGTE(v string) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldErrorMessage, v))
}
// ErrorMessageLT applies the LT predicate on the "error_message" field.
func ErrorMessageLT(v string) predicate.Account {
return predicate.Account(sql.FieldLT(FieldErrorMessage, v))
}
// ErrorMessageLTE applies the LTE predicate on the "error_message" field.
func ErrorMessageLTE(v string) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldErrorMessage, v))
}
// ErrorMessageContains applies the Contains predicate on the "error_message" field.
func ErrorMessageContains(v string) predicate.Account {
return predicate.Account(sql.FieldContains(FieldErrorMessage, v))
}
// ErrorMessageHasPrefix applies the HasPrefix predicate on the "error_message" field.
func ErrorMessageHasPrefix(v string) predicate.Account {
return predicate.Account(sql.FieldHasPrefix(FieldErrorMessage, v))
}
// ErrorMessageHasSuffix applies the HasSuffix predicate on the "error_message" field.
func ErrorMessageHasSuffix(v string) predicate.Account {
return predicate.Account(sql.FieldHasSuffix(FieldErrorMessage, v))
}
// ErrorMessageIsNil applies the IsNil predicate on the "error_message" field.
func ErrorMessageIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldErrorMessage))
}
// ErrorMessageNotNil applies the NotNil predicate on the "error_message" field.
func ErrorMessageNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldErrorMessage))
}
// ErrorMessageEqualFold applies the EqualFold predicate on the "error_message" field.
func ErrorMessageEqualFold(v string) predicate.Account {
return predicate.Account(sql.FieldEqualFold(FieldErrorMessage, v))
}
// ErrorMessageContainsFold applies the ContainsFold predicate on the "error_message" field.
func ErrorMessageContainsFold(v string) predicate.Account {
return predicate.Account(sql.FieldContainsFold(FieldErrorMessage, v))
}
// LastUsedAtEQ applies the EQ predicate on the "last_used_at" field.
func LastUsedAtEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldLastUsedAt, v))
}
// LastUsedAtNEQ applies the NEQ predicate on the "last_used_at" field.
func LastUsedAtNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldLastUsedAt, v))
}
// LastUsedAtIn applies the In predicate on the "last_used_at" field.
func LastUsedAtIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldLastUsedAt, vs...))
}
// LastUsedAtNotIn applies the NotIn predicate on the "last_used_at" field.
func LastUsedAtNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldLastUsedAt, vs...))
}
// LastUsedAtGT applies the GT predicate on the "last_used_at" field.
func LastUsedAtGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldLastUsedAt, v))
}
// LastUsedAtGTE applies the GTE predicate on the "last_used_at" field.
func LastUsedAtGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldLastUsedAt, v))
}
// LastUsedAtLT applies the LT predicate on the "last_used_at" field.
func LastUsedAtLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldLastUsedAt, v))
}
// LastUsedAtLTE applies the LTE predicate on the "last_used_at" field.
func LastUsedAtLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldLastUsedAt, v))
}
// LastUsedAtIsNil applies the IsNil predicate on the "last_used_at" field.
func LastUsedAtIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldLastUsedAt))
}
// LastUsedAtNotNil applies the NotNil predicate on the "last_used_at" field.
func LastUsedAtNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldLastUsedAt))
}
// SchedulableEQ applies the EQ predicate on the "schedulable" field.
func SchedulableEQ(v bool) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldSchedulable, v))
}
// SchedulableNEQ applies the NEQ predicate on the "schedulable" field.
func SchedulableNEQ(v bool) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldSchedulable, v))
}
// RateLimitedAtEQ applies the EQ predicate on the "rate_limited_at" field.
func RateLimitedAtEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldRateLimitedAt, v))
}
// RateLimitedAtNEQ applies the NEQ predicate on the "rate_limited_at" field.
func RateLimitedAtNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldRateLimitedAt, v))
}
// RateLimitedAtIn applies the In predicate on the "rate_limited_at" field.
func RateLimitedAtIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldRateLimitedAt, vs...))
}
// RateLimitedAtNotIn applies the NotIn predicate on the "rate_limited_at" field.
func RateLimitedAtNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldRateLimitedAt, vs...))
}
// RateLimitedAtGT applies the GT predicate on the "rate_limited_at" field.
func RateLimitedAtGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldRateLimitedAt, v))
}
// RateLimitedAtGTE applies the GTE predicate on the "rate_limited_at" field.
func RateLimitedAtGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldRateLimitedAt, v))
}
// RateLimitedAtLT applies the LT predicate on the "rate_limited_at" field.
func RateLimitedAtLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldRateLimitedAt, v))
}
// RateLimitedAtLTE applies the LTE predicate on the "rate_limited_at" field.
func RateLimitedAtLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldRateLimitedAt, v))
}
// RateLimitedAtIsNil applies the IsNil predicate on the "rate_limited_at" field.
func RateLimitedAtIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldRateLimitedAt))
}
// RateLimitedAtNotNil applies the NotNil predicate on the "rate_limited_at" field.
func RateLimitedAtNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldRateLimitedAt))
}
// RateLimitResetAtEQ applies the EQ predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldRateLimitResetAt, v))
}
// RateLimitResetAtNEQ applies the NEQ predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldRateLimitResetAt, v))
}
// RateLimitResetAtIn applies the In predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldRateLimitResetAt, vs...))
}
// RateLimitResetAtNotIn applies the NotIn predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldRateLimitResetAt, vs...))
}
// RateLimitResetAtGT applies the GT predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldRateLimitResetAt, v))
}
// RateLimitResetAtGTE applies the GTE predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldRateLimitResetAt, v))
}
// RateLimitResetAtLT applies the LT predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldRateLimitResetAt, v))
}
// RateLimitResetAtLTE applies the LTE predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldRateLimitResetAt, v))
}
// RateLimitResetAtIsNil applies the IsNil predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldRateLimitResetAt))
}
// RateLimitResetAtNotNil applies the NotNil predicate on the "rate_limit_reset_at" field.
func RateLimitResetAtNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldRateLimitResetAt))
}
// OverloadUntilEQ applies the EQ predicate on the "overload_until" field.
func OverloadUntilEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldOverloadUntil, v))
}
// OverloadUntilNEQ applies the NEQ predicate on the "overload_until" field.
func OverloadUntilNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldOverloadUntil, v))
}
// OverloadUntilIn applies the In predicate on the "overload_until" field.
func OverloadUntilIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldOverloadUntil, vs...))
}
// OverloadUntilNotIn applies the NotIn predicate on the "overload_until" field.
func OverloadUntilNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldOverloadUntil, vs...))
}
// OverloadUntilGT applies the GT predicate on the "overload_until" field.
func OverloadUntilGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldOverloadUntil, v))
}
// OverloadUntilGTE applies the GTE predicate on the "overload_until" field.
func OverloadUntilGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldOverloadUntil, v))
}
// OverloadUntilLT applies the LT predicate on the "overload_until" field.
func OverloadUntilLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldOverloadUntil, v))
}
// OverloadUntilLTE applies the LTE predicate on the "overload_until" field.
func OverloadUntilLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldOverloadUntil, v))
}
// OverloadUntilIsNil applies the IsNil predicate on the "overload_until" field.
func OverloadUntilIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldOverloadUntil))
}
// OverloadUntilNotNil applies the NotNil predicate on the "overload_until" field.
func OverloadUntilNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldOverloadUntil))
}
// SessionWindowStartEQ applies the EQ predicate on the "session_window_start" field.
func SessionWindowStartEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldSessionWindowStart, v))
}
// SessionWindowStartNEQ applies the NEQ predicate on the "session_window_start" field.
func SessionWindowStartNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldSessionWindowStart, v))
}
// SessionWindowStartIn applies the In predicate on the "session_window_start" field.
func SessionWindowStartIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldSessionWindowStart, vs...))
}
// SessionWindowStartNotIn applies the NotIn predicate on the "session_window_start" field.
func SessionWindowStartNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldSessionWindowStart, vs...))
}
// SessionWindowStartGT applies the GT predicate on the "session_window_start" field.
func SessionWindowStartGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldSessionWindowStart, v))
}
// SessionWindowStartGTE applies the GTE predicate on the "session_window_start" field.
func SessionWindowStartGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldSessionWindowStart, v))
}
// SessionWindowStartLT applies the LT predicate on the "session_window_start" field.
func SessionWindowStartLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldSessionWindowStart, v))
}
// SessionWindowStartLTE applies the LTE predicate on the "session_window_start" field.
func SessionWindowStartLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldSessionWindowStart, v))
}
// SessionWindowStartIsNil applies the IsNil predicate on the "session_window_start" field.
func SessionWindowStartIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldSessionWindowStart))
}
// SessionWindowStartNotNil applies the NotNil predicate on the "session_window_start" field.
func SessionWindowStartNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldSessionWindowStart))
}
// SessionWindowEndEQ applies the EQ predicate on the "session_window_end" field.
func SessionWindowEndEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldSessionWindowEnd, v))
}
// SessionWindowEndNEQ applies the NEQ predicate on the "session_window_end" field.
func SessionWindowEndNEQ(v time.Time) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldSessionWindowEnd, v))
}
// SessionWindowEndIn applies the In predicate on the "session_window_end" field.
func SessionWindowEndIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldIn(FieldSessionWindowEnd, vs...))
}
// SessionWindowEndNotIn applies the NotIn predicate on the "session_window_end" field.
func SessionWindowEndNotIn(vs ...time.Time) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldSessionWindowEnd, vs...))
}
// SessionWindowEndGT applies the GT predicate on the "session_window_end" field.
func SessionWindowEndGT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGT(FieldSessionWindowEnd, v))
}
// SessionWindowEndGTE applies the GTE predicate on the "session_window_end" field.
func SessionWindowEndGTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldSessionWindowEnd, v))
}
// SessionWindowEndLT applies the LT predicate on the "session_window_end" field.
func SessionWindowEndLT(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLT(FieldSessionWindowEnd, v))
}
// SessionWindowEndLTE applies the LTE predicate on the "session_window_end" field.
func SessionWindowEndLTE(v time.Time) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldSessionWindowEnd, v))
}
// SessionWindowEndIsNil applies the IsNil predicate on the "session_window_end" field.
func SessionWindowEndIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldSessionWindowEnd))
}
// SessionWindowEndNotNil applies the NotNil predicate on the "session_window_end" field.
func SessionWindowEndNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldSessionWindowEnd))
}
// SessionWindowStatusEQ applies the EQ predicate on the "session_window_status" field.
func SessionWindowStatusEQ(v string) predicate.Account {
return predicate.Account(sql.FieldEQ(FieldSessionWindowStatus, v))
}
// SessionWindowStatusNEQ applies the NEQ predicate on the "session_window_status" field.
func SessionWindowStatusNEQ(v string) predicate.Account {
return predicate.Account(sql.FieldNEQ(FieldSessionWindowStatus, v))
}
// SessionWindowStatusIn applies the In predicate on the "session_window_status" field.
func SessionWindowStatusIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldIn(FieldSessionWindowStatus, vs...))
}
// SessionWindowStatusNotIn applies the NotIn predicate on the "session_window_status" field.
func SessionWindowStatusNotIn(vs ...string) predicate.Account {
return predicate.Account(sql.FieldNotIn(FieldSessionWindowStatus, vs...))
}
// SessionWindowStatusGT applies the GT predicate on the "session_window_status" field.
func SessionWindowStatusGT(v string) predicate.Account {
return predicate.Account(sql.FieldGT(FieldSessionWindowStatus, v))
}
// SessionWindowStatusGTE applies the GTE predicate on the "session_window_status" field.
func SessionWindowStatusGTE(v string) predicate.Account {
return predicate.Account(sql.FieldGTE(FieldSessionWindowStatus, v))
}
// SessionWindowStatusLT applies the LT predicate on the "session_window_status" field.
func SessionWindowStatusLT(v string) predicate.Account {
return predicate.Account(sql.FieldLT(FieldSessionWindowStatus, v))
}
// SessionWindowStatusLTE applies the LTE predicate on the "session_window_status" field.
func SessionWindowStatusLTE(v string) predicate.Account {
return predicate.Account(sql.FieldLTE(FieldSessionWindowStatus, v))
}
// SessionWindowStatusContains applies the Contains predicate on the "session_window_status" field.
func SessionWindowStatusContains(v string) predicate.Account {
return predicate.Account(sql.FieldContains(FieldSessionWindowStatus, v))
}
// SessionWindowStatusHasPrefix applies the HasPrefix predicate on the "session_window_status" field.
func SessionWindowStatusHasPrefix(v string) predicate.Account {
return predicate.Account(sql.FieldHasPrefix(FieldSessionWindowStatus, v))
}
// SessionWindowStatusHasSuffix applies the HasSuffix predicate on the "session_window_status" field.
func SessionWindowStatusHasSuffix(v string) predicate.Account {
return predicate.Account(sql.FieldHasSuffix(FieldSessionWindowStatus, v))
}
// SessionWindowStatusIsNil applies the IsNil predicate on the "session_window_status" field.
func SessionWindowStatusIsNil() predicate.Account {
return predicate.Account(sql.FieldIsNull(FieldSessionWindowStatus))
}
// SessionWindowStatusNotNil applies the NotNil predicate on the "session_window_status" field.
func SessionWindowStatusNotNil() predicate.Account {
return predicate.Account(sql.FieldNotNull(FieldSessionWindowStatus))
}
// SessionWindowStatusEqualFold applies the EqualFold predicate on the "session_window_status" field.
func SessionWindowStatusEqualFold(v string) predicate.Account {
return predicate.Account(sql.FieldEqualFold(FieldSessionWindowStatus, v))
}
// SessionWindowStatusContainsFold applies the ContainsFold predicate on the "session_window_status" field.
func SessionWindowStatusContainsFold(v string) predicate.Account {
return predicate.Account(sql.FieldContainsFold(FieldSessionWindowStatus, v))
}
// HasGroups applies the HasEdge predicate on the "groups" edge.
func HasGroups() predicate.Account {
return predicate.Account(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, GroupsTable, GroupsPrimaryKey...),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasGroupsWith applies the HasEdge predicate on the "groups" edge with a given conditions (other predicates).
func HasGroupsWith(preds ...predicate.Group) predicate.Account {
return predicate.Account(func(s *sql.Selector) {
step := newGroupsStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasAccountGroups applies the HasEdge predicate on the "account_groups" edge.
func HasAccountGroups() predicate.Account {
return predicate.Account(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, AccountGroupsTable, AccountGroupsColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasAccountGroupsWith applies the HasEdge predicate on the "account_groups" edge with a given conditions (other predicates).
func HasAccountGroupsWith(preds ...predicate.AccountGroup) predicate.Account {
return predicate.Account(func(s *sql.Selector) {
step := newAccountGroupsStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.Account) predicate.Account {
return predicate.Account(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Account) predicate.Account {
return predicate.Account(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.Account) predicate.Account {
return predicate.Account(sql.NotPredicates(p))
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/account"
"github.com/Wei-Shaw/sub2api/ent/group"
)
// AccountCreate is the builder for creating a Account entity.
type AccountCreate struct {
config
mutation *AccountMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (_c *AccountCreate) SetCreatedAt(v time.Time) *AccountCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *AccountCreate) SetNillableCreatedAt(v *time.Time) *AccountCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *AccountCreate) SetUpdatedAt(v time.Time) *AccountCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *AccountCreate) SetNillableUpdatedAt(v *time.Time) *AccountCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
return _c
}
// SetDeletedAt sets the "deleted_at" field.
func (_c *AccountCreate) SetDeletedAt(v time.Time) *AccountCreate {
_c.mutation.SetDeletedAt(v)
return _c
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_c *AccountCreate) SetNillableDeletedAt(v *time.Time) *AccountCreate {
if v != nil {
_c.SetDeletedAt(*v)
}
return _c
}
// SetName sets the "name" field.
func (_c *AccountCreate) SetName(v string) *AccountCreate {
_c.mutation.SetName(v)
return _c
}
// SetPlatform sets the "platform" field.
func (_c *AccountCreate) SetPlatform(v string) *AccountCreate {
_c.mutation.SetPlatform(v)
return _c
}
// SetType sets the "type" field.
func (_c *AccountCreate) SetType(v string) *AccountCreate {
_c.mutation.SetType(v)
return _c
}
// SetCredentials sets the "credentials" field.
func (_c *AccountCreate) SetCredentials(v map[string]interface{}) *AccountCreate {
_c.mutation.SetCredentials(v)
return _c
}
// SetExtra sets the "extra" field.
func (_c *AccountCreate) SetExtra(v map[string]interface{}) *AccountCreate {
_c.mutation.SetExtra(v)
return _c
}
// SetProxyID sets the "proxy_id" field.
func (_c *AccountCreate) SetProxyID(v int64) *AccountCreate {
_c.mutation.SetProxyID(v)
return _c
}
// SetNillableProxyID sets the "proxy_id" field if the given value is not nil.
func (_c *AccountCreate) SetNillableProxyID(v *int64) *AccountCreate {
if v != nil {
_c.SetProxyID(*v)
}
return _c
}
// SetConcurrency sets the "concurrency" field.
func (_c *AccountCreate) SetConcurrency(v int) *AccountCreate {
_c.mutation.SetConcurrency(v)
return _c
}
// SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
func (_c *AccountCreate) SetNillableConcurrency(v *int) *AccountCreate {
if v != nil {
_c.SetConcurrency(*v)
}
return _c
}
// SetPriority sets the "priority" field.
func (_c *AccountCreate) SetPriority(v int) *AccountCreate {
_c.mutation.SetPriority(v)
return _c
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func (_c *AccountCreate) SetNillablePriority(v *int) *AccountCreate {
if v != nil {
_c.SetPriority(*v)
}
return _c
}
// SetStatus sets the "status" field.
func (_c *AccountCreate) SetStatus(v string) *AccountCreate {
_c.mutation.SetStatus(v)
return _c
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_c *AccountCreate) SetNillableStatus(v *string) *AccountCreate {
if v != nil {
_c.SetStatus(*v)
}
return _c
}
// SetErrorMessage sets the "error_message" field.
func (_c *AccountCreate) SetErrorMessage(v string) *AccountCreate {
_c.mutation.SetErrorMessage(v)
return _c
}
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
func (_c *AccountCreate) SetNillableErrorMessage(v *string) *AccountCreate {
if v != nil {
_c.SetErrorMessage(*v)
}
return _c
}
// SetLastUsedAt sets the "last_used_at" field.
func (_c *AccountCreate) SetLastUsedAt(v time.Time) *AccountCreate {
_c.mutation.SetLastUsedAt(v)
return _c
}
// SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
func (_c *AccountCreate) SetNillableLastUsedAt(v *time.Time) *AccountCreate {
if v != nil {
_c.SetLastUsedAt(*v)
}
return _c
}
// SetSchedulable sets the "schedulable" field.
func (_c *AccountCreate) SetSchedulable(v bool) *AccountCreate {
_c.mutation.SetSchedulable(v)
return _c
}
// SetNillableSchedulable sets the "schedulable" field if the given value is not nil.
func (_c *AccountCreate) SetNillableSchedulable(v *bool) *AccountCreate {
if v != nil {
_c.SetSchedulable(*v)
}
return _c
}
// SetRateLimitedAt sets the "rate_limited_at" field.
func (_c *AccountCreate) SetRateLimitedAt(v time.Time) *AccountCreate {
_c.mutation.SetRateLimitedAt(v)
return _c
}
// SetNillableRateLimitedAt sets the "rate_limited_at" field if the given value is not nil.
func (_c *AccountCreate) SetNillableRateLimitedAt(v *time.Time) *AccountCreate {
if v != nil {
_c.SetRateLimitedAt(*v)
}
return _c
}
// SetRateLimitResetAt sets the "rate_limit_reset_at" field.
func (_c *AccountCreate) SetRateLimitResetAt(v time.Time) *AccountCreate {
_c.mutation.SetRateLimitResetAt(v)
return _c
}
// SetNillableRateLimitResetAt sets the "rate_limit_reset_at" field if the given value is not nil.
func (_c *AccountCreate) SetNillableRateLimitResetAt(v *time.Time) *AccountCreate {
if v != nil {
_c.SetRateLimitResetAt(*v)
}
return _c
}
// SetOverloadUntil sets the "overload_until" field.
func (_c *AccountCreate) SetOverloadUntil(v time.Time) *AccountCreate {
_c.mutation.SetOverloadUntil(v)
return _c
}
// SetNillableOverloadUntil sets the "overload_until" field if the given value is not nil.
func (_c *AccountCreate) SetNillableOverloadUntil(v *time.Time) *AccountCreate {
if v != nil {
_c.SetOverloadUntil(*v)
}
return _c
}
// SetSessionWindowStart sets the "session_window_start" field.
func (_c *AccountCreate) SetSessionWindowStart(v time.Time) *AccountCreate {
_c.mutation.SetSessionWindowStart(v)
return _c
}
// SetNillableSessionWindowStart sets the "session_window_start" field if the given value is not nil.
func (_c *AccountCreate) SetNillableSessionWindowStart(v *time.Time) *AccountCreate {
if v != nil {
_c.SetSessionWindowStart(*v)
}
return _c
}
// SetSessionWindowEnd sets the "session_window_end" field.
func (_c *AccountCreate) SetSessionWindowEnd(v time.Time) *AccountCreate {
_c.mutation.SetSessionWindowEnd(v)
return _c
}
// SetNillableSessionWindowEnd sets the "session_window_end" field if the given value is not nil.
func (_c *AccountCreate) SetNillableSessionWindowEnd(v *time.Time) *AccountCreate {
if v != nil {
_c.SetSessionWindowEnd(*v)
}
return _c
}
// SetSessionWindowStatus sets the "session_window_status" field.
func (_c *AccountCreate) SetSessionWindowStatus(v string) *AccountCreate {
_c.mutation.SetSessionWindowStatus(v)
return _c
}
// SetNillableSessionWindowStatus sets the "session_window_status" field if the given value is not nil.
func (_c *AccountCreate) SetNillableSessionWindowStatus(v *string) *AccountCreate {
if v != nil {
_c.SetSessionWindowStatus(*v)
}
return _c
}
// AddGroupIDs adds the "groups" edge to the Group entity by IDs.
func (_c *AccountCreate) AddGroupIDs(ids ...int64) *AccountCreate {
_c.mutation.AddGroupIDs(ids...)
return _c
}
// AddGroups adds the "groups" edges to the Group entity.
func (_c *AccountCreate) AddGroups(v ...*Group) *AccountCreate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddGroupIDs(ids...)
}
// Mutation returns the AccountMutation object of the builder.
func (_c *AccountCreate) Mutation() *AccountMutation {
return _c.mutation
}
// Save creates the Account in the database.
func (_c *AccountCreate) Save(ctx context.Context) (*Account, error) {
if err := _c.defaults(); err != nil {
return nil, err
}
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *AccountCreate) SaveX(ctx context.Context) *Account {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *AccountCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *AccountCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *AccountCreate) defaults() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
if account.DefaultCreatedAt == nil {
return fmt.Errorf("ent: uninitialized account.DefaultCreatedAt (forgotten import ent/runtime?)")
}
v := account.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
if account.DefaultUpdatedAt == nil {
return fmt.Errorf("ent: uninitialized account.DefaultUpdatedAt (forgotten import ent/runtime?)")
}
v := account.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.Credentials(); !ok {
if account.DefaultCredentials == nil {
return fmt.Errorf("ent: uninitialized account.DefaultCredentials (forgotten import ent/runtime?)")
}
v := account.DefaultCredentials()
_c.mutation.SetCredentials(v)
}
if _, ok := _c.mutation.Extra(); !ok {
if account.DefaultExtra == nil {
return fmt.Errorf("ent: uninitialized account.DefaultExtra (forgotten import ent/runtime?)")
}
v := account.DefaultExtra()
_c.mutation.SetExtra(v)
}
if _, ok := _c.mutation.Concurrency(); !ok {
v := account.DefaultConcurrency
_c.mutation.SetConcurrency(v)
}
if _, ok := _c.mutation.Priority(); !ok {
v := account.DefaultPriority
_c.mutation.SetPriority(v)
}
if _, ok := _c.mutation.Status(); !ok {
v := account.DefaultStatus
_c.mutation.SetStatus(v)
}
if _, ok := _c.mutation.Schedulable(); !ok {
v := account.DefaultSchedulable
_c.mutation.SetSchedulable(v)
}
return nil
}
// check runs all checks and user-defined validators on the builder.
func (_c *AccountCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Account.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Account.updated_at"`)}
}
if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Account.name"`)}
}
if v, ok := _c.mutation.Name(); ok {
if err := account.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)}
}
}
if _, ok := _c.mutation.Platform(); !ok {
return &ValidationError{Name: "platform", err: errors.New(`ent: missing required field "Account.platform"`)}
}
if v, ok := _c.mutation.Platform(); ok {
if err := account.PlatformValidator(v); err != nil {
return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "Account.platform": %w`, err)}
}
}
if _, ok := _c.mutation.GetType(); !ok {
return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Account.type"`)}
}
if v, ok := _c.mutation.GetType(); ok {
if err := account.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Account.type": %w`, err)}
}
}
if _, ok := _c.mutation.Credentials(); !ok {
return &ValidationError{Name: "credentials", err: errors.New(`ent: missing required field "Account.credentials"`)}
}
if _, ok := _c.mutation.Extra(); !ok {
return &ValidationError{Name: "extra", err: errors.New(`ent: missing required field "Account.extra"`)}
}
if _, ok := _c.mutation.Concurrency(); !ok {
return &ValidationError{Name: "concurrency", err: errors.New(`ent: missing required field "Account.concurrency"`)}
}
if _, ok := _c.mutation.Priority(); !ok {
return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "Account.priority"`)}
}
if _, ok := _c.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Account.status"`)}
}
if v, ok := _c.mutation.Status(); ok {
if err := account.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Account.status": %w`, err)}
}
}
if _, ok := _c.mutation.Schedulable(); !ok {
return &ValidationError{Name: "schedulable", err: errors.New(`ent: missing required field "Account.schedulable"`)}
}
if v, ok := _c.mutation.SessionWindowStatus(); ok {
if err := account.SessionWindowStatusValidator(v); err != nil {
return &ValidationError{Name: "session_window_status", err: fmt.Errorf(`ent: validator failed for field "Account.session_window_status": %w`, err)}
}
}
return nil
}
func (_c *AccountCreate) sqlSave(ctx context.Context) (*Account, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *AccountCreate) createSpec() (*Account, *sqlgraph.CreateSpec) {
var (
_node = &Account{config: _c.config}
_spec = sqlgraph.NewCreateSpec(account.Table, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(account.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.DeletedAt(); ok {
_spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
_node.DeletedAt = &value
}
if value, ok := _c.mutation.Name(); ok {
_spec.SetField(account.FieldName, field.TypeString, value)
_node.Name = value
}
if value, ok := _c.mutation.Platform(); ok {
_spec.SetField(account.FieldPlatform, field.TypeString, value)
_node.Platform = value
}
if value, ok := _c.mutation.GetType(); ok {
_spec.SetField(account.FieldType, field.TypeString, value)
_node.Type = value
}
if value, ok := _c.mutation.Credentials(); ok {
_spec.SetField(account.FieldCredentials, field.TypeJSON, value)
_node.Credentials = value
}
if value, ok := _c.mutation.Extra(); ok {
_spec.SetField(account.FieldExtra, field.TypeJSON, value)
_node.Extra = value
}
if value, ok := _c.mutation.ProxyID(); ok {
_spec.SetField(account.FieldProxyID, field.TypeInt64, value)
_node.ProxyID = &value
}
if value, ok := _c.mutation.Concurrency(); ok {
_spec.SetField(account.FieldConcurrency, field.TypeInt, value)
_node.Concurrency = value
}
if value, ok := _c.mutation.Priority(); ok {
_spec.SetField(account.FieldPriority, field.TypeInt, value)
_node.Priority = value
}
if value, ok := _c.mutation.Status(); ok {
_spec.SetField(account.FieldStatus, field.TypeString, value)
_node.Status = value
}
if value, ok := _c.mutation.ErrorMessage(); ok {
_spec.SetField(account.FieldErrorMessage, field.TypeString, value)
_node.ErrorMessage = &value
}
if value, ok := _c.mutation.LastUsedAt(); ok {
_spec.SetField(account.FieldLastUsedAt, field.TypeTime, value)
_node.LastUsedAt = &value
}
if value, ok := _c.mutation.Schedulable(); ok {
_spec.SetField(account.FieldSchedulable, field.TypeBool, value)
_node.Schedulable = value
}
if value, ok := _c.mutation.RateLimitedAt(); ok {
_spec.SetField(account.FieldRateLimitedAt, field.TypeTime, value)
_node.RateLimitedAt = &value
}
if value, ok := _c.mutation.RateLimitResetAt(); ok {
_spec.SetField(account.FieldRateLimitResetAt, field.TypeTime, value)
_node.RateLimitResetAt = &value
}
if value, ok := _c.mutation.OverloadUntil(); ok {
_spec.SetField(account.FieldOverloadUntil, field.TypeTime, value)
_node.OverloadUntil = &value
}
if value, ok := _c.mutation.SessionWindowStart(); ok {
_spec.SetField(account.FieldSessionWindowStart, field.TypeTime, value)
_node.SessionWindowStart = &value
}
if value, ok := _c.mutation.SessionWindowEnd(); ok {
_spec.SetField(account.FieldSessionWindowEnd, field.TypeTime, value)
_node.SessionWindowEnd = &value
}
if value, ok := _c.mutation.SessionWindowStatus(); ok {
_spec.SetField(account.FieldSessionWindowStatus, field.TypeString, value)
_node.SessionWindowStatus = &value
}
if nodes := _c.mutation.GroupsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: account.GroupsTable,
Columns: account.GroupsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
createE := &AccountGroupCreate{config: _c.config, mutation: newAccountGroupMutation(_c.config, OpCreate)}
createE.defaults()
_, specE := createE.createSpec()
edge.Target.Fields = specE.Fields
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.Account.Create().
// SetCreatedAt(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.AccountUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *AccountCreate) OnConflict(opts ...sql.ConflictOption) *AccountUpsertOne {
_c.conflict = opts
return &AccountUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Account.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *AccountCreate) OnConflictColumns(columns ...string) *AccountUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &AccountUpsertOne{
create: _c,
}
}
type (
// AccountUpsertOne is the builder for "upsert"-ing
// one Account node.
AccountUpsertOne struct {
create *AccountCreate
}
// AccountUpsert is the "OnConflict" setter.
AccountUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *AccountUpsert) SetUpdatedAt(v time.Time) *AccountUpsert {
u.Set(account.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AccountUpsert) UpdateUpdatedAt() *AccountUpsert {
u.SetExcluded(account.FieldUpdatedAt)
return u
}
// SetDeletedAt sets the "deleted_at" field.
func (u *AccountUpsert) SetDeletedAt(v time.Time) *AccountUpsert {
u.Set(account.FieldDeletedAt, v)
return u
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *AccountUpsert) UpdateDeletedAt() *AccountUpsert {
u.SetExcluded(account.FieldDeletedAt)
return u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *AccountUpsert) ClearDeletedAt() *AccountUpsert {
u.SetNull(account.FieldDeletedAt)
return u
}
// SetName sets the "name" field.
func (u *AccountUpsert) SetName(v string) *AccountUpsert {
u.Set(account.FieldName, v)
return u
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *AccountUpsert) UpdateName() *AccountUpsert {
u.SetExcluded(account.FieldName)
return u
}
// SetPlatform sets the "platform" field.
func (u *AccountUpsert) SetPlatform(v string) *AccountUpsert {
u.Set(account.FieldPlatform, v)
return u
}
// UpdatePlatform sets the "platform" field to the value that was provided on create.
func (u *AccountUpsert) UpdatePlatform() *AccountUpsert {
u.SetExcluded(account.FieldPlatform)
return u
}
// SetType sets the "type" field.
func (u *AccountUpsert) SetType(v string) *AccountUpsert {
u.Set(account.FieldType, v)
return u
}
// UpdateType sets the "type" field to the value that was provided on create.
func (u *AccountUpsert) UpdateType() *AccountUpsert {
u.SetExcluded(account.FieldType)
return u
}
// SetCredentials sets the "credentials" field.
func (u *AccountUpsert) SetCredentials(v map[string]interface{}) *AccountUpsert {
u.Set(account.FieldCredentials, v)
return u
}
// UpdateCredentials sets the "credentials" field to the value that was provided on create.
func (u *AccountUpsert) UpdateCredentials() *AccountUpsert {
u.SetExcluded(account.FieldCredentials)
return u
}
// SetExtra sets the "extra" field.
func (u *AccountUpsert) SetExtra(v map[string]interface{}) *AccountUpsert {
u.Set(account.FieldExtra, v)
return u
}
// UpdateExtra sets the "extra" field to the value that was provided on create.
func (u *AccountUpsert) UpdateExtra() *AccountUpsert {
u.SetExcluded(account.FieldExtra)
return u
}
// SetProxyID sets the "proxy_id" field.
func (u *AccountUpsert) SetProxyID(v int64) *AccountUpsert {
u.Set(account.FieldProxyID, v)
return u
}
// UpdateProxyID sets the "proxy_id" field to the value that was provided on create.
func (u *AccountUpsert) UpdateProxyID() *AccountUpsert {
u.SetExcluded(account.FieldProxyID)
return u
}
// AddProxyID adds v to the "proxy_id" field.
func (u *AccountUpsert) AddProxyID(v int64) *AccountUpsert {
u.Add(account.FieldProxyID, v)
return u
}
// ClearProxyID clears the value of the "proxy_id" field.
func (u *AccountUpsert) ClearProxyID() *AccountUpsert {
u.SetNull(account.FieldProxyID)
return u
}
// SetConcurrency sets the "concurrency" field.
func (u *AccountUpsert) SetConcurrency(v int) *AccountUpsert {
u.Set(account.FieldConcurrency, v)
return u
}
// UpdateConcurrency sets the "concurrency" field to the value that was provided on create.
func (u *AccountUpsert) UpdateConcurrency() *AccountUpsert {
u.SetExcluded(account.FieldConcurrency)
return u
}
// AddConcurrency adds v to the "concurrency" field.
func (u *AccountUpsert) AddConcurrency(v int) *AccountUpsert {
u.Add(account.FieldConcurrency, v)
return u
}
// SetPriority sets the "priority" field.
func (u *AccountUpsert) SetPriority(v int) *AccountUpsert {
u.Set(account.FieldPriority, v)
return u
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *AccountUpsert) UpdatePriority() *AccountUpsert {
u.SetExcluded(account.FieldPriority)
return u
}
// AddPriority adds v to the "priority" field.
func (u *AccountUpsert) AddPriority(v int) *AccountUpsert {
u.Add(account.FieldPriority, v)
return u
}
// SetStatus sets the "status" field.
func (u *AccountUpsert) SetStatus(v string) *AccountUpsert {
u.Set(account.FieldStatus, v)
return u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *AccountUpsert) UpdateStatus() *AccountUpsert {
u.SetExcluded(account.FieldStatus)
return u
}
// SetErrorMessage sets the "error_message" field.
func (u *AccountUpsert) SetErrorMessage(v string) *AccountUpsert {
u.Set(account.FieldErrorMessage, v)
return u
}
// UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
func (u *AccountUpsert) UpdateErrorMessage() *AccountUpsert {
u.SetExcluded(account.FieldErrorMessage)
return u
}
// ClearErrorMessage clears the value of the "error_message" field.
func (u *AccountUpsert) ClearErrorMessage() *AccountUpsert {
u.SetNull(account.FieldErrorMessage)
return u
}
// SetLastUsedAt sets the "last_used_at" field.
func (u *AccountUpsert) SetLastUsedAt(v time.Time) *AccountUpsert {
u.Set(account.FieldLastUsedAt, v)
return u
}
// UpdateLastUsedAt sets the "last_used_at" field to the value that was provided on create.
func (u *AccountUpsert) UpdateLastUsedAt() *AccountUpsert {
u.SetExcluded(account.FieldLastUsedAt)
return u
}
// ClearLastUsedAt clears the value of the "last_used_at" field.
func (u *AccountUpsert) ClearLastUsedAt() *AccountUpsert {
u.SetNull(account.FieldLastUsedAt)
return u
}
// SetSchedulable sets the "schedulable" field.
func (u *AccountUpsert) SetSchedulable(v bool) *AccountUpsert {
u.Set(account.FieldSchedulable, v)
return u
}
// UpdateSchedulable sets the "schedulable" field to the value that was provided on create.
func (u *AccountUpsert) UpdateSchedulable() *AccountUpsert {
u.SetExcluded(account.FieldSchedulable)
return u
}
// SetRateLimitedAt sets the "rate_limited_at" field.
func (u *AccountUpsert) SetRateLimitedAt(v time.Time) *AccountUpsert {
u.Set(account.FieldRateLimitedAt, v)
return u
}
// UpdateRateLimitedAt sets the "rate_limited_at" field to the value that was provided on create.
func (u *AccountUpsert) UpdateRateLimitedAt() *AccountUpsert {
u.SetExcluded(account.FieldRateLimitedAt)
return u
}
// ClearRateLimitedAt clears the value of the "rate_limited_at" field.
func (u *AccountUpsert) ClearRateLimitedAt() *AccountUpsert {
u.SetNull(account.FieldRateLimitedAt)
return u
}
// SetRateLimitResetAt sets the "rate_limit_reset_at" field.
func (u *AccountUpsert) SetRateLimitResetAt(v time.Time) *AccountUpsert {
u.Set(account.FieldRateLimitResetAt, v)
return u
}
// UpdateRateLimitResetAt sets the "rate_limit_reset_at" field to the value that was provided on create.
func (u *AccountUpsert) UpdateRateLimitResetAt() *AccountUpsert {
u.SetExcluded(account.FieldRateLimitResetAt)
return u
}
// ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
func (u *AccountUpsert) ClearRateLimitResetAt() *AccountUpsert {
u.SetNull(account.FieldRateLimitResetAt)
return u
}
// SetOverloadUntil sets the "overload_until" field.
func (u *AccountUpsert) SetOverloadUntil(v time.Time) *AccountUpsert {
u.Set(account.FieldOverloadUntil, v)
return u
}
// UpdateOverloadUntil sets the "overload_until" field to the value that was provided on create.
func (u *AccountUpsert) UpdateOverloadUntil() *AccountUpsert {
u.SetExcluded(account.FieldOverloadUntil)
return u
}
// ClearOverloadUntil clears the value of the "overload_until" field.
func (u *AccountUpsert) ClearOverloadUntil() *AccountUpsert {
u.SetNull(account.FieldOverloadUntil)
return u
}
// SetSessionWindowStart sets the "session_window_start" field.
func (u *AccountUpsert) SetSessionWindowStart(v time.Time) *AccountUpsert {
u.Set(account.FieldSessionWindowStart, v)
return u
}
// UpdateSessionWindowStart sets the "session_window_start" field to the value that was provided on create.
func (u *AccountUpsert) UpdateSessionWindowStart() *AccountUpsert {
u.SetExcluded(account.FieldSessionWindowStart)
return u
}
// ClearSessionWindowStart clears the value of the "session_window_start" field.
func (u *AccountUpsert) ClearSessionWindowStart() *AccountUpsert {
u.SetNull(account.FieldSessionWindowStart)
return u
}
// SetSessionWindowEnd sets the "session_window_end" field.
func (u *AccountUpsert) SetSessionWindowEnd(v time.Time) *AccountUpsert {
u.Set(account.FieldSessionWindowEnd, v)
return u
}
// UpdateSessionWindowEnd sets the "session_window_end" field to the value that was provided on create.
func (u *AccountUpsert) UpdateSessionWindowEnd() *AccountUpsert {
u.SetExcluded(account.FieldSessionWindowEnd)
return u
}
// ClearSessionWindowEnd clears the value of the "session_window_end" field.
func (u *AccountUpsert) ClearSessionWindowEnd() *AccountUpsert {
u.SetNull(account.FieldSessionWindowEnd)
return u
}
// SetSessionWindowStatus sets the "session_window_status" field.
func (u *AccountUpsert) SetSessionWindowStatus(v string) *AccountUpsert {
u.Set(account.FieldSessionWindowStatus, v)
return u
}
// UpdateSessionWindowStatus sets the "session_window_status" field to the value that was provided on create.
func (u *AccountUpsert) UpdateSessionWindowStatus() *AccountUpsert {
u.SetExcluded(account.FieldSessionWindowStatus)
return u
}
// ClearSessionWindowStatus clears the value of the "session_window_status" field.
func (u *AccountUpsert) ClearSessionWindowStatus() *AccountUpsert {
u.SetNull(account.FieldSessionWindowStatus)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.Account.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *AccountUpsertOne) UpdateNewValues() *AccountUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
if _, exists := u.create.mutation.CreatedAt(); exists {
s.SetIgnore(account.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Account.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *AccountUpsertOne) Ignore() *AccountUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *AccountUpsertOne) DoNothing() *AccountUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the AccountCreate.OnConflict
// documentation for more info.
func (u *AccountUpsertOne) Update(set func(*AccountUpsert)) *AccountUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&AccountUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *AccountUpsertOne) SetUpdatedAt(v time.Time) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateUpdatedAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateUpdatedAt()
})
}
// SetDeletedAt sets the "deleted_at" field.
func (u *AccountUpsertOne) SetDeletedAt(v time.Time) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateDeletedAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *AccountUpsertOne) ClearDeletedAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearDeletedAt()
})
}
// SetName sets the "name" field.
func (u *AccountUpsertOne) SetName(v string) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetName(v)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateName() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateName()
})
}
// SetPlatform sets the "platform" field.
func (u *AccountUpsertOne) SetPlatform(v string) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetPlatform(v)
})
}
// UpdatePlatform sets the "platform" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdatePlatform() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdatePlatform()
})
}
// SetType sets the "type" field.
func (u *AccountUpsertOne) SetType(v string) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetType(v)
})
}
// UpdateType sets the "type" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateType() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateType()
})
}
// SetCredentials sets the "credentials" field.
func (u *AccountUpsertOne) SetCredentials(v map[string]interface{}) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetCredentials(v)
})
}
// UpdateCredentials sets the "credentials" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateCredentials() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateCredentials()
})
}
// SetExtra sets the "extra" field.
func (u *AccountUpsertOne) SetExtra(v map[string]interface{}) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetExtra(v)
})
}
// UpdateExtra sets the "extra" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateExtra() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateExtra()
})
}
// SetProxyID sets the "proxy_id" field.
func (u *AccountUpsertOne) SetProxyID(v int64) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetProxyID(v)
})
}
// AddProxyID adds v to the "proxy_id" field.
func (u *AccountUpsertOne) AddProxyID(v int64) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.AddProxyID(v)
})
}
// UpdateProxyID sets the "proxy_id" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateProxyID() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateProxyID()
})
}
// ClearProxyID clears the value of the "proxy_id" field.
func (u *AccountUpsertOne) ClearProxyID() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearProxyID()
})
}
// SetConcurrency sets the "concurrency" field.
func (u *AccountUpsertOne) SetConcurrency(v int) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetConcurrency(v)
})
}
// AddConcurrency adds v to the "concurrency" field.
func (u *AccountUpsertOne) AddConcurrency(v int) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.AddConcurrency(v)
})
}
// UpdateConcurrency sets the "concurrency" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateConcurrency() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateConcurrency()
})
}
// SetPriority sets the "priority" field.
func (u *AccountUpsertOne) SetPriority(v int) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetPriority(v)
})
}
// AddPriority adds v to the "priority" field.
func (u *AccountUpsertOne) AddPriority(v int) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.AddPriority(v)
})
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdatePriority() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdatePriority()
})
}
// SetStatus sets the "status" field.
func (u *AccountUpsertOne) SetStatus(v string) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateStatus() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateStatus()
})
}
// SetErrorMessage sets the "error_message" field.
func (u *AccountUpsertOne) SetErrorMessage(v string) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetErrorMessage(v)
})
}
// UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateErrorMessage() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateErrorMessage()
})
}
// ClearErrorMessage clears the value of the "error_message" field.
func (u *AccountUpsertOne) ClearErrorMessage() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearErrorMessage()
})
}
// SetLastUsedAt sets the "last_used_at" field.
func (u *AccountUpsertOne) SetLastUsedAt(v time.Time) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetLastUsedAt(v)
})
}
// UpdateLastUsedAt sets the "last_used_at" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateLastUsedAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateLastUsedAt()
})
}
// ClearLastUsedAt clears the value of the "last_used_at" field.
func (u *AccountUpsertOne) ClearLastUsedAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearLastUsedAt()
})
}
// SetSchedulable sets the "schedulable" field.
func (u *AccountUpsertOne) SetSchedulable(v bool) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetSchedulable(v)
})
}
// UpdateSchedulable sets the "schedulable" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateSchedulable() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateSchedulable()
})
}
// SetRateLimitedAt sets the "rate_limited_at" field.
func (u *AccountUpsertOne) SetRateLimitedAt(v time.Time) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetRateLimitedAt(v)
})
}
// UpdateRateLimitedAt sets the "rate_limited_at" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateRateLimitedAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateRateLimitedAt()
})
}
// ClearRateLimitedAt clears the value of the "rate_limited_at" field.
func (u *AccountUpsertOne) ClearRateLimitedAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearRateLimitedAt()
})
}
// SetRateLimitResetAt sets the "rate_limit_reset_at" field.
func (u *AccountUpsertOne) SetRateLimitResetAt(v time.Time) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetRateLimitResetAt(v)
})
}
// UpdateRateLimitResetAt sets the "rate_limit_reset_at" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateRateLimitResetAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateRateLimitResetAt()
})
}
// ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
func (u *AccountUpsertOne) ClearRateLimitResetAt() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearRateLimitResetAt()
})
}
// SetOverloadUntil sets the "overload_until" field.
func (u *AccountUpsertOne) SetOverloadUntil(v time.Time) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetOverloadUntil(v)
})
}
// UpdateOverloadUntil sets the "overload_until" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateOverloadUntil() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateOverloadUntil()
})
}
// ClearOverloadUntil clears the value of the "overload_until" field.
func (u *AccountUpsertOne) ClearOverloadUntil() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearOverloadUntil()
})
}
// SetSessionWindowStart sets the "session_window_start" field.
func (u *AccountUpsertOne) SetSessionWindowStart(v time.Time) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetSessionWindowStart(v)
})
}
// UpdateSessionWindowStart sets the "session_window_start" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateSessionWindowStart() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateSessionWindowStart()
})
}
// ClearSessionWindowStart clears the value of the "session_window_start" field.
func (u *AccountUpsertOne) ClearSessionWindowStart() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearSessionWindowStart()
})
}
// SetSessionWindowEnd sets the "session_window_end" field.
func (u *AccountUpsertOne) SetSessionWindowEnd(v time.Time) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetSessionWindowEnd(v)
})
}
// UpdateSessionWindowEnd sets the "session_window_end" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateSessionWindowEnd() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateSessionWindowEnd()
})
}
// ClearSessionWindowEnd clears the value of the "session_window_end" field.
func (u *AccountUpsertOne) ClearSessionWindowEnd() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearSessionWindowEnd()
})
}
// SetSessionWindowStatus sets the "session_window_status" field.
func (u *AccountUpsertOne) SetSessionWindowStatus(v string) *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.SetSessionWindowStatus(v)
})
}
// UpdateSessionWindowStatus sets the "session_window_status" field to the value that was provided on create.
func (u *AccountUpsertOne) UpdateSessionWindowStatus() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.UpdateSessionWindowStatus()
})
}
// ClearSessionWindowStatus clears the value of the "session_window_status" field.
func (u *AccountUpsertOne) ClearSessionWindowStatus() *AccountUpsertOne {
return u.Update(func(s *AccountUpsert) {
s.ClearSessionWindowStatus()
})
}
// Exec executes the query.
func (u *AccountUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for AccountCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *AccountUpsertOne) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *AccountUpsertOne) ID(ctx context.Context) (id int64, err error) {
node, err := u.create.Save(ctx)
if err != nil {
return id, err
}
return node.ID, nil
}
// IDX is like ID, but panics if an error occurs.
func (u *AccountUpsertOne) IDX(ctx context.Context) int64 {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// AccountCreateBulk is the builder for creating many Account entities in bulk.
type AccountCreateBulk struct {
config
err error
builders []*AccountCreate
conflict []sql.ConflictOption
}
// Save creates the Account entities in the database.
func (_c *AccountCreateBulk) Save(ctx context.Context) ([]*Account, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*Account, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AccountMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *AccountCreateBulk) SaveX(ctx context.Context) []*Account {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *AccountCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *AccountCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.Account.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.AccountUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *AccountCreateBulk) OnConflict(opts ...sql.ConflictOption) *AccountUpsertBulk {
_c.conflict = opts
return &AccountUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.Account.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *AccountCreateBulk) OnConflictColumns(columns ...string) *AccountUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &AccountUpsertBulk{
create: _c,
}
}
// AccountUpsertBulk is the builder for "upsert"-ing
// a bulk of Account nodes.
type AccountUpsertBulk struct {
create *AccountCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.Account.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *AccountUpsertBulk) UpdateNewValues() *AccountUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
for _, b := range u.create.builders {
if _, exists := b.mutation.CreatedAt(); exists {
s.SetIgnore(account.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.Account.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *AccountUpsertBulk) Ignore() *AccountUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *AccountUpsertBulk) DoNothing() *AccountUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the AccountCreateBulk.OnConflict
// documentation for more info.
func (u *AccountUpsertBulk) Update(set func(*AccountUpsert)) *AccountUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&AccountUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *AccountUpsertBulk) SetUpdatedAt(v time.Time) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateUpdatedAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateUpdatedAt()
})
}
// SetDeletedAt sets the "deleted_at" field.
func (u *AccountUpsertBulk) SetDeletedAt(v time.Time) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetDeletedAt(v)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateDeletedAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateDeletedAt()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *AccountUpsertBulk) ClearDeletedAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearDeletedAt()
})
}
// SetName sets the "name" field.
func (u *AccountUpsertBulk) SetName(v string) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetName(v)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateName() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateName()
})
}
// SetPlatform sets the "platform" field.
func (u *AccountUpsertBulk) SetPlatform(v string) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetPlatform(v)
})
}
// UpdatePlatform sets the "platform" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdatePlatform() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdatePlatform()
})
}
// SetType sets the "type" field.
func (u *AccountUpsertBulk) SetType(v string) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetType(v)
})
}
// UpdateType sets the "type" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateType() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateType()
})
}
// SetCredentials sets the "credentials" field.
func (u *AccountUpsertBulk) SetCredentials(v map[string]interface{}) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetCredentials(v)
})
}
// UpdateCredentials sets the "credentials" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateCredentials() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateCredentials()
})
}
// SetExtra sets the "extra" field.
func (u *AccountUpsertBulk) SetExtra(v map[string]interface{}) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetExtra(v)
})
}
// UpdateExtra sets the "extra" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateExtra() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateExtra()
})
}
// SetProxyID sets the "proxy_id" field.
func (u *AccountUpsertBulk) SetProxyID(v int64) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetProxyID(v)
})
}
// AddProxyID adds v to the "proxy_id" field.
func (u *AccountUpsertBulk) AddProxyID(v int64) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.AddProxyID(v)
})
}
// UpdateProxyID sets the "proxy_id" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateProxyID() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateProxyID()
})
}
// ClearProxyID clears the value of the "proxy_id" field.
func (u *AccountUpsertBulk) ClearProxyID() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearProxyID()
})
}
// SetConcurrency sets the "concurrency" field.
func (u *AccountUpsertBulk) SetConcurrency(v int) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetConcurrency(v)
})
}
// AddConcurrency adds v to the "concurrency" field.
func (u *AccountUpsertBulk) AddConcurrency(v int) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.AddConcurrency(v)
})
}
// UpdateConcurrency sets the "concurrency" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateConcurrency() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateConcurrency()
})
}
// SetPriority sets the "priority" field.
func (u *AccountUpsertBulk) SetPriority(v int) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetPriority(v)
})
}
// AddPriority adds v to the "priority" field.
func (u *AccountUpsertBulk) AddPriority(v int) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.AddPriority(v)
})
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdatePriority() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdatePriority()
})
}
// SetStatus sets the "status" field.
func (u *AccountUpsertBulk) SetStatus(v string) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateStatus() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateStatus()
})
}
// SetErrorMessage sets the "error_message" field.
func (u *AccountUpsertBulk) SetErrorMessage(v string) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetErrorMessage(v)
})
}
// UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateErrorMessage() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateErrorMessage()
})
}
// ClearErrorMessage clears the value of the "error_message" field.
func (u *AccountUpsertBulk) ClearErrorMessage() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearErrorMessage()
})
}
// SetLastUsedAt sets the "last_used_at" field.
func (u *AccountUpsertBulk) SetLastUsedAt(v time.Time) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetLastUsedAt(v)
})
}
// UpdateLastUsedAt sets the "last_used_at" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateLastUsedAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateLastUsedAt()
})
}
// ClearLastUsedAt clears the value of the "last_used_at" field.
func (u *AccountUpsertBulk) ClearLastUsedAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearLastUsedAt()
})
}
// SetSchedulable sets the "schedulable" field.
func (u *AccountUpsertBulk) SetSchedulable(v bool) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetSchedulable(v)
})
}
// UpdateSchedulable sets the "schedulable" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateSchedulable() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateSchedulable()
})
}
// SetRateLimitedAt sets the "rate_limited_at" field.
func (u *AccountUpsertBulk) SetRateLimitedAt(v time.Time) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetRateLimitedAt(v)
})
}
// UpdateRateLimitedAt sets the "rate_limited_at" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateRateLimitedAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateRateLimitedAt()
})
}
// ClearRateLimitedAt clears the value of the "rate_limited_at" field.
func (u *AccountUpsertBulk) ClearRateLimitedAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearRateLimitedAt()
})
}
// SetRateLimitResetAt sets the "rate_limit_reset_at" field.
func (u *AccountUpsertBulk) SetRateLimitResetAt(v time.Time) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetRateLimitResetAt(v)
})
}
// UpdateRateLimitResetAt sets the "rate_limit_reset_at" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateRateLimitResetAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateRateLimitResetAt()
})
}
// ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
func (u *AccountUpsertBulk) ClearRateLimitResetAt() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearRateLimitResetAt()
})
}
// SetOverloadUntil sets the "overload_until" field.
func (u *AccountUpsertBulk) SetOverloadUntil(v time.Time) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetOverloadUntil(v)
})
}
// UpdateOverloadUntil sets the "overload_until" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateOverloadUntil() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateOverloadUntil()
})
}
// ClearOverloadUntil clears the value of the "overload_until" field.
func (u *AccountUpsertBulk) ClearOverloadUntil() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearOverloadUntil()
})
}
// SetSessionWindowStart sets the "session_window_start" field.
func (u *AccountUpsertBulk) SetSessionWindowStart(v time.Time) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetSessionWindowStart(v)
})
}
// UpdateSessionWindowStart sets the "session_window_start" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateSessionWindowStart() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateSessionWindowStart()
})
}
// ClearSessionWindowStart clears the value of the "session_window_start" field.
func (u *AccountUpsertBulk) ClearSessionWindowStart() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearSessionWindowStart()
})
}
// SetSessionWindowEnd sets the "session_window_end" field.
func (u *AccountUpsertBulk) SetSessionWindowEnd(v time.Time) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetSessionWindowEnd(v)
})
}
// UpdateSessionWindowEnd sets the "session_window_end" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateSessionWindowEnd() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateSessionWindowEnd()
})
}
// ClearSessionWindowEnd clears the value of the "session_window_end" field.
func (u *AccountUpsertBulk) ClearSessionWindowEnd() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearSessionWindowEnd()
})
}
// SetSessionWindowStatus sets the "session_window_status" field.
func (u *AccountUpsertBulk) SetSessionWindowStatus(v string) *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.SetSessionWindowStatus(v)
})
}
// UpdateSessionWindowStatus sets the "session_window_status" field to the value that was provided on create.
func (u *AccountUpsertBulk) UpdateSessionWindowStatus() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.UpdateSessionWindowStatus()
})
}
// ClearSessionWindowStatus clears the value of the "session_window_status" field.
func (u *AccountUpsertBulk) ClearSessionWindowStatus() *AccountUpsertBulk {
return u.Update(func(s *AccountUpsert) {
s.ClearSessionWindowStatus()
})
}
// Exec executes the query.
func (u *AccountUpsertBulk) Exec(ctx context.Context) error {
if u.create.err != nil {
return u.create.err
}
for i, b := range u.create.builders {
if len(b.conflict) != 0 {
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the AccountCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for AccountCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *AccountUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/account"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AccountDelete is the builder for deleting a Account entity.
type AccountDelete struct {
config
hooks []Hook
mutation *AccountMutation
}
// Where appends a list predicates to the AccountDelete builder.
func (_d *AccountDelete) Where(ps ...predicate.Account) *AccountDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *AccountDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *AccountDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *AccountDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(account.Table, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
_d.mutation.done = true
return affected, err
}
// AccountDeleteOne is the builder for deleting a single Account entity.
type AccountDeleteOne struct {
_d *AccountDelete
}
// Where appends a list predicates to the AccountDelete builder.
func (_d *AccountDeleteOne) Where(ps ...predicate.Account) *AccountDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *AccountDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{account.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *AccountDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/account"
"github.com/Wei-Shaw/sub2api/ent/accountgroup"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AccountQuery is the builder for querying Account entities.
type AccountQuery struct {
config
ctx *QueryContext
order []account.OrderOption
inters []Interceptor
predicates []predicate.Account
withGroups *GroupQuery
withAccountGroups *AccountGroupQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the AccountQuery builder.
func (_q *AccountQuery) Where(ps ...predicate.Account) *AccountQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *AccountQuery) Limit(limit int) *AccountQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *AccountQuery) Offset(offset int) *AccountQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *AccountQuery) Unique(unique bool) *AccountQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *AccountQuery) Order(o ...account.OrderOption) *AccountQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryGroups chains the current query on the "groups" edge.
func (_q *AccountQuery) QueryGroups() *GroupQuery {
query := (&GroupClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(account.Table, account.FieldID, selector),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, account.GroupsTable, account.GroupsPrimaryKey...),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryAccountGroups chains the current query on the "account_groups" edge.
func (_q *AccountQuery) QueryAccountGroups() *AccountGroupQuery {
query := (&AccountGroupClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(account.Table, account.FieldID, selector),
sqlgraph.To(accountgroup.Table, accountgroup.AccountColumn),
sqlgraph.Edge(sqlgraph.O2M, true, account.AccountGroupsTable, account.AccountGroupsColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// First returns the first Account entity from the query.
// Returns a *NotFoundError when no Account was found.
func (_q *AccountQuery) First(ctx context.Context) (*Account, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{account.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *AccountQuery) FirstX(ctx context.Context) *Account {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first Account ID from the query.
// Returns a *NotFoundError when no Account ID was found.
func (_q *AccountQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{account.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *AccountQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single Account entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one Account entity is found.
// Returns a *NotFoundError when no Account entities are found.
func (_q *AccountQuery) Only(ctx context.Context) (*Account, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{account.Label}
default:
return nil, &NotSingularError{account.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *AccountQuery) OnlyX(ctx context.Context) *Account {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only Account ID in the query.
// Returns a *NotSingularError when more than one Account ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *AccountQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{account.Label}
default:
err = &NotSingularError{account.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *AccountQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of Accounts.
func (_q *AccountQuery) All(ctx context.Context) ([]*Account, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*Account, *AccountQuery]()
return withInterceptors[[]*Account](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *AccountQuery) AllX(ctx context.Context) []*Account {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of Account IDs.
func (_q *AccountQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(account.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *AccountQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *AccountQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*AccountQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *AccountQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *AccountQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *AccountQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the AccountQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *AccountQuery) Clone() *AccountQuery {
if _q == nil {
return nil
}
return &AccountQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]account.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Account{}, _q.predicates...),
withGroups: _q.withGroups.Clone(),
withAccountGroups: _q.withAccountGroups.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithGroups tells the query-builder to eager-load the nodes that are connected to
// the "groups" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AccountQuery) WithGroups(opts ...func(*GroupQuery)) *AccountQuery {
query := (&GroupClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withGroups = query
return _q
}
// WithAccountGroups tells the query-builder to eager-load the nodes that are connected to
// the "account_groups" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AccountQuery) WithAccountGroups(opts ...func(*AccountGroupQuery)) *AccountQuery {
query := (&AccountGroupClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withAccountGroups = query
return _q
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.Account.Query().
// GroupBy(account.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *AccountQuery) GroupBy(field string, fields ...string) *AccountGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &AccountGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = account.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.Account.Query().
// Select(account.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *AccountQuery) Select(fields ...string) *AccountSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &AccountSelect{AccountQuery: _q}
sbuild.label = account.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a AccountSelect configured with the given aggregations.
func (_q *AccountQuery) Aggregate(fns ...AggregateFunc) *AccountSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *AccountQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !account.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *AccountQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Account, error) {
var (
nodes = []*Account{}
_spec = _q.querySpec()
loadedTypes = [2]bool{
_q.withGroups != nil,
_q.withAccountGroups != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*Account).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &Account{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withGroups; query != nil {
if err := _q.loadGroups(ctx, query, nodes,
func(n *Account) { n.Edges.Groups = []*Group{} },
func(n *Account, e *Group) { n.Edges.Groups = append(n.Edges.Groups, e) }); err != nil {
return nil, err
}
}
if query := _q.withAccountGroups; query != nil {
if err := _q.loadAccountGroups(ctx, query, nodes,
func(n *Account) { n.Edges.AccountGroups = []*AccountGroup{} },
func(n *Account, e *AccountGroup) { n.Edges.AccountGroups = append(n.Edges.AccountGroups, e) }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *AccountQuery) loadGroups(ctx context.Context, query *GroupQuery, nodes []*Account, init func(*Account), assign func(*Account, *Group)) error {
edgeIDs := make([]driver.Value, len(nodes))
byID := make(map[int64]*Account)
nids := make(map[int64]map[*Account]struct{})
for i, node := range nodes {
edgeIDs[i] = node.ID
byID[node.ID] = node
if init != nil {
init(node)
}
}
query.Where(func(s *sql.Selector) {
joinT := sql.Table(account.GroupsTable)
s.Join(joinT).On(s.C(group.FieldID), joinT.C(account.GroupsPrimaryKey[1]))
s.Where(sql.InValues(joinT.C(account.GroupsPrimaryKey[0]), edgeIDs...))
columns := s.SelectedColumns()
s.Select(joinT.C(account.GroupsPrimaryKey[0]))
s.AppendSelect(columns...)
s.SetDistinct(false)
})
if err := query.prepareQuery(ctx); err != nil {
return err
}
qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) {
assign := spec.Assign
values := spec.ScanValues
spec.ScanValues = func(columns []string) ([]any, error) {
values, err := values(columns[1:])
if err != nil {
return nil, err
}
return append([]any{new(sql.NullInt64)}, values...), nil
}
spec.Assign = func(columns []string, values []any) error {
outValue := values[0].(*sql.NullInt64).Int64
inValue := values[1].(*sql.NullInt64).Int64
if nids[inValue] == nil {
nids[inValue] = map[*Account]struct{}{byID[outValue]: {}}
return assign(columns[1:], values[1:])
}
nids[inValue][byID[outValue]] = struct{}{}
return nil
}
})
})
neighbors, err := withInterceptors[[]*Group](ctx, query, qr, query.inters)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nids[n.ID]
if !ok {
return fmt.Errorf(`unexpected "groups" node returned %v`, n.ID)
}
for kn := range nodes {
assign(kn, n)
}
}
return nil
}
func (_q *AccountQuery) loadAccountGroups(ctx context.Context, query *AccountGroupQuery, nodes []*Account, init func(*Account), assign func(*Account, *AccountGroup)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int64]*Account)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
if len(query.ctx.Fields) > 0 {
query.ctx.AppendFieldOnce(accountgroup.FieldAccountID)
}
query.Where(predicate.AccountGroup(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(account.AccountGroupsColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.AccountID
node, ok := nodeids[fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "account_id" returned %v for node %v`, fk, n)
}
assign(node, n)
}
return nil
}
func (_q *AccountQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *AccountQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, account.FieldID)
for i := range fields {
if fields[i] != account.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *AccountQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(account.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = account.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// AccountGroupBy is the group-by builder for Account entities.
type AccountGroupBy struct {
selector
build *AccountQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *AccountGroupBy) Aggregate(fns ...AggregateFunc) *AccountGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *AccountGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*AccountQuery, *AccountGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *AccountGroupBy) sqlScan(ctx context.Context, root *AccountQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// AccountSelect is the builder for selecting fields of Account entities.
type AccountSelect struct {
*AccountQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *AccountSelect) Aggregate(fns ...AggregateFunc) *AccountSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *AccountSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*AccountQuery, *AccountSelect](ctx, _s.AccountQuery, _s, _s.inters, v)
}
func (_s *AccountSelect) sqlScan(ctx context.Context, root *AccountQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/account"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AccountUpdate is the builder for updating Account entities.
type AccountUpdate struct {
config
hooks []Hook
mutation *AccountMutation
}
// Where appends a list predicates to the AccountUpdate builder.
func (_u *AccountUpdate) Where(ps ...predicate.Account) *AccountUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *AccountUpdate) SetUpdatedAt(v time.Time) *AccountUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetDeletedAt sets the "deleted_at" field.
func (_u *AccountUpdate) SetDeletedAt(v time.Time) *AccountUpdate {
_u.mutation.SetDeletedAt(v)
return _u
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableDeletedAt(v *time.Time) *AccountUpdate {
if v != nil {
_u.SetDeletedAt(*v)
}
return _u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (_u *AccountUpdate) ClearDeletedAt() *AccountUpdate {
_u.mutation.ClearDeletedAt()
return _u
}
// SetName sets the "name" field.
func (_u *AccountUpdate) SetName(v string) *AccountUpdate {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableName(v *string) *AccountUpdate {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetPlatform sets the "platform" field.
func (_u *AccountUpdate) SetPlatform(v string) *AccountUpdate {
_u.mutation.SetPlatform(v)
return _u
}
// SetNillablePlatform sets the "platform" field if the given value is not nil.
func (_u *AccountUpdate) SetNillablePlatform(v *string) *AccountUpdate {
if v != nil {
_u.SetPlatform(*v)
}
return _u
}
// SetType sets the "type" field.
func (_u *AccountUpdate) SetType(v string) *AccountUpdate {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableType(v *string) *AccountUpdate {
if v != nil {
_u.SetType(*v)
}
return _u
}
// SetCredentials sets the "credentials" field.
func (_u *AccountUpdate) SetCredentials(v map[string]interface{}) *AccountUpdate {
_u.mutation.SetCredentials(v)
return _u
}
// SetExtra sets the "extra" field.
func (_u *AccountUpdate) SetExtra(v map[string]interface{}) *AccountUpdate {
_u.mutation.SetExtra(v)
return _u
}
// SetProxyID sets the "proxy_id" field.
func (_u *AccountUpdate) SetProxyID(v int64) *AccountUpdate {
_u.mutation.ResetProxyID()
_u.mutation.SetProxyID(v)
return _u
}
// SetNillableProxyID sets the "proxy_id" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableProxyID(v *int64) *AccountUpdate {
if v != nil {
_u.SetProxyID(*v)
}
return _u
}
// AddProxyID adds value to the "proxy_id" field.
func (_u *AccountUpdate) AddProxyID(v int64) *AccountUpdate {
_u.mutation.AddProxyID(v)
return _u
}
// ClearProxyID clears the value of the "proxy_id" field.
func (_u *AccountUpdate) ClearProxyID() *AccountUpdate {
_u.mutation.ClearProxyID()
return _u
}
// SetConcurrency sets the "concurrency" field.
func (_u *AccountUpdate) SetConcurrency(v int) *AccountUpdate {
_u.mutation.ResetConcurrency()
_u.mutation.SetConcurrency(v)
return _u
}
// SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableConcurrency(v *int) *AccountUpdate {
if v != nil {
_u.SetConcurrency(*v)
}
return _u
}
// AddConcurrency adds value to the "concurrency" field.
func (_u *AccountUpdate) AddConcurrency(v int) *AccountUpdate {
_u.mutation.AddConcurrency(v)
return _u
}
// SetPriority sets the "priority" field.
func (_u *AccountUpdate) SetPriority(v int) *AccountUpdate {
_u.mutation.ResetPriority()
_u.mutation.SetPriority(v)
return _u
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func (_u *AccountUpdate) SetNillablePriority(v *int) *AccountUpdate {
if v != nil {
_u.SetPriority(*v)
}
return _u
}
// AddPriority adds value to the "priority" field.
func (_u *AccountUpdate) AddPriority(v int) *AccountUpdate {
_u.mutation.AddPriority(v)
return _u
}
// SetStatus sets the "status" field.
func (_u *AccountUpdate) SetStatus(v string) *AccountUpdate {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableStatus(v *string) *AccountUpdate {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetErrorMessage sets the "error_message" field.
func (_u *AccountUpdate) SetErrorMessage(v string) *AccountUpdate {
_u.mutation.SetErrorMessage(v)
return _u
}
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableErrorMessage(v *string) *AccountUpdate {
if v != nil {
_u.SetErrorMessage(*v)
}
return _u
}
// ClearErrorMessage clears the value of the "error_message" field.
func (_u *AccountUpdate) ClearErrorMessage() *AccountUpdate {
_u.mutation.ClearErrorMessage()
return _u
}
// SetLastUsedAt sets the "last_used_at" field.
func (_u *AccountUpdate) SetLastUsedAt(v time.Time) *AccountUpdate {
_u.mutation.SetLastUsedAt(v)
return _u
}
// SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableLastUsedAt(v *time.Time) *AccountUpdate {
if v != nil {
_u.SetLastUsedAt(*v)
}
return _u
}
// ClearLastUsedAt clears the value of the "last_used_at" field.
func (_u *AccountUpdate) ClearLastUsedAt() *AccountUpdate {
_u.mutation.ClearLastUsedAt()
return _u
}
// SetSchedulable sets the "schedulable" field.
func (_u *AccountUpdate) SetSchedulable(v bool) *AccountUpdate {
_u.mutation.SetSchedulable(v)
return _u
}
// SetNillableSchedulable sets the "schedulable" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableSchedulable(v *bool) *AccountUpdate {
if v != nil {
_u.SetSchedulable(*v)
}
return _u
}
// SetRateLimitedAt sets the "rate_limited_at" field.
func (_u *AccountUpdate) SetRateLimitedAt(v time.Time) *AccountUpdate {
_u.mutation.SetRateLimitedAt(v)
return _u
}
// SetNillableRateLimitedAt sets the "rate_limited_at" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableRateLimitedAt(v *time.Time) *AccountUpdate {
if v != nil {
_u.SetRateLimitedAt(*v)
}
return _u
}
// ClearRateLimitedAt clears the value of the "rate_limited_at" field.
func (_u *AccountUpdate) ClearRateLimitedAt() *AccountUpdate {
_u.mutation.ClearRateLimitedAt()
return _u
}
// SetRateLimitResetAt sets the "rate_limit_reset_at" field.
func (_u *AccountUpdate) SetRateLimitResetAt(v time.Time) *AccountUpdate {
_u.mutation.SetRateLimitResetAt(v)
return _u
}
// SetNillableRateLimitResetAt sets the "rate_limit_reset_at" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableRateLimitResetAt(v *time.Time) *AccountUpdate {
if v != nil {
_u.SetRateLimitResetAt(*v)
}
return _u
}
// ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
func (_u *AccountUpdate) ClearRateLimitResetAt() *AccountUpdate {
_u.mutation.ClearRateLimitResetAt()
return _u
}
// SetOverloadUntil sets the "overload_until" field.
func (_u *AccountUpdate) SetOverloadUntil(v time.Time) *AccountUpdate {
_u.mutation.SetOverloadUntil(v)
return _u
}
// SetNillableOverloadUntil sets the "overload_until" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableOverloadUntil(v *time.Time) *AccountUpdate {
if v != nil {
_u.SetOverloadUntil(*v)
}
return _u
}
// ClearOverloadUntil clears the value of the "overload_until" field.
func (_u *AccountUpdate) ClearOverloadUntil() *AccountUpdate {
_u.mutation.ClearOverloadUntil()
return _u
}
// SetSessionWindowStart sets the "session_window_start" field.
func (_u *AccountUpdate) SetSessionWindowStart(v time.Time) *AccountUpdate {
_u.mutation.SetSessionWindowStart(v)
return _u
}
// SetNillableSessionWindowStart sets the "session_window_start" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableSessionWindowStart(v *time.Time) *AccountUpdate {
if v != nil {
_u.SetSessionWindowStart(*v)
}
return _u
}
// ClearSessionWindowStart clears the value of the "session_window_start" field.
func (_u *AccountUpdate) ClearSessionWindowStart() *AccountUpdate {
_u.mutation.ClearSessionWindowStart()
return _u
}
// SetSessionWindowEnd sets the "session_window_end" field.
func (_u *AccountUpdate) SetSessionWindowEnd(v time.Time) *AccountUpdate {
_u.mutation.SetSessionWindowEnd(v)
return _u
}
// SetNillableSessionWindowEnd sets the "session_window_end" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableSessionWindowEnd(v *time.Time) *AccountUpdate {
if v != nil {
_u.SetSessionWindowEnd(*v)
}
return _u
}
// ClearSessionWindowEnd clears the value of the "session_window_end" field.
func (_u *AccountUpdate) ClearSessionWindowEnd() *AccountUpdate {
_u.mutation.ClearSessionWindowEnd()
return _u
}
// SetSessionWindowStatus sets the "session_window_status" field.
func (_u *AccountUpdate) SetSessionWindowStatus(v string) *AccountUpdate {
_u.mutation.SetSessionWindowStatus(v)
return _u
}
// SetNillableSessionWindowStatus sets the "session_window_status" field if the given value is not nil.
func (_u *AccountUpdate) SetNillableSessionWindowStatus(v *string) *AccountUpdate {
if v != nil {
_u.SetSessionWindowStatus(*v)
}
return _u
}
// ClearSessionWindowStatus clears the value of the "session_window_status" field.
func (_u *AccountUpdate) ClearSessionWindowStatus() *AccountUpdate {
_u.mutation.ClearSessionWindowStatus()
return _u
}
// AddGroupIDs adds the "groups" edge to the Group entity by IDs.
func (_u *AccountUpdate) AddGroupIDs(ids ...int64) *AccountUpdate {
_u.mutation.AddGroupIDs(ids...)
return _u
}
// AddGroups adds the "groups" edges to the Group entity.
func (_u *AccountUpdate) AddGroups(v ...*Group) *AccountUpdate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddGroupIDs(ids...)
}
// Mutation returns the AccountMutation object of the builder.
func (_u *AccountUpdate) Mutation() *AccountMutation {
return _u.mutation
}
// ClearGroups clears all "groups" edges to the Group entity.
func (_u *AccountUpdate) ClearGroups() *AccountUpdate {
_u.mutation.ClearGroups()
return _u
}
// RemoveGroupIDs removes the "groups" edge to Group entities by IDs.
func (_u *AccountUpdate) RemoveGroupIDs(ids ...int64) *AccountUpdate {
_u.mutation.RemoveGroupIDs(ids...)
return _u
}
// RemoveGroups removes "groups" edges to Group entities.
func (_u *AccountUpdate) RemoveGroups(v ...*Group) *AccountUpdate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveGroupIDs(ids...)
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *AccountUpdate) Save(ctx context.Context) (int, error) {
if err := _u.defaults(); err != nil {
return 0, err
}
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AccountUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *AccountUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AccountUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *AccountUpdate) defaults() error {
if _, ok := _u.mutation.UpdatedAt(); !ok {
if account.UpdateDefaultUpdatedAt == nil {
return fmt.Errorf("ent: uninitialized account.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
}
v := account.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
return nil
}
// check runs all checks and user-defined validators on the builder.
func (_u *AccountUpdate) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := account.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)}
}
}
if v, ok := _u.mutation.Platform(); ok {
if err := account.PlatformValidator(v); err != nil {
return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "Account.platform": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := account.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Account.type": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := account.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Account.status": %w`, err)}
}
}
if v, ok := _u.mutation.SessionWindowStatus(); ok {
if err := account.SessionWindowStatusValidator(v); err != nil {
return &ValidationError{Name: "session_window_status", err: fmt.Errorf(`ent: validator failed for field "Account.session_window_status": %w`, err)}
}
}
return nil
}
func (_u *AccountUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.DeletedAt(); ok {
_spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
}
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(account.FieldDeletedAt, field.TypeTime)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(account.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Platform(); ok {
_spec.SetField(account.FieldPlatform, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(account.FieldType, field.TypeString, value)
}
if value, ok := _u.mutation.Credentials(); ok {
_spec.SetField(account.FieldCredentials, field.TypeJSON, value)
}
if value, ok := _u.mutation.Extra(); ok {
_spec.SetField(account.FieldExtra, field.TypeJSON, value)
}
if value, ok := _u.mutation.ProxyID(); ok {
_spec.SetField(account.FieldProxyID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedProxyID(); ok {
_spec.AddField(account.FieldProxyID, field.TypeInt64, value)
}
if _u.mutation.ProxyIDCleared() {
_spec.ClearField(account.FieldProxyID, field.TypeInt64)
}
if value, ok := _u.mutation.Concurrency(); ok {
_spec.SetField(account.FieldConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedConcurrency(); ok {
_spec.AddField(account.FieldConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.Priority(); ok {
_spec.SetField(account.FieldPriority, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedPriority(); ok {
_spec.AddField(account.FieldPriority, field.TypeInt, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(account.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.ErrorMessage(); ok {
_spec.SetField(account.FieldErrorMessage, field.TypeString, value)
}
if _u.mutation.ErrorMessageCleared() {
_spec.ClearField(account.FieldErrorMessage, field.TypeString)
}
if value, ok := _u.mutation.LastUsedAt(); ok {
_spec.SetField(account.FieldLastUsedAt, field.TypeTime, value)
}
if _u.mutation.LastUsedAtCleared() {
_spec.ClearField(account.FieldLastUsedAt, field.TypeTime)
}
if value, ok := _u.mutation.Schedulable(); ok {
_spec.SetField(account.FieldSchedulable, field.TypeBool, value)
}
if value, ok := _u.mutation.RateLimitedAt(); ok {
_spec.SetField(account.FieldRateLimitedAt, field.TypeTime, value)
}
if _u.mutation.RateLimitedAtCleared() {
_spec.ClearField(account.FieldRateLimitedAt, field.TypeTime)
}
if value, ok := _u.mutation.RateLimitResetAt(); ok {
_spec.SetField(account.FieldRateLimitResetAt, field.TypeTime, value)
}
if _u.mutation.RateLimitResetAtCleared() {
_spec.ClearField(account.FieldRateLimitResetAt, field.TypeTime)
}
if value, ok := _u.mutation.OverloadUntil(); ok {
_spec.SetField(account.FieldOverloadUntil, field.TypeTime, value)
}
if _u.mutation.OverloadUntilCleared() {
_spec.ClearField(account.FieldOverloadUntil, field.TypeTime)
}
if value, ok := _u.mutation.SessionWindowStart(); ok {
_spec.SetField(account.FieldSessionWindowStart, field.TypeTime, value)
}
if _u.mutation.SessionWindowStartCleared() {
_spec.ClearField(account.FieldSessionWindowStart, field.TypeTime)
}
if value, ok := _u.mutation.SessionWindowEnd(); ok {
_spec.SetField(account.FieldSessionWindowEnd, field.TypeTime, value)
}
if _u.mutation.SessionWindowEndCleared() {
_spec.ClearField(account.FieldSessionWindowEnd, field.TypeTime)
}
if value, ok := _u.mutation.SessionWindowStatus(); ok {
_spec.SetField(account.FieldSessionWindowStatus, field.TypeString, value)
}
if _u.mutation.SessionWindowStatusCleared() {
_spec.ClearField(account.FieldSessionWindowStatus, field.TypeString)
}
if _u.mutation.GroupsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: account.GroupsTable,
Columns: account.GroupsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
},
}
createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
createE.defaults()
_, specE := createE.createSpec()
edge.Target.Fields = specE.Fields
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !_u.mutation.GroupsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: account.GroupsTable,
Columns: account.GroupsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
createE.defaults()
_, specE := createE.createSpec()
edge.Target.Fields = specE.Fields
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.GroupsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: account.GroupsTable,
Columns: account.GroupsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
createE.defaults()
_, specE := createE.createSpec()
edge.Target.Fields = specE.Fields
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{account.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// AccountUpdateOne is the builder for updating a single Account entity.
type AccountUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AccountMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *AccountUpdateOne) SetUpdatedAt(v time.Time) *AccountUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetDeletedAt sets the "deleted_at" field.
func (_u *AccountUpdateOne) SetDeletedAt(v time.Time) *AccountUpdateOne {
_u.mutation.SetDeletedAt(v)
return _u
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableDeletedAt(v *time.Time) *AccountUpdateOne {
if v != nil {
_u.SetDeletedAt(*v)
}
return _u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func (_u *AccountUpdateOne) ClearDeletedAt() *AccountUpdateOne {
_u.mutation.ClearDeletedAt()
return _u
}
// SetName sets the "name" field.
func (_u *AccountUpdateOne) SetName(v string) *AccountUpdateOne {
_u.mutation.SetName(v)
return _u
}
// SetNillableName sets the "name" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableName(v *string) *AccountUpdateOne {
if v != nil {
_u.SetName(*v)
}
return _u
}
// SetPlatform sets the "platform" field.
func (_u *AccountUpdateOne) SetPlatform(v string) *AccountUpdateOne {
_u.mutation.SetPlatform(v)
return _u
}
// SetNillablePlatform sets the "platform" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillablePlatform(v *string) *AccountUpdateOne {
if v != nil {
_u.SetPlatform(*v)
}
return _u
}
// SetType sets the "type" field.
func (_u *AccountUpdateOne) SetType(v string) *AccountUpdateOne {
_u.mutation.SetType(v)
return _u
}
// SetNillableType sets the "type" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableType(v *string) *AccountUpdateOne {
if v != nil {
_u.SetType(*v)
}
return _u
}
// SetCredentials sets the "credentials" field.
func (_u *AccountUpdateOne) SetCredentials(v map[string]interface{}) *AccountUpdateOne {
_u.mutation.SetCredentials(v)
return _u
}
// SetExtra sets the "extra" field.
func (_u *AccountUpdateOne) SetExtra(v map[string]interface{}) *AccountUpdateOne {
_u.mutation.SetExtra(v)
return _u
}
// SetProxyID sets the "proxy_id" field.
func (_u *AccountUpdateOne) SetProxyID(v int64) *AccountUpdateOne {
_u.mutation.ResetProxyID()
_u.mutation.SetProxyID(v)
return _u
}
// SetNillableProxyID sets the "proxy_id" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableProxyID(v *int64) *AccountUpdateOne {
if v != nil {
_u.SetProxyID(*v)
}
return _u
}
// AddProxyID adds value to the "proxy_id" field.
func (_u *AccountUpdateOne) AddProxyID(v int64) *AccountUpdateOne {
_u.mutation.AddProxyID(v)
return _u
}
// ClearProxyID clears the value of the "proxy_id" field.
func (_u *AccountUpdateOne) ClearProxyID() *AccountUpdateOne {
_u.mutation.ClearProxyID()
return _u
}
// SetConcurrency sets the "concurrency" field.
func (_u *AccountUpdateOne) SetConcurrency(v int) *AccountUpdateOne {
_u.mutation.ResetConcurrency()
_u.mutation.SetConcurrency(v)
return _u
}
// SetNillableConcurrency sets the "concurrency" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableConcurrency(v *int) *AccountUpdateOne {
if v != nil {
_u.SetConcurrency(*v)
}
return _u
}
// AddConcurrency adds value to the "concurrency" field.
func (_u *AccountUpdateOne) AddConcurrency(v int) *AccountUpdateOne {
_u.mutation.AddConcurrency(v)
return _u
}
// SetPriority sets the "priority" field.
func (_u *AccountUpdateOne) SetPriority(v int) *AccountUpdateOne {
_u.mutation.ResetPriority()
_u.mutation.SetPriority(v)
return _u
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillablePriority(v *int) *AccountUpdateOne {
if v != nil {
_u.SetPriority(*v)
}
return _u
}
// AddPriority adds value to the "priority" field.
func (_u *AccountUpdateOne) AddPriority(v int) *AccountUpdateOne {
_u.mutation.AddPriority(v)
return _u
}
// SetStatus sets the "status" field.
func (_u *AccountUpdateOne) SetStatus(v string) *AccountUpdateOne {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableStatus(v *string) *AccountUpdateOne {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetErrorMessage sets the "error_message" field.
func (_u *AccountUpdateOne) SetErrorMessage(v string) *AccountUpdateOne {
_u.mutation.SetErrorMessage(v)
return _u
}
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableErrorMessage(v *string) *AccountUpdateOne {
if v != nil {
_u.SetErrorMessage(*v)
}
return _u
}
// ClearErrorMessage clears the value of the "error_message" field.
func (_u *AccountUpdateOne) ClearErrorMessage() *AccountUpdateOne {
_u.mutation.ClearErrorMessage()
return _u
}
// SetLastUsedAt sets the "last_used_at" field.
func (_u *AccountUpdateOne) SetLastUsedAt(v time.Time) *AccountUpdateOne {
_u.mutation.SetLastUsedAt(v)
return _u
}
// SetNillableLastUsedAt sets the "last_used_at" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableLastUsedAt(v *time.Time) *AccountUpdateOne {
if v != nil {
_u.SetLastUsedAt(*v)
}
return _u
}
// ClearLastUsedAt clears the value of the "last_used_at" field.
func (_u *AccountUpdateOne) ClearLastUsedAt() *AccountUpdateOne {
_u.mutation.ClearLastUsedAt()
return _u
}
// SetSchedulable sets the "schedulable" field.
func (_u *AccountUpdateOne) SetSchedulable(v bool) *AccountUpdateOne {
_u.mutation.SetSchedulable(v)
return _u
}
// SetNillableSchedulable sets the "schedulable" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableSchedulable(v *bool) *AccountUpdateOne {
if v != nil {
_u.SetSchedulable(*v)
}
return _u
}
// SetRateLimitedAt sets the "rate_limited_at" field.
func (_u *AccountUpdateOne) SetRateLimitedAt(v time.Time) *AccountUpdateOne {
_u.mutation.SetRateLimitedAt(v)
return _u
}
// SetNillableRateLimitedAt sets the "rate_limited_at" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableRateLimitedAt(v *time.Time) *AccountUpdateOne {
if v != nil {
_u.SetRateLimitedAt(*v)
}
return _u
}
// ClearRateLimitedAt clears the value of the "rate_limited_at" field.
func (_u *AccountUpdateOne) ClearRateLimitedAt() *AccountUpdateOne {
_u.mutation.ClearRateLimitedAt()
return _u
}
// SetRateLimitResetAt sets the "rate_limit_reset_at" field.
func (_u *AccountUpdateOne) SetRateLimitResetAt(v time.Time) *AccountUpdateOne {
_u.mutation.SetRateLimitResetAt(v)
return _u
}
// SetNillableRateLimitResetAt sets the "rate_limit_reset_at" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableRateLimitResetAt(v *time.Time) *AccountUpdateOne {
if v != nil {
_u.SetRateLimitResetAt(*v)
}
return _u
}
// ClearRateLimitResetAt clears the value of the "rate_limit_reset_at" field.
func (_u *AccountUpdateOne) ClearRateLimitResetAt() *AccountUpdateOne {
_u.mutation.ClearRateLimitResetAt()
return _u
}
// SetOverloadUntil sets the "overload_until" field.
func (_u *AccountUpdateOne) SetOverloadUntil(v time.Time) *AccountUpdateOne {
_u.mutation.SetOverloadUntil(v)
return _u
}
// SetNillableOverloadUntil sets the "overload_until" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableOverloadUntil(v *time.Time) *AccountUpdateOne {
if v != nil {
_u.SetOverloadUntil(*v)
}
return _u
}
// ClearOverloadUntil clears the value of the "overload_until" field.
func (_u *AccountUpdateOne) ClearOverloadUntil() *AccountUpdateOne {
_u.mutation.ClearOverloadUntil()
return _u
}
// SetSessionWindowStart sets the "session_window_start" field.
func (_u *AccountUpdateOne) SetSessionWindowStart(v time.Time) *AccountUpdateOne {
_u.mutation.SetSessionWindowStart(v)
return _u
}
// SetNillableSessionWindowStart sets the "session_window_start" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableSessionWindowStart(v *time.Time) *AccountUpdateOne {
if v != nil {
_u.SetSessionWindowStart(*v)
}
return _u
}
// ClearSessionWindowStart clears the value of the "session_window_start" field.
func (_u *AccountUpdateOne) ClearSessionWindowStart() *AccountUpdateOne {
_u.mutation.ClearSessionWindowStart()
return _u
}
// SetSessionWindowEnd sets the "session_window_end" field.
func (_u *AccountUpdateOne) SetSessionWindowEnd(v time.Time) *AccountUpdateOne {
_u.mutation.SetSessionWindowEnd(v)
return _u
}
// SetNillableSessionWindowEnd sets the "session_window_end" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableSessionWindowEnd(v *time.Time) *AccountUpdateOne {
if v != nil {
_u.SetSessionWindowEnd(*v)
}
return _u
}
// ClearSessionWindowEnd clears the value of the "session_window_end" field.
func (_u *AccountUpdateOne) ClearSessionWindowEnd() *AccountUpdateOne {
_u.mutation.ClearSessionWindowEnd()
return _u
}
// SetSessionWindowStatus sets the "session_window_status" field.
func (_u *AccountUpdateOne) SetSessionWindowStatus(v string) *AccountUpdateOne {
_u.mutation.SetSessionWindowStatus(v)
return _u
}
// SetNillableSessionWindowStatus sets the "session_window_status" field if the given value is not nil.
func (_u *AccountUpdateOne) SetNillableSessionWindowStatus(v *string) *AccountUpdateOne {
if v != nil {
_u.SetSessionWindowStatus(*v)
}
return _u
}
// ClearSessionWindowStatus clears the value of the "session_window_status" field.
func (_u *AccountUpdateOne) ClearSessionWindowStatus() *AccountUpdateOne {
_u.mutation.ClearSessionWindowStatus()
return _u
}
// AddGroupIDs adds the "groups" edge to the Group entity by IDs.
func (_u *AccountUpdateOne) AddGroupIDs(ids ...int64) *AccountUpdateOne {
_u.mutation.AddGroupIDs(ids...)
return _u
}
// AddGroups adds the "groups" edges to the Group entity.
func (_u *AccountUpdateOne) AddGroups(v ...*Group) *AccountUpdateOne {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddGroupIDs(ids...)
}
// Mutation returns the AccountMutation object of the builder.
func (_u *AccountUpdateOne) Mutation() *AccountMutation {
return _u.mutation
}
// ClearGroups clears all "groups" edges to the Group entity.
func (_u *AccountUpdateOne) ClearGroups() *AccountUpdateOne {
_u.mutation.ClearGroups()
return _u
}
// RemoveGroupIDs removes the "groups" edge to Group entities by IDs.
func (_u *AccountUpdateOne) RemoveGroupIDs(ids ...int64) *AccountUpdateOne {
_u.mutation.RemoveGroupIDs(ids...)
return _u
}
// RemoveGroups removes "groups" edges to Group entities.
func (_u *AccountUpdateOne) RemoveGroups(v ...*Group) *AccountUpdateOne {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveGroupIDs(ids...)
}
// Where appends a list predicates to the AccountUpdate builder.
func (_u *AccountUpdateOne) Where(ps ...predicate.Account) *AccountUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *AccountUpdateOne) Select(field string, fields ...string) *AccountUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated Account entity.
func (_u *AccountUpdateOne) Save(ctx context.Context) (*Account, error) {
if err := _u.defaults(); err != nil {
return nil, err
}
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AccountUpdateOne) SaveX(ctx context.Context) *Account {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *AccountUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AccountUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *AccountUpdateOne) defaults() error {
if _, ok := _u.mutation.UpdatedAt(); !ok {
if account.UpdateDefaultUpdatedAt == nil {
return fmt.Errorf("ent: uninitialized account.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
}
v := account.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
return nil
}
// check runs all checks and user-defined validators on the builder.
func (_u *AccountUpdateOne) check() error {
if v, ok := _u.mutation.Name(); ok {
if err := account.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Account.name": %w`, err)}
}
}
if v, ok := _u.mutation.Platform(); ok {
if err := account.PlatformValidator(v); err != nil {
return &ValidationError{Name: "platform", err: fmt.Errorf(`ent: validator failed for field "Account.platform": %w`, err)}
}
}
if v, ok := _u.mutation.GetType(); ok {
if err := account.TypeValidator(v); err != nil {
return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Account.type": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := account.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Account.status": %w`, err)}
}
}
if v, ok := _u.mutation.SessionWindowStatus(); ok {
if err := account.SessionWindowStatusValidator(v); err != nil {
return &ValidationError{Name: "session_window_status", err: fmt.Errorf(`ent: validator failed for field "Account.session_window_status": %w`, err)}
}
}
return nil
}
func (_u *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(account.Table, account.Columns, sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Account.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, account.FieldID)
for _, f := range fields {
if !account.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != account.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(account.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.DeletedAt(); ok {
_spec.SetField(account.FieldDeletedAt, field.TypeTime, value)
}
if _u.mutation.DeletedAtCleared() {
_spec.ClearField(account.FieldDeletedAt, field.TypeTime)
}
if value, ok := _u.mutation.Name(); ok {
_spec.SetField(account.FieldName, field.TypeString, value)
}
if value, ok := _u.mutation.Platform(); ok {
_spec.SetField(account.FieldPlatform, field.TypeString, value)
}
if value, ok := _u.mutation.GetType(); ok {
_spec.SetField(account.FieldType, field.TypeString, value)
}
if value, ok := _u.mutation.Credentials(); ok {
_spec.SetField(account.FieldCredentials, field.TypeJSON, value)
}
if value, ok := _u.mutation.Extra(); ok {
_spec.SetField(account.FieldExtra, field.TypeJSON, value)
}
if value, ok := _u.mutation.ProxyID(); ok {
_spec.SetField(account.FieldProxyID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedProxyID(); ok {
_spec.AddField(account.FieldProxyID, field.TypeInt64, value)
}
if _u.mutation.ProxyIDCleared() {
_spec.ClearField(account.FieldProxyID, field.TypeInt64)
}
if value, ok := _u.mutation.Concurrency(); ok {
_spec.SetField(account.FieldConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedConcurrency(); ok {
_spec.AddField(account.FieldConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.Priority(); ok {
_spec.SetField(account.FieldPriority, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedPriority(); ok {
_spec.AddField(account.FieldPriority, field.TypeInt, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(account.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.ErrorMessage(); ok {
_spec.SetField(account.FieldErrorMessage, field.TypeString, value)
}
if _u.mutation.ErrorMessageCleared() {
_spec.ClearField(account.FieldErrorMessage, field.TypeString)
}
if value, ok := _u.mutation.LastUsedAt(); ok {
_spec.SetField(account.FieldLastUsedAt, field.TypeTime, value)
}
if _u.mutation.LastUsedAtCleared() {
_spec.ClearField(account.FieldLastUsedAt, field.TypeTime)
}
if value, ok := _u.mutation.Schedulable(); ok {
_spec.SetField(account.FieldSchedulable, field.TypeBool, value)
}
if value, ok := _u.mutation.RateLimitedAt(); ok {
_spec.SetField(account.FieldRateLimitedAt, field.TypeTime, value)
}
if _u.mutation.RateLimitedAtCleared() {
_spec.ClearField(account.FieldRateLimitedAt, field.TypeTime)
}
if value, ok := _u.mutation.RateLimitResetAt(); ok {
_spec.SetField(account.FieldRateLimitResetAt, field.TypeTime, value)
}
if _u.mutation.RateLimitResetAtCleared() {
_spec.ClearField(account.FieldRateLimitResetAt, field.TypeTime)
}
if value, ok := _u.mutation.OverloadUntil(); ok {
_spec.SetField(account.FieldOverloadUntil, field.TypeTime, value)
}
if _u.mutation.OverloadUntilCleared() {
_spec.ClearField(account.FieldOverloadUntil, field.TypeTime)
}
if value, ok := _u.mutation.SessionWindowStart(); ok {
_spec.SetField(account.FieldSessionWindowStart, field.TypeTime, value)
}
if _u.mutation.SessionWindowStartCleared() {
_spec.ClearField(account.FieldSessionWindowStart, field.TypeTime)
}
if value, ok := _u.mutation.SessionWindowEnd(); ok {
_spec.SetField(account.FieldSessionWindowEnd, field.TypeTime, value)
}
if _u.mutation.SessionWindowEndCleared() {
_spec.ClearField(account.FieldSessionWindowEnd, field.TypeTime)
}
if value, ok := _u.mutation.SessionWindowStatus(); ok {
_spec.SetField(account.FieldSessionWindowStatus, field.TypeString, value)
}
if _u.mutation.SessionWindowStatusCleared() {
_spec.ClearField(account.FieldSessionWindowStatus, field.TypeString)
}
if _u.mutation.GroupsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: account.GroupsTable,
Columns: account.GroupsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
},
}
createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
createE.defaults()
_, specE := createE.createSpec()
edge.Target.Fields = specE.Fields
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedGroupsIDs(); len(nodes) > 0 && !_u.mutation.GroupsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: account.GroupsTable,
Columns: account.GroupsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
createE.defaults()
_, specE := createE.createSpec()
edge.Target.Fields = specE.Fields
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.GroupsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M,
Inverse: false,
Table: account.GroupsTable,
Columns: account.GroupsPrimaryKey,
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
createE := &AccountGroupCreate{config: _u.config, mutation: newAccountGroupMutation(_u.config, OpCreate)}
createE.defaults()
_, specE := createE.createSpec()
edge.Target.Fields = specE.Fields
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &Account{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{account.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}
// 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/account"
"github.com/Wei-Shaw/sub2api/ent/accountgroup"
"github.com/Wei-Shaw/sub2api/ent/group"
)
// AccountGroup is the model entity for the AccountGroup schema.
type AccountGroup struct {
config `json:"-"`
// AccountID holds the value of the "account_id" field.
AccountID int64 `json:"account_id,omitempty"`
// GroupID holds the value of the "group_id" field.
GroupID int64 `json:"group_id,omitempty"`
// Priority holds the value of the "priority" field.
Priority int `json:"priority,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the AccountGroupQuery when eager-loading is set.
Edges AccountGroupEdges `json:"edges"`
selectValues sql.SelectValues
}
// AccountGroupEdges holds the relations/edges for other nodes in the graph.
type AccountGroupEdges struct {
// Account holds the value of the account edge.
Account *Account `json:"account,omitempty"`
// Group holds the value of the group edge.
Group *Group `json:"group,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
}
// AccountOrErr returns the Account value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AccountGroupEdges) AccountOrErr() (*Account, error) {
if e.Account != nil {
return e.Account, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: account.Label}
}
return nil, &NotLoadedError{edge: "account"}
}
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AccountGroupEdges) GroupOrErr() (*Group, error) {
if e.Group != nil {
return e.Group, nil
} else if e.loadedTypes[1] {
return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "group"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*AccountGroup) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case accountgroup.FieldAccountID, accountgroup.FieldGroupID, accountgroup.FieldPriority:
values[i] = new(sql.NullInt64)
case accountgroup.FieldCreatedAt:
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 AccountGroup fields.
func (_m *AccountGroup) 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 accountgroup.FieldAccountID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field account_id", values[i])
} else if value.Valid {
_m.AccountID = value.Int64
}
case accountgroup.FieldGroupID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field group_id", values[i])
} else if value.Valid {
_m.GroupID = value.Int64
}
case accountgroup.FieldPriority:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field priority", values[i])
} else if value.Valid {
_m.Priority = int(value.Int64)
}
case accountgroup.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
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the AccountGroup.
// This includes values selected through modifiers, order, etc.
func (_m *AccountGroup) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryAccount queries the "account" edge of the AccountGroup entity.
func (_m *AccountGroup) QueryAccount() *AccountQuery {
return NewAccountGroupClient(_m.config).QueryAccount(_m)
}
// QueryGroup queries the "group" edge of the AccountGroup entity.
func (_m *AccountGroup) QueryGroup() *GroupQuery {
return NewAccountGroupClient(_m.config).QueryGroup(_m)
}
// Update returns a builder for updating this AccountGroup.
// Note that you need to call AccountGroup.Unwrap() before calling this method if this AccountGroup
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *AccountGroup) Update() *AccountGroupUpdateOne {
return NewAccountGroupClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the AccountGroup 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 *AccountGroup) Unwrap() *AccountGroup {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: AccountGroup is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *AccountGroup) String() string {
var builder strings.Builder
builder.WriteString("AccountGroup(")
builder.WriteString("account_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AccountID))
builder.WriteString(", ")
builder.WriteString("group_id=")
builder.WriteString(fmt.Sprintf("%v", _m.GroupID))
builder.WriteString(", ")
builder.WriteString("priority=")
builder.WriteString(fmt.Sprintf("%v", _m.Priority))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// AccountGroups is a parsable slice of AccountGroup.
type AccountGroups []*AccountGroup
// Code generated by ent, DO NOT EDIT.
package accountgroup
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the accountgroup type in the database.
Label = "account_group"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldGroupID holds the string denoting the group_id field in the database.
FieldGroupID = "group_id"
// FieldPriority holds the string denoting the priority field in the database.
FieldPriority = "priority"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// EdgeAccount holds the string denoting the account edge name in mutations.
EdgeAccount = "account"
// EdgeGroup holds the string denoting the group edge name in mutations.
EdgeGroup = "group"
// AccountFieldID holds the string denoting the ID field of the Account.
AccountFieldID = "id"
// GroupFieldID holds the string denoting the ID field of the Group.
GroupFieldID = "id"
// Table holds the table name of the accountgroup in the database.
Table = "account_groups"
// AccountTable is the table that holds the account relation/edge.
AccountTable = "account_groups"
// AccountInverseTable is the table name for the Account entity.
// It exists in this package in order to avoid circular dependency with the "account" package.
AccountInverseTable = "accounts"
// AccountColumn is the table column denoting the account relation/edge.
AccountColumn = "account_id"
// GroupTable is the table that holds the group relation/edge.
GroupTable = "account_groups"
// GroupInverseTable is the table name for the Group entity.
// It exists in this package in order to avoid circular dependency with the "group" package.
GroupInverseTable = "groups"
// GroupColumn is the table column denoting the group relation/edge.
GroupColumn = "group_id"
)
// Columns holds all SQL columns for accountgroup fields.
var Columns = []string{
FieldAccountID,
FieldGroupID,
FieldPriority,
FieldCreatedAt,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultPriority holds the default value on creation for the "priority" field.
DefaultPriority int
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the AccountGroup queries.
type OrderOption func(*sql.Selector)
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByGroupID orders the results by the group_id field.
func ByGroupID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldGroupID, opts...).ToFunc()
}
// ByPriority orders the results by the priority field.
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPriority, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByAccountField orders the results by account field.
func ByAccountField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAccountStep(), sql.OrderByField(field, opts...))
}
}
// ByGroupField orders the results by group field.
func ByGroupField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newGroupStep(), sql.OrderByField(field, opts...))
}
}
func newAccountStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, AccountColumn),
sqlgraph.To(AccountInverseTable, AccountFieldID),
sqlgraph.Edge(sqlgraph.M2O, false, AccountTable, AccountColumn),
)
}
func newGroupStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, GroupColumn),
sqlgraph.To(GroupInverseTable, GroupFieldID),
sqlgraph.Edge(sqlgraph.M2O, false, GroupTable, GroupColumn),
)
}
// Code generated by ent, DO NOT EDIT.
package accountgroup
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ.
func AccountID(v int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldEQ(FieldAccountID, v))
}
// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ.
func GroupID(v int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldEQ(FieldGroupID, v))
}
// Priority applies equality check predicate on the "priority" field. It's identical to PriorityEQ.
func Priority(v int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldEQ(FieldPriority, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldEQ(FieldCreatedAt, v))
}
// AccountIDEQ applies the EQ predicate on the "account_id" field.
func AccountIDEQ(v int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldEQ(FieldAccountID, v))
}
// AccountIDNEQ applies the NEQ predicate on the "account_id" field.
func AccountIDNEQ(v int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldNEQ(FieldAccountID, v))
}
// AccountIDIn applies the In predicate on the "account_id" field.
func AccountIDIn(vs ...int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldIn(FieldAccountID, vs...))
}
// AccountIDNotIn applies the NotIn predicate on the "account_id" field.
func AccountIDNotIn(vs ...int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldNotIn(FieldAccountID, vs...))
}
// GroupIDEQ applies the EQ predicate on the "group_id" field.
func GroupIDEQ(v int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldEQ(FieldGroupID, v))
}
// GroupIDNEQ applies the NEQ predicate on the "group_id" field.
func GroupIDNEQ(v int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldNEQ(FieldGroupID, v))
}
// GroupIDIn applies the In predicate on the "group_id" field.
func GroupIDIn(vs ...int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldIn(FieldGroupID, vs...))
}
// GroupIDNotIn applies the NotIn predicate on the "group_id" field.
func GroupIDNotIn(vs ...int64) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldNotIn(FieldGroupID, vs...))
}
// PriorityEQ applies the EQ predicate on the "priority" field.
func PriorityEQ(v int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldEQ(FieldPriority, v))
}
// PriorityNEQ applies the NEQ predicate on the "priority" field.
func PriorityNEQ(v int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldNEQ(FieldPriority, v))
}
// PriorityIn applies the In predicate on the "priority" field.
func PriorityIn(vs ...int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldIn(FieldPriority, vs...))
}
// PriorityNotIn applies the NotIn predicate on the "priority" field.
func PriorityNotIn(vs ...int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldNotIn(FieldPriority, vs...))
}
// PriorityGT applies the GT predicate on the "priority" field.
func PriorityGT(v int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldGT(FieldPriority, v))
}
// PriorityGTE applies the GTE predicate on the "priority" field.
func PriorityGTE(v int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldGTE(FieldPriority, v))
}
// PriorityLT applies the LT predicate on the "priority" field.
func PriorityLT(v int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldLT(FieldPriority, v))
}
// PriorityLTE applies the LTE predicate on the "priority" field.
func PriorityLTE(v int) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldLTE(FieldPriority, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.AccountGroup {
return predicate.AccountGroup(sql.FieldLTE(FieldCreatedAt, v))
}
// HasAccount applies the HasEdge predicate on the "account" edge.
func HasAccount() predicate.AccountGroup {
return predicate.AccountGroup(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, AccountColumn),
sqlgraph.Edge(sqlgraph.M2O, false, AccountTable, AccountColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasAccountWith applies the HasEdge predicate on the "account" edge with a given conditions (other predicates).
func HasAccountWith(preds ...predicate.Account) predicate.AccountGroup {
return predicate.AccountGroup(func(s *sql.Selector) {
step := newAccountStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasGroup applies the HasEdge predicate on the "group" edge.
func HasGroup() predicate.AccountGroup {
return predicate.AccountGroup(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, GroupColumn),
sqlgraph.Edge(sqlgraph.M2O, false, GroupTable, GroupColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
func HasGroupWith(preds ...predicate.Group) predicate.AccountGroup {
return predicate.AccountGroup(func(s *sql.Selector) {
step := newGroupStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.AccountGroup) predicate.AccountGroup {
return predicate.AccountGroup(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.AccountGroup) predicate.AccountGroup {
return predicate.AccountGroup(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.AccountGroup) predicate.AccountGroup {
return predicate.AccountGroup(sql.NotPredicates(p))
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/account"
"github.com/Wei-Shaw/sub2api/ent/accountgroup"
"github.com/Wei-Shaw/sub2api/ent/group"
)
// AccountGroupCreate is the builder for creating a AccountGroup entity.
type AccountGroupCreate struct {
config
mutation *AccountGroupMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetAccountID sets the "account_id" field.
func (_c *AccountGroupCreate) SetAccountID(v int64) *AccountGroupCreate {
_c.mutation.SetAccountID(v)
return _c
}
// SetGroupID sets the "group_id" field.
func (_c *AccountGroupCreate) SetGroupID(v int64) *AccountGroupCreate {
_c.mutation.SetGroupID(v)
return _c
}
// SetPriority sets the "priority" field.
func (_c *AccountGroupCreate) SetPriority(v int) *AccountGroupCreate {
_c.mutation.SetPriority(v)
return _c
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func (_c *AccountGroupCreate) SetNillablePriority(v *int) *AccountGroupCreate {
if v != nil {
_c.SetPriority(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *AccountGroupCreate) SetCreatedAt(v time.Time) *AccountGroupCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *AccountGroupCreate) SetNillableCreatedAt(v *time.Time) *AccountGroupCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetAccount sets the "account" edge to the Account entity.
func (_c *AccountGroupCreate) SetAccount(v *Account) *AccountGroupCreate {
return _c.SetAccountID(v.ID)
}
// SetGroup sets the "group" edge to the Group entity.
func (_c *AccountGroupCreate) SetGroup(v *Group) *AccountGroupCreate {
return _c.SetGroupID(v.ID)
}
// Mutation returns the AccountGroupMutation object of the builder.
func (_c *AccountGroupCreate) Mutation() *AccountGroupMutation {
return _c.mutation
}
// Save creates the AccountGroup in the database.
func (_c *AccountGroupCreate) Save(ctx context.Context) (*AccountGroup, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *AccountGroupCreate) SaveX(ctx context.Context) *AccountGroup {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *AccountGroupCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *AccountGroupCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *AccountGroupCreate) defaults() {
if _, ok := _c.mutation.Priority(); !ok {
v := accountgroup.DefaultPriority
_c.mutation.SetPriority(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := accountgroup.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *AccountGroupCreate) check() error {
if _, ok := _c.mutation.AccountID(); !ok {
return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "AccountGroup.account_id"`)}
}
if _, ok := _c.mutation.GroupID(); !ok {
return &ValidationError{Name: "group_id", err: errors.New(`ent: missing required field "AccountGroup.group_id"`)}
}
if _, ok := _c.mutation.Priority(); !ok {
return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "AccountGroup.priority"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AccountGroup.created_at"`)}
}
if len(_c.mutation.AccountIDs()) == 0 {
return &ValidationError{Name: "account", err: errors.New(`ent: missing required edge "AccountGroup.account"`)}
}
if len(_c.mutation.GroupIDs()) == 0 {
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "AccountGroup.group"`)}
}
return nil
}
func (_c *AccountGroupCreate) sqlSave(ctx context.Context) (*AccountGroup, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
return _node, nil
}
func (_c *AccountGroupCreate) createSpec() (*AccountGroup, *sqlgraph.CreateSpec) {
var (
_node = &AccountGroup{config: _c.config}
_spec = sqlgraph.NewCreateSpec(accountgroup.Table, nil)
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.Priority(); ok {
_spec.SetField(accountgroup.FieldPriority, field.TypeInt, value)
_node.Priority = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(accountgroup.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if nodes := _c.mutation.AccountIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: accountgroup.AccountTable,
Columns: []string{accountgroup.AccountColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.AccountID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: false,
Table: accountgroup.GroupTable,
Columns: []string{accountgroup.GroupColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.GroupID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.AccountGroup.Create().
// SetAccountID(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.AccountGroupUpsert) {
// SetAccountID(v+v).
// }).
// Exec(ctx)
func (_c *AccountGroupCreate) OnConflict(opts ...sql.ConflictOption) *AccountGroupUpsertOne {
_c.conflict = opts
return &AccountGroupUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.AccountGroup.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *AccountGroupCreate) OnConflictColumns(columns ...string) *AccountGroupUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &AccountGroupUpsertOne{
create: _c,
}
}
type (
// AccountGroupUpsertOne is the builder for "upsert"-ing
// one AccountGroup node.
AccountGroupUpsertOne struct {
create *AccountGroupCreate
}
// AccountGroupUpsert is the "OnConflict" setter.
AccountGroupUpsert struct {
*sql.UpdateSet
}
)
// SetAccountID sets the "account_id" field.
func (u *AccountGroupUpsert) SetAccountID(v int64) *AccountGroupUpsert {
u.Set(accountgroup.FieldAccountID, v)
return u
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *AccountGroupUpsert) UpdateAccountID() *AccountGroupUpsert {
u.SetExcluded(accountgroup.FieldAccountID)
return u
}
// SetGroupID sets the "group_id" field.
func (u *AccountGroupUpsert) SetGroupID(v int64) *AccountGroupUpsert {
u.Set(accountgroup.FieldGroupID, v)
return u
}
// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *AccountGroupUpsert) UpdateGroupID() *AccountGroupUpsert {
u.SetExcluded(accountgroup.FieldGroupID)
return u
}
// SetPriority sets the "priority" field.
func (u *AccountGroupUpsert) SetPriority(v int) *AccountGroupUpsert {
u.Set(accountgroup.FieldPriority, v)
return u
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *AccountGroupUpsert) UpdatePriority() *AccountGroupUpsert {
u.SetExcluded(accountgroup.FieldPriority)
return u
}
// AddPriority adds v to the "priority" field.
func (u *AccountGroupUpsert) AddPriority(v int) *AccountGroupUpsert {
u.Add(accountgroup.FieldPriority, v)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.AccountGroup.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *AccountGroupUpsertOne) UpdateNewValues() *AccountGroupUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
if _, exists := u.create.mutation.CreatedAt(); exists {
s.SetIgnore(accountgroup.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.AccountGroup.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *AccountGroupUpsertOne) Ignore() *AccountGroupUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *AccountGroupUpsertOne) DoNothing() *AccountGroupUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the AccountGroupCreate.OnConflict
// documentation for more info.
func (u *AccountGroupUpsertOne) Update(set func(*AccountGroupUpsert)) *AccountGroupUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&AccountGroupUpsert{UpdateSet: update})
}))
return u
}
// SetAccountID sets the "account_id" field.
func (u *AccountGroupUpsertOne) SetAccountID(v int64) *AccountGroupUpsertOne {
return u.Update(func(s *AccountGroupUpsert) {
s.SetAccountID(v)
})
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *AccountGroupUpsertOne) UpdateAccountID() *AccountGroupUpsertOne {
return u.Update(func(s *AccountGroupUpsert) {
s.UpdateAccountID()
})
}
// SetGroupID sets the "group_id" field.
func (u *AccountGroupUpsertOne) SetGroupID(v int64) *AccountGroupUpsertOne {
return u.Update(func(s *AccountGroupUpsert) {
s.SetGroupID(v)
})
}
// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *AccountGroupUpsertOne) UpdateGroupID() *AccountGroupUpsertOne {
return u.Update(func(s *AccountGroupUpsert) {
s.UpdateGroupID()
})
}
// SetPriority sets the "priority" field.
func (u *AccountGroupUpsertOne) SetPriority(v int) *AccountGroupUpsertOne {
return u.Update(func(s *AccountGroupUpsert) {
s.SetPriority(v)
})
}
// AddPriority adds v to the "priority" field.
func (u *AccountGroupUpsertOne) AddPriority(v int) *AccountGroupUpsertOne {
return u.Update(func(s *AccountGroupUpsert) {
s.AddPriority(v)
})
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *AccountGroupUpsertOne) UpdatePriority() *AccountGroupUpsertOne {
return u.Update(func(s *AccountGroupUpsert) {
s.UpdatePriority()
})
}
// Exec executes the query.
func (u *AccountGroupUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for AccountGroupCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *AccountGroupUpsertOne) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// AccountGroupCreateBulk is the builder for creating many AccountGroup entities in bulk.
type AccountGroupCreateBulk struct {
config
err error
builders []*AccountGroupCreate
conflict []sql.ConflictOption
}
// Save creates the AccountGroup entities in the database.
func (_c *AccountGroupCreateBulk) Save(ctx context.Context) ([]*AccountGroup, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*AccountGroup, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AccountGroupMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *AccountGroupCreateBulk) SaveX(ctx context.Context) []*AccountGroup {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *AccountGroupCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *AccountGroupCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.AccountGroup.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.AccountGroupUpsert) {
// SetAccountID(v+v).
// }).
// Exec(ctx)
func (_c *AccountGroupCreateBulk) OnConflict(opts ...sql.ConflictOption) *AccountGroupUpsertBulk {
_c.conflict = opts
return &AccountGroupUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.AccountGroup.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *AccountGroupCreateBulk) OnConflictColumns(columns ...string) *AccountGroupUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &AccountGroupUpsertBulk{
create: _c,
}
}
// AccountGroupUpsertBulk is the builder for "upsert"-ing
// a bulk of AccountGroup nodes.
type AccountGroupUpsertBulk struct {
create *AccountGroupCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.AccountGroup.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *AccountGroupUpsertBulk) UpdateNewValues() *AccountGroupUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
for _, b := range u.create.builders {
if _, exists := b.mutation.CreatedAt(); exists {
s.SetIgnore(accountgroup.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.AccountGroup.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *AccountGroupUpsertBulk) Ignore() *AccountGroupUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *AccountGroupUpsertBulk) DoNothing() *AccountGroupUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the AccountGroupCreateBulk.OnConflict
// documentation for more info.
func (u *AccountGroupUpsertBulk) Update(set func(*AccountGroupUpsert)) *AccountGroupUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&AccountGroupUpsert{UpdateSet: update})
}))
return u
}
// SetAccountID sets the "account_id" field.
func (u *AccountGroupUpsertBulk) SetAccountID(v int64) *AccountGroupUpsertBulk {
return u.Update(func(s *AccountGroupUpsert) {
s.SetAccountID(v)
})
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *AccountGroupUpsertBulk) UpdateAccountID() *AccountGroupUpsertBulk {
return u.Update(func(s *AccountGroupUpsert) {
s.UpdateAccountID()
})
}
// SetGroupID sets the "group_id" field.
func (u *AccountGroupUpsertBulk) SetGroupID(v int64) *AccountGroupUpsertBulk {
return u.Update(func(s *AccountGroupUpsert) {
s.SetGroupID(v)
})
}
// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *AccountGroupUpsertBulk) UpdateGroupID() *AccountGroupUpsertBulk {
return u.Update(func(s *AccountGroupUpsert) {
s.UpdateGroupID()
})
}
// SetPriority sets the "priority" field.
func (u *AccountGroupUpsertBulk) SetPriority(v int) *AccountGroupUpsertBulk {
return u.Update(func(s *AccountGroupUpsert) {
s.SetPriority(v)
})
}
// AddPriority adds v to the "priority" field.
func (u *AccountGroupUpsertBulk) AddPriority(v int) *AccountGroupUpsertBulk {
return u.Update(func(s *AccountGroupUpsert) {
s.AddPriority(v)
})
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func (u *AccountGroupUpsertBulk) UpdatePriority() *AccountGroupUpsertBulk {
return u.Update(func(s *AccountGroupUpsert) {
s.UpdatePriority()
})
}
// Exec executes the query.
func (u *AccountGroupUpsertBulk) Exec(ctx context.Context) error {
if u.create.err != nil {
return u.create.err
}
for i, b := range u.create.builders {
if len(b.conflict) != 0 {
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the AccountGroupCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for AccountGroupCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *AccountGroupUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/Wei-Shaw/sub2api/ent/accountgroup"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AccountGroupDelete is the builder for deleting a AccountGroup entity.
type AccountGroupDelete struct {
config
hooks []Hook
mutation *AccountGroupMutation
}
// Where appends a list predicates to the AccountGroupDelete builder.
func (_d *AccountGroupDelete) Where(ps ...predicate.AccountGroup) *AccountGroupDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *AccountGroupDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *AccountGroupDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *AccountGroupDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(accountgroup.Table, nil)
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
_d.mutation.done = true
return affected, err
}
// AccountGroupDeleteOne is the builder for deleting a single AccountGroup entity.
type AccountGroupDeleteOne struct {
_d *AccountGroupDelete
}
// Where appends a list predicates to the AccountGroupDelete builder.
func (_d *AccountGroupDeleteOne) Where(ps ...predicate.AccountGroup) *AccountGroupDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *AccountGroupDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{accountgroup.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *AccountGroupDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/Wei-Shaw/sub2api/ent/account"
"github.com/Wei-Shaw/sub2api/ent/accountgroup"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AccountGroupQuery is the builder for querying AccountGroup entities.
type AccountGroupQuery struct {
config
ctx *QueryContext
order []accountgroup.OrderOption
inters []Interceptor
predicates []predicate.AccountGroup
withAccount *AccountQuery
withGroup *GroupQuery
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the AccountGroupQuery builder.
func (_q *AccountGroupQuery) Where(ps ...predicate.AccountGroup) *AccountGroupQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *AccountGroupQuery) Limit(limit int) *AccountGroupQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *AccountGroupQuery) Offset(offset int) *AccountGroupQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *AccountGroupQuery) Unique(unique bool) *AccountGroupQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *AccountGroupQuery) Order(o ...accountgroup.OrderOption) *AccountGroupQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryAccount chains the current query on the "account" edge.
func (_q *AccountGroupQuery) QueryAccount() *AccountQuery {
query := (&AccountClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(accountgroup.Table, accountgroup.AccountColumn, selector),
sqlgraph.To(account.Table, account.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, accountgroup.AccountTable, accountgroup.AccountColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryGroup chains the current query on the "group" edge.
func (_q *AccountGroupQuery) QueryGroup() *GroupQuery {
query := (&GroupClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(accountgroup.Table, accountgroup.GroupColumn, selector),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, accountgroup.GroupTable, accountgroup.GroupColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// First returns the first AccountGroup entity from the query.
// Returns a *NotFoundError when no AccountGroup was found.
func (_q *AccountGroupQuery) First(ctx context.Context) (*AccountGroup, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{accountgroup.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *AccountGroupQuery) FirstX(ctx context.Context) *AccountGroup {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// Only returns a single AccountGroup entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one AccountGroup entity is found.
// Returns a *NotFoundError when no AccountGroup entities are found.
func (_q *AccountGroupQuery) Only(ctx context.Context) (*AccountGroup, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{accountgroup.Label}
default:
return nil, &NotSingularError{accountgroup.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *AccountGroupQuery) OnlyX(ctx context.Context) *AccountGroup {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// All executes the query and returns a list of AccountGroups.
func (_q *AccountGroupQuery) All(ctx context.Context) ([]*AccountGroup, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*AccountGroup, *AccountGroupQuery]()
return withInterceptors[[]*AccountGroup](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *AccountGroupQuery) AllX(ctx context.Context) []*AccountGroup {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// Count returns the count of the given query.
func (_q *AccountGroupQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*AccountGroupQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *AccountGroupQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *AccountGroupQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.First(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *AccountGroupQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the AccountGroupQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *AccountGroupQuery) Clone() *AccountGroupQuery {
if _q == nil {
return nil
}
return &AccountGroupQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]accountgroup.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.AccountGroup{}, _q.predicates...),
withAccount: _q.withAccount.Clone(),
withGroup: _q.withGroup.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithAccount tells the query-builder to eager-load the nodes that are connected to
// the "account" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AccountGroupQuery) WithAccount(opts ...func(*AccountQuery)) *AccountGroupQuery {
query := (&AccountClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withAccount = query
return _q
}
// WithGroup tells the query-builder to eager-load the nodes that are connected to
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AccountGroupQuery) WithGroup(opts ...func(*GroupQuery)) *AccountGroupQuery {
query := (&GroupClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withGroup = query
return _q
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// AccountID int64 `json:"account_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.AccountGroup.Query().
// GroupBy(accountgroup.FieldAccountID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *AccountGroupQuery) GroupBy(field string, fields ...string) *AccountGroupGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &AccountGroupGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = accountgroup.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// AccountID int64 `json:"account_id,omitempty"`
// }
//
// client.AccountGroup.Query().
// Select(accountgroup.FieldAccountID).
// Scan(ctx, &v)
func (_q *AccountGroupQuery) Select(fields ...string) *AccountGroupSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &AccountGroupSelect{AccountGroupQuery: _q}
sbuild.label = accountgroup.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a AccountGroupSelect configured with the given aggregations.
func (_q *AccountGroupQuery) Aggregate(fns ...AggregateFunc) *AccountGroupSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *AccountGroupQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !accountgroup.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *AccountGroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AccountGroup, error) {
var (
nodes = []*AccountGroup{}
_spec = _q.querySpec()
loadedTypes = [2]bool{
_q.withAccount != nil,
_q.withGroup != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*AccountGroup).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &AccountGroup{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withAccount; query != nil {
if err := _q.loadAccount(ctx, query, nodes, nil,
func(n *AccountGroup, e *Account) { n.Edges.Account = e }); err != nil {
return nil, err
}
}
if query := _q.withGroup; query != nil {
if err := _q.loadGroup(ctx, query, nodes, nil,
func(n *AccountGroup, e *Group) { n.Edges.Group = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *AccountGroupQuery) loadAccount(ctx context.Context, query *AccountQuery, nodes []*AccountGroup, init func(*AccountGroup), assign func(*AccountGroup, *Account)) error {
ids := make([]int64, 0, len(nodes))
nodeids := make(map[int64][]*AccountGroup)
for i := range nodes {
fk := nodes[i].AccountID
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(account.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "account_id" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (_q *AccountGroupQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*AccountGroup, init func(*AccountGroup), assign func(*AccountGroup, *Group)) error {
ids := make([]int64, 0, len(nodes))
nodeids := make(map[int64][]*AccountGroup)
for i := range nodes {
fk := nodes[i].GroupID
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(group.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "group_id" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (_q *AccountGroupQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
_spec.Unique = false
_spec.Node.Columns = nil
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *AccountGroupQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(accountgroup.Table, accountgroup.Columns, nil)
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
for i := range fields {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
if _q.withAccount != nil {
_spec.Node.AddColumnOnce(accountgroup.FieldAccountID)
}
if _q.withGroup != nil {
_spec.Node.AddColumnOnce(accountgroup.FieldGroupID)
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *AccountGroupQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(accountgroup.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = accountgroup.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// AccountGroupGroupBy is the group-by builder for AccountGroup entities.
type AccountGroupGroupBy struct {
selector
build *AccountGroupQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *AccountGroupGroupBy) Aggregate(fns ...AggregateFunc) *AccountGroupGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *AccountGroupGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*AccountGroupQuery, *AccountGroupGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *AccountGroupGroupBy) sqlScan(ctx context.Context, root *AccountGroupQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// AccountGroupSelect is the builder for selecting fields of AccountGroup entities.
type AccountGroupSelect struct {
*AccountGroupQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *AccountGroupSelect) Aggregate(fns ...AggregateFunc) *AccountGroupSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *AccountGroupSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*AccountGroupQuery, *AccountGroupSelect](ctx, _s.AccountGroupQuery, _s, _s.inters, v)
}
func (_s *AccountGroupSelect) sqlScan(ctx context.Context, root *AccountGroupQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment