Commit 112a2d08 authored by ianshaw's avatar ianshaw
Browse files

chore: 更新依赖、配置和代码生成

主要更新:
- 更新 go.mod/go.sum 依赖
- 重新生成 Ent ORM 代码
- 更新 Wire 依赖注入配置
- 添加 docker-compose.override.yml 到 .gitignore
- 更新 README 文档(Simple Mode 说明和已知问题)
- 清理调试日志
- 其他代码优化和格式修复
parent b1702de5
...@@ -48,6 +48,7 @@ pnpm-debug.log* ...@@ -48,6 +48,7 @@ pnpm-debug.log*
.env.*.local .env.*.local
*.env *.env
!.env.example !.env.example
docker-compose.override.yml
# =================== # ===================
# IDE / 编辑器 # IDE / 编辑器
...@@ -78,8 +79,6 @@ temp/ ...@@ -78,8 +79,6 @@ temp/
*.log *.log
*.bak *.bak
.cache/ .cache/
.gemini-clipboard/
migrations/
# =================== # ===================
# 构建产物 # 构建产物
...@@ -121,3 +120,4 @@ code-reviews/ ...@@ -121,3 +120,4 @@ code-reviews/
AGENTS.md AGENTS.md
backend/cmd/server/server backend/cmd/server/server
deploy/docker-compose.override.yml deploy/docker-compose.override.yml
.gocache/
...@@ -297,6 +297,16 @@ go generate ./cmd/server ...@@ -297,6 +297,16 @@ go generate ./cmd/server
--- ---
## Simple Mode
Simple Mode is designed for individual developers or internal teams who want quick access without full SaaS features.
- Enable: Set environment variable `RUN_MODE=simple`
- Difference: Hides SaaS-related features and skips billing process
- Security note: In production, you must also set `SIMPLE_MODE_CONFIRM=true` to allow startup
---
## Antigravity Support ## Antigravity Support
Sub2API supports [Antigravity](https://antigravity.so/) accounts. After authorization, dedicated endpoints are available for Claude and Gemini models. Sub2API supports [Antigravity](https://antigravity.so/) accounts. After authorization, dedicated endpoints are available for Claude and Gemini models.
...@@ -321,6 +331,12 @@ Antigravity accounts support optional **hybrid scheduling**. When enabled, the g ...@@ -321,6 +331,12 @@ Antigravity accounts support optional **hybrid scheduling**. When enabled, the g
> **⚠️ Warning**: Anthropic Claude and Antigravity Claude **cannot be mixed within the same conversation context**. Use groups to isolate them properly. > **⚠️ Warning**: Anthropic Claude and Antigravity Claude **cannot be mixed within the same conversation context**. Use groups to isolate them properly.
### Known Issues
In Claude Code, Plan Mode cannot exit automatically. (Normally when using the native Claude API, after planning is complete, Claude Code will pop up options for users to approve or reject the plan.)
**Workaround**: Press `Shift + Tab` to manually exit Plan Mode, then type your response to approve or reject the plan.
--- ---
## Project Structure ## Project Structure
......
...@@ -331,6 +331,10 @@ Antigravity 账户支持可选的**混合调度**功能。开启后,通用端 ...@@ -331,6 +331,10 @@ Antigravity 账户支持可选的**混合调度**功能。开启后,通用端
> **⚠️ 注意**:Anthropic Claude 和 Antigravity Claude **不能在同一上下文中混合使用**,请通过分组功能做好隔离。 > **⚠️ 注意**:Anthropic Claude 和 Antigravity Claude **不能在同一上下文中混合使用**,请通过分组功能做好隔离。
### 已知问题
在 Claude Code 中,无法自动退出Plan Mode。(正常使用原生Claude Api时,Plan 完成后,Claude Code会弹出弹出选项让用户同意或拒绝Plan。)
解决办法:shift + Tab,手动退出Plan mode,然后输入内容 告诉 Claude Code 同意或拒绝 Plan
--- ---
## 项目结构 ## 项目结构
......
...@@ -70,13 +70,7 @@ func provideCleanup( ...@@ -70,13 +70,7 @@ func provideCleanup(
openaiOAuth *service.OpenAIOAuthService, openaiOAuth *service.OpenAIOAuthService,
geminiOAuth *service.GeminiOAuthService, geminiOAuth *service.GeminiOAuthService,
antigravityOAuth *service.AntigravityOAuthService, antigravityOAuth *service.AntigravityOAuthService,
antigravityQuota *service.AntigravityQuotaRefresher,
opsMetricsCollector *service.OpsMetricsCollector,
opsAlertService *service.OpsAlertService,
) func() { ) func() {
if opsAlertService != nil {
opsAlertService.Start()
}
return func() { return func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
...@@ -86,14 +80,6 @@ func provideCleanup( ...@@ -86,14 +80,6 @@ func provideCleanup(
name string name string
fn func() error fn func() error
}{ }{
{"OpsMetricsCollector", func() error {
opsMetricsCollector.Stop()
return nil
}},
{"OpsAlertService", func() error {
opsAlertService.Stop()
return nil
}},
{"TokenRefreshService", func() error { {"TokenRefreshService", func() error {
tokenRefresh.Stop() tokenRefresh.Stop()
return nil return nil
...@@ -126,10 +112,6 @@ func provideCleanup( ...@@ -126,10 +112,6 @@ func provideCleanup(
antigravityOAuth.Stop() antigravityOAuth.Stop()
return nil return nil
}}, }},
{"AntigravityQuotaRefresher", func() error {
antigravityQuota.Stop()
return nil
}},
{"Redis", func() error { {"Redis", func() error {
return rdb.Close() return rdb.Close()
}}, }},
......
...@@ -55,11 +55,11 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -55,11 +55,11 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
userService := service.NewUserService(userRepository) userService := service.NewUserService(userRepository)
authHandler := handler.NewAuthHandler(configConfig, authService, userService) authHandler := handler.NewAuthHandler(configConfig, authService, userService)
userHandler := handler.NewUserHandler(userService) userHandler := handler.NewUserHandler(userService)
apiKeyRepository := repository.NewAPIKeyRepository(client) apiKeyRepository := repository.NewApiKeyRepository(client)
groupRepository := repository.NewGroupRepository(client, db) groupRepository := repository.NewGroupRepository(client, db)
userSubscriptionRepository := repository.NewUserSubscriptionRepository(client) userSubscriptionRepository := repository.NewUserSubscriptionRepository(client)
apiKeyCache := repository.NewAPIKeyCache(redisClient) apiKeyCache := repository.NewApiKeyCache(redisClient)
apiKeyService := service.NewAPIKeyService(apiKeyRepository, userRepository, groupRepository, userSubscriptionRepository, apiKeyCache, configConfig) apiKeyService := service.NewApiKeyService(apiKeyRepository, userRepository, groupRepository, userSubscriptionRepository, apiKeyCache, configConfig)
apiKeyHandler := handler.NewAPIKeyHandler(apiKeyService) apiKeyHandler := handler.NewAPIKeyHandler(apiKeyService)
usageLogRepository := repository.NewUsageLogRepository(client, db) usageLogRepository := repository.NewUsageLogRepository(client, db)
usageService := service.NewUsageService(usageLogRepository, userRepository) usageService := service.NewUsageService(usageLogRepository, userRepository)
...@@ -74,9 +74,6 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -74,9 +74,6 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
subscriptionHandler := handler.NewSubscriptionHandler(subscriptionService) subscriptionHandler := handler.NewSubscriptionHandler(subscriptionService)
dashboardService := service.NewDashboardService(usageLogRepository) dashboardService := service.NewDashboardService(usageLogRepository)
dashboardHandler := admin.NewDashboardHandler(dashboardService) dashboardHandler := admin.NewDashboardHandler(dashboardService)
opsRepository := repository.NewOpsRepository(client, db, redisClient)
opsService := service.NewOpsService(opsRepository, db)
opsHandler := admin.NewOpsHandler(opsService)
accountRepository := repository.NewAccountRepository(client, db) accountRepository := repository.NewAccountRepository(client, db)
proxyRepository := repository.NewProxyRepository(client, db) proxyRepository := repository.NewProxyRepository(client, db)
proxyExitInfoProber := repository.NewProxyExitInfoProber() proxyExitInfoProber := repository.NewProxyExitInfoProber()
...@@ -91,16 +88,19 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -91,16 +88,19 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
geminiCliCodeAssistClient := repository.NewGeminiCliCodeAssistClient() geminiCliCodeAssistClient := repository.NewGeminiCliCodeAssistClient()
geminiOAuthService := service.NewGeminiOAuthService(proxyRepository, geminiOAuthClient, geminiCliCodeAssistClient, configConfig) geminiOAuthService := service.NewGeminiOAuthService(proxyRepository, geminiOAuthClient, geminiCliCodeAssistClient, configConfig)
geminiQuotaService := service.NewGeminiQuotaService(configConfig, settingRepository) geminiQuotaService := service.NewGeminiQuotaService(configConfig, settingRepository)
rateLimitService := service.NewRateLimitService(accountRepository, usageLogRepository, configConfig, geminiQuotaService) tempUnschedCache := repository.NewTempUnschedCache(redisClient)
rateLimitService := service.NewRateLimitService(accountRepository, usageLogRepository, configConfig, geminiQuotaService, tempUnschedCache)
claudeUsageFetcher := repository.NewClaudeUsageFetcher() claudeUsageFetcher := repository.NewClaudeUsageFetcher()
accountUsageService := service.NewAccountUsageService(accountRepository, usageLogRepository, claudeUsageFetcher, geminiQuotaService) antigravityQuotaFetcher := service.NewAntigravityQuotaFetcher(proxyRepository)
usageCache := service.NewUsageCache()
accountUsageService := service.NewAccountUsageService(accountRepository, usageLogRepository, claudeUsageFetcher, geminiQuotaService, antigravityQuotaFetcher, usageCache)
geminiTokenCache := repository.NewGeminiTokenCache(redisClient) geminiTokenCache := repository.NewGeminiTokenCache(redisClient)
geminiTokenProvider := service.NewGeminiTokenProvider(accountRepository, geminiTokenCache, geminiOAuthService) geminiTokenProvider := service.NewGeminiTokenProvider(accountRepository, geminiTokenCache, geminiOAuthService)
gatewayCache := repository.NewGatewayCache(redisClient) gatewayCache := repository.NewGatewayCache(redisClient)
antigravityOAuthService := service.NewAntigravityOAuthService(proxyRepository) antigravityOAuthService := service.NewAntigravityOAuthService(proxyRepository)
antigravityTokenProvider := service.NewAntigravityTokenProvider(accountRepository, geminiTokenCache, antigravityOAuthService) antigravityTokenProvider := service.NewAntigravityTokenProvider(accountRepository, geminiTokenCache, antigravityOAuthService)
httpUpstream := repository.NewHTTPUpstream(configConfig) httpUpstream := repository.NewHTTPUpstream(configConfig)
antigravityGatewayService := service.NewAntigravityGatewayService(accountRepository, gatewayCache, antigravityTokenProvider, rateLimitService, httpUpstream) antigravityGatewayService := service.NewAntigravityGatewayService(accountRepository, gatewayCache, antigravityTokenProvider, rateLimitService, httpUpstream, settingService)
accountTestService := service.NewAccountTestService(accountRepository, oAuthService, openAIOAuthService, geminiTokenProvider, antigravityGatewayService, httpUpstream) accountTestService := service.NewAccountTestService(accountRepository, oAuthService, openAIOAuthService, geminiTokenProvider, antigravityGatewayService, httpUpstream)
concurrencyCache := repository.ProvideConcurrencyCache(redisClient, configConfig) concurrencyCache := repository.ProvideConcurrencyCache(redisClient, configConfig)
concurrencyService := service.ProvideConcurrencyService(concurrencyCache, accountRepository, configConfig) concurrencyService := service.ProvideConcurrencyService(concurrencyCache, accountRepository, configConfig)
...@@ -124,24 +124,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -124,24 +124,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
userAttributeValueRepository := repository.NewUserAttributeValueRepository(client) userAttributeValueRepository := repository.NewUserAttributeValueRepository(client)
userAttributeService := service.NewUserAttributeService(userAttributeDefinitionRepository, userAttributeValueRepository) userAttributeService := service.NewUserAttributeService(userAttributeDefinitionRepository, userAttributeValueRepository)
userAttributeHandler := admin.NewUserAttributeHandler(userAttributeService) userAttributeHandler := admin.NewUserAttributeHandler(userAttributeService)
adminHandlers := handler.ProvideAdminHandlers( adminHandlers := handler.ProvideAdminHandlers(dashboardHandler, adminUserHandler, groupHandler, accountHandler, oAuthHandler, openAIOAuthHandler, geminiOAuthHandler, antigravityOAuthHandler, proxyHandler, adminRedeemHandler, settingHandler, systemHandler, adminSubscriptionHandler, adminUsageHandler, userAttributeHandler)
dashboardHandler,
opsHandler,
adminUserHandler,
groupHandler,
accountHandler,
oAuthHandler,
openAIOAuthHandler,
geminiOAuthHandler,
antigravityOAuthHandler,
proxyHandler,
adminRedeemHandler,
settingHandler,
systemHandler,
adminSubscriptionHandler,
adminUsageHandler,
userAttributeHandler,
)
pricingRemoteClient := repository.NewPricingRemoteClient() pricingRemoteClient := repository.NewPricingRemoteClient()
pricingService, err := service.ProvidePricingService(configConfig, pricingRemoteClient) pricingService, err := service.ProvidePricingService(configConfig, pricingRemoteClient)
if err != nil { if err != nil {
...@@ -154,21 +137,18 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) { ...@@ -154,21 +137,18 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
deferredService := service.ProvideDeferredService(accountRepository, timingWheelService) deferredService := service.ProvideDeferredService(accountRepository, timingWheelService)
gatewayService := service.NewGatewayService(accountRepository, groupRepository, usageLogRepository, userRepository, userSubscriptionRepository, gatewayCache, configConfig, concurrencyService, billingService, rateLimitService, billingCacheService, identityService, httpUpstream, deferredService) gatewayService := service.NewGatewayService(accountRepository, groupRepository, usageLogRepository, userRepository, userSubscriptionRepository, gatewayCache, configConfig, concurrencyService, billingService, rateLimitService, billingCacheService, identityService, httpUpstream, deferredService)
geminiMessagesCompatService := service.NewGeminiMessagesCompatService(accountRepository, groupRepository, gatewayCache, geminiTokenProvider, rateLimitService, httpUpstream, antigravityGatewayService) geminiMessagesCompatService := service.NewGeminiMessagesCompatService(accountRepository, groupRepository, gatewayCache, geminiTokenProvider, rateLimitService, httpUpstream, antigravityGatewayService)
gatewayHandler := handler.NewGatewayHandler(gatewayService, geminiMessagesCompatService, antigravityGatewayService, userService, concurrencyService, billingCacheService, opsService) gatewayHandler := handler.NewGatewayHandler(gatewayService, geminiMessagesCompatService, antigravityGatewayService, userService, concurrencyService, billingCacheService)
openAIGatewayService := service.NewOpenAIGatewayService(accountRepository, usageLogRepository, userRepository, userSubscriptionRepository, gatewayCache, configConfig, concurrencyService, billingService, rateLimitService, billingCacheService, httpUpstream, deferredService) openAIGatewayService := service.NewOpenAIGatewayService(accountRepository, usageLogRepository, userRepository, userSubscriptionRepository, gatewayCache, configConfig, concurrencyService, billingService, rateLimitService, billingCacheService, httpUpstream, deferredService)
openAIGatewayHandler := handler.NewOpenAIGatewayHandler(openAIGatewayService, concurrencyService, billingCacheService, opsService) openAIGatewayHandler := handler.NewOpenAIGatewayHandler(openAIGatewayService, concurrencyService, billingCacheService)
handlerSettingHandler := handler.ProvideSettingHandler(settingService, buildInfo) handlerSettingHandler := handler.ProvideSettingHandler(settingService, buildInfo)
handlers := handler.ProvideHandlers(authHandler, userHandler, apiKeyHandler, usageHandler, redeemHandler, subscriptionHandler, adminHandlers, gatewayHandler, openAIGatewayHandler, handlerSettingHandler) handlers := handler.ProvideHandlers(authHandler, userHandler, apiKeyHandler, usageHandler, redeemHandler, subscriptionHandler, adminHandlers, gatewayHandler, openAIGatewayHandler, handlerSettingHandler)
jwtAuthMiddleware := middleware.NewJWTAuthMiddleware(authService, userService) jwtAuthMiddleware := middleware.NewJWTAuthMiddleware(authService, userService)
adminAuthMiddleware := middleware.NewAdminAuthMiddleware(authService, userService, settingService) adminAuthMiddleware := middleware.NewAdminAuthMiddleware(authService, userService, settingService)
apiKeyAuthMiddleware := middleware.NewAPIKeyAuthMiddleware(apiKeyService, subscriptionService, configConfig, opsService) apiKeyAuthMiddleware := middleware.NewApiKeyAuthMiddleware(apiKeyService, subscriptionService, configConfig)
engine := server.ProvideRouter(configConfig, handlers, jwtAuthMiddleware, adminAuthMiddleware, apiKeyAuthMiddleware, apiKeyService, subscriptionService) engine := server.ProvideRouter(configConfig, handlers, jwtAuthMiddleware, adminAuthMiddleware, apiKeyAuthMiddleware, apiKeyService, subscriptionService)
httpServer := server.ProvideHTTPServer(configConfig, engine) httpServer := server.ProvideHTTPServer(configConfig, engine)
tokenRefreshService := service.ProvideTokenRefreshService(accountRepository, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService, configConfig) tokenRefreshService := service.ProvideTokenRefreshService(accountRepository, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService, configConfig)
antigravityQuotaRefresher := service.ProvideAntigravityQuotaRefresher(accountRepository, proxyRepository, antigravityOAuthService, configConfig) v := provideCleanup(client, redisClient, tokenRefreshService, pricingService, emailQueueService, billingCacheService, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService)
opsAlertService := service.ProvideOpsAlertService(opsService, userService, emailService)
opsMetricsCollector := service.ProvideOpsMetricsCollector(opsService, concurrencyService)
v := provideCleanup(client, redisClient, tokenRefreshService, pricingService, emailQueueService, billingCacheService, oAuthService, openAIOAuthService, geminiOAuthService, antigravityOAuthService, antigravityQuotaRefresher, opsMetricsCollector, opsAlertService)
application := &Application{ application := &Application{
Server: httpServer, Server: httpServer,
Cleanup: v, Cleanup: v,
...@@ -201,13 +181,7 @@ func provideCleanup( ...@@ -201,13 +181,7 @@ func provideCleanup(
openaiOAuth *service.OpenAIOAuthService, openaiOAuth *service.OpenAIOAuthService,
geminiOAuth *service.GeminiOAuthService, geminiOAuth *service.GeminiOAuthService,
antigravityOAuth *service.AntigravityOAuthService, antigravityOAuth *service.AntigravityOAuthService,
antigravityQuota *service.AntigravityQuotaRefresher,
opsMetricsCollector *service.OpsMetricsCollector,
opsAlertService *service.OpsAlertService,
) func() { ) func() {
if opsAlertService != nil {
opsAlertService.Start()
}
return func() { return func() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel() defer cancel()
...@@ -216,14 +190,6 @@ func provideCleanup( ...@@ -216,14 +190,6 @@ func provideCleanup(
name string name string
fn func() error fn func() error
}{ }{
{"OpsMetricsCollector", func() error {
opsMetricsCollector.Stop()
return nil
}},
{"OpsAlertService", func() error {
opsAlertService.Stop()
return nil
}},
{"TokenRefreshService", func() error { {"TokenRefreshService", func() error {
tokenRefresh.Stop() tokenRefresh.Stop()
return nil return nil
...@@ -256,10 +222,6 @@ func provideCleanup( ...@@ -256,10 +222,6 @@ func provideCleanup(
antigravityOAuth.Stop() antigravityOAuth.Stop()
return nil return nil
}}, }},
{"AntigravityQuotaRefresher", func() error {
antigravityQuota.Stop()
return nil
}},
{"Redis", func() error { {"Redis", func() error {
return rdb.Close() return rdb.Close()
}}, }},
......
...@@ -14,8 +14,8 @@ import ( ...@@ -14,8 +14,8 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user" "github.com/Wei-Shaw/sub2api/ent/user"
) )
// APIKey is the model entity for the APIKey schema. // ApiKey is the model entity for the ApiKey schema.
type APIKey struct { type ApiKey struct {
config `json:"-"` config `json:"-"`
// ID of the ent. // ID of the ent.
ID int64 `json:"id,omitempty"` ID int64 `json:"id,omitempty"`
...@@ -36,13 +36,13 @@ type APIKey struct { ...@@ -36,13 +36,13 @@ type APIKey struct {
// Status holds the value of the "status" field. // Status holds the value of the "status" field.
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
// Edges holds the relations/edges for other nodes in the graph. // Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the APIKeyQuery when eager-loading is set. // The values are being populated by the ApiKeyQuery when eager-loading is set.
Edges APIKeyEdges `json:"edges"` Edges ApiKeyEdges `json:"edges"`
selectValues sql.SelectValues selectValues sql.SelectValues
} }
// APIKeyEdges holds the relations/edges for other nodes in the graph. // ApiKeyEdges holds the relations/edges for other nodes in the graph.
type APIKeyEdges struct { type ApiKeyEdges struct {
// User holds the value of the user edge. // User holds the value of the user edge.
User *User `json:"user,omitempty"` User *User `json:"user,omitempty"`
// Group holds the value of the group edge. // Group holds the value of the group edge.
...@@ -56,7 +56,7 @@ type APIKeyEdges struct { ...@@ -56,7 +56,7 @@ type APIKeyEdges struct {
// UserOrErr returns the User value or an error if the edge // UserOrErr returns the User value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e APIKeyEdges) UserOrErr() (*User, error) { func (e ApiKeyEdges) UserOrErr() (*User, error) {
if e.User != nil { if e.User != nil {
return e.User, nil return e.User, nil
} else if e.loadedTypes[0] { } else if e.loadedTypes[0] {
...@@ -67,7 +67,7 @@ func (e APIKeyEdges) UserOrErr() (*User, error) { ...@@ -67,7 +67,7 @@ func (e APIKeyEdges) UserOrErr() (*User, error) {
// GroupOrErr returns the Group value or an error if the edge // GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e APIKeyEdges) GroupOrErr() (*Group, error) { func (e ApiKeyEdges) GroupOrErr() (*Group, error) {
if e.Group != nil { if e.Group != nil {
return e.Group, nil return e.Group, nil
} else if e.loadedTypes[1] { } else if e.loadedTypes[1] {
...@@ -78,7 +78,7 @@ func (e APIKeyEdges) GroupOrErr() (*Group, error) { ...@@ -78,7 +78,7 @@ func (e APIKeyEdges) GroupOrErr() (*Group, error) {
// UsageLogsOrErr returns the UsageLogs value or an error if the edge // UsageLogsOrErr returns the UsageLogs value or an error if the edge
// was not loaded in eager-loading. // was not loaded in eager-loading.
func (e APIKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) { func (e ApiKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) {
if e.loadedTypes[2] { if e.loadedTypes[2] {
return e.UsageLogs, nil return e.UsageLogs, nil
} }
...@@ -86,7 +86,7 @@ func (e APIKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) { ...@@ -86,7 +86,7 @@ func (e APIKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) {
} }
// scanValues returns the types for scanning values from sql.Rows. // scanValues returns the types for scanning values from sql.Rows.
func (*APIKey) scanValues(columns []string) ([]any, error) { func (*ApiKey) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns)) values := make([]any, len(columns))
for i := range columns { for i := range columns {
switch columns[i] { switch columns[i] {
...@@ -104,8 +104,8 @@ func (*APIKey) scanValues(columns []string) ([]any, error) { ...@@ -104,8 +104,8 @@ func (*APIKey) scanValues(columns []string) ([]any, error) {
} }
// assignValues assigns the values that were returned from sql.Rows (after scanning) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the APIKey fields. // to the ApiKey fields.
func (_m *APIKey) assignValues(columns []string, values []any) error { func (_m *ApiKey) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
} }
...@@ -174,49 +174,49 @@ func (_m *APIKey) assignValues(columns []string, values []any) error { ...@@ -174,49 +174,49 @@ func (_m *APIKey) assignValues(columns []string, values []any) error {
return nil return nil
} }
// Value returns the ent.Value that was dynamically selected and assigned to the APIKey. // Value returns the ent.Value that was dynamically selected and assigned to the ApiKey.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (_m *APIKey) Value(name string) (ent.Value, error) { func (_m *ApiKey) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryUser queries the "user" edge of the APIKey entity. // QueryUser queries the "user" edge of the ApiKey entity.
func (_m *APIKey) QueryUser() *UserQuery { func (_m *ApiKey) QueryUser() *UserQuery {
return NewAPIKeyClient(_m.config).QueryUser(_m) return NewApiKeyClient(_m.config).QueryUser(_m)
} }
// QueryGroup queries the "group" edge of the APIKey entity. // QueryGroup queries the "group" edge of the ApiKey entity.
func (_m *APIKey) QueryGroup() *GroupQuery { func (_m *ApiKey) QueryGroup() *GroupQuery {
return NewAPIKeyClient(_m.config).QueryGroup(_m) return NewApiKeyClient(_m.config).QueryGroup(_m)
} }
// QueryUsageLogs queries the "usage_logs" edge of the APIKey entity. // QueryUsageLogs queries the "usage_logs" edge of the ApiKey entity.
func (_m *APIKey) QueryUsageLogs() *UsageLogQuery { func (_m *ApiKey) QueryUsageLogs() *UsageLogQuery {
return NewAPIKeyClient(_m.config).QueryUsageLogs(_m) return NewApiKeyClient(_m.config).QueryUsageLogs(_m)
} }
// Update returns a builder for updating this APIKey. // Update returns a builder for updating this ApiKey.
// Note that you need to call APIKey.Unwrap() before calling this method if this APIKey // Note that you need to call ApiKey.Unwrap() before calling this method if this ApiKey
// was returned from a transaction, and the transaction was committed or rolled back. // was returned from a transaction, and the transaction was committed or rolled back.
func (_m *APIKey) Update() *APIKeyUpdateOne { func (_m *ApiKey) Update() *ApiKeyUpdateOne {
return NewAPIKeyClient(_m.config).UpdateOne(_m) return NewApiKeyClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the APIKey entity that was returned from a transaction after it was closed, // Unwrap unwraps the ApiKey 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. // so that all future queries will be executed through the driver which created the transaction.
func (_m *APIKey) Unwrap() *APIKey { func (_m *ApiKey) Unwrap() *ApiKey {
_tx, ok := _m.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: APIKey is not a transactional entity") panic("ent: ApiKey is not a transactional entity")
} }
_m.config.driver = _tx.drv _m.config.driver = _tx.drv
return _m return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (_m *APIKey) String() string { func (_m *ApiKey) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("APIKey(") builder.WriteString("ApiKey(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=") builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
...@@ -249,5 +249,5 @@ func (_m *APIKey) String() string { ...@@ -249,5 +249,5 @@ func (_m *APIKey) String() string {
return builder.String() return builder.String()
} }
// APIKeys is a parsable slice of APIKey. // ApiKeys is a parsable slice of ApiKey.
type APIKeys []*APIKey type ApiKeys []*ApiKey
...@@ -109,7 +109,7 @@ var ( ...@@ -109,7 +109,7 @@ var (
StatusValidator func(string) error StatusValidator func(string) error
) )
// OrderOption defines the ordering options for the APIKey queries. // OrderOption defines the ordering options for the ApiKey queries.
type OrderOption func(*sql.Selector) type OrderOption func(*sql.Selector)
// ByID orders the results by the id field. // ByID orders the results by the id field.
......
...@@ -11,468 +11,468 @@ import ( ...@@ -11,468 +11,468 @@ import (
) )
// ID filters vertices based on their ID field. // ID filters vertices based on their ID field.
func ID(id int64) predicate.APIKey { func ID(id int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldID, id)) return predicate.ApiKey(sql.FieldEQ(FieldID, id))
} }
// IDEQ applies the EQ predicate on the ID field. // IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.APIKey { func IDEQ(id int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldID, id)) return predicate.ApiKey(sql.FieldEQ(FieldID, id))
} }
// IDNEQ applies the NEQ predicate on the ID field. // IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.APIKey { func IDNEQ(id int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldID, id)) return predicate.ApiKey(sql.FieldNEQ(FieldID, id))
} }
// IDIn applies the In predicate on the ID field. // IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.APIKey { func IDIn(ids ...int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldID, ids...)) return predicate.ApiKey(sql.FieldIn(FieldID, ids...))
} }
// IDNotIn applies the NotIn predicate on the ID field. // IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.APIKey { func IDNotIn(ids ...int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldID, ids...)) return predicate.ApiKey(sql.FieldNotIn(FieldID, ids...))
} }
// IDGT applies the GT predicate on the ID field. // IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.APIKey { func IDGT(id int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldGT(FieldID, id)) return predicate.ApiKey(sql.FieldGT(FieldID, id))
} }
// IDGTE applies the GTE predicate on the ID field. // IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.APIKey { func IDGTE(id int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldGTE(FieldID, id)) return predicate.ApiKey(sql.FieldGTE(FieldID, id))
} }
// IDLT applies the LT predicate on the ID field. // IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.APIKey { func IDLT(id int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldLT(FieldID, id)) return predicate.ApiKey(sql.FieldLT(FieldID, id))
} }
// IDLTE applies the LTE predicate on the ID field. // IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.APIKey { func IDLTE(id int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldLTE(FieldID, id)) return predicate.ApiKey(sql.FieldLTE(FieldID, id))
} }
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ. // CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.APIKey { func CreatedAt(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldCreatedAt, v)) return predicate.ApiKey(sql.FieldEQ(FieldCreatedAt, v))
} }
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ. // UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.APIKey { func UpdatedAt(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldUpdatedAt, v)) return predicate.ApiKey(sql.FieldEQ(FieldUpdatedAt, v))
} }
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ. // DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
func DeletedAt(v time.Time) predicate.APIKey { func DeletedAt(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldDeletedAt, v)) return predicate.ApiKey(sql.FieldEQ(FieldDeletedAt, v))
} }
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. // UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v int64) predicate.APIKey { func UserID(v int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldUserID, v)) return predicate.ApiKey(sql.FieldEQ(FieldUserID, v))
} }
// Key applies equality check predicate on the "key" field. It's identical to KeyEQ. // Key applies equality check predicate on the "key" field. It's identical to KeyEQ.
func Key(v string) predicate.APIKey { func Key(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldKey, v)) return predicate.ApiKey(sql.FieldEQ(FieldKey, v))
} }
// Name applies equality check predicate on the "name" field. It's identical to NameEQ. // Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func Name(v string) predicate.APIKey { func Name(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldName, v)) return predicate.ApiKey(sql.FieldEQ(FieldName, v))
} }
// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ. // GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ.
func GroupID(v int64) predicate.APIKey { func GroupID(v int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldGroupID, v)) return predicate.ApiKey(sql.FieldEQ(FieldGroupID, v))
} }
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. // Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func Status(v string) predicate.APIKey { func Status(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldStatus, v)) return predicate.ApiKey(sql.FieldEQ(FieldStatus, v))
} }
// CreatedAtEQ applies the EQ predicate on the "created_at" field. // CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.APIKey { func CreatedAtEQ(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldCreatedAt, v)) return predicate.ApiKey(sql.FieldEQ(FieldCreatedAt, v))
} }
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field. // CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.APIKey { func CreatedAtNEQ(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldCreatedAt, v)) return predicate.ApiKey(sql.FieldNEQ(FieldCreatedAt, v))
} }
// CreatedAtIn applies the In predicate on the "created_at" field. // CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.APIKey { func CreatedAtIn(vs ...time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldCreatedAt, vs...)) return predicate.ApiKey(sql.FieldIn(FieldCreatedAt, vs...))
} }
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field. // CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.APIKey { func CreatedAtNotIn(vs ...time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldCreatedAt, vs...)) return predicate.ApiKey(sql.FieldNotIn(FieldCreatedAt, vs...))
} }
// CreatedAtGT applies the GT predicate on the "created_at" field. // CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.APIKey { func CreatedAtGT(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldGT(FieldCreatedAt, v)) return predicate.ApiKey(sql.FieldGT(FieldCreatedAt, v))
} }
// CreatedAtGTE applies the GTE predicate on the "created_at" field. // CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.APIKey { func CreatedAtGTE(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldGTE(FieldCreatedAt, v)) return predicate.ApiKey(sql.FieldGTE(FieldCreatedAt, v))
} }
// CreatedAtLT applies the LT predicate on the "created_at" field. // CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.APIKey { func CreatedAtLT(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldLT(FieldCreatedAt, v)) return predicate.ApiKey(sql.FieldLT(FieldCreatedAt, v))
} }
// CreatedAtLTE applies the LTE predicate on the "created_at" field. // CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.APIKey { func CreatedAtLTE(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldLTE(FieldCreatedAt, v)) return predicate.ApiKey(sql.FieldLTE(FieldCreatedAt, v))
} }
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field. // UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.APIKey { func UpdatedAtEQ(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldUpdatedAt, v)) return predicate.ApiKey(sql.FieldEQ(FieldUpdatedAt, v))
} }
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field. // UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.APIKey { func UpdatedAtNEQ(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldUpdatedAt, v)) return predicate.ApiKey(sql.FieldNEQ(FieldUpdatedAt, v))
} }
// UpdatedAtIn applies the In predicate on the "updated_at" field. // UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.APIKey { func UpdatedAtIn(vs ...time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldUpdatedAt, vs...)) return predicate.ApiKey(sql.FieldIn(FieldUpdatedAt, vs...))
} }
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field. // UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.APIKey { func UpdatedAtNotIn(vs ...time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldUpdatedAt, vs...)) return predicate.ApiKey(sql.FieldNotIn(FieldUpdatedAt, vs...))
} }
// UpdatedAtGT applies the GT predicate on the "updated_at" field. // UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.APIKey { func UpdatedAtGT(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldGT(FieldUpdatedAt, v)) return predicate.ApiKey(sql.FieldGT(FieldUpdatedAt, v))
} }
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field. // UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.APIKey { func UpdatedAtGTE(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldGTE(FieldUpdatedAt, v)) return predicate.ApiKey(sql.FieldGTE(FieldUpdatedAt, v))
} }
// UpdatedAtLT applies the LT predicate on the "updated_at" field. // UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.APIKey { func UpdatedAtLT(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldLT(FieldUpdatedAt, v)) return predicate.ApiKey(sql.FieldLT(FieldUpdatedAt, v))
} }
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field. // UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.APIKey { func UpdatedAtLTE(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldLTE(FieldUpdatedAt, v)) return predicate.ApiKey(sql.FieldLTE(FieldUpdatedAt, v))
} }
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field. // DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
func DeletedAtEQ(v time.Time) predicate.APIKey { func DeletedAtEQ(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldDeletedAt, v)) return predicate.ApiKey(sql.FieldEQ(FieldDeletedAt, v))
} }
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field. // DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
func DeletedAtNEQ(v time.Time) predicate.APIKey { func DeletedAtNEQ(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldDeletedAt, v)) return predicate.ApiKey(sql.FieldNEQ(FieldDeletedAt, v))
} }
// DeletedAtIn applies the In predicate on the "deleted_at" field. // DeletedAtIn applies the In predicate on the "deleted_at" field.
func DeletedAtIn(vs ...time.Time) predicate.APIKey { func DeletedAtIn(vs ...time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldDeletedAt, vs...)) return predicate.ApiKey(sql.FieldIn(FieldDeletedAt, vs...))
} }
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field. // DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
func DeletedAtNotIn(vs ...time.Time) predicate.APIKey { func DeletedAtNotIn(vs ...time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldDeletedAt, vs...)) return predicate.ApiKey(sql.FieldNotIn(FieldDeletedAt, vs...))
} }
// DeletedAtGT applies the GT predicate on the "deleted_at" field. // DeletedAtGT applies the GT predicate on the "deleted_at" field.
func DeletedAtGT(v time.Time) predicate.APIKey { func DeletedAtGT(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldGT(FieldDeletedAt, v)) return predicate.ApiKey(sql.FieldGT(FieldDeletedAt, v))
} }
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field. // DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
func DeletedAtGTE(v time.Time) predicate.APIKey { func DeletedAtGTE(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldGTE(FieldDeletedAt, v)) return predicate.ApiKey(sql.FieldGTE(FieldDeletedAt, v))
} }
// DeletedAtLT applies the LT predicate on the "deleted_at" field. // DeletedAtLT applies the LT predicate on the "deleted_at" field.
func DeletedAtLT(v time.Time) predicate.APIKey { func DeletedAtLT(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldLT(FieldDeletedAt, v)) return predicate.ApiKey(sql.FieldLT(FieldDeletedAt, v))
} }
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field. // DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
func DeletedAtLTE(v time.Time) predicate.APIKey { func DeletedAtLTE(v time.Time) predicate.ApiKey {
return predicate.APIKey(sql.FieldLTE(FieldDeletedAt, v)) return predicate.ApiKey(sql.FieldLTE(FieldDeletedAt, v))
} }
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field. // DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
func DeletedAtIsNil() predicate.APIKey { func DeletedAtIsNil() predicate.ApiKey {
return predicate.APIKey(sql.FieldIsNull(FieldDeletedAt)) return predicate.ApiKey(sql.FieldIsNull(FieldDeletedAt))
} }
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field. // DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
func DeletedAtNotNil() predicate.APIKey { func DeletedAtNotNil() predicate.ApiKey {
return predicate.APIKey(sql.FieldNotNull(FieldDeletedAt)) return predicate.ApiKey(sql.FieldNotNull(FieldDeletedAt))
} }
// UserIDEQ applies the EQ predicate on the "user_id" field. // UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v int64) predicate.APIKey { func UserIDEQ(v int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldUserID, v)) return predicate.ApiKey(sql.FieldEQ(FieldUserID, v))
} }
// UserIDNEQ applies the NEQ predicate on the "user_id" field. // UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v int64) predicate.APIKey { func UserIDNEQ(v int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldUserID, v)) return predicate.ApiKey(sql.FieldNEQ(FieldUserID, v))
} }
// UserIDIn applies the In predicate on the "user_id" field. // UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...int64) predicate.APIKey { func UserIDIn(vs ...int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldUserID, vs...)) return predicate.ApiKey(sql.FieldIn(FieldUserID, vs...))
} }
// UserIDNotIn applies the NotIn predicate on the "user_id" field. // UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...int64) predicate.APIKey { func UserIDNotIn(vs ...int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldUserID, vs...)) return predicate.ApiKey(sql.FieldNotIn(FieldUserID, vs...))
} }
// KeyEQ applies the EQ predicate on the "key" field. // KeyEQ applies the EQ predicate on the "key" field.
func KeyEQ(v string) predicate.APIKey { func KeyEQ(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldKey, v)) return predicate.ApiKey(sql.FieldEQ(FieldKey, v))
} }
// KeyNEQ applies the NEQ predicate on the "key" field. // KeyNEQ applies the NEQ predicate on the "key" field.
func KeyNEQ(v string) predicate.APIKey { func KeyNEQ(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldKey, v)) return predicate.ApiKey(sql.FieldNEQ(FieldKey, v))
} }
// KeyIn applies the In predicate on the "key" field. // KeyIn applies the In predicate on the "key" field.
func KeyIn(vs ...string) predicate.APIKey { func KeyIn(vs ...string) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldKey, vs...)) return predicate.ApiKey(sql.FieldIn(FieldKey, vs...))
} }
// KeyNotIn applies the NotIn predicate on the "key" field. // KeyNotIn applies the NotIn predicate on the "key" field.
func KeyNotIn(vs ...string) predicate.APIKey { func KeyNotIn(vs ...string) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldKey, vs...)) return predicate.ApiKey(sql.FieldNotIn(FieldKey, vs...))
} }
// KeyGT applies the GT predicate on the "key" field. // KeyGT applies the GT predicate on the "key" field.
func KeyGT(v string) predicate.APIKey { func KeyGT(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldGT(FieldKey, v)) return predicate.ApiKey(sql.FieldGT(FieldKey, v))
} }
// KeyGTE applies the GTE predicate on the "key" field. // KeyGTE applies the GTE predicate on the "key" field.
func KeyGTE(v string) predicate.APIKey { func KeyGTE(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldGTE(FieldKey, v)) return predicate.ApiKey(sql.FieldGTE(FieldKey, v))
} }
// KeyLT applies the LT predicate on the "key" field. // KeyLT applies the LT predicate on the "key" field.
func KeyLT(v string) predicate.APIKey { func KeyLT(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldLT(FieldKey, v)) return predicate.ApiKey(sql.FieldLT(FieldKey, v))
} }
// KeyLTE applies the LTE predicate on the "key" field. // KeyLTE applies the LTE predicate on the "key" field.
func KeyLTE(v string) predicate.APIKey { func KeyLTE(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldLTE(FieldKey, v)) return predicate.ApiKey(sql.FieldLTE(FieldKey, v))
} }
// KeyContains applies the Contains predicate on the "key" field. // KeyContains applies the Contains predicate on the "key" field.
func KeyContains(v string) predicate.APIKey { func KeyContains(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldContains(FieldKey, v)) return predicate.ApiKey(sql.FieldContains(FieldKey, v))
} }
// KeyHasPrefix applies the HasPrefix predicate on the "key" field. // KeyHasPrefix applies the HasPrefix predicate on the "key" field.
func KeyHasPrefix(v string) predicate.APIKey { func KeyHasPrefix(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldHasPrefix(FieldKey, v)) return predicate.ApiKey(sql.FieldHasPrefix(FieldKey, v))
} }
// KeyHasSuffix applies the HasSuffix predicate on the "key" field. // KeyHasSuffix applies the HasSuffix predicate on the "key" field.
func KeyHasSuffix(v string) predicate.APIKey { func KeyHasSuffix(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldHasSuffix(FieldKey, v)) return predicate.ApiKey(sql.FieldHasSuffix(FieldKey, v))
} }
// KeyEqualFold applies the EqualFold predicate on the "key" field. // KeyEqualFold applies the EqualFold predicate on the "key" field.
func KeyEqualFold(v string) predicate.APIKey { func KeyEqualFold(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEqualFold(FieldKey, v)) return predicate.ApiKey(sql.FieldEqualFold(FieldKey, v))
} }
// KeyContainsFold applies the ContainsFold predicate on the "key" field. // KeyContainsFold applies the ContainsFold predicate on the "key" field.
func KeyContainsFold(v string) predicate.APIKey { func KeyContainsFold(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldContainsFold(FieldKey, v)) return predicate.ApiKey(sql.FieldContainsFold(FieldKey, v))
} }
// NameEQ applies the EQ predicate on the "name" field. // NameEQ applies the EQ predicate on the "name" field.
func NameEQ(v string) predicate.APIKey { func NameEQ(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldName, v)) return predicate.ApiKey(sql.FieldEQ(FieldName, v))
} }
// NameNEQ applies the NEQ predicate on the "name" field. // NameNEQ applies the NEQ predicate on the "name" field.
func NameNEQ(v string) predicate.APIKey { func NameNEQ(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldName, v)) return predicate.ApiKey(sql.FieldNEQ(FieldName, v))
} }
// NameIn applies the In predicate on the "name" field. // NameIn applies the In predicate on the "name" field.
func NameIn(vs ...string) predicate.APIKey { func NameIn(vs ...string) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldName, vs...)) return predicate.ApiKey(sql.FieldIn(FieldName, vs...))
} }
// NameNotIn applies the NotIn predicate on the "name" field. // NameNotIn applies the NotIn predicate on the "name" field.
func NameNotIn(vs ...string) predicate.APIKey { func NameNotIn(vs ...string) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldName, vs...)) return predicate.ApiKey(sql.FieldNotIn(FieldName, vs...))
} }
// NameGT applies the GT predicate on the "name" field. // NameGT applies the GT predicate on the "name" field.
func NameGT(v string) predicate.APIKey { func NameGT(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldGT(FieldName, v)) return predicate.ApiKey(sql.FieldGT(FieldName, v))
} }
// NameGTE applies the GTE predicate on the "name" field. // NameGTE applies the GTE predicate on the "name" field.
func NameGTE(v string) predicate.APIKey { func NameGTE(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldGTE(FieldName, v)) return predicate.ApiKey(sql.FieldGTE(FieldName, v))
} }
// NameLT applies the LT predicate on the "name" field. // NameLT applies the LT predicate on the "name" field.
func NameLT(v string) predicate.APIKey { func NameLT(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldLT(FieldName, v)) return predicate.ApiKey(sql.FieldLT(FieldName, v))
} }
// NameLTE applies the LTE predicate on the "name" field. // NameLTE applies the LTE predicate on the "name" field.
func NameLTE(v string) predicate.APIKey { func NameLTE(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldLTE(FieldName, v)) return predicate.ApiKey(sql.FieldLTE(FieldName, v))
} }
// NameContains applies the Contains predicate on the "name" field. // NameContains applies the Contains predicate on the "name" field.
func NameContains(v string) predicate.APIKey { func NameContains(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldContains(FieldName, v)) return predicate.ApiKey(sql.FieldContains(FieldName, v))
} }
// NameHasPrefix applies the HasPrefix predicate on the "name" field. // NameHasPrefix applies the HasPrefix predicate on the "name" field.
func NameHasPrefix(v string) predicate.APIKey { func NameHasPrefix(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldHasPrefix(FieldName, v)) return predicate.ApiKey(sql.FieldHasPrefix(FieldName, v))
} }
// NameHasSuffix applies the HasSuffix predicate on the "name" field. // NameHasSuffix applies the HasSuffix predicate on the "name" field.
func NameHasSuffix(v string) predicate.APIKey { func NameHasSuffix(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldHasSuffix(FieldName, v)) return predicate.ApiKey(sql.FieldHasSuffix(FieldName, v))
} }
// NameEqualFold applies the EqualFold predicate on the "name" field. // NameEqualFold applies the EqualFold predicate on the "name" field.
func NameEqualFold(v string) predicate.APIKey { func NameEqualFold(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEqualFold(FieldName, v)) return predicate.ApiKey(sql.FieldEqualFold(FieldName, v))
} }
// NameContainsFold applies the ContainsFold predicate on the "name" field. // NameContainsFold applies the ContainsFold predicate on the "name" field.
func NameContainsFold(v string) predicate.APIKey { func NameContainsFold(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldContainsFold(FieldName, v)) return predicate.ApiKey(sql.FieldContainsFold(FieldName, v))
} }
// GroupIDEQ applies the EQ predicate on the "group_id" field. // GroupIDEQ applies the EQ predicate on the "group_id" field.
func GroupIDEQ(v int64) predicate.APIKey { func GroupIDEQ(v int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldGroupID, v)) return predicate.ApiKey(sql.FieldEQ(FieldGroupID, v))
} }
// GroupIDNEQ applies the NEQ predicate on the "group_id" field. // GroupIDNEQ applies the NEQ predicate on the "group_id" field.
func GroupIDNEQ(v int64) predicate.APIKey { func GroupIDNEQ(v int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldGroupID, v)) return predicate.ApiKey(sql.FieldNEQ(FieldGroupID, v))
} }
// GroupIDIn applies the In predicate on the "group_id" field. // GroupIDIn applies the In predicate on the "group_id" field.
func GroupIDIn(vs ...int64) predicate.APIKey { func GroupIDIn(vs ...int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldGroupID, vs...)) return predicate.ApiKey(sql.FieldIn(FieldGroupID, vs...))
} }
// GroupIDNotIn applies the NotIn predicate on the "group_id" field. // GroupIDNotIn applies the NotIn predicate on the "group_id" field.
func GroupIDNotIn(vs ...int64) predicate.APIKey { func GroupIDNotIn(vs ...int64) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldGroupID, vs...)) return predicate.ApiKey(sql.FieldNotIn(FieldGroupID, vs...))
} }
// GroupIDIsNil applies the IsNil predicate on the "group_id" field. // GroupIDIsNil applies the IsNil predicate on the "group_id" field.
func GroupIDIsNil() predicate.APIKey { func GroupIDIsNil() predicate.ApiKey {
return predicate.APIKey(sql.FieldIsNull(FieldGroupID)) return predicate.ApiKey(sql.FieldIsNull(FieldGroupID))
} }
// GroupIDNotNil applies the NotNil predicate on the "group_id" field. // GroupIDNotNil applies the NotNil predicate on the "group_id" field.
func GroupIDNotNil() predicate.APIKey { func GroupIDNotNil() predicate.ApiKey {
return predicate.APIKey(sql.FieldNotNull(FieldGroupID)) return predicate.ApiKey(sql.FieldNotNull(FieldGroupID))
} }
// StatusEQ applies the EQ predicate on the "status" field. // StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v string) predicate.APIKey { func StatusEQ(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEQ(FieldStatus, v)) return predicate.ApiKey(sql.FieldEQ(FieldStatus, v))
} }
// StatusNEQ applies the NEQ predicate on the "status" field. // StatusNEQ applies the NEQ predicate on the "status" field.
func StatusNEQ(v string) predicate.APIKey { func StatusNEQ(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldNEQ(FieldStatus, v)) return predicate.ApiKey(sql.FieldNEQ(FieldStatus, v))
} }
// StatusIn applies the In predicate on the "status" field. // StatusIn applies the In predicate on the "status" field.
func StatusIn(vs ...string) predicate.APIKey { func StatusIn(vs ...string) predicate.ApiKey {
return predicate.APIKey(sql.FieldIn(FieldStatus, vs...)) return predicate.ApiKey(sql.FieldIn(FieldStatus, vs...))
} }
// StatusNotIn applies the NotIn predicate on the "status" field. // StatusNotIn applies the NotIn predicate on the "status" field.
func StatusNotIn(vs ...string) predicate.APIKey { func StatusNotIn(vs ...string) predicate.ApiKey {
return predicate.APIKey(sql.FieldNotIn(FieldStatus, vs...)) return predicate.ApiKey(sql.FieldNotIn(FieldStatus, vs...))
} }
// StatusGT applies the GT predicate on the "status" field. // StatusGT applies the GT predicate on the "status" field.
func StatusGT(v string) predicate.APIKey { func StatusGT(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldGT(FieldStatus, v)) return predicate.ApiKey(sql.FieldGT(FieldStatus, v))
} }
// StatusGTE applies the GTE predicate on the "status" field. // StatusGTE applies the GTE predicate on the "status" field.
func StatusGTE(v string) predicate.APIKey { func StatusGTE(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldGTE(FieldStatus, v)) return predicate.ApiKey(sql.FieldGTE(FieldStatus, v))
} }
// StatusLT applies the LT predicate on the "status" field. // StatusLT applies the LT predicate on the "status" field.
func StatusLT(v string) predicate.APIKey { func StatusLT(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldLT(FieldStatus, v)) return predicate.ApiKey(sql.FieldLT(FieldStatus, v))
} }
// StatusLTE applies the LTE predicate on the "status" field. // StatusLTE applies the LTE predicate on the "status" field.
func StatusLTE(v string) predicate.APIKey { func StatusLTE(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldLTE(FieldStatus, v)) return predicate.ApiKey(sql.FieldLTE(FieldStatus, v))
} }
// StatusContains applies the Contains predicate on the "status" field. // StatusContains applies the Contains predicate on the "status" field.
func StatusContains(v string) predicate.APIKey { func StatusContains(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldContains(FieldStatus, v)) return predicate.ApiKey(sql.FieldContains(FieldStatus, v))
} }
// StatusHasPrefix applies the HasPrefix predicate on the "status" field. // StatusHasPrefix applies the HasPrefix predicate on the "status" field.
func StatusHasPrefix(v string) predicate.APIKey { func StatusHasPrefix(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldHasPrefix(FieldStatus, v)) return predicate.ApiKey(sql.FieldHasPrefix(FieldStatus, v))
} }
// StatusHasSuffix applies the HasSuffix predicate on the "status" field. // StatusHasSuffix applies the HasSuffix predicate on the "status" field.
func StatusHasSuffix(v string) predicate.APIKey { func StatusHasSuffix(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldHasSuffix(FieldStatus, v)) return predicate.ApiKey(sql.FieldHasSuffix(FieldStatus, v))
} }
// StatusEqualFold applies the EqualFold predicate on the "status" field. // StatusEqualFold applies the EqualFold predicate on the "status" field.
func StatusEqualFold(v string) predicate.APIKey { func StatusEqualFold(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldEqualFold(FieldStatus, v)) return predicate.ApiKey(sql.FieldEqualFold(FieldStatus, v))
} }
// StatusContainsFold applies the ContainsFold predicate on the "status" field. // StatusContainsFold applies the ContainsFold predicate on the "status" field.
func StatusContainsFold(v string) predicate.APIKey { func StatusContainsFold(v string) predicate.ApiKey {
return predicate.APIKey(sql.FieldContainsFold(FieldStatus, v)) return predicate.ApiKey(sql.FieldContainsFold(FieldStatus, v))
} }
// HasUser applies the HasEdge predicate on the "user" edge. // HasUser applies the HasEdge predicate on the "user" edge.
func HasUser() predicate.APIKey { func HasUser() predicate.ApiKey {
return predicate.APIKey(func(s *sql.Selector) { return predicate.ApiKey(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn), sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
...@@ -482,8 +482,8 @@ func HasUser() predicate.APIKey { ...@@ -482,8 +482,8 @@ func HasUser() predicate.APIKey {
} }
// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). // HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates).
func HasUserWith(preds ...predicate.User) predicate.APIKey { func HasUserWith(preds ...predicate.User) predicate.ApiKey {
return predicate.APIKey(func(s *sql.Selector) { return predicate.ApiKey(func(s *sql.Selector) {
step := newUserStep() step := newUserStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds { for _, p := range preds {
...@@ -494,8 +494,8 @@ func HasUserWith(preds ...predicate.User) predicate.APIKey { ...@@ -494,8 +494,8 @@ func HasUserWith(preds ...predicate.User) predicate.APIKey {
} }
// HasGroup applies the HasEdge predicate on the "group" edge. // HasGroup applies the HasEdge predicate on the "group" edge.
func HasGroup() predicate.APIKey { func HasGroup() predicate.ApiKey {
return predicate.APIKey(func(s *sql.Selector) { return predicate.ApiKey(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn), sqlgraph.Edge(sqlgraph.M2O, true, GroupTable, GroupColumn),
...@@ -505,8 +505,8 @@ func HasGroup() predicate.APIKey { ...@@ -505,8 +505,8 @@ func HasGroup() predicate.APIKey {
} }
// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates). // HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
func HasGroupWith(preds ...predicate.Group) predicate.APIKey { func HasGroupWith(preds ...predicate.Group) predicate.ApiKey {
return predicate.APIKey(func(s *sql.Selector) { return predicate.ApiKey(func(s *sql.Selector) {
step := newGroupStep() step := newGroupStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds { for _, p := range preds {
...@@ -517,8 +517,8 @@ func HasGroupWith(preds ...predicate.Group) predicate.APIKey { ...@@ -517,8 +517,8 @@ func HasGroupWith(preds ...predicate.Group) predicate.APIKey {
} }
// HasUsageLogs applies the HasEdge predicate on the "usage_logs" edge. // HasUsageLogs applies the HasEdge predicate on the "usage_logs" edge.
func HasUsageLogs() predicate.APIKey { func HasUsageLogs() predicate.ApiKey {
return predicate.APIKey(func(s *sql.Selector) { return predicate.ApiKey(func(s *sql.Selector) {
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID), sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, UsageLogsTable, UsageLogsColumn), sqlgraph.Edge(sqlgraph.O2M, false, UsageLogsTable, UsageLogsColumn),
...@@ -528,8 +528,8 @@ func HasUsageLogs() predicate.APIKey { ...@@ -528,8 +528,8 @@ func HasUsageLogs() predicate.APIKey {
} }
// HasUsageLogsWith applies the HasEdge predicate on the "usage_logs" edge with a given conditions (other predicates). // HasUsageLogsWith applies the HasEdge predicate on the "usage_logs" edge with a given conditions (other predicates).
func HasUsageLogsWith(preds ...predicate.UsageLog) predicate.APIKey { func HasUsageLogsWith(preds ...predicate.UsageLog) predicate.ApiKey {
return predicate.APIKey(func(s *sql.Selector) { return predicate.ApiKey(func(s *sql.Selector) {
step := newUsageLogsStep() step := newUsageLogsStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds { for _, p := range preds {
...@@ -540,16 +540,16 @@ func HasUsageLogsWith(preds ...predicate.UsageLog) predicate.APIKey { ...@@ -540,16 +540,16 @@ func HasUsageLogsWith(preds ...predicate.UsageLog) predicate.APIKey {
} }
// And groups predicates with the AND operator between them. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.APIKey) predicate.APIKey { func And(predicates ...predicate.ApiKey) predicate.ApiKey {
return predicate.APIKey(sql.AndPredicates(predicates...)) return predicate.ApiKey(sql.AndPredicates(predicates...))
} }
// Or groups predicates with the OR operator between them. // Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.APIKey) predicate.APIKey { func Or(predicates ...predicate.ApiKey) predicate.ApiKey {
return predicate.APIKey(sql.OrPredicates(predicates...)) return predicate.ApiKey(sql.OrPredicates(predicates...))
} }
// Not applies the not operator on the given predicate. // Not applies the not operator on the given predicate.
func Not(p predicate.APIKey) predicate.APIKey { func Not(p predicate.ApiKey) predicate.ApiKey {
return predicate.APIKey(sql.NotPredicates(p)) return predicate.ApiKey(sql.NotPredicates(p))
} }
...@@ -17,22 +17,22 @@ import ( ...@@ -17,22 +17,22 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user" "github.com/Wei-Shaw/sub2api/ent/user"
) )
// APIKeyCreate is the builder for creating a APIKey entity. // ApiKeyCreate is the builder for creating a ApiKey entity.
type APIKeyCreate struct { type ApiKeyCreate struct {
config config
mutation *APIKeyMutation mutation *ApiKeyMutation
hooks []Hook hooks []Hook
conflict []sql.ConflictOption conflict []sql.ConflictOption
} }
// SetCreatedAt sets the "created_at" field. // SetCreatedAt sets the "created_at" field.
func (_c *APIKeyCreate) SetCreatedAt(v time.Time) *APIKeyCreate { func (_c *ApiKeyCreate) SetCreatedAt(v time.Time) *ApiKeyCreate {
_c.mutation.SetCreatedAt(v) _c.mutation.SetCreatedAt(v)
return _c return _c
} }
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *APIKeyCreate) SetNillableCreatedAt(v *time.Time) *APIKeyCreate { func (_c *ApiKeyCreate) SetNillableCreatedAt(v *time.Time) *ApiKeyCreate {
if v != nil { if v != nil {
_c.SetCreatedAt(*v) _c.SetCreatedAt(*v)
} }
...@@ -40,13 +40,13 @@ func (_c *APIKeyCreate) SetNillableCreatedAt(v *time.Time) *APIKeyCreate { ...@@ -40,13 +40,13 @@ func (_c *APIKeyCreate) SetNillableCreatedAt(v *time.Time) *APIKeyCreate {
} }
// SetUpdatedAt sets the "updated_at" field. // SetUpdatedAt sets the "updated_at" field.
func (_c *APIKeyCreate) SetUpdatedAt(v time.Time) *APIKeyCreate { func (_c *ApiKeyCreate) SetUpdatedAt(v time.Time) *ApiKeyCreate {
_c.mutation.SetUpdatedAt(v) _c.mutation.SetUpdatedAt(v)
return _c return _c
} }
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *APIKeyCreate) SetNillableUpdatedAt(v *time.Time) *APIKeyCreate { func (_c *ApiKeyCreate) SetNillableUpdatedAt(v *time.Time) *ApiKeyCreate {
if v != nil { if v != nil {
_c.SetUpdatedAt(*v) _c.SetUpdatedAt(*v)
} }
...@@ -54,13 +54,13 @@ func (_c *APIKeyCreate) SetNillableUpdatedAt(v *time.Time) *APIKeyCreate { ...@@ -54,13 +54,13 @@ func (_c *APIKeyCreate) SetNillableUpdatedAt(v *time.Time) *APIKeyCreate {
} }
// SetDeletedAt sets the "deleted_at" field. // SetDeletedAt sets the "deleted_at" field.
func (_c *APIKeyCreate) SetDeletedAt(v time.Time) *APIKeyCreate { func (_c *ApiKeyCreate) SetDeletedAt(v time.Time) *ApiKeyCreate {
_c.mutation.SetDeletedAt(v) _c.mutation.SetDeletedAt(v)
return _c return _c
} }
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_c *APIKeyCreate) SetNillableDeletedAt(v *time.Time) *APIKeyCreate { func (_c *ApiKeyCreate) SetNillableDeletedAt(v *time.Time) *ApiKeyCreate {
if v != nil { if v != nil {
_c.SetDeletedAt(*v) _c.SetDeletedAt(*v)
} }
...@@ -68,31 +68,31 @@ func (_c *APIKeyCreate) SetNillableDeletedAt(v *time.Time) *APIKeyCreate { ...@@ -68,31 +68,31 @@ func (_c *APIKeyCreate) SetNillableDeletedAt(v *time.Time) *APIKeyCreate {
} }
// SetUserID sets the "user_id" field. // SetUserID sets the "user_id" field.
func (_c *APIKeyCreate) SetUserID(v int64) *APIKeyCreate { func (_c *ApiKeyCreate) SetUserID(v int64) *ApiKeyCreate {
_c.mutation.SetUserID(v) _c.mutation.SetUserID(v)
return _c return _c
} }
// SetKey sets the "key" field. // SetKey sets the "key" field.
func (_c *APIKeyCreate) SetKey(v string) *APIKeyCreate { func (_c *ApiKeyCreate) SetKey(v string) *ApiKeyCreate {
_c.mutation.SetKey(v) _c.mutation.SetKey(v)
return _c return _c
} }
// SetName sets the "name" field. // SetName sets the "name" field.
func (_c *APIKeyCreate) SetName(v string) *APIKeyCreate { func (_c *ApiKeyCreate) SetName(v string) *ApiKeyCreate {
_c.mutation.SetName(v) _c.mutation.SetName(v)
return _c return _c
} }
// SetGroupID sets the "group_id" field. // SetGroupID sets the "group_id" field.
func (_c *APIKeyCreate) SetGroupID(v int64) *APIKeyCreate { func (_c *ApiKeyCreate) SetGroupID(v int64) *ApiKeyCreate {
_c.mutation.SetGroupID(v) _c.mutation.SetGroupID(v)
return _c return _c
} }
// SetNillableGroupID sets the "group_id" field if the given value is not nil. // SetNillableGroupID sets the "group_id" field if the given value is not nil.
func (_c *APIKeyCreate) SetNillableGroupID(v *int64) *APIKeyCreate { func (_c *ApiKeyCreate) SetNillableGroupID(v *int64) *ApiKeyCreate {
if v != nil { if v != nil {
_c.SetGroupID(*v) _c.SetGroupID(*v)
} }
...@@ -100,13 +100,13 @@ func (_c *APIKeyCreate) SetNillableGroupID(v *int64) *APIKeyCreate { ...@@ -100,13 +100,13 @@ func (_c *APIKeyCreate) SetNillableGroupID(v *int64) *APIKeyCreate {
} }
// SetStatus sets the "status" field. // SetStatus sets the "status" field.
func (_c *APIKeyCreate) SetStatus(v string) *APIKeyCreate { func (_c *ApiKeyCreate) SetStatus(v string) *ApiKeyCreate {
_c.mutation.SetStatus(v) _c.mutation.SetStatus(v)
return _c return _c
} }
// SetNillableStatus sets the "status" field if the given value is not nil. // SetNillableStatus sets the "status" field if the given value is not nil.
func (_c *APIKeyCreate) SetNillableStatus(v *string) *APIKeyCreate { func (_c *ApiKeyCreate) SetNillableStatus(v *string) *ApiKeyCreate {
if v != nil { if v != nil {
_c.SetStatus(*v) _c.SetStatus(*v)
} }
...@@ -114,23 +114,23 @@ func (_c *APIKeyCreate) SetNillableStatus(v *string) *APIKeyCreate { ...@@ -114,23 +114,23 @@ func (_c *APIKeyCreate) SetNillableStatus(v *string) *APIKeyCreate {
} }
// SetUser sets the "user" edge to the User entity. // SetUser sets the "user" edge to the User entity.
func (_c *APIKeyCreate) SetUser(v *User) *APIKeyCreate { func (_c *ApiKeyCreate) SetUser(v *User) *ApiKeyCreate {
return _c.SetUserID(v.ID) return _c.SetUserID(v.ID)
} }
// SetGroup sets the "group" edge to the Group entity. // SetGroup sets the "group" edge to the Group entity.
func (_c *APIKeyCreate) SetGroup(v *Group) *APIKeyCreate { func (_c *ApiKeyCreate) SetGroup(v *Group) *ApiKeyCreate {
return _c.SetGroupID(v.ID) return _c.SetGroupID(v.ID)
} }
// AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
func (_c *APIKeyCreate) AddUsageLogIDs(ids ...int64) *APIKeyCreate { func (_c *ApiKeyCreate) AddUsageLogIDs(ids ...int64) *ApiKeyCreate {
_c.mutation.AddUsageLogIDs(ids...) _c.mutation.AddUsageLogIDs(ids...)
return _c return _c
} }
// AddUsageLogs adds the "usage_logs" edges to the UsageLog entity. // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
func (_c *APIKeyCreate) AddUsageLogs(v ...*UsageLog) *APIKeyCreate { func (_c *ApiKeyCreate) AddUsageLogs(v ...*UsageLog) *ApiKeyCreate {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
...@@ -138,13 +138,13 @@ func (_c *APIKeyCreate) AddUsageLogs(v ...*UsageLog) *APIKeyCreate { ...@@ -138,13 +138,13 @@ func (_c *APIKeyCreate) AddUsageLogs(v ...*UsageLog) *APIKeyCreate {
return _c.AddUsageLogIDs(ids...) return _c.AddUsageLogIDs(ids...)
} }
// Mutation returns the APIKeyMutation object of the builder. // Mutation returns the ApiKeyMutation object of the builder.
func (_c *APIKeyCreate) Mutation() *APIKeyMutation { func (_c *ApiKeyCreate) Mutation() *ApiKeyMutation {
return _c.mutation return _c.mutation
} }
// Save creates the APIKey in the database. // Save creates the ApiKey in the database.
func (_c *APIKeyCreate) Save(ctx context.Context) (*APIKey, error) { func (_c *ApiKeyCreate) Save(ctx context.Context) (*ApiKey, error) {
if err := _c.defaults(); err != nil { if err := _c.defaults(); err != nil {
return nil, err return nil, err
} }
...@@ -152,7 +152,7 @@ func (_c *APIKeyCreate) Save(ctx context.Context) (*APIKey, error) { ...@@ -152,7 +152,7 @@ func (_c *APIKeyCreate) Save(ctx context.Context) (*APIKey, error) {
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
func (_c *APIKeyCreate) SaveX(ctx context.Context) *APIKey { func (_c *ApiKeyCreate) SaveX(ctx context.Context) *ApiKey {
v, err := _c.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -161,20 +161,20 @@ func (_c *APIKeyCreate) SaveX(ctx context.Context) *APIKey { ...@@ -161,20 +161,20 @@ func (_c *APIKeyCreate) SaveX(ctx context.Context) *APIKey {
} }
// Exec executes the query. // Exec executes the query.
func (_c *APIKeyCreate) Exec(ctx context.Context) error { func (_c *ApiKeyCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (_c *APIKeyCreate) ExecX(ctx context.Context) { func (_c *ApiKeyCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// defaults sets the default values of the builder before save. // defaults sets the default values of the builder before save.
func (_c *APIKeyCreate) defaults() error { func (_c *ApiKeyCreate) defaults() error {
if _, ok := _c.mutation.CreatedAt(); !ok { if _, ok := _c.mutation.CreatedAt(); !ok {
if apikey.DefaultCreatedAt == nil { if apikey.DefaultCreatedAt == nil {
return fmt.Errorf("ent: uninitialized apikey.DefaultCreatedAt (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized apikey.DefaultCreatedAt (forgotten import ent/runtime?)")
...@@ -197,47 +197,47 @@ func (_c *APIKeyCreate) defaults() error { ...@@ -197,47 +197,47 @@ func (_c *APIKeyCreate) defaults() error {
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (_c *APIKeyCreate) check() error { func (_c *ApiKeyCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok { if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "APIKey.created_at"`)} return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ApiKey.created_at"`)}
} }
if _, ok := _c.mutation.UpdatedAt(); !ok { if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "APIKey.updated_at"`)} return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ApiKey.updated_at"`)}
} }
if _, ok := _c.mutation.UserID(); !ok { if _, ok := _c.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "APIKey.user_id"`)} return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "ApiKey.user_id"`)}
} }
if _, ok := _c.mutation.Key(); !ok { if _, ok := _c.mutation.Key(); !ok {
return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "APIKey.key"`)} return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "ApiKey.key"`)}
} }
if v, ok := _c.mutation.Key(); ok { if v, ok := _c.mutation.Key(); ok {
if err := apikey.KeyValidator(v); err != nil { if err := apikey.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "APIKey.key": %w`, err)} return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "ApiKey.key": %w`, err)}
} }
} }
if _, ok := _c.mutation.Name(); !ok { if _, ok := _c.mutation.Name(); !ok {
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "APIKey.name"`)} return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "ApiKey.name"`)}
} }
if v, ok := _c.mutation.Name(); ok { if v, ok := _c.mutation.Name(); ok {
if err := apikey.NameValidator(v); err != nil { if err := apikey.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "APIKey.name": %w`, err)} return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ApiKey.name": %w`, err)}
} }
} }
if _, ok := _c.mutation.Status(); !ok { if _, ok := _c.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "APIKey.status"`)} return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "ApiKey.status"`)}
} }
if v, ok := _c.mutation.Status(); ok { if v, ok := _c.mutation.Status(); ok {
if err := apikey.StatusValidator(v); err != nil { if err := apikey.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "APIKey.status": %w`, err)} return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ApiKey.status": %w`, err)}
} }
} }
if len(_c.mutation.UserIDs()) == 0 { if len(_c.mutation.UserIDs()) == 0 {
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "APIKey.user"`)} return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "ApiKey.user"`)}
} }
return nil return nil
} }
func (_c *APIKeyCreate) sqlSave(ctx context.Context) (*APIKey, error) { func (_c *ApiKeyCreate) sqlSave(ctx context.Context) (*ApiKey, error) {
if err := _c.check(); err != nil { if err := _c.check(); err != nil {
return nil, err return nil, err
} }
...@@ -255,9 +255,9 @@ func (_c *APIKeyCreate) sqlSave(ctx context.Context) (*APIKey, error) { ...@@ -255,9 +255,9 @@ func (_c *APIKeyCreate) sqlSave(ctx context.Context) (*APIKey, error) {
return _node, nil return _node, nil
} }
func (_c *APIKeyCreate) createSpec() (*APIKey, *sqlgraph.CreateSpec) { func (_c *ApiKeyCreate) createSpec() (*ApiKey, *sqlgraph.CreateSpec) {
var ( var (
_node = &APIKey{config: _c.config} _node = &ApiKey{config: _c.config}
_spec = sqlgraph.NewCreateSpec(apikey.Table, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64)) _spec = sqlgraph.NewCreateSpec(apikey.Table, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64))
) )
_spec.OnConflict = _c.conflict _spec.OnConflict = _c.conflict
...@@ -341,7 +341,7 @@ func (_c *APIKeyCreate) createSpec() (*APIKey, *sqlgraph.CreateSpec) { ...@@ -341,7 +341,7 @@ func (_c *APIKeyCreate) createSpec() (*APIKey, *sqlgraph.CreateSpec) {
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example: // of the `INSERT` statement. For example:
// //
// client.APIKey.Create(). // client.ApiKey.Create().
// SetCreatedAt(v). // SetCreatedAt(v).
// OnConflict( // OnConflict(
// // Update the row with the new values // // Update the row with the new values
...@@ -350,13 +350,13 @@ func (_c *APIKeyCreate) createSpec() (*APIKey, *sqlgraph.CreateSpec) { ...@@ -350,13 +350,13 @@ func (_c *APIKeyCreate) createSpec() (*APIKey, *sqlgraph.CreateSpec) {
// ). // ).
// // Override some of the fields with custom // // Override some of the fields with custom
// // update values. // // update values.
// Update(func(u *ent.APIKeyUpsert) { // Update(func(u *ent.ApiKeyUpsert) {
// SetCreatedAt(v+v). // SetCreatedAt(v+v).
// }). // }).
// Exec(ctx) // Exec(ctx)
func (_c *APIKeyCreate) OnConflict(opts ...sql.ConflictOption) *APIKeyUpsertOne { func (_c *ApiKeyCreate) OnConflict(opts ...sql.ConflictOption) *ApiKeyUpsertOne {
_c.conflict = opts _c.conflict = opts
return &APIKeyUpsertOne{ return &ApiKeyUpsertOne{
create: _c, create: _c,
} }
} }
...@@ -364,121 +364,121 @@ func (_c *APIKeyCreate) OnConflict(opts ...sql.ConflictOption) *APIKeyUpsertOne ...@@ -364,121 +364,121 @@ func (_c *APIKeyCreate) OnConflict(opts ...sql.ConflictOption) *APIKeyUpsertOne
// OnConflictColumns calls `OnConflict` and configures the columns // OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using: // as conflict target. Using this option is equivalent to using:
// //
// client.APIKey.Create(). // client.ApiKey.Create().
// OnConflict(sql.ConflictColumns(columns...)). // OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx) // Exec(ctx)
func (_c *APIKeyCreate) OnConflictColumns(columns ...string) *APIKeyUpsertOne { func (_c *ApiKeyCreate) OnConflictColumns(columns ...string) *ApiKeyUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &APIKeyUpsertOne{ return &ApiKeyUpsertOne{
create: _c, create: _c,
} }
} }
type ( type (
// APIKeyUpsertOne is the builder for "upsert"-ing // ApiKeyUpsertOne is the builder for "upsert"-ing
// one APIKey node. // one ApiKey node.
APIKeyUpsertOne struct { ApiKeyUpsertOne struct {
create *APIKeyCreate create *ApiKeyCreate
} }
// APIKeyUpsert is the "OnConflict" setter. // ApiKeyUpsert is the "OnConflict" setter.
APIKeyUpsert struct { ApiKeyUpsert struct {
*sql.UpdateSet *sql.UpdateSet
} }
) )
// SetUpdatedAt sets the "updated_at" field. // SetUpdatedAt sets the "updated_at" field.
func (u *APIKeyUpsert) SetUpdatedAt(v time.Time) *APIKeyUpsert { func (u *ApiKeyUpsert) SetUpdatedAt(v time.Time) *ApiKeyUpsert {
u.Set(apikey.FieldUpdatedAt, v) u.Set(apikey.FieldUpdatedAt, v)
return u return u
} }
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *APIKeyUpsert) UpdateUpdatedAt() *APIKeyUpsert { func (u *ApiKeyUpsert) UpdateUpdatedAt() *ApiKeyUpsert {
u.SetExcluded(apikey.FieldUpdatedAt) u.SetExcluded(apikey.FieldUpdatedAt)
return u return u
} }
// SetDeletedAt sets the "deleted_at" field. // SetDeletedAt sets the "deleted_at" field.
func (u *APIKeyUpsert) SetDeletedAt(v time.Time) *APIKeyUpsert { func (u *ApiKeyUpsert) SetDeletedAt(v time.Time) *ApiKeyUpsert {
u.Set(apikey.FieldDeletedAt, v) u.Set(apikey.FieldDeletedAt, v)
return u return u
} }
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *APIKeyUpsert) UpdateDeletedAt() *APIKeyUpsert { func (u *ApiKeyUpsert) UpdateDeletedAt() *ApiKeyUpsert {
u.SetExcluded(apikey.FieldDeletedAt) u.SetExcluded(apikey.FieldDeletedAt)
return u return u
} }
// ClearDeletedAt clears the value of the "deleted_at" field. // ClearDeletedAt clears the value of the "deleted_at" field.
func (u *APIKeyUpsert) ClearDeletedAt() *APIKeyUpsert { func (u *ApiKeyUpsert) ClearDeletedAt() *ApiKeyUpsert {
u.SetNull(apikey.FieldDeletedAt) u.SetNull(apikey.FieldDeletedAt)
return u return u
} }
// SetUserID sets the "user_id" field. // SetUserID sets the "user_id" field.
func (u *APIKeyUpsert) SetUserID(v int64) *APIKeyUpsert { func (u *ApiKeyUpsert) SetUserID(v int64) *ApiKeyUpsert {
u.Set(apikey.FieldUserID, v) u.Set(apikey.FieldUserID, v)
return u return u
} }
// UpdateUserID sets the "user_id" field to the value that was provided on create. // UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *APIKeyUpsert) UpdateUserID() *APIKeyUpsert { func (u *ApiKeyUpsert) UpdateUserID() *ApiKeyUpsert {
u.SetExcluded(apikey.FieldUserID) u.SetExcluded(apikey.FieldUserID)
return u return u
} }
// SetKey sets the "key" field. // SetKey sets the "key" field.
func (u *APIKeyUpsert) SetKey(v string) *APIKeyUpsert { func (u *ApiKeyUpsert) SetKey(v string) *ApiKeyUpsert {
u.Set(apikey.FieldKey, v) u.Set(apikey.FieldKey, v)
return u return u
} }
// UpdateKey sets the "key" field to the value that was provided on create. // UpdateKey sets the "key" field to the value that was provided on create.
func (u *APIKeyUpsert) UpdateKey() *APIKeyUpsert { func (u *ApiKeyUpsert) UpdateKey() *ApiKeyUpsert {
u.SetExcluded(apikey.FieldKey) u.SetExcluded(apikey.FieldKey)
return u return u
} }
// SetName sets the "name" field. // SetName sets the "name" field.
func (u *APIKeyUpsert) SetName(v string) *APIKeyUpsert { func (u *ApiKeyUpsert) SetName(v string) *ApiKeyUpsert {
u.Set(apikey.FieldName, v) u.Set(apikey.FieldName, v)
return u return u
} }
// UpdateName sets the "name" field to the value that was provided on create. // UpdateName sets the "name" field to the value that was provided on create.
func (u *APIKeyUpsert) UpdateName() *APIKeyUpsert { func (u *ApiKeyUpsert) UpdateName() *ApiKeyUpsert {
u.SetExcluded(apikey.FieldName) u.SetExcluded(apikey.FieldName)
return u return u
} }
// SetGroupID sets the "group_id" field. // SetGroupID sets the "group_id" field.
func (u *APIKeyUpsert) SetGroupID(v int64) *APIKeyUpsert { func (u *ApiKeyUpsert) SetGroupID(v int64) *ApiKeyUpsert {
u.Set(apikey.FieldGroupID, v) u.Set(apikey.FieldGroupID, v)
return u return u
} }
// UpdateGroupID sets the "group_id" field to the value that was provided on create. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *APIKeyUpsert) UpdateGroupID() *APIKeyUpsert { func (u *ApiKeyUpsert) UpdateGroupID() *ApiKeyUpsert {
u.SetExcluded(apikey.FieldGroupID) u.SetExcluded(apikey.FieldGroupID)
return u return u
} }
// ClearGroupID clears the value of the "group_id" field. // ClearGroupID clears the value of the "group_id" field.
func (u *APIKeyUpsert) ClearGroupID() *APIKeyUpsert { func (u *ApiKeyUpsert) ClearGroupID() *ApiKeyUpsert {
u.SetNull(apikey.FieldGroupID) u.SetNull(apikey.FieldGroupID)
return u return u
} }
// SetStatus sets the "status" field. // SetStatus sets the "status" field.
func (u *APIKeyUpsert) SetStatus(v string) *APIKeyUpsert { func (u *ApiKeyUpsert) SetStatus(v string) *ApiKeyUpsert {
u.Set(apikey.FieldStatus, v) u.Set(apikey.FieldStatus, v)
return u return u
} }
// UpdateStatus sets the "status" field to the value that was provided on create. // UpdateStatus sets the "status" field to the value that was provided on create.
func (u *APIKeyUpsert) UpdateStatus() *APIKeyUpsert { func (u *ApiKeyUpsert) UpdateStatus() *ApiKeyUpsert {
u.SetExcluded(apikey.FieldStatus) u.SetExcluded(apikey.FieldStatus)
return u return u
} }
...@@ -486,12 +486,12 @@ func (u *APIKeyUpsert) UpdateStatus() *APIKeyUpsert { ...@@ -486,12 +486,12 @@ func (u *APIKeyUpsert) UpdateStatus() *APIKeyUpsert {
// UpdateNewValues updates the mutable fields using the new values that were set on create. // UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using: // Using this option is equivalent to using:
// //
// client.APIKey.Create(). // client.ApiKey.Create().
// OnConflict( // OnConflict(
// sql.ResolveWithNewValues(), // sql.ResolveWithNewValues(),
// ). // ).
// Exec(ctx) // Exec(ctx)
func (u *APIKeyUpsertOne) UpdateNewValues() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) UpdateNewValues() *ApiKeyUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
if _, exists := u.create.mutation.CreatedAt(); exists { if _, exists := u.create.mutation.CreatedAt(); exists {
...@@ -504,159 +504,159 @@ func (u *APIKeyUpsertOne) UpdateNewValues() *APIKeyUpsertOne { ...@@ -504,159 +504,159 @@ func (u *APIKeyUpsertOne) UpdateNewValues() *APIKeyUpsertOne {
// Ignore sets each column to itself in case of conflict. // Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using: // Using this option is equivalent to using:
// //
// client.APIKey.Create(). // client.ApiKey.Create().
// OnConflict(sql.ResolveWithIgnore()). // OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx) // Exec(ctx)
func (u *APIKeyUpsertOne) Ignore() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) Ignore() *ApiKeyUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u return u
} }
// DoNothing configures the conflict_action to `DO NOTHING`. // DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL. // Supported only by SQLite and PostgreSQL.
func (u *APIKeyUpsertOne) DoNothing() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) DoNothing() *ApiKeyUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing()) u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u return u
} }
// Update allows overriding fields `UPDATE` values. See the APIKeyCreate.OnConflict // Update allows overriding fields `UPDATE` values. See the ApiKeyCreate.OnConflict
// documentation for more info. // documentation for more info.
func (u *APIKeyUpsertOne) Update(set func(*APIKeyUpsert)) *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) Update(set func(*ApiKeyUpsert)) *ApiKeyUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&APIKeyUpsert{UpdateSet: update}) set(&ApiKeyUpsert{UpdateSet: update})
})) }))
return u return u
} }
// SetUpdatedAt sets the "updated_at" field. // SetUpdatedAt sets the "updated_at" field.
func (u *APIKeyUpsertOne) SetUpdatedAt(v time.Time) *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) SetUpdatedAt(v time.Time) *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetUpdatedAt(v) s.SetUpdatedAt(v)
}) })
} }
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *APIKeyUpsertOne) UpdateUpdatedAt() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) UpdateUpdatedAt() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateUpdatedAt() s.UpdateUpdatedAt()
}) })
} }
// SetDeletedAt sets the "deleted_at" field. // SetDeletedAt sets the "deleted_at" field.
func (u *APIKeyUpsertOne) SetDeletedAt(v time.Time) *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) SetDeletedAt(v time.Time) *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetDeletedAt(v) s.SetDeletedAt(v)
}) })
} }
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *APIKeyUpsertOne) UpdateDeletedAt() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) UpdateDeletedAt() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateDeletedAt() s.UpdateDeletedAt()
}) })
} }
// ClearDeletedAt clears the value of the "deleted_at" field. // ClearDeletedAt clears the value of the "deleted_at" field.
func (u *APIKeyUpsertOne) ClearDeletedAt() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) ClearDeletedAt() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.ClearDeletedAt() s.ClearDeletedAt()
}) })
} }
// SetUserID sets the "user_id" field. // SetUserID sets the "user_id" field.
func (u *APIKeyUpsertOne) SetUserID(v int64) *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) SetUserID(v int64) *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetUserID(v) s.SetUserID(v)
}) })
} }
// UpdateUserID sets the "user_id" field to the value that was provided on create. // UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *APIKeyUpsertOne) UpdateUserID() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) UpdateUserID() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateUserID() s.UpdateUserID()
}) })
} }
// SetKey sets the "key" field. // SetKey sets the "key" field.
func (u *APIKeyUpsertOne) SetKey(v string) *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) SetKey(v string) *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetKey(v) s.SetKey(v)
}) })
} }
// UpdateKey sets the "key" field to the value that was provided on create. // UpdateKey sets the "key" field to the value that was provided on create.
func (u *APIKeyUpsertOne) UpdateKey() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) UpdateKey() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateKey() s.UpdateKey()
}) })
} }
// SetName sets the "name" field. // SetName sets the "name" field.
func (u *APIKeyUpsertOne) SetName(v string) *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) SetName(v string) *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetName(v) s.SetName(v)
}) })
} }
// UpdateName sets the "name" field to the value that was provided on create. // UpdateName sets the "name" field to the value that was provided on create.
func (u *APIKeyUpsertOne) UpdateName() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) UpdateName() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateName() s.UpdateName()
}) })
} }
// SetGroupID sets the "group_id" field. // SetGroupID sets the "group_id" field.
func (u *APIKeyUpsertOne) SetGroupID(v int64) *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) SetGroupID(v int64) *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetGroupID(v) s.SetGroupID(v)
}) })
} }
// UpdateGroupID sets the "group_id" field to the value that was provided on create. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *APIKeyUpsertOne) UpdateGroupID() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) UpdateGroupID() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateGroupID() s.UpdateGroupID()
}) })
} }
// ClearGroupID clears the value of the "group_id" field. // ClearGroupID clears the value of the "group_id" field.
func (u *APIKeyUpsertOne) ClearGroupID() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) ClearGroupID() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.ClearGroupID() s.ClearGroupID()
}) })
} }
// SetStatus sets the "status" field. // SetStatus sets the "status" field.
func (u *APIKeyUpsertOne) SetStatus(v string) *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) SetStatus(v string) *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetStatus(v) s.SetStatus(v)
}) })
} }
// UpdateStatus sets the "status" field to the value that was provided on create. // UpdateStatus sets the "status" field to the value that was provided on create.
func (u *APIKeyUpsertOne) UpdateStatus() *APIKeyUpsertOne { func (u *ApiKeyUpsertOne) UpdateStatus() *ApiKeyUpsertOne {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateStatus() s.UpdateStatus()
}) })
} }
// Exec executes the query. // Exec executes the query.
func (u *APIKeyUpsertOne) Exec(ctx context.Context) error { func (u *ApiKeyUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 { if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for APIKeyCreate.OnConflict") return errors.New("ent: missing options for ApiKeyCreate.OnConflict")
} }
return u.create.Exec(ctx) return u.create.Exec(ctx)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (u *APIKeyUpsertOne) ExecX(ctx context.Context) { func (u *ApiKeyUpsertOne) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil { if err := u.create.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Exec executes the UPSERT query and returns the inserted/updated ID. // Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *APIKeyUpsertOne) ID(ctx context.Context) (id int64, err error) { func (u *ApiKeyUpsertOne) ID(ctx context.Context) (id int64, err error) {
node, err := u.create.Save(ctx) node, err := u.create.Save(ctx)
if err != nil { if err != nil {
return id, err return id, err
...@@ -665,7 +665,7 @@ func (u *APIKeyUpsertOne) ID(ctx context.Context) (id int64, err error) { ...@@ -665,7 +665,7 @@ func (u *APIKeyUpsertOne) ID(ctx context.Context) (id int64, err error) {
} }
// IDX is like ID, but panics if an error occurs. // IDX is like ID, but panics if an error occurs.
func (u *APIKeyUpsertOne) IDX(ctx context.Context) int64 { func (u *ApiKeyUpsertOne) IDX(ctx context.Context) int64 {
id, err := u.ID(ctx) id, err := u.ID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -673,28 +673,28 @@ func (u *APIKeyUpsertOne) IDX(ctx context.Context) int64 { ...@@ -673,28 +673,28 @@ func (u *APIKeyUpsertOne) IDX(ctx context.Context) int64 {
return id return id
} }
// APIKeyCreateBulk is the builder for creating many APIKey entities in bulk. // ApiKeyCreateBulk is the builder for creating many ApiKey entities in bulk.
type APIKeyCreateBulk struct { type ApiKeyCreateBulk struct {
config config
err error err error
builders []*APIKeyCreate builders []*ApiKeyCreate
conflict []sql.ConflictOption conflict []sql.ConflictOption
} }
// Save creates the APIKey entities in the database. // Save creates the ApiKey entities in the database.
func (_c *APIKeyCreateBulk) Save(ctx context.Context) ([]*APIKey, error) { func (_c *ApiKeyCreateBulk) Save(ctx context.Context) ([]*ApiKey, error) {
if _c.err != nil { if _c.err != nil {
return nil, _c.err return nil, _c.err
} }
specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*APIKey, len(_c.builders)) nodes := make([]*ApiKey, len(_c.builders))
mutators := make([]Mutator, len(_c.builders)) mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders { for i := range _c.builders {
func(i int, root context.Context) { func(i int, root context.Context) {
builder := _c.builders[i] builder := _c.builders[i]
builder.defaults() builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*APIKeyMutation) mutation, ok := m.(*ApiKeyMutation)
if !ok { if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m) return nil, fmt.Errorf("unexpected mutation type %T", m)
} }
...@@ -742,7 +742,7 @@ func (_c *APIKeyCreateBulk) Save(ctx context.Context) ([]*APIKey, error) { ...@@ -742,7 +742,7 @@ func (_c *APIKeyCreateBulk) Save(ctx context.Context) ([]*APIKey, error) {
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (_c *APIKeyCreateBulk) SaveX(ctx context.Context) []*APIKey { func (_c *ApiKeyCreateBulk) SaveX(ctx context.Context) []*ApiKey {
v, err := _c.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -751,13 +751,13 @@ func (_c *APIKeyCreateBulk) SaveX(ctx context.Context) []*APIKey { ...@@ -751,13 +751,13 @@ func (_c *APIKeyCreateBulk) SaveX(ctx context.Context) []*APIKey {
} }
// Exec executes the query. // Exec executes the query.
func (_c *APIKeyCreateBulk) Exec(ctx context.Context) error { func (_c *ApiKeyCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (_c *APIKeyCreateBulk) ExecX(ctx context.Context) { func (_c *ApiKeyCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
...@@ -766,7 +766,7 @@ func (_c *APIKeyCreateBulk) ExecX(ctx context.Context) { ...@@ -766,7 +766,7 @@ func (_c *APIKeyCreateBulk) ExecX(ctx context.Context) {
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example: // of the `INSERT` statement. For example:
// //
// client.APIKey.CreateBulk(builders...). // client.ApiKey.CreateBulk(builders...).
// OnConflict( // OnConflict(
// // Update the row with the new values // // Update the row with the new values
// // the was proposed for insertion. // // the was proposed for insertion.
...@@ -774,13 +774,13 @@ func (_c *APIKeyCreateBulk) ExecX(ctx context.Context) { ...@@ -774,13 +774,13 @@ func (_c *APIKeyCreateBulk) ExecX(ctx context.Context) {
// ). // ).
// // Override some of the fields with custom // // Override some of the fields with custom
// // update values. // // update values.
// Update(func(u *ent.APIKeyUpsert) { // Update(func(u *ent.ApiKeyUpsert) {
// SetCreatedAt(v+v). // SetCreatedAt(v+v).
// }). // }).
// Exec(ctx) // Exec(ctx)
func (_c *APIKeyCreateBulk) OnConflict(opts ...sql.ConflictOption) *APIKeyUpsertBulk { func (_c *ApiKeyCreateBulk) OnConflict(opts ...sql.ConflictOption) *ApiKeyUpsertBulk {
_c.conflict = opts _c.conflict = opts
return &APIKeyUpsertBulk{ return &ApiKeyUpsertBulk{
create: _c, create: _c,
} }
} }
...@@ -788,31 +788,31 @@ func (_c *APIKeyCreateBulk) OnConflict(opts ...sql.ConflictOption) *APIKeyUpsert ...@@ -788,31 +788,31 @@ func (_c *APIKeyCreateBulk) OnConflict(opts ...sql.ConflictOption) *APIKeyUpsert
// OnConflictColumns calls `OnConflict` and configures the columns // OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using: // as conflict target. Using this option is equivalent to using:
// //
// client.APIKey.Create(). // client.ApiKey.Create().
// OnConflict(sql.ConflictColumns(columns...)). // OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx) // Exec(ctx)
func (_c *APIKeyCreateBulk) OnConflictColumns(columns ...string) *APIKeyUpsertBulk { func (_c *ApiKeyCreateBulk) OnConflictColumns(columns ...string) *ApiKeyUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &APIKeyUpsertBulk{ return &ApiKeyUpsertBulk{
create: _c, create: _c,
} }
} }
// APIKeyUpsertBulk is the builder for "upsert"-ing // ApiKeyUpsertBulk is the builder for "upsert"-ing
// a bulk of APIKey nodes. // a bulk of ApiKey nodes.
type APIKeyUpsertBulk struct { type ApiKeyUpsertBulk struct {
create *APIKeyCreateBulk create *ApiKeyCreateBulk
} }
// UpdateNewValues updates the mutable fields using the new values that // UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using: // were set on create. Using this option is equivalent to using:
// //
// client.APIKey.Create(). // client.ApiKey.Create().
// OnConflict( // OnConflict(
// sql.ResolveWithNewValues(), // sql.ResolveWithNewValues(),
// ). // ).
// Exec(ctx) // Exec(ctx)
func (u *APIKeyUpsertBulk) UpdateNewValues() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) UpdateNewValues() *ApiKeyUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
for _, b := range u.create.builders { for _, b := range u.create.builders {
...@@ -827,160 +827,160 @@ func (u *APIKeyUpsertBulk) UpdateNewValues() *APIKeyUpsertBulk { ...@@ -827,160 +827,160 @@ func (u *APIKeyUpsertBulk) UpdateNewValues() *APIKeyUpsertBulk {
// Ignore sets each column to itself in case of conflict. // Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using: // Using this option is equivalent to using:
// //
// client.APIKey.Create(). // client.ApiKey.Create().
// OnConflict(sql.ResolveWithIgnore()). // OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx) // Exec(ctx)
func (u *APIKeyUpsertBulk) Ignore() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) Ignore() *ApiKeyUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u return u
} }
// DoNothing configures the conflict_action to `DO NOTHING`. // DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL. // Supported only by SQLite and PostgreSQL.
func (u *APIKeyUpsertBulk) DoNothing() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) DoNothing() *ApiKeyUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing()) u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u return u
} }
// Update allows overriding fields `UPDATE` values. See the APIKeyCreateBulk.OnConflict // Update allows overriding fields `UPDATE` values. See the ApiKeyCreateBulk.OnConflict
// documentation for more info. // documentation for more info.
func (u *APIKeyUpsertBulk) Update(set func(*APIKeyUpsert)) *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) Update(set func(*ApiKeyUpsert)) *ApiKeyUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&APIKeyUpsert{UpdateSet: update}) set(&ApiKeyUpsert{UpdateSet: update})
})) }))
return u return u
} }
// SetUpdatedAt sets the "updated_at" field. // SetUpdatedAt sets the "updated_at" field.
func (u *APIKeyUpsertBulk) SetUpdatedAt(v time.Time) *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) SetUpdatedAt(v time.Time) *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetUpdatedAt(v) s.SetUpdatedAt(v)
}) })
} }
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *APIKeyUpsertBulk) UpdateUpdatedAt() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) UpdateUpdatedAt() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateUpdatedAt() s.UpdateUpdatedAt()
}) })
} }
// SetDeletedAt sets the "deleted_at" field. // SetDeletedAt sets the "deleted_at" field.
func (u *APIKeyUpsertBulk) SetDeletedAt(v time.Time) *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) SetDeletedAt(v time.Time) *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetDeletedAt(v) s.SetDeletedAt(v)
}) })
} }
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *APIKeyUpsertBulk) UpdateDeletedAt() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) UpdateDeletedAt() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateDeletedAt() s.UpdateDeletedAt()
}) })
} }
// ClearDeletedAt clears the value of the "deleted_at" field. // ClearDeletedAt clears the value of the "deleted_at" field.
func (u *APIKeyUpsertBulk) ClearDeletedAt() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) ClearDeletedAt() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.ClearDeletedAt() s.ClearDeletedAt()
}) })
} }
// SetUserID sets the "user_id" field. // SetUserID sets the "user_id" field.
func (u *APIKeyUpsertBulk) SetUserID(v int64) *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) SetUserID(v int64) *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetUserID(v) s.SetUserID(v)
}) })
} }
// UpdateUserID sets the "user_id" field to the value that was provided on create. // UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *APIKeyUpsertBulk) UpdateUserID() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) UpdateUserID() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateUserID() s.UpdateUserID()
}) })
} }
// SetKey sets the "key" field. // SetKey sets the "key" field.
func (u *APIKeyUpsertBulk) SetKey(v string) *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) SetKey(v string) *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetKey(v) s.SetKey(v)
}) })
} }
// UpdateKey sets the "key" field to the value that was provided on create. // UpdateKey sets the "key" field to the value that was provided on create.
func (u *APIKeyUpsertBulk) UpdateKey() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) UpdateKey() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateKey() s.UpdateKey()
}) })
} }
// SetName sets the "name" field. // SetName sets the "name" field.
func (u *APIKeyUpsertBulk) SetName(v string) *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) SetName(v string) *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetName(v) s.SetName(v)
}) })
} }
// UpdateName sets the "name" field to the value that was provided on create. // UpdateName sets the "name" field to the value that was provided on create.
func (u *APIKeyUpsertBulk) UpdateName() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) UpdateName() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateName() s.UpdateName()
}) })
} }
// SetGroupID sets the "group_id" field. // SetGroupID sets the "group_id" field.
func (u *APIKeyUpsertBulk) SetGroupID(v int64) *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) SetGroupID(v int64) *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetGroupID(v) s.SetGroupID(v)
}) })
} }
// UpdateGroupID sets the "group_id" field to the value that was provided on create. // UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *APIKeyUpsertBulk) UpdateGroupID() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) UpdateGroupID() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateGroupID() s.UpdateGroupID()
}) })
} }
// ClearGroupID clears the value of the "group_id" field. // ClearGroupID clears the value of the "group_id" field.
func (u *APIKeyUpsertBulk) ClearGroupID() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) ClearGroupID() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.ClearGroupID() s.ClearGroupID()
}) })
} }
// SetStatus sets the "status" field. // SetStatus sets the "status" field.
func (u *APIKeyUpsertBulk) SetStatus(v string) *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) SetStatus(v string) *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.SetStatus(v) s.SetStatus(v)
}) })
} }
// UpdateStatus sets the "status" field to the value that was provided on create. // UpdateStatus sets the "status" field to the value that was provided on create.
func (u *APIKeyUpsertBulk) UpdateStatus() *APIKeyUpsertBulk { func (u *ApiKeyUpsertBulk) UpdateStatus() *ApiKeyUpsertBulk {
return u.Update(func(s *APIKeyUpsert) { return u.Update(func(s *ApiKeyUpsert) {
s.UpdateStatus() s.UpdateStatus()
}) })
} }
// Exec executes the query. // Exec executes the query.
func (u *APIKeyUpsertBulk) Exec(ctx context.Context) error { func (u *ApiKeyUpsertBulk) Exec(ctx context.Context) error {
if u.create.err != nil { if u.create.err != nil {
return u.create.err return u.create.err
} }
for i, b := range u.create.builders { for i, b := range u.create.builders {
if len(b.conflict) != 0 { if len(b.conflict) != 0 {
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the APIKeyCreateBulk instead", i) return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ApiKeyCreateBulk instead", i)
} }
} }
if len(u.create.conflict) == 0 { if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for APIKeyCreateBulk.OnConflict") return errors.New("ent: missing options for ApiKeyCreateBulk.OnConflict")
} }
return u.create.Exec(ctx) return u.create.Exec(ctx)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (u *APIKeyUpsertBulk) ExecX(ctx context.Context) { func (u *ApiKeyUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil { if err := u.create.Exec(ctx); err != nil {
panic(err) panic(err)
} }
......
...@@ -12,26 +12,26 @@ import ( ...@@ -12,26 +12,26 @@ import (
"github.com/Wei-Shaw/sub2api/ent/predicate" "github.com/Wei-Shaw/sub2api/ent/predicate"
) )
// APIKeyDelete is the builder for deleting a APIKey entity. // ApiKeyDelete is the builder for deleting a ApiKey entity.
type APIKeyDelete struct { type ApiKeyDelete struct {
config config
hooks []Hook hooks []Hook
mutation *APIKeyMutation mutation *ApiKeyMutation
} }
// Where appends a list predicates to the APIKeyDelete builder. // Where appends a list predicates to the ApiKeyDelete builder.
func (_d *APIKeyDelete) Where(ps ...predicate.APIKey) *APIKeyDelete { func (_d *ApiKeyDelete) Where(ps ...predicate.ApiKey) *ApiKeyDelete {
_d.mutation.Where(ps...) _d.mutation.Where(ps...)
return _d return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (_d *APIKeyDelete) Exec(ctx context.Context) (int, error) { func (_d *ApiKeyDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (_d *APIKeyDelete) ExecX(ctx context.Context) int { func (_d *ApiKeyDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -39,7 +39,7 @@ func (_d *APIKeyDelete) ExecX(ctx context.Context) int { ...@@ -39,7 +39,7 @@ func (_d *APIKeyDelete) ExecX(ctx context.Context) int {
return n return n
} }
func (_d *APIKeyDelete) sqlExec(ctx context.Context) (int, error) { func (_d *ApiKeyDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(apikey.Table, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64)) _spec := sqlgraph.NewDeleteSpec(apikey.Table, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64))
if ps := _d.mutation.predicates; len(ps) > 0 { if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) { _spec.Predicate = func(selector *sql.Selector) {
...@@ -56,19 +56,19 @@ func (_d *APIKeyDelete) sqlExec(ctx context.Context) (int, error) { ...@@ -56,19 +56,19 @@ func (_d *APIKeyDelete) sqlExec(ctx context.Context) (int, error) {
return affected, err return affected, err
} }
// APIKeyDeleteOne is the builder for deleting a single APIKey entity. // ApiKeyDeleteOne is the builder for deleting a single ApiKey entity.
type APIKeyDeleteOne struct { type ApiKeyDeleteOne struct {
_d *APIKeyDelete _d *ApiKeyDelete
} }
// Where appends a list predicates to the APIKeyDelete builder. // Where appends a list predicates to the ApiKeyDelete builder.
func (_d *APIKeyDeleteOne) Where(ps ...predicate.APIKey) *APIKeyDeleteOne { func (_d *ApiKeyDeleteOne) Where(ps ...predicate.ApiKey) *ApiKeyDeleteOne {
_d._d.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return _d return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (_d *APIKeyDeleteOne) Exec(ctx context.Context) error { func (_d *ApiKeyDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
...@@ -81,7 +81,7 @@ func (_d *APIKeyDeleteOne) Exec(ctx context.Context) error { ...@@ -81,7 +81,7 @@ func (_d *APIKeyDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (_d *APIKeyDeleteOne) ExecX(ctx context.Context) { func (_d *ApiKeyDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
......
...@@ -19,13 +19,13 @@ import ( ...@@ -19,13 +19,13 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user" "github.com/Wei-Shaw/sub2api/ent/user"
) )
// APIKeyQuery is the builder for querying APIKey entities. // ApiKeyQuery is the builder for querying ApiKey entities.
type APIKeyQuery struct { type ApiKeyQuery struct {
config config
ctx *QueryContext ctx *QueryContext
order []apikey.OrderOption order []apikey.OrderOption
inters []Interceptor inters []Interceptor
predicates []predicate.APIKey predicates []predicate.ApiKey
withUser *UserQuery withUser *UserQuery
withGroup *GroupQuery withGroup *GroupQuery
withUsageLogs *UsageLogQuery withUsageLogs *UsageLogQuery
...@@ -34,39 +34,39 @@ type APIKeyQuery struct { ...@@ -34,39 +34,39 @@ type APIKeyQuery struct {
path func(context.Context) (*sql.Selector, error) path func(context.Context) (*sql.Selector, error)
} }
// Where adds a new predicate for the APIKeyQuery builder. // Where adds a new predicate for the ApiKeyQuery builder.
func (_q *APIKeyQuery) Where(ps ...predicate.APIKey) *APIKeyQuery { func (_q *ApiKeyQuery) Where(ps ...predicate.ApiKey) *ApiKeyQuery {
_q.predicates = append(_q.predicates, ps...) _q.predicates = append(_q.predicates, ps...)
return _q return _q
} }
// Limit the number of records to be returned by this query. // Limit the number of records to be returned by this query.
func (_q *APIKeyQuery) Limit(limit int) *APIKeyQuery { func (_q *ApiKeyQuery) Limit(limit int) *ApiKeyQuery {
_q.ctx.Limit = &limit _q.ctx.Limit = &limit
return _q return _q
} }
// Offset to start from. // Offset to start from.
func (_q *APIKeyQuery) Offset(offset int) *APIKeyQuery { func (_q *ApiKeyQuery) Offset(offset int) *ApiKeyQuery {
_q.ctx.Offset = &offset _q.ctx.Offset = &offset
return _q return _q
} }
// Unique configures the query builder to filter duplicate records on query. // 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. // By default, unique is set to true, and can be disabled using this method.
func (_q *APIKeyQuery) Unique(unique bool) *APIKeyQuery { func (_q *ApiKeyQuery) Unique(unique bool) *ApiKeyQuery {
_q.ctx.Unique = &unique _q.ctx.Unique = &unique
return _q return _q
} }
// Order specifies how the records should be ordered. // Order specifies how the records should be ordered.
func (_q *APIKeyQuery) Order(o ...apikey.OrderOption) *APIKeyQuery { func (_q *ApiKeyQuery) Order(o ...apikey.OrderOption) *ApiKeyQuery {
_q.order = append(_q.order, o...) _q.order = append(_q.order, o...)
return _q return _q
} }
// QueryUser chains the current query on the "user" edge. // QueryUser chains the current query on the "user" edge.
func (_q *APIKeyQuery) QueryUser() *UserQuery { func (_q *ApiKeyQuery) QueryUser() *UserQuery {
query := (&UserClient{config: _q.config}).Query() query := (&UserClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
...@@ -88,7 +88,7 @@ func (_q *APIKeyQuery) QueryUser() *UserQuery { ...@@ -88,7 +88,7 @@ func (_q *APIKeyQuery) QueryUser() *UserQuery {
} }
// QueryGroup chains the current query on the "group" edge. // QueryGroup chains the current query on the "group" edge.
func (_q *APIKeyQuery) QueryGroup() *GroupQuery { func (_q *ApiKeyQuery) QueryGroup() *GroupQuery {
query := (&GroupClient{config: _q.config}).Query() query := (&GroupClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
...@@ -110,7 +110,7 @@ func (_q *APIKeyQuery) QueryGroup() *GroupQuery { ...@@ -110,7 +110,7 @@ func (_q *APIKeyQuery) QueryGroup() *GroupQuery {
} }
// QueryUsageLogs chains the current query on the "usage_logs" edge. // QueryUsageLogs chains the current query on the "usage_logs" edge.
func (_q *APIKeyQuery) QueryUsageLogs() *UsageLogQuery { func (_q *ApiKeyQuery) QueryUsageLogs() *UsageLogQuery {
query := (&UsageLogClient{config: _q.config}).Query() query := (&UsageLogClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
...@@ -131,9 +131,9 @@ func (_q *APIKeyQuery) QueryUsageLogs() *UsageLogQuery { ...@@ -131,9 +131,9 @@ func (_q *APIKeyQuery) QueryUsageLogs() *UsageLogQuery {
return query return query
} }
// First returns the first APIKey entity from the query. // First returns the first ApiKey entity from the query.
// Returns a *NotFoundError when no APIKey was found. // Returns a *NotFoundError when no ApiKey was found.
func (_q *APIKeyQuery) First(ctx context.Context) (*APIKey, error) { func (_q *ApiKeyQuery) First(ctx context.Context) (*ApiKey, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -145,7 +145,7 @@ func (_q *APIKeyQuery) First(ctx context.Context) (*APIKey, error) { ...@@ -145,7 +145,7 @@ func (_q *APIKeyQuery) First(ctx context.Context) (*APIKey, error) {
} }
// FirstX is like First, but panics if an error occurs. // FirstX is like First, but panics if an error occurs.
func (_q *APIKeyQuery) FirstX(ctx context.Context) *APIKey { func (_q *ApiKeyQuery) FirstX(ctx context.Context) *ApiKey {
node, err := _q.First(ctx) node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
...@@ -153,9 +153,9 @@ func (_q *APIKeyQuery) FirstX(ctx context.Context) *APIKey { ...@@ -153,9 +153,9 @@ func (_q *APIKeyQuery) FirstX(ctx context.Context) *APIKey {
return node return node
} }
// FirstID returns the first APIKey ID from the query. // FirstID returns the first ApiKey ID from the query.
// Returns a *NotFoundError when no APIKey ID was found. // Returns a *NotFoundError when no ApiKey ID was found.
func (_q *APIKeyQuery) FirstID(ctx context.Context) (id int64, err error) { func (_q *ApiKeyQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64 var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return return
...@@ -168,7 +168,7 @@ func (_q *APIKeyQuery) FirstID(ctx context.Context) (id int64, err error) { ...@@ -168,7 +168,7 @@ func (_q *APIKeyQuery) FirstID(ctx context.Context) (id int64, err error) {
} }
// FirstIDX is like FirstID, but panics if an error occurs. // FirstIDX is like FirstID, but panics if an error occurs.
func (_q *APIKeyQuery) FirstIDX(ctx context.Context) int64 { func (_q *ApiKeyQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx) id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
...@@ -176,10 +176,10 @@ func (_q *APIKeyQuery) FirstIDX(ctx context.Context) int64 { ...@@ -176,10 +176,10 @@ func (_q *APIKeyQuery) FirstIDX(ctx context.Context) int64 {
return id return id
} }
// Only returns a single APIKey entity found by the query, ensuring it only returns one. // Only returns a single ApiKey entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one APIKey entity is found. // Returns a *NotSingularError when more than one ApiKey entity is found.
// Returns a *NotFoundError when no APIKey entities are found. // Returns a *NotFoundError when no ApiKey entities are found.
func (_q *APIKeyQuery) Only(ctx context.Context) (*APIKey, error) { func (_q *ApiKeyQuery) Only(ctx context.Context) (*ApiKey, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -195,7 +195,7 @@ func (_q *APIKeyQuery) Only(ctx context.Context) (*APIKey, error) { ...@@ -195,7 +195,7 @@ func (_q *APIKeyQuery) Only(ctx context.Context) (*APIKey, error) {
} }
// OnlyX is like Only, but panics if an error occurs. // OnlyX is like Only, but panics if an error occurs.
func (_q *APIKeyQuery) OnlyX(ctx context.Context) *APIKey { func (_q *ApiKeyQuery) OnlyX(ctx context.Context) *ApiKey {
node, err := _q.Only(ctx) node, err := _q.Only(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -203,10 +203,10 @@ func (_q *APIKeyQuery) OnlyX(ctx context.Context) *APIKey { ...@@ -203,10 +203,10 @@ func (_q *APIKeyQuery) OnlyX(ctx context.Context) *APIKey {
return node return node
} }
// OnlyID is like Only, but returns the only APIKey ID in the query. // OnlyID is like Only, but returns the only ApiKey ID in the query.
// Returns a *NotSingularError when more than one APIKey ID is found. // Returns a *NotSingularError when more than one ApiKey ID is found.
// Returns a *NotFoundError when no entities are found. // Returns a *NotFoundError when no entities are found.
func (_q *APIKeyQuery) OnlyID(ctx context.Context) (id int64, err error) { func (_q *ApiKeyQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64 var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return return
...@@ -223,7 +223,7 @@ func (_q *APIKeyQuery) OnlyID(ctx context.Context) (id int64, err error) { ...@@ -223,7 +223,7 @@ func (_q *APIKeyQuery) OnlyID(ctx context.Context) (id int64, err error) {
} }
// OnlyIDX is like OnlyID, but panics if an error occurs. // OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *APIKeyQuery) OnlyIDX(ctx context.Context) int64 { func (_q *ApiKeyQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx) id, err := _q.OnlyID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -231,18 +231,18 @@ func (_q *APIKeyQuery) OnlyIDX(ctx context.Context) int64 { ...@@ -231,18 +231,18 @@ func (_q *APIKeyQuery) OnlyIDX(ctx context.Context) int64 {
return id return id
} }
// All executes the query and returns a list of APIKeys. // All executes the query and returns a list of ApiKeys.
func (_q *APIKeyQuery) All(ctx context.Context) ([]*APIKey, error) { func (_q *ApiKeyQuery) All(ctx context.Context) ([]*ApiKey, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
qr := querierAll[[]*APIKey, *APIKeyQuery]() qr := querierAll[[]*ApiKey, *ApiKeyQuery]()
return withInterceptors[[]*APIKey](ctx, _q, qr, _q.inters) return withInterceptors[[]*ApiKey](ctx, _q, qr, _q.inters)
} }
// AllX is like All, but panics if an error occurs. // AllX is like All, but panics if an error occurs.
func (_q *APIKeyQuery) AllX(ctx context.Context) []*APIKey { func (_q *ApiKeyQuery) AllX(ctx context.Context) []*ApiKey {
nodes, err := _q.All(ctx) nodes, err := _q.All(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -250,8 +250,8 @@ func (_q *APIKeyQuery) AllX(ctx context.Context) []*APIKey { ...@@ -250,8 +250,8 @@ func (_q *APIKeyQuery) AllX(ctx context.Context) []*APIKey {
return nodes return nodes
} }
// IDs executes the query and returns a list of APIKey IDs. // IDs executes the query and returns a list of ApiKey IDs.
func (_q *APIKeyQuery) IDs(ctx context.Context) (ids []int64, err error) { func (_q *ApiKeyQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil { if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true) _q.Unique(true)
} }
...@@ -263,7 +263,7 @@ func (_q *APIKeyQuery) IDs(ctx context.Context) (ids []int64, err error) { ...@@ -263,7 +263,7 @@ func (_q *APIKeyQuery) IDs(ctx context.Context) (ids []int64, err error) {
} }
// IDsX is like IDs, but panics if an error occurs. // IDsX is like IDs, but panics if an error occurs.
func (_q *APIKeyQuery) IDsX(ctx context.Context) []int64 { func (_q *ApiKeyQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx) ids, err := _q.IDs(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -272,16 +272,16 @@ func (_q *APIKeyQuery) IDsX(ctx context.Context) []int64 { ...@@ -272,16 +272,16 @@ func (_q *APIKeyQuery) IDsX(ctx context.Context) []int64 {
} }
// Count returns the count of the given query. // Count returns the count of the given query.
func (_q *APIKeyQuery) Count(ctx context.Context) (int, error) { func (_q *ApiKeyQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return 0, err return 0, err
} }
return withInterceptors[int](ctx, _q, querierCount[*APIKeyQuery](), _q.inters) return withInterceptors[int](ctx, _q, querierCount[*ApiKeyQuery](), _q.inters)
} }
// CountX is like Count, but panics if an error occurs. // CountX is like Count, but panics if an error occurs.
func (_q *APIKeyQuery) CountX(ctx context.Context) int { func (_q *ApiKeyQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx) count, err := _q.Count(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -290,7 +290,7 @@ func (_q *APIKeyQuery) CountX(ctx context.Context) int { ...@@ -290,7 +290,7 @@ func (_q *APIKeyQuery) CountX(ctx context.Context) int {
} }
// Exist returns true if the query has elements in the graph. // Exist returns true if the query has elements in the graph.
func (_q *APIKeyQuery) Exist(ctx context.Context) (bool, error) { func (_q *ApiKeyQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); { switch _, err := _q.FirstID(ctx); {
case IsNotFound(err): case IsNotFound(err):
...@@ -303,7 +303,7 @@ func (_q *APIKeyQuery) Exist(ctx context.Context) (bool, error) { ...@@ -303,7 +303,7 @@ func (_q *APIKeyQuery) Exist(ctx context.Context) (bool, error) {
} }
// ExistX is like Exist, but panics if an error occurs. // ExistX is like Exist, but panics if an error occurs.
func (_q *APIKeyQuery) ExistX(ctx context.Context) bool { func (_q *ApiKeyQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx) exist, err := _q.Exist(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -311,18 +311,18 @@ func (_q *APIKeyQuery) ExistX(ctx context.Context) bool { ...@@ -311,18 +311,18 @@ func (_q *APIKeyQuery) ExistX(ctx context.Context) bool {
return exist return exist
} }
// Clone returns a duplicate of the APIKeyQuery builder, including all associated steps. It can be // Clone returns a duplicate of the ApiKeyQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made. // used to prepare common query builders and use them differently after the clone is made.
func (_q *APIKeyQuery) Clone() *APIKeyQuery { func (_q *ApiKeyQuery) Clone() *ApiKeyQuery {
if _q == nil { if _q == nil {
return nil return nil
} }
return &APIKeyQuery{ return &ApiKeyQuery{
config: _q.config, config: _q.config,
ctx: _q.ctx.Clone(), ctx: _q.ctx.Clone(),
order: append([]apikey.OrderOption{}, _q.order...), order: append([]apikey.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...), inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.APIKey{}, _q.predicates...), predicates: append([]predicate.ApiKey{}, _q.predicates...),
withUser: _q.withUser.Clone(), withUser: _q.withUser.Clone(),
withGroup: _q.withGroup.Clone(), withGroup: _q.withGroup.Clone(),
withUsageLogs: _q.withUsageLogs.Clone(), withUsageLogs: _q.withUsageLogs.Clone(),
...@@ -334,7 +334,7 @@ func (_q *APIKeyQuery) Clone() *APIKeyQuery { ...@@ -334,7 +334,7 @@ func (_q *APIKeyQuery) Clone() *APIKeyQuery {
// WithUser tells the query-builder to eager-load the nodes that are connected to // WithUser tells the query-builder to eager-load the nodes that are connected to
// the "user" edge. The optional arguments are used to configure the query builder of the edge. // the "user" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *APIKeyQuery) WithUser(opts ...func(*UserQuery)) *APIKeyQuery { func (_q *ApiKeyQuery) WithUser(opts ...func(*UserQuery)) *ApiKeyQuery {
query := (&UserClient{config: _q.config}).Query() query := (&UserClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
...@@ -345,7 +345,7 @@ func (_q *APIKeyQuery) WithUser(opts ...func(*UserQuery)) *APIKeyQuery { ...@@ -345,7 +345,7 @@ func (_q *APIKeyQuery) WithUser(opts ...func(*UserQuery)) *APIKeyQuery {
// WithGroup tells the query-builder to eager-load the nodes that are connected to // 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. // the "group" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *APIKeyQuery) WithGroup(opts ...func(*GroupQuery)) *APIKeyQuery { func (_q *ApiKeyQuery) WithGroup(opts ...func(*GroupQuery)) *ApiKeyQuery {
query := (&GroupClient{config: _q.config}).Query() query := (&GroupClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
...@@ -356,7 +356,7 @@ func (_q *APIKeyQuery) WithGroup(opts ...func(*GroupQuery)) *APIKeyQuery { ...@@ -356,7 +356,7 @@ func (_q *APIKeyQuery) WithGroup(opts ...func(*GroupQuery)) *APIKeyQuery {
// WithUsageLogs tells the query-builder to eager-load the nodes that are connected to // WithUsageLogs tells the query-builder to eager-load the nodes that are connected to
// the "usage_logs" edge. The optional arguments are used to configure the query builder of the edge. // the "usage_logs" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *APIKeyQuery) WithUsageLogs(opts ...func(*UsageLogQuery)) *APIKeyQuery { func (_q *ApiKeyQuery) WithUsageLogs(opts ...func(*UsageLogQuery)) *ApiKeyQuery {
query := (&UsageLogClient{config: _q.config}).Query() query := (&UsageLogClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
...@@ -375,13 +375,13 @@ func (_q *APIKeyQuery) WithUsageLogs(opts ...func(*UsageLogQuery)) *APIKeyQuery ...@@ -375,13 +375,13 @@ func (_q *APIKeyQuery) WithUsageLogs(opts ...func(*UsageLogQuery)) *APIKeyQuery
// Count int `json:"count,omitempty"` // Count int `json:"count,omitempty"`
// } // }
// //
// client.APIKey.Query(). // client.ApiKey.Query().
// GroupBy(apikey.FieldCreatedAt). // GroupBy(apikey.FieldCreatedAt).
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (_q *APIKeyQuery) GroupBy(field string, fields ...string) *APIKeyGroupBy { func (_q *ApiKeyQuery) GroupBy(field string, fields ...string) *ApiKeyGroupBy {
_q.ctx.Fields = append([]string{field}, fields...) _q.ctx.Fields = append([]string{field}, fields...)
grbuild := &APIKeyGroupBy{build: _q} grbuild := &ApiKeyGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields grbuild.flds = &_q.ctx.Fields
grbuild.label = apikey.Label grbuild.label = apikey.Label
grbuild.scan = grbuild.Scan grbuild.scan = grbuild.Scan
...@@ -397,23 +397,23 @@ func (_q *APIKeyQuery) GroupBy(field string, fields ...string) *APIKeyGroupBy { ...@@ -397,23 +397,23 @@ func (_q *APIKeyQuery) GroupBy(field string, fields ...string) *APIKeyGroupBy {
// CreatedAt time.Time `json:"created_at,omitempty"` // CreatedAt time.Time `json:"created_at,omitempty"`
// } // }
// //
// client.APIKey.Query(). // client.ApiKey.Query().
// Select(apikey.FieldCreatedAt). // Select(apikey.FieldCreatedAt).
// Scan(ctx, &v) // Scan(ctx, &v)
func (_q *APIKeyQuery) Select(fields ...string) *APIKeySelect { func (_q *ApiKeyQuery) Select(fields ...string) *ApiKeySelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...) _q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &APIKeySelect{APIKeyQuery: _q} sbuild := &ApiKeySelect{ApiKeyQuery: _q}
sbuild.label = apikey.Label sbuild.label = apikey.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild return sbuild
} }
// Aggregate returns a APIKeySelect configured with the given aggregations. // Aggregate returns a ApiKeySelect configured with the given aggregations.
func (_q *APIKeyQuery) Aggregate(fns ...AggregateFunc) *APIKeySelect { func (_q *ApiKeyQuery) Aggregate(fns ...AggregateFunc) *ApiKeySelect {
return _q.Select().Aggregate(fns...) return _q.Select().Aggregate(fns...)
} }
func (_q *APIKeyQuery) prepareQuery(ctx context.Context) error { func (_q *ApiKeyQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters { for _, inter := range _q.inters {
if inter == nil { if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
...@@ -439,9 +439,9 @@ func (_q *APIKeyQuery) prepareQuery(ctx context.Context) error { ...@@ -439,9 +439,9 @@ func (_q *APIKeyQuery) prepareQuery(ctx context.Context) error {
return nil return nil
} }
func (_q *APIKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*APIKey, error) { func (_q *ApiKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ApiKey, error) {
var ( var (
nodes = []*APIKey{} nodes = []*ApiKey{}
_spec = _q.querySpec() _spec = _q.querySpec()
loadedTypes = [3]bool{ loadedTypes = [3]bool{
_q.withUser != nil, _q.withUser != nil,
...@@ -450,10 +450,10 @@ func (_q *APIKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*APIKe ...@@ -450,10 +450,10 @@ func (_q *APIKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*APIKe
} }
) )
_spec.ScanValues = func(columns []string) ([]any, error) { _spec.ScanValues = func(columns []string) ([]any, error) {
return (*APIKey).scanValues(nil, columns) return (*ApiKey).scanValues(nil, columns)
} }
_spec.Assign = func(columns []string, values []any) error { _spec.Assign = func(columns []string, values []any) error {
node := &APIKey{config: _q.config} node := &ApiKey{config: _q.config}
nodes = append(nodes, node) nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values) return node.assignValues(columns, values)
...@@ -469,29 +469,29 @@ func (_q *APIKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*APIKe ...@@ -469,29 +469,29 @@ func (_q *APIKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*APIKe
} }
if query := _q.withUser; query != nil { if query := _q.withUser; query != nil {
if err := _q.loadUser(ctx, query, nodes, nil, if err := _q.loadUser(ctx, query, nodes, nil,
func(n *APIKey, e *User) { n.Edges.User = e }); err != nil { func(n *ApiKey, e *User) { n.Edges.User = e }); err != nil {
return nil, err return nil, err
} }
} }
if query := _q.withGroup; query != nil { if query := _q.withGroup; query != nil {
if err := _q.loadGroup(ctx, query, nodes, nil, if err := _q.loadGroup(ctx, query, nodes, nil,
func(n *APIKey, e *Group) { n.Edges.Group = e }); err != nil { func(n *ApiKey, e *Group) { n.Edges.Group = e }); err != nil {
return nil, err return nil, err
} }
} }
if query := _q.withUsageLogs; query != nil { if query := _q.withUsageLogs; query != nil {
if err := _q.loadUsageLogs(ctx, query, nodes, if err := _q.loadUsageLogs(ctx, query, nodes,
func(n *APIKey) { n.Edges.UsageLogs = []*UsageLog{} }, func(n *ApiKey) { n.Edges.UsageLogs = []*UsageLog{} },
func(n *APIKey, e *UsageLog) { n.Edges.UsageLogs = append(n.Edges.UsageLogs, e) }); err != nil { func(n *ApiKey, e *UsageLog) { n.Edges.UsageLogs = append(n.Edges.UsageLogs, e) }); err != nil {
return nil, err return nil, err
} }
} }
return nodes, nil return nodes, nil
} }
func (_q *APIKeyQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*APIKey, init func(*APIKey), assign func(*APIKey, *User)) error { func (_q *ApiKeyQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*ApiKey, init func(*ApiKey), assign func(*ApiKey, *User)) error {
ids := make([]int64, 0, len(nodes)) ids := make([]int64, 0, len(nodes))
nodeids := make(map[int64][]*APIKey) nodeids := make(map[int64][]*ApiKey)
for i := range nodes { for i := range nodes {
fk := nodes[i].UserID fk := nodes[i].UserID
if _, ok := nodeids[fk]; !ok { if _, ok := nodeids[fk]; !ok {
...@@ -518,9 +518,9 @@ func (_q *APIKeyQuery) loadUser(ctx context.Context, query *UserQuery, nodes []* ...@@ -518,9 +518,9 @@ func (_q *APIKeyQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*
} }
return nil return nil
} }
func (_q *APIKeyQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*APIKey, init func(*APIKey), assign func(*APIKey, *Group)) error { func (_q *ApiKeyQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*ApiKey, init func(*ApiKey), assign func(*ApiKey, *Group)) error {
ids := make([]int64, 0, len(nodes)) ids := make([]int64, 0, len(nodes))
nodeids := make(map[int64][]*APIKey) nodeids := make(map[int64][]*ApiKey)
for i := range nodes { for i := range nodes {
if nodes[i].GroupID == nil { if nodes[i].GroupID == nil {
continue continue
...@@ -550,9 +550,9 @@ func (_q *APIKeyQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes [ ...@@ -550,9 +550,9 @@ func (_q *APIKeyQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes [
} }
return nil return nil
} }
func (_q *APIKeyQuery) loadUsageLogs(ctx context.Context, query *UsageLogQuery, nodes []*APIKey, init func(*APIKey), assign func(*APIKey, *UsageLog)) error { func (_q *ApiKeyQuery) loadUsageLogs(ctx context.Context, query *UsageLogQuery, nodes []*ApiKey, init func(*ApiKey), assign func(*ApiKey, *UsageLog)) error {
fks := make([]driver.Value, 0, len(nodes)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int64]*APIKey) nodeids := make(map[int64]*ApiKey)
for i := range nodes { for i := range nodes {
fks = append(fks, nodes[i].ID) fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i] nodeids[nodes[i].ID] = nodes[i]
...@@ -581,7 +581,7 @@ func (_q *APIKeyQuery) loadUsageLogs(ctx context.Context, query *UsageLogQuery, ...@@ -581,7 +581,7 @@ func (_q *APIKeyQuery) loadUsageLogs(ctx context.Context, query *UsageLogQuery,
return nil return nil
} }
func (_q *APIKeyQuery) sqlCount(ctx context.Context) (int, error) { func (_q *ApiKeyQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec() _spec := _q.querySpec()
_spec.Node.Columns = _q.ctx.Fields _spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 { if len(_q.ctx.Fields) > 0 {
...@@ -590,7 +590,7 @@ func (_q *APIKeyQuery) sqlCount(ctx context.Context) (int, error) { ...@@ -590,7 +590,7 @@ func (_q *APIKeyQuery) sqlCount(ctx context.Context) (int, error) {
return sqlgraph.CountNodes(ctx, _q.driver, _spec) return sqlgraph.CountNodes(ctx, _q.driver, _spec)
} }
func (_q *APIKeyQuery) querySpec() *sqlgraph.QuerySpec { func (_q *ApiKeyQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(apikey.Table, apikey.Columns, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64)) _spec := sqlgraph.NewQuerySpec(apikey.Table, apikey.Columns, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64))
_spec.From = _q.sql _spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil { if unique := _q.ctx.Unique; unique != nil {
...@@ -636,7 +636,7 @@ func (_q *APIKeyQuery) querySpec() *sqlgraph.QuerySpec { ...@@ -636,7 +636,7 @@ func (_q *APIKeyQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (_q *APIKeyQuery) sqlQuery(ctx context.Context) *sql.Selector { func (_q *ApiKeyQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect()) builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(apikey.Table) t1 := builder.Table(apikey.Table)
columns := _q.ctx.Fields columns := _q.ctx.Fields
...@@ -668,28 +668,28 @@ func (_q *APIKeyQuery) sqlQuery(ctx context.Context) *sql.Selector { ...@@ -668,28 +668,28 @@ func (_q *APIKeyQuery) sqlQuery(ctx context.Context) *sql.Selector {
return selector return selector
} }
// APIKeyGroupBy is the group-by builder for APIKey entities. // ApiKeyGroupBy is the group-by builder for ApiKey entities.
type APIKeyGroupBy struct { type ApiKeyGroupBy struct {
selector selector
build *APIKeyQuery build *ApiKeyQuery
} }
// Aggregate adds the given aggregation functions to the group-by query. // Aggregate adds the given aggregation functions to the group-by query.
func (_g *APIKeyGroupBy) Aggregate(fns ...AggregateFunc) *APIKeyGroupBy { func (_g *ApiKeyGroupBy) Aggregate(fns ...AggregateFunc) *ApiKeyGroupBy {
_g.fns = append(_g.fns, fns...) _g.fns = append(_g.fns, fns...)
return _g return _g
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (_g *APIKeyGroupBy) Scan(ctx context.Context, v any) error { func (_g *ApiKeyGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil { if err := _g.build.prepareQuery(ctx); err != nil {
return err return err
} }
return scanWithInterceptors[*APIKeyQuery, *APIKeyGroupBy](ctx, _g.build, _g, _g.build.inters, v) return scanWithInterceptors[*ApiKeyQuery, *ApiKeyGroupBy](ctx, _g.build, _g, _g.build.inters, v)
} }
func (_g *APIKeyGroupBy) sqlScan(ctx context.Context, root *APIKeyQuery, v any) error { func (_g *ApiKeyGroupBy) sqlScan(ctx context.Context, root *ApiKeyQuery, v any) error {
selector := root.sqlQuery(ctx).Select() selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns)) aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns { for _, fn := range _g.fns {
...@@ -716,28 +716,28 @@ func (_g *APIKeyGroupBy) sqlScan(ctx context.Context, root *APIKeyQuery, v any) ...@@ -716,28 +716,28 @@ func (_g *APIKeyGroupBy) sqlScan(ctx context.Context, root *APIKeyQuery, v any)
return sql.ScanSlice(rows, v) return sql.ScanSlice(rows, v)
} }
// APIKeySelect is the builder for selecting fields of APIKey entities. // ApiKeySelect is the builder for selecting fields of ApiKey entities.
type APIKeySelect struct { type ApiKeySelect struct {
*APIKeyQuery *ApiKeyQuery
selector selector
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
func (_s *APIKeySelect) Aggregate(fns ...AggregateFunc) *APIKeySelect { func (_s *ApiKeySelect) Aggregate(fns ...AggregateFunc) *ApiKeySelect {
_s.fns = append(_s.fns, fns...) _s.fns = append(_s.fns, fns...)
return _s return _s
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (_s *APIKeySelect) Scan(ctx context.Context, v any) error { func (_s *ApiKeySelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil { if err := _s.prepareQuery(ctx); err != nil {
return err return err
} }
return scanWithInterceptors[*APIKeyQuery, *APIKeySelect](ctx, _s.APIKeyQuery, _s, _s.inters, v) return scanWithInterceptors[*ApiKeyQuery, *ApiKeySelect](ctx, _s.ApiKeyQuery, _s, _s.inters, v)
} }
func (_s *APIKeySelect) sqlScan(ctx context.Context, root *APIKeyQuery, v any) error { func (_s *ApiKeySelect) sqlScan(ctx context.Context, root *ApiKeyQuery, v any) error {
selector := root.sqlQuery(ctx) selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns)) aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns { for _, fn := range _s.fns {
......
...@@ -18,33 +18,33 @@ import ( ...@@ -18,33 +18,33 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user" "github.com/Wei-Shaw/sub2api/ent/user"
) )
// APIKeyUpdate is the builder for updating APIKey entities. // ApiKeyUpdate is the builder for updating ApiKey entities.
type APIKeyUpdate struct { type ApiKeyUpdate struct {
config config
hooks []Hook hooks []Hook
mutation *APIKeyMutation mutation *ApiKeyMutation
} }
// Where appends a list predicates to the APIKeyUpdate builder. // Where appends a list predicates to the ApiKeyUpdate builder.
func (_u *APIKeyUpdate) Where(ps ...predicate.APIKey) *APIKeyUpdate { func (_u *ApiKeyUpdate) Where(ps ...predicate.ApiKey) *ApiKeyUpdate {
_u.mutation.Where(ps...) _u.mutation.Where(ps...)
return _u return _u
} }
// SetUpdatedAt sets the "updated_at" field. // SetUpdatedAt sets the "updated_at" field.
func (_u *APIKeyUpdate) SetUpdatedAt(v time.Time) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetUpdatedAt(v time.Time) *ApiKeyUpdate {
_u.mutation.SetUpdatedAt(v) _u.mutation.SetUpdatedAt(v)
return _u return _u
} }
// SetDeletedAt sets the "deleted_at" field. // SetDeletedAt sets the "deleted_at" field.
func (_u *APIKeyUpdate) SetDeletedAt(v time.Time) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetDeletedAt(v time.Time) *ApiKeyUpdate {
_u.mutation.SetDeletedAt(v) _u.mutation.SetDeletedAt(v)
return _u return _u
} }
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_u *APIKeyUpdate) SetNillableDeletedAt(v *time.Time) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetNillableDeletedAt(v *time.Time) *ApiKeyUpdate {
if v != nil { if v != nil {
_u.SetDeletedAt(*v) _u.SetDeletedAt(*v)
} }
...@@ -52,19 +52,19 @@ func (_u *APIKeyUpdate) SetNillableDeletedAt(v *time.Time) *APIKeyUpdate { ...@@ -52,19 +52,19 @@ func (_u *APIKeyUpdate) SetNillableDeletedAt(v *time.Time) *APIKeyUpdate {
} }
// ClearDeletedAt clears the value of the "deleted_at" field. // ClearDeletedAt clears the value of the "deleted_at" field.
func (_u *APIKeyUpdate) ClearDeletedAt() *APIKeyUpdate { func (_u *ApiKeyUpdate) ClearDeletedAt() *ApiKeyUpdate {
_u.mutation.ClearDeletedAt() _u.mutation.ClearDeletedAt()
return _u return _u
} }
// SetUserID sets the "user_id" field. // SetUserID sets the "user_id" field.
func (_u *APIKeyUpdate) SetUserID(v int64) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetUserID(v int64) *ApiKeyUpdate {
_u.mutation.SetUserID(v) _u.mutation.SetUserID(v)
return _u return _u
} }
// SetNillableUserID sets the "user_id" field if the given value is not nil. // SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *APIKeyUpdate) SetNillableUserID(v *int64) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetNillableUserID(v *int64) *ApiKeyUpdate {
if v != nil { if v != nil {
_u.SetUserID(*v) _u.SetUserID(*v)
} }
...@@ -72,13 +72,13 @@ func (_u *APIKeyUpdate) SetNillableUserID(v *int64) *APIKeyUpdate { ...@@ -72,13 +72,13 @@ func (_u *APIKeyUpdate) SetNillableUserID(v *int64) *APIKeyUpdate {
} }
// SetKey sets the "key" field. // SetKey sets the "key" field.
func (_u *APIKeyUpdate) SetKey(v string) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetKey(v string) *ApiKeyUpdate {
_u.mutation.SetKey(v) _u.mutation.SetKey(v)
return _u return _u
} }
// SetNillableKey sets the "key" field if the given value is not nil. // SetNillableKey sets the "key" field if the given value is not nil.
func (_u *APIKeyUpdate) SetNillableKey(v *string) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetNillableKey(v *string) *ApiKeyUpdate {
if v != nil { if v != nil {
_u.SetKey(*v) _u.SetKey(*v)
} }
...@@ -86,13 +86,13 @@ func (_u *APIKeyUpdate) SetNillableKey(v *string) *APIKeyUpdate { ...@@ -86,13 +86,13 @@ func (_u *APIKeyUpdate) SetNillableKey(v *string) *APIKeyUpdate {
} }
// SetName sets the "name" field. // SetName sets the "name" field.
func (_u *APIKeyUpdate) SetName(v string) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetName(v string) *ApiKeyUpdate {
_u.mutation.SetName(v) _u.mutation.SetName(v)
return _u return _u
} }
// SetNillableName sets the "name" field if the given value is not nil. // SetNillableName sets the "name" field if the given value is not nil.
func (_u *APIKeyUpdate) SetNillableName(v *string) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetNillableName(v *string) *ApiKeyUpdate {
if v != nil { if v != nil {
_u.SetName(*v) _u.SetName(*v)
} }
...@@ -100,13 +100,13 @@ func (_u *APIKeyUpdate) SetNillableName(v *string) *APIKeyUpdate { ...@@ -100,13 +100,13 @@ func (_u *APIKeyUpdate) SetNillableName(v *string) *APIKeyUpdate {
} }
// SetGroupID sets the "group_id" field. // SetGroupID sets the "group_id" field.
func (_u *APIKeyUpdate) SetGroupID(v int64) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetGroupID(v int64) *ApiKeyUpdate {
_u.mutation.SetGroupID(v) _u.mutation.SetGroupID(v)
return _u return _u
} }
// SetNillableGroupID sets the "group_id" field if the given value is not nil. // SetNillableGroupID sets the "group_id" field if the given value is not nil.
func (_u *APIKeyUpdate) SetNillableGroupID(v *int64) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetNillableGroupID(v *int64) *ApiKeyUpdate {
if v != nil { if v != nil {
_u.SetGroupID(*v) _u.SetGroupID(*v)
} }
...@@ -114,19 +114,19 @@ func (_u *APIKeyUpdate) SetNillableGroupID(v *int64) *APIKeyUpdate { ...@@ -114,19 +114,19 @@ func (_u *APIKeyUpdate) SetNillableGroupID(v *int64) *APIKeyUpdate {
} }
// ClearGroupID clears the value of the "group_id" field. // ClearGroupID clears the value of the "group_id" field.
func (_u *APIKeyUpdate) ClearGroupID() *APIKeyUpdate { func (_u *ApiKeyUpdate) ClearGroupID() *ApiKeyUpdate {
_u.mutation.ClearGroupID() _u.mutation.ClearGroupID()
return _u return _u
} }
// SetStatus sets the "status" field. // SetStatus sets the "status" field.
func (_u *APIKeyUpdate) SetStatus(v string) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetStatus(v string) *ApiKeyUpdate {
_u.mutation.SetStatus(v) _u.mutation.SetStatus(v)
return _u return _u
} }
// SetNillableStatus sets the "status" field if the given value is not nil. // SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *APIKeyUpdate) SetNillableStatus(v *string) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetNillableStatus(v *string) *ApiKeyUpdate {
if v != nil { if v != nil {
_u.SetStatus(*v) _u.SetStatus(*v)
} }
...@@ -134,23 +134,23 @@ func (_u *APIKeyUpdate) SetNillableStatus(v *string) *APIKeyUpdate { ...@@ -134,23 +134,23 @@ func (_u *APIKeyUpdate) SetNillableStatus(v *string) *APIKeyUpdate {
} }
// SetUser sets the "user" edge to the User entity. // SetUser sets the "user" edge to the User entity.
func (_u *APIKeyUpdate) SetUser(v *User) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetUser(v *User) *ApiKeyUpdate {
return _u.SetUserID(v.ID) return _u.SetUserID(v.ID)
} }
// SetGroup sets the "group" edge to the Group entity. // SetGroup sets the "group" edge to the Group entity.
func (_u *APIKeyUpdate) SetGroup(v *Group) *APIKeyUpdate { func (_u *ApiKeyUpdate) SetGroup(v *Group) *ApiKeyUpdate {
return _u.SetGroupID(v.ID) return _u.SetGroupID(v.ID)
} }
// AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
func (_u *APIKeyUpdate) AddUsageLogIDs(ids ...int64) *APIKeyUpdate { func (_u *ApiKeyUpdate) AddUsageLogIDs(ids ...int64) *ApiKeyUpdate {
_u.mutation.AddUsageLogIDs(ids...) _u.mutation.AddUsageLogIDs(ids...)
return _u return _u
} }
// AddUsageLogs adds the "usage_logs" edges to the UsageLog entity. // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
func (_u *APIKeyUpdate) AddUsageLogs(v ...*UsageLog) *APIKeyUpdate { func (_u *ApiKeyUpdate) AddUsageLogs(v ...*UsageLog) *ApiKeyUpdate {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
...@@ -158,37 +158,37 @@ func (_u *APIKeyUpdate) AddUsageLogs(v ...*UsageLog) *APIKeyUpdate { ...@@ -158,37 +158,37 @@ func (_u *APIKeyUpdate) AddUsageLogs(v ...*UsageLog) *APIKeyUpdate {
return _u.AddUsageLogIDs(ids...) return _u.AddUsageLogIDs(ids...)
} }
// Mutation returns the APIKeyMutation object of the builder. // Mutation returns the ApiKeyMutation object of the builder.
func (_u *APIKeyUpdate) Mutation() *APIKeyMutation { func (_u *ApiKeyUpdate) Mutation() *ApiKeyMutation {
return _u.mutation return _u.mutation
} }
// ClearUser clears the "user" edge to the User entity. // ClearUser clears the "user" edge to the User entity.
func (_u *APIKeyUpdate) ClearUser() *APIKeyUpdate { func (_u *ApiKeyUpdate) ClearUser() *ApiKeyUpdate {
_u.mutation.ClearUser() _u.mutation.ClearUser()
return _u return _u
} }
// ClearGroup clears the "group" edge to the Group entity. // ClearGroup clears the "group" edge to the Group entity.
func (_u *APIKeyUpdate) ClearGroup() *APIKeyUpdate { func (_u *ApiKeyUpdate) ClearGroup() *ApiKeyUpdate {
_u.mutation.ClearGroup() _u.mutation.ClearGroup()
return _u return _u
} }
// ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity. // ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
func (_u *APIKeyUpdate) ClearUsageLogs() *APIKeyUpdate { func (_u *ApiKeyUpdate) ClearUsageLogs() *ApiKeyUpdate {
_u.mutation.ClearUsageLogs() _u.mutation.ClearUsageLogs()
return _u return _u
} }
// RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs. // RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
func (_u *APIKeyUpdate) RemoveUsageLogIDs(ids ...int64) *APIKeyUpdate { func (_u *ApiKeyUpdate) RemoveUsageLogIDs(ids ...int64) *ApiKeyUpdate {
_u.mutation.RemoveUsageLogIDs(ids...) _u.mutation.RemoveUsageLogIDs(ids...)
return _u return _u
} }
// RemoveUsageLogs removes "usage_logs" edges to UsageLog entities. // RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
func (_u *APIKeyUpdate) RemoveUsageLogs(v ...*UsageLog) *APIKeyUpdate { func (_u *ApiKeyUpdate) RemoveUsageLogs(v ...*UsageLog) *ApiKeyUpdate {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
...@@ -197,7 +197,7 @@ func (_u *APIKeyUpdate) RemoveUsageLogs(v ...*UsageLog) *APIKeyUpdate { ...@@ -197,7 +197,7 @@ func (_u *APIKeyUpdate) RemoveUsageLogs(v ...*UsageLog) *APIKeyUpdate {
} }
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (_u *APIKeyUpdate) Save(ctx context.Context) (int, error) { func (_u *ApiKeyUpdate) Save(ctx context.Context) (int, error) {
if err := _u.defaults(); err != nil { if err := _u.defaults(); err != nil {
return 0, err return 0, err
} }
...@@ -205,7 +205,7 @@ func (_u *APIKeyUpdate) Save(ctx context.Context) (int, error) { ...@@ -205,7 +205,7 @@ func (_u *APIKeyUpdate) Save(ctx context.Context) (int, error) {
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (_u *APIKeyUpdate) SaveX(ctx context.Context) int { func (_u *ApiKeyUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx) affected, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -214,20 +214,20 @@ func (_u *APIKeyUpdate) SaveX(ctx context.Context) int { ...@@ -214,20 +214,20 @@ func (_u *APIKeyUpdate) SaveX(ctx context.Context) int {
} }
// Exec executes the query. // Exec executes the query.
func (_u *APIKeyUpdate) Exec(ctx context.Context) error { func (_u *ApiKeyUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (_u *APIKeyUpdate) ExecX(ctx context.Context) { func (_u *ApiKeyUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// defaults sets the default values of the builder before save. // defaults sets the default values of the builder before save.
func (_u *APIKeyUpdate) defaults() error { func (_u *ApiKeyUpdate) defaults() error {
if _, ok := _u.mutation.UpdatedAt(); !ok { if _, ok := _u.mutation.UpdatedAt(); !ok {
if apikey.UpdateDefaultUpdatedAt == nil { if apikey.UpdateDefaultUpdatedAt == nil {
return fmt.Errorf("ent: uninitialized apikey.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized apikey.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
...@@ -239,29 +239,29 @@ func (_u *APIKeyUpdate) defaults() error { ...@@ -239,29 +239,29 @@ func (_u *APIKeyUpdate) defaults() error {
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (_u *APIKeyUpdate) check() error { func (_u *ApiKeyUpdate) check() error {
if v, ok := _u.mutation.Key(); ok { if v, ok := _u.mutation.Key(); ok {
if err := apikey.KeyValidator(v); err != nil { if err := apikey.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "APIKey.key": %w`, err)} return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "ApiKey.key": %w`, err)}
} }
} }
if v, ok := _u.mutation.Name(); ok { if v, ok := _u.mutation.Name(); ok {
if err := apikey.NameValidator(v); err != nil { if err := apikey.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "APIKey.name": %w`, err)} return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ApiKey.name": %w`, err)}
} }
} }
if v, ok := _u.mutation.Status(); ok { if v, ok := _u.mutation.Status(); ok {
if err := apikey.StatusValidator(v); err != nil { if err := apikey.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "APIKey.status": %w`, err)} return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ApiKey.status": %w`, err)}
} }
} }
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "APIKey.user"`) return errors.New(`ent: clearing a required unique edge "ApiKey.user"`)
} }
return nil return nil
} }
func (_u *APIKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) { func (_u *ApiKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil { if err := _u.check(); err != nil {
return _node, err return _node, err
} }
...@@ -406,28 +406,28 @@ func (_u *APIKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) { ...@@ -406,28 +406,28 @@ func (_u *APIKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) {
return _node, nil return _node, nil
} }
// APIKeyUpdateOne is the builder for updating a single APIKey entity. // ApiKeyUpdateOne is the builder for updating a single ApiKey entity.
type APIKeyUpdateOne struct { type ApiKeyUpdateOne struct {
config config
fields []string fields []string
hooks []Hook hooks []Hook
mutation *APIKeyMutation mutation *ApiKeyMutation
} }
// SetUpdatedAt sets the "updated_at" field. // SetUpdatedAt sets the "updated_at" field.
func (_u *APIKeyUpdateOne) SetUpdatedAt(v time.Time) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetUpdatedAt(v time.Time) *ApiKeyUpdateOne {
_u.mutation.SetUpdatedAt(v) _u.mutation.SetUpdatedAt(v)
return _u return _u
} }
// SetDeletedAt sets the "deleted_at" field. // SetDeletedAt sets the "deleted_at" field.
func (_u *APIKeyUpdateOne) SetDeletedAt(v time.Time) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetDeletedAt(v time.Time) *ApiKeyUpdateOne {
_u.mutation.SetDeletedAt(v) _u.mutation.SetDeletedAt(v)
return _u return _u
} }
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (_u *APIKeyUpdateOne) SetNillableDeletedAt(v *time.Time) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetNillableDeletedAt(v *time.Time) *ApiKeyUpdateOne {
if v != nil { if v != nil {
_u.SetDeletedAt(*v) _u.SetDeletedAt(*v)
} }
...@@ -435,19 +435,19 @@ func (_u *APIKeyUpdateOne) SetNillableDeletedAt(v *time.Time) *APIKeyUpdateOne { ...@@ -435,19 +435,19 @@ func (_u *APIKeyUpdateOne) SetNillableDeletedAt(v *time.Time) *APIKeyUpdateOne {
} }
// ClearDeletedAt clears the value of the "deleted_at" field. // ClearDeletedAt clears the value of the "deleted_at" field.
func (_u *APIKeyUpdateOne) ClearDeletedAt() *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) ClearDeletedAt() *ApiKeyUpdateOne {
_u.mutation.ClearDeletedAt() _u.mutation.ClearDeletedAt()
return _u return _u
} }
// SetUserID sets the "user_id" field. // SetUserID sets the "user_id" field.
func (_u *APIKeyUpdateOne) SetUserID(v int64) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetUserID(v int64) *ApiKeyUpdateOne {
_u.mutation.SetUserID(v) _u.mutation.SetUserID(v)
return _u return _u
} }
// SetNillableUserID sets the "user_id" field if the given value is not nil. // SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *APIKeyUpdateOne) SetNillableUserID(v *int64) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetNillableUserID(v *int64) *ApiKeyUpdateOne {
if v != nil { if v != nil {
_u.SetUserID(*v) _u.SetUserID(*v)
} }
...@@ -455,13 +455,13 @@ func (_u *APIKeyUpdateOne) SetNillableUserID(v *int64) *APIKeyUpdateOne { ...@@ -455,13 +455,13 @@ func (_u *APIKeyUpdateOne) SetNillableUserID(v *int64) *APIKeyUpdateOne {
} }
// SetKey sets the "key" field. // SetKey sets the "key" field.
func (_u *APIKeyUpdateOne) SetKey(v string) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetKey(v string) *ApiKeyUpdateOne {
_u.mutation.SetKey(v) _u.mutation.SetKey(v)
return _u return _u
} }
// SetNillableKey sets the "key" field if the given value is not nil. // SetNillableKey sets the "key" field if the given value is not nil.
func (_u *APIKeyUpdateOne) SetNillableKey(v *string) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetNillableKey(v *string) *ApiKeyUpdateOne {
if v != nil { if v != nil {
_u.SetKey(*v) _u.SetKey(*v)
} }
...@@ -469,13 +469,13 @@ func (_u *APIKeyUpdateOne) SetNillableKey(v *string) *APIKeyUpdateOne { ...@@ -469,13 +469,13 @@ func (_u *APIKeyUpdateOne) SetNillableKey(v *string) *APIKeyUpdateOne {
} }
// SetName sets the "name" field. // SetName sets the "name" field.
func (_u *APIKeyUpdateOne) SetName(v string) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetName(v string) *ApiKeyUpdateOne {
_u.mutation.SetName(v) _u.mutation.SetName(v)
return _u return _u
} }
// SetNillableName sets the "name" field if the given value is not nil. // SetNillableName sets the "name" field if the given value is not nil.
func (_u *APIKeyUpdateOne) SetNillableName(v *string) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetNillableName(v *string) *ApiKeyUpdateOne {
if v != nil { if v != nil {
_u.SetName(*v) _u.SetName(*v)
} }
...@@ -483,13 +483,13 @@ func (_u *APIKeyUpdateOne) SetNillableName(v *string) *APIKeyUpdateOne { ...@@ -483,13 +483,13 @@ func (_u *APIKeyUpdateOne) SetNillableName(v *string) *APIKeyUpdateOne {
} }
// SetGroupID sets the "group_id" field. // SetGroupID sets the "group_id" field.
func (_u *APIKeyUpdateOne) SetGroupID(v int64) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetGroupID(v int64) *ApiKeyUpdateOne {
_u.mutation.SetGroupID(v) _u.mutation.SetGroupID(v)
return _u return _u
} }
// SetNillableGroupID sets the "group_id" field if the given value is not nil. // SetNillableGroupID sets the "group_id" field if the given value is not nil.
func (_u *APIKeyUpdateOne) SetNillableGroupID(v *int64) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetNillableGroupID(v *int64) *ApiKeyUpdateOne {
if v != nil { if v != nil {
_u.SetGroupID(*v) _u.SetGroupID(*v)
} }
...@@ -497,19 +497,19 @@ func (_u *APIKeyUpdateOne) SetNillableGroupID(v *int64) *APIKeyUpdateOne { ...@@ -497,19 +497,19 @@ func (_u *APIKeyUpdateOne) SetNillableGroupID(v *int64) *APIKeyUpdateOne {
} }
// ClearGroupID clears the value of the "group_id" field. // ClearGroupID clears the value of the "group_id" field.
func (_u *APIKeyUpdateOne) ClearGroupID() *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) ClearGroupID() *ApiKeyUpdateOne {
_u.mutation.ClearGroupID() _u.mutation.ClearGroupID()
return _u return _u
} }
// SetStatus sets the "status" field. // SetStatus sets the "status" field.
func (_u *APIKeyUpdateOne) SetStatus(v string) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetStatus(v string) *ApiKeyUpdateOne {
_u.mutation.SetStatus(v) _u.mutation.SetStatus(v)
return _u return _u
} }
// SetNillableStatus sets the "status" field if the given value is not nil. // SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *APIKeyUpdateOne) SetNillableStatus(v *string) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetNillableStatus(v *string) *ApiKeyUpdateOne {
if v != nil { if v != nil {
_u.SetStatus(*v) _u.SetStatus(*v)
} }
...@@ -517,23 +517,23 @@ func (_u *APIKeyUpdateOne) SetNillableStatus(v *string) *APIKeyUpdateOne { ...@@ -517,23 +517,23 @@ func (_u *APIKeyUpdateOne) SetNillableStatus(v *string) *APIKeyUpdateOne {
} }
// SetUser sets the "user" edge to the User entity. // SetUser sets the "user" edge to the User entity.
func (_u *APIKeyUpdateOne) SetUser(v *User) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetUser(v *User) *ApiKeyUpdateOne {
return _u.SetUserID(v.ID) return _u.SetUserID(v.ID)
} }
// SetGroup sets the "group" edge to the Group entity. // SetGroup sets the "group" edge to the Group entity.
func (_u *APIKeyUpdateOne) SetGroup(v *Group) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) SetGroup(v *Group) *ApiKeyUpdateOne {
return _u.SetGroupID(v.ID) return _u.SetGroupID(v.ID)
} }
// AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs. // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
func (_u *APIKeyUpdateOne) AddUsageLogIDs(ids ...int64) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) AddUsageLogIDs(ids ...int64) *ApiKeyUpdateOne {
_u.mutation.AddUsageLogIDs(ids...) _u.mutation.AddUsageLogIDs(ids...)
return _u return _u
} }
// AddUsageLogs adds the "usage_logs" edges to the UsageLog entity. // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
func (_u *APIKeyUpdateOne) AddUsageLogs(v ...*UsageLog) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) AddUsageLogs(v ...*UsageLog) *ApiKeyUpdateOne {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
...@@ -541,37 +541,37 @@ func (_u *APIKeyUpdateOne) AddUsageLogs(v ...*UsageLog) *APIKeyUpdateOne { ...@@ -541,37 +541,37 @@ func (_u *APIKeyUpdateOne) AddUsageLogs(v ...*UsageLog) *APIKeyUpdateOne {
return _u.AddUsageLogIDs(ids...) return _u.AddUsageLogIDs(ids...)
} }
// Mutation returns the APIKeyMutation object of the builder. // Mutation returns the ApiKeyMutation object of the builder.
func (_u *APIKeyUpdateOne) Mutation() *APIKeyMutation { func (_u *ApiKeyUpdateOne) Mutation() *ApiKeyMutation {
return _u.mutation return _u.mutation
} }
// ClearUser clears the "user" edge to the User entity. // ClearUser clears the "user" edge to the User entity.
func (_u *APIKeyUpdateOne) ClearUser() *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) ClearUser() *ApiKeyUpdateOne {
_u.mutation.ClearUser() _u.mutation.ClearUser()
return _u return _u
} }
// ClearGroup clears the "group" edge to the Group entity. // ClearGroup clears the "group" edge to the Group entity.
func (_u *APIKeyUpdateOne) ClearGroup() *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) ClearGroup() *ApiKeyUpdateOne {
_u.mutation.ClearGroup() _u.mutation.ClearGroup()
return _u return _u
} }
// ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity. // ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
func (_u *APIKeyUpdateOne) ClearUsageLogs() *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) ClearUsageLogs() *ApiKeyUpdateOne {
_u.mutation.ClearUsageLogs() _u.mutation.ClearUsageLogs()
return _u return _u
} }
// RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs. // RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
func (_u *APIKeyUpdateOne) RemoveUsageLogIDs(ids ...int64) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) RemoveUsageLogIDs(ids ...int64) *ApiKeyUpdateOne {
_u.mutation.RemoveUsageLogIDs(ids...) _u.mutation.RemoveUsageLogIDs(ids...)
return _u return _u
} }
// RemoveUsageLogs removes "usage_logs" edges to UsageLog entities. // RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
func (_u *APIKeyUpdateOne) RemoveUsageLogs(v ...*UsageLog) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) RemoveUsageLogs(v ...*UsageLog) *ApiKeyUpdateOne {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
...@@ -579,21 +579,21 @@ func (_u *APIKeyUpdateOne) RemoveUsageLogs(v ...*UsageLog) *APIKeyUpdateOne { ...@@ -579,21 +579,21 @@ func (_u *APIKeyUpdateOne) RemoveUsageLogs(v ...*UsageLog) *APIKeyUpdateOne {
return _u.RemoveUsageLogIDs(ids...) return _u.RemoveUsageLogIDs(ids...)
} }
// Where appends a list predicates to the APIKeyUpdate builder. // Where appends a list predicates to the ApiKeyUpdate builder.
func (_u *APIKeyUpdateOne) Where(ps ...predicate.APIKey) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) Where(ps ...predicate.ApiKey) *ApiKeyUpdateOne {
_u.mutation.Where(ps...) _u.mutation.Where(ps...)
return _u return _u
} }
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (_u *APIKeyUpdateOne) Select(field string, fields ...string) *APIKeyUpdateOne { func (_u *ApiKeyUpdateOne) Select(field string, fields ...string) *ApiKeyUpdateOne {
_u.fields = append([]string{field}, fields...) _u.fields = append([]string{field}, fields...)
return _u return _u
} }
// Save executes the query and returns the updated APIKey entity. // Save executes the query and returns the updated ApiKey entity.
func (_u *APIKeyUpdateOne) Save(ctx context.Context) (*APIKey, error) { func (_u *ApiKeyUpdateOne) Save(ctx context.Context) (*ApiKey, error) {
if err := _u.defaults(); err != nil { if err := _u.defaults(); err != nil {
return nil, err return nil, err
} }
...@@ -601,7 +601,7 @@ func (_u *APIKeyUpdateOne) Save(ctx context.Context) (*APIKey, error) { ...@@ -601,7 +601,7 @@ func (_u *APIKeyUpdateOne) Save(ctx context.Context) (*APIKey, error) {
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (_u *APIKeyUpdateOne) SaveX(ctx context.Context) *APIKey { func (_u *ApiKeyUpdateOne) SaveX(ctx context.Context) *ApiKey {
node, err := _u.Save(ctx) node, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
...@@ -610,20 +610,20 @@ func (_u *APIKeyUpdateOne) SaveX(ctx context.Context) *APIKey { ...@@ -610,20 +610,20 @@ func (_u *APIKeyUpdateOne) SaveX(ctx context.Context) *APIKey {
} }
// Exec executes the query on the entity. // Exec executes the query on the entity.
func (_u *APIKeyUpdateOne) Exec(ctx context.Context) error { func (_u *ApiKeyUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (_u *APIKeyUpdateOne) ExecX(ctx context.Context) { func (_u *ApiKeyUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// defaults sets the default values of the builder before save. // defaults sets the default values of the builder before save.
func (_u *APIKeyUpdateOne) defaults() error { func (_u *ApiKeyUpdateOne) defaults() error {
if _, ok := _u.mutation.UpdatedAt(); !ok { if _, ok := _u.mutation.UpdatedAt(); !ok {
if apikey.UpdateDefaultUpdatedAt == nil { if apikey.UpdateDefaultUpdatedAt == nil {
return fmt.Errorf("ent: uninitialized apikey.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized apikey.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
...@@ -635,36 +635,36 @@ func (_u *APIKeyUpdateOne) defaults() error { ...@@ -635,36 +635,36 @@ func (_u *APIKeyUpdateOne) defaults() error {
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (_u *APIKeyUpdateOne) check() error { func (_u *ApiKeyUpdateOne) check() error {
if v, ok := _u.mutation.Key(); ok { if v, ok := _u.mutation.Key(); ok {
if err := apikey.KeyValidator(v); err != nil { if err := apikey.KeyValidator(v); err != nil {
return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "APIKey.key": %w`, err)} return &ValidationError{Name: "key", err: fmt.Errorf(`ent: validator failed for field "ApiKey.key": %w`, err)}
} }
} }
if v, ok := _u.mutation.Name(); ok { if v, ok := _u.mutation.Name(); ok {
if err := apikey.NameValidator(v); err != nil { if err := apikey.NameValidator(v); err != nil {
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "APIKey.name": %w`, err)} return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ApiKey.name": %w`, err)}
} }
} }
if v, ok := _u.mutation.Status(); ok { if v, ok := _u.mutation.Status(); ok {
if err := apikey.StatusValidator(v); err != nil { if err := apikey.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "APIKey.status": %w`, err)} return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "ApiKey.status": %w`, err)}
} }
} }
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "APIKey.user"`) return errors.New(`ent: clearing a required unique edge "ApiKey.user"`)
} }
return nil return nil
} }
func (_u *APIKeyUpdateOne) sqlSave(ctx context.Context) (_node *APIKey, err error) { func (_u *ApiKeyUpdateOne) sqlSave(ctx context.Context) (_node *ApiKey, err error) {
if err := _u.check(); err != nil { if err := _u.check(); err != nil {
return _node, err return _node, err
} }
_spec := sqlgraph.NewUpdateSpec(apikey.Table, apikey.Columns, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64)) _spec := sqlgraph.NewUpdateSpec(apikey.Table, apikey.Columns, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID() id, ok := _u.mutation.ID()
if !ok { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "APIKey.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ApiKey.id" for update`)}
} }
_spec.Node.ID.Value = id _spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 { if fields := _u.fields; len(fields) > 0 {
...@@ -807,7 +807,7 @@ func (_u *APIKeyUpdateOne) sqlSave(ctx context.Context) (_node *APIKey, err erro ...@@ -807,7 +807,7 @@ func (_u *APIKeyUpdateOne) sqlSave(ctx context.Context) (_node *APIKey, err erro
} }
_spec.Edges.Add = append(_spec.Edges.Add, edge) _spec.Edges.Add = append(_spec.Edges.Add, edge)
} }
_node = &APIKey{config: _u.config} _node = &ApiKey{config: _u.config}
_spec.Assign = _node.assignValues _spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues _spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
......
...@@ -37,12 +37,12 @@ type Client struct { ...@@ -37,12 +37,12 @@ type Client struct {
config config
// Schema is the client for creating, migrating and dropping schema. // Schema is the client for creating, migrating and dropping schema.
Schema *migrate.Schema Schema *migrate.Schema
// APIKey is the client for interacting with the APIKey builders.
APIKey *APIKeyClient
// Account is the client for interacting with the Account builders. // Account is the client for interacting with the Account builders.
Account *AccountClient Account *AccountClient
// AccountGroup is the client for interacting with the AccountGroup builders. // AccountGroup is the client for interacting with the AccountGroup builders.
AccountGroup *AccountGroupClient AccountGroup *AccountGroupClient
// ApiKey is the client for interacting with the ApiKey builders.
ApiKey *ApiKeyClient
// Group is the client for interacting with the Group builders. // Group is the client for interacting with the Group builders.
Group *GroupClient Group *GroupClient
// Proxy is the client for interacting with the Proxy builders. // Proxy is the client for interacting with the Proxy builders.
...@@ -74,9 +74,9 @@ func NewClient(opts ...Option) *Client { ...@@ -74,9 +74,9 @@ func NewClient(opts ...Option) *Client {
func (c *Client) init() { func (c *Client) init() {
c.Schema = migrate.NewSchema(c.driver) c.Schema = migrate.NewSchema(c.driver)
c.APIKey = NewAPIKeyClient(c.config)
c.Account = NewAccountClient(c.config) c.Account = NewAccountClient(c.config)
c.AccountGroup = NewAccountGroupClient(c.config) c.AccountGroup = NewAccountGroupClient(c.config)
c.ApiKey = NewApiKeyClient(c.config)
c.Group = NewGroupClient(c.config) c.Group = NewGroupClient(c.config)
c.Proxy = NewProxyClient(c.config) c.Proxy = NewProxyClient(c.config)
c.RedeemCode = NewRedeemCodeClient(c.config) c.RedeemCode = NewRedeemCodeClient(c.config)
...@@ -179,9 +179,9 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { ...@@ -179,9 +179,9 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
return &Tx{ return &Tx{
ctx: ctx, ctx: ctx,
config: cfg, config: cfg,
APIKey: NewAPIKeyClient(cfg),
Account: NewAccountClient(cfg), Account: NewAccountClient(cfg),
AccountGroup: NewAccountGroupClient(cfg), AccountGroup: NewAccountGroupClient(cfg),
ApiKey: NewApiKeyClient(cfg),
Group: NewGroupClient(cfg), Group: NewGroupClient(cfg),
Proxy: NewProxyClient(cfg), Proxy: NewProxyClient(cfg),
RedeemCode: NewRedeemCodeClient(cfg), RedeemCode: NewRedeemCodeClient(cfg),
...@@ -211,9 +211,9 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) ...@@ -211,9 +211,9 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
return &Tx{ return &Tx{
ctx: ctx, ctx: ctx,
config: cfg, config: cfg,
APIKey: NewAPIKeyClient(cfg),
Account: NewAccountClient(cfg), Account: NewAccountClient(cfg),
AccountGroup: NewAccountGroupClient(cfg), AccountGroup: NewAccountGroupClient(cfg),
ApiKey: NewApiKeyClient(cfg),
Group: NewGroupClient(cfg), Group: NewGroupClient(cfg),
Proxy: NewProxyClient(cfg), Proxy: NewProxyClient(cfg),
RedeemCode: NewRedeemCodeClient(cfg), RedeemCode: NewRedeemCodeClient(cfg),
...@@ -230,7 +230,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) ...@@ -230,7 +230,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
// Debug returns a new debug-client. It's used to get verbose logging on specific operations. // Debug returns a new debug-client. It's used to get verbose logging on specific operations.
// //
// client.Debug(). // client.Debug().
// APIKey. // Account.
// Query(). // Query().
// Count(ctx) // Count(ctx)
func (c *Client) Debug() *Client { func (c *Client) Debug() *Client {
...@@ -253,9 +253,9 @@ func (c *Client) Close() error { ...@@ -253,9 +253,9 @@ func (c *Client) Close() error {
// In order to add hooks to a specific client, call: `client.Node.Use(...)`. // In order to add hooks to a specific client, call: `client.Node.Use(...)`.
func (c *Client) Use(hooks ...Hook) { func (c *Client) Use(hooks ...Hook) {
for _, n := range []interface{ Use(...Hook) }{ for _, n := range []interface{ Use(...Hook) }{
c.APIKey, c.Account, c.AccountGroup, c.Group, c.Proxy, c.RedeemCode, c.Setting, c.Account, c.AccountGroup, c.ApiKey, c.Group, c.Proxy, c.RedeemCode, c.Setting,
c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue, c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition,
c.UserSubscription, c.UserAttributeValue, c.UserSubscription,
} { } {
n.Use(hooks...) n.Use(hooks...)
} }
...@@ -265,9 +265,9 @@ func (c *Client) Use(hooks ...Hook) { ...@@ -265,9 +265,9 @@ func (c *Client) Use(hooks ...Hook) {
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
func (c *Client) Intercept(interceptors ...Interceptor) { func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{ for _, n := range []interface{ Intercept(...Interceptor) }{
c.APIKey, c.Account, c.AccountGroup, c.Group, c.Proxy, c.RedeemCode, c.Setting, c.Account, c.AccountGroup, c.ApiKey, c.Group, c.Proxy, c.RedeemCode, c.Setting,
c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue, c.UsageLog, c.User, c.UserAllowedGroup, c.UserAttributeDefinition,
c.UserSubscription, c.UserAttributeValue, c.UserSubscription,
} { } {
n.Intercept(interceptors...) n.Intercept(interceptors...)
} }
...@@ -276,12 +276,12 @@ func (c *Client) Intercept(interceptors ...Interceptor) { ...@@ -276,12 +276,12 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
// Mutate implements the ent.Mutator interface. // Mutate implements the ent.Mutator interface.
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
switch m := m.(type) { switch m := m.(type) {
case *APIKeyMutation:
return c.APIKey.mutate(ctx, m)
case *AccountMutation: case *AccountMutation:
return c.Account.mutate(ctx, m) return c.Account.mutate(ctx, m)
case *AccountGroupMutation: case *AccountGroupMutation:
return c.AccountGroup.mutate(ctx, m) return c.AccountGroup.mutate(ctx, m)
case *ApiKeyMutation:
return c.ApiKey.mutate(ctx, m)
case *GroupMutation: case *GroupMutation:
return c.Group.mutate(ctx, m) return c.Group.mutate(ctx, m)
case *ProxyMutation: case *ProxyMutation:
...@@ -307,189 +307,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { ...@@ -307,189 +307,6 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
} }
} }
// APIKeyClient is a client for the APIKey schema.
type APIKeyClient struct {
config
}
// NewAPIKeyClient returns a client for the APIKey from the given config.
func NewAPIKeyClient(c config) *APIKeyClient {
return &APIKeyClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `apikey.Hooks(f(g(h())))`.
func (c *APIKeyClient) Use(hooks ...Hook) {
c.hooks.APIKey = append(c.hooks.APIKey, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `apikey.Intercept(f(g(h())))`.
func (c *APIKeyClient) Intercept(interceptors ...Interceptor) {
c.inters.APIKey = append(c.inters.APIKey, interceptors...)
}
// Create returns a builder for creating a APIKey entity.
func (c *APIKeyClient) Create() *APIKeyCreate {
mutation := newAPIKeyMutation(c.config, OpCreate)
return &APIKeyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of APIKey entities.
func (c *APIKeyClient) CreateBulk(builders ...*APIKeyCreate) *APIKeyCreateBulk {
return &APIKeyCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *APIKeyClient) MapCreateBulk(slice any, setFunc func(*APIKeyCreate, int)) *APIKeyCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &APIKeyCreateBulk{err: fmt.Errorf("calling to APIKeyClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*APIKeyCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &APIKeyCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for APIKey.
func (c *APIKeyClient) Update() *APIKeyUpdate {
mutation := newAPIKeyMutation(c.config, OpUpdate)
return &APIKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *APIKeyClient) UpdateOne(_m *APIKey) *APIKeyUpdateOne {
mutation := newAPIKeyMutation(c.config, OpUpdateOne, withAPIKey(_m))
return &APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *APIKeyClient) UpdateOneID(id int64) *APIKeyUpdateOne {
mutation := newAPIKeyMutation(c.config, OpUpdateOne, withAPIKeyID(id))
return &APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for APIKey.
func (c *APIKeyClient) Delete() *APIKeyDelete {
mutation := newAPIKeyMutation(c.config, OpDelete)
return &APIKeyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *APIKeyClient) DeleteOne(_m *APIKey) *APIKeyDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *APIKeyClient) DeleteOneID(id int64) *APIKeyDeleteOne {
builder := c.Delete().Where(apikey.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &APIKeyDeleteOne{builder}
}
// Query returns a query builder for APIKey.
func (c *APIKeyClient) Query() *APIKeyQuery {
return &APIKeyQuery{
config: c.config,
ctx: &QueryContext{Type: TypeAPIKey},
inters: c.Interceptors(),
}
}
// Get returns a APIKey entity by its id.
func (c *APIKeyClient) Get(ctx context.Context, id int64) (*APIKey, error) {
return c.Query().Where(apikey.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *APIKeyClient) GetX(ctx context.Context, id int64) *APIKey {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a APIKey.
func (c *APIKeyClient) QueryUser(_m *APIKey) *UserQuery {
query := (&UserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, apikey.UserTable, apikey.UserColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryGroup queries the group edge of a APIKey.
func (c *APIKeyClient) QueryGroup(_m *APIKey) *GroupQuery {
query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, apikey.GroupTable, apikey.GroupColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryUsageLogs queries the usage_logs edge of a APIKey.
func (c *APIKeyClient) QueryUsageLogs(_m *APIKey) *UsageLogQuery {
query := (&UsageLogClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(usagelog.Table, usagelog.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, apikey.UsageLogsTable, apikey.UsageLogsColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *APIKeyClient) Hooks() []Hook {
hooks := c.hooks.APIKey
return append(hooks[:len(hooks):len(hooks)], apikey.Hooks[:]...)
}
// Interceptors returns the client interceptors.
func (c *APIKeyClient) Interceptors() []Interceptor {
inters := c.inters.APIKey
return append(inters[:len(inters):len(inters)], apikey.Interceptors[:]...)
}
func (c *APIKeyClient) mutate(ctx context.Context, m *APIKeyMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&APIKeyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&APIKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&APIKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&APIKeyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown APIKey mutation op: %q", m.Op())
}
}
// AccountClient is a client for the Account schema. // AccountClient is a client for the Account schema.
type AccountClient struct { type AccountClient struct {
config config
...@@ -805,6 +622,189 @@ func (c *AccountGroupClient) mutate(ctx context.Context, m *AccountGroupMutation ...@@ -805,6 +622,189 @@ func (c *AccountGroupClient) mutate(ctx context.Context, m *AccountGroupMutation
} }
} }
// ApiKeyClient is a client for the ApiKey schema.
type ApiKeyClient struct {
config
}
// NewApiKeyClient returns a client for the ApiKey from the given config.
func NewApiKeyClient(c config) *ApiKeyClient {
return &ApiKeyClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `apikey.Hooks(f(g(h())))`.
func (c *ApiKeyClient) Use(hooks ...Hook) {
c.hooks.ApiKey = append(c.hooks.ApiKey, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `apikey.Intercept(f(g(h())))`.
func (c *ApiKeyClient) Intercept(interceptors ...Interceptor) {
c.inters.ApiKey = append(c.inters.ApiKey, interceptors...)
}
// Create returns a builder for creating a ApiKey entity.
func (c *ApiKeyClient) Create() *ApiKeyCreate {
mutation := newApiKeyMutation(c.config, OpCreate)
return &ApiKeyCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of ApiKey entities.
func (c *ApiKeyClient) CreateBulk(builders ...*ApiKeyCreate) *ApiKeyCreateBulk {
return &ApiKeyCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *ApiKeyClient) MapCreateBulk(slice any, setFunc func(*ApiKeyCreate, int)) *ApiKeyCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &ApiKeyCreateBulk{err: fmt.Errorf("calling to ApiKeyClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*ApiKeyCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &ApiKeyCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for ApiKey.
func (c *ApiKeyClient) Update() *ApiKeyUpdate {
mutation := newApiKeyMutation(c.config, OpUpdate)
return &ApiKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *ApiKeyClient) UpdateOne(_m *ApiKey) *ApiKeyUpdateOne {
mutation := newApiKeyMutation(c.config, OpUpdateOne, withApiKey(_m))
return &ApiKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *ApiKeyClient) UpdateOneID(id int64) *ApiKeyUpdateOne {
mutation := newApiKeyMutation(c.config, OpUpdateOne, withApiKeyID(id))
return &ApiKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for ApiKey.
func (c *ApiKeyClient) Delete() *ApiKeyDelete {
mutation := newApiKeyMutation(c.config, OpDelete)
return &ApiKeyDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *ApiKeyClient) DeleteOne(_m *ApiKey) *ApiKeyDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *ApiKeyClient) DeleteOneID(id int64) *ApiKeyDeleteOne {
builder := c.Delete().Where(apikey.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &ApiKeyDeleteOne{builder}
}
// Query returns a query builder for ApiKey.
func (c *ApiKeyClient) Query() *ApiKeyQuery {
return &ApiKeyQuery{
config: c.config,
ctx: &QueryContext{Type: TypeApiKey},
inters: c.Interceptors(),
}
}
// Get returns a ApiKey entity by its id.
func (c *ApiKeyClient) Get(ctx context.Context, id int64) (*ApiKey, error) {
return c.Query().Where(apikey.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *ApiKeyClient) GetX(ctx context.Context, id int64) *ApiKey {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a ApiKey.
func (c *ApiKeyClient) QueryUser(_m *ApiKey) *UserQuery {
query := (&UserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, apikey.UserTable, apikey.UserColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryGroup queries the group edge of a ApiKey.
func (c *ApiKeyClient) QueryGroup(_m *ApiKey) *GroupQuery {
query := (&GroupClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(group.Table, group.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, apikey.GroupTable, apikey.GroupColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryUsageLogs queries the usage_logs edge of a ApiKey.
func (c *ApiKeyClient) QueryUsageLogs(_m *ApiKey) *UsageLogQuery {
query := (&UsageLogClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(apikey.Table, apikey.FieldID, id),
sqlgraph.To(usagelog.Table, usagelog.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, apikey.UsageLogsTable, apikey.UsageLogsColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *ApiKeyClient) Hooks() []Hook {
hooks := c.hooks.ApiKey
return append(hooks[:len(hooks):len(hooks)], apikey.Hooks[:]...)
}
// Interceptors returns the client interceptors.
func (c *ApiKeyClient) Interceptors() []Interceptor {
inters := c.inters.ApiKey
return append(inters[:len(inters):len(inters)], apikey.Interceptors[:]...)
}
func (c *ApiKeyClient) mutate(ctx context.Context, m *ApiKeyMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&ApiKeyCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&ApiKeyUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&ApiKeyUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&ApiKeyDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown ApiKey mutation op: %q", m.Op())
}
}
// GroupClient is a client for the Group schema. // GroupClient is a client for the Group schema.
type GroupClient struct { type GroupClient struct {
config config
...@@ -914,8 +914,8 @@ func (c *GroupClient) GetX(ctx context.Context, id int64) *Group { ...@@ -914,8 +914,8 @@ func (c *GroupClient) GetX(ctx context.Context, id int64) *Group {
} }
// QueryAPIKeys queries the api_keys edge of a Group. // QueryAPIKeys queries the api_keys edge of a Group.
func (c *GroupClient) QueryAPIKeys(_m *Group) *APIKeyQuery { func (c *GroupClient) QueryAPIKeys(_m *Group) *ApiKeyQuery {
query := (&APIKeyClient{config: c.config}).Query() query := (&ApiKeyClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
...@@ -1642,8 +1642,8 @@ func (c *UsageLogClient) QueryUser(_m *UsageLog) *UserQuery { ...@@ -1642,8 +1642,8 @@ func (c *UsageLogClient) QueryUser(_m *UsageLog) *UserQuery {
} }
// QueryAPIKey queries the api_key edge of a UsageLog. // QueryAPIKey queries the api_key edge of a UsageLog.
func (c *UsageLogClient) QueryAPIKey(_m *UsageLog) *APIKeyQuery { func (c *UsageLogClient) QueryAPIKey(_m *UsageLog) *ApiKeyQuery {
query := (&APIKeyClient{config: c.config}).Query() query := (&ApiKeyClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
...@@ -1839,8 +1839,8 @@ func (c *UserClient) GetX(ctx context.Context, id int64) *User { ...@@ -1839,8 +1839,8 @@ func (c *UserClient) GetX(ctx context.Context, id int64) *User {
} }
// QueryAPIKeys queries the api_keys edge of a User. // QueryAPIKeys queries the api_keys edge of a User.
func (c *UserClient) QueryAPIKeys(_m *User) *APIKeyQuery { func (c *UserClient) QueryAPIKeys(_m *User) *ApiKeyQuery {
query := (&APIKeyClient{config: c.config}).Query() query := (&ApiKeyClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
...@@ -2627,12 +2627,12 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription ...@@ -2627,12 +2627,12 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription
// hooks and interceptors per client, for fast access. // hooks and interceptors per client, for fast access.
type ( type (
hooks struct { hooks struct {
APIKey, Account, AccountGroup, Group, Proxy, RedeemCode, Setting, UsageLog, Account, AccountGroup, ApiKey, Group, Proxy, RedeemCode, Setting, UsageLog,
User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue, User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue,
UserSubscription []ent.Hook UserSubscription []ent.Hook
} }
inters struct { inters struct {
APIKey, Account, AccountGroup, Group, Proxy, RedeemCode, Setting, UsageLog, Account, AccountGroup, ApiKey, Group, Proxy, RedeemCode, Setting, UsageLog,
User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue, User, UserAllowedGroup, UserAttributeDefinition, UserAttributeValue,
UserSubscription []ent.Interceptor UserSubscription []ent.Interceptor
} }
......
// Package ent provides database entity definitions and operations.
package ent package ent
import "entgo.io/ent/dialect" import "entgo.io/ent/dialect"
......
...@@ -54,7 +54,7 @@ type Group struct { ...@@ -54,7 +54,7 @@ type Group struct {
// GroupEdges holds the relations/edges for other nodes in the graph. // GroupEdges holds the relations/edges for other nodes in the graph.
type GroupEdges struct { type GroupEdges struct {
// APIKeys holds the value of the api_keys edge. // APIKeys holds the value of the api_keys edge.
APIKeys []*APIKey `json:"api_keys,omitempty"` APIKeys []*ApiKey `json:"api_keys,omitempty"`
// RedeemCodes holds the value of the redeem_codes edge. // RedeemCodes holds the value of the redeem_codes edge.
RedeemCodes []*RedeemCode `json:"redeem_codes,omitempty"` RedeemCodes []*RedeemCode `json:"redeem_codes,omitempty"`
// Subscriptions holds the value of the subscriptions edge. // Subscriptions holds the value of the subscriptions edge.
...@@ -76,7 +76,7 @@ type GroupEdges struct { ...@@ -76,7 +76,7 @@ type GroupEdges struct {
// APIKeysOrErr returns the APIKeys value or an error if the edge // APIKeysOrErr returns the APIKeys value or an error if the edge
// was not loaded in eager-loading. // was not loaded in eager-loading.
func (e GroupEdges) APIKeysOrErr() ([]*APIKey, error) { func (e GroupEdges) APIKeysOrErr() ([]*ApiKey, error) {
if e.loadedTypes[0] { if e.loadedTypes[0] {
return e.APIKeys, nil return e.APIKeys, nil
} }
...@@ -285,7 +285,7 @@ func (_m *Group) Value(name string) (ent.Value, error) { ...@@ -285,7 +285,7 @@ func (_m *Group) Value(name string) (ent.Value, error) {
} }
// QueryAPIKeys queries the "api_keys" edge of the Group entity. // QueryAPIKeys queries the "api_keys" edge of the Group entity.
func (_m *Group) QueryAPIKeys() *APIKeyQuery { func (_m *Group) QueryAPIKeys() *ApiKeyQuery {
return NewGroupClient(_m.config).QueryAPIKeys(_m) return NewGroupClient(_m.config).QueryAPIKeys(_m)
} }
......
...@@ -63,7 +63,7 @@ const ( ...@@ -63,7 +63,7 @@ const (
Table = "groups" Table = "groups"
// APIKeysTable is the table that holds the api_keys relation/edge. // APIKeysTable is the table that holds the api_keys relation/edge.
APIKeysTable = "api_keys" APIKeysTable = "api_keys"
// APIKeysInverseTable is the table name for the APIKey entity. // APIKeysInverseTable is the table name for the ApiKey entity.
// It exists in this package in order to avoid circular dependency with the "apikey" package. // It exists in this package in order to avoid circular dependency with the "apikey" package.
APIKeysInverseTable = "api_keys" APIKeysInverseTable = "api_keys"
// APIKeysColumn is the table column denoting the api_keys relation/edge. // APIKeysColumn is the table column denoting the api_keys relation/edge.
......
...@@ -842,7 +842,7 @@ func HasAPIKeys() predicate.Group { ...@@ -842,7 +842,7 @@ func HasAPIKeys() predicate.Group {
} }
// HasAPIKeysWith applies the HasEdge predicate on the "api_keys" edge with a given conditions (other predicates). // HasAPIKeysWith applies the HasEdge predicate on the "api_keys" edge with a given conditions (other predicates).
func HasAPIKeysWith(preds ...predicate.APIKey) predicate.Group { func HasAPIKeysWith(preds ...predicate.ApiKey) predicate.Group {
return predicate.Group(func(s *sql.Selector) { return predicate.Group(func(s *sql.Selector) {
step := newAPIKeysStep() step := newAPIKeysStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
......
...@@ -216,14 +216,14 @@ func (_c *GroupCreate) SetNillableDefaultValidityDays(v *int) *GroupCreate { ...@@ -216,14 +216,14 @@ func (_c *GroupCreate) SetNillableDefaultValidityDays(v *int) *GroupCreate {
return _c return _c
} }
// AddAPIKeyIDs adds the "api_keys" edge to the APIKey entity by IDs. // AddAPIKeyIDs adds the "api_keys" edge to the ApiKey entity by IDs.
func (_c *GroupCreate) AddAPIKeyIDs(ids ...int64) *GroupCreate { func (_c *GroupCreate) AddAPIKeyIDs(ids ...int64) *GroupCreate {
_c.mutation.AddAPIKeyIDs(ids...) _c.mutation.AddAPIKeyIDs(ids...)
return _c return _c
} }
// AddAPIKeys adds the "api_keys" edges to the APIKey entity. // AddAPIKeys adds the "api_keys" edges to the ApiKey entity.
func (_c *GroupCreate) AddAPIKeys(v ...*APIKey) *GroupCreate { func (_c *GroupCreate) AddAPIKeys(v ...*ApiKey) *GroupCreate {
ids := make([]int64, len(v)) ids := make([]int64, len(v))
for i := range v { for i := range v {
ids[i] = v[i].ID ids[i] = v[i].ID
......
...@@ -31,7 +31,7 @@ type GroupQuery struct { ...@@ -31,7 +31,7 @@ type GroupQuery struct {
order []group.OrderOption order []group.OrderOption
inters []Interceptor inters []Interceptor
predicates []predicate.Group predicates []predicate.Group
withAPIKeys *APIKeyQuery withAPIKeys *ApiKeyQuery
withRedeemCodes *RedeemCodeQuery withRedeemCodes *RedeemCodeQuery
withSubscriptions *UserSubscriptionQuery withSubscriptions *UserSubscriptionQuery
withUsageLogs *UsageLogQuery withUsageLogs *UsageLogQuery
...@@ -76,8 +76,8 @@ func (_q *GroupQuery) Order(o ...group.OrderOption) *GroupQuery { ...@@ -76,8 +76,8 @@ func (_q *GroupQuery) Order(o ...group.OrderOption) *GroupQuery {
} }
// QueryAPIKeys chains the current query on the "api_keys" edge. // QueryAPIKeys chains the current query on the "api_keys" edge.
func (_q *GroupQuery) QueryAPIKeys() *APIKeyQuery { func (_q *GroupQuery) QueryAPIKeys() *ApiKeyQuery {
query := (&APIKeyClient{config: _q.config}).Query() query := (&ApiKeyClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
...@@ -459,8 +459,8 @@ func (_q *GroupQuery) Clone() *GroupQuery { ...@@ -459,8 +459,8 @@ func (_q *GroupQuery) Clone() *GroupQuery {
// WithAPIKeys tells the query-builder to eager-load the nodes that are connected to // WithAPIKeys tells the query-builder to eager-load the nodes that are connected to
// the "api_keys" edge. The optional arguments are used to configure the query builder of the edge. // the "api_keys" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *GroupQuery) WithAPIKeys(opts ...func(*APIKeyQuery)) *GroupQuery { func (_q *GroupQuery) WithAPIKeys(opts ...func(*ApiKeyQuery)) *GroupQuery {
query := (&APIKeyClient{config: _q.config}).Query() query := (&ApiKeyClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
...@@ -654,8 +654,8 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, ...@@ -654,8 +654,8 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
} }
if query := _q.withAPIKeys; query != nil { if query := _q.withAPIKeys; query != nil {
if err := _q.loadAPIKeys(ctx, query, nodes, if err := _q.loadAPIKeys(ctx, query, nodes,
func(n *Group) { n.Edges.APIKeys = []*APIKey{} }, func(n *Group) { n.Edges.APIKeys = []*ApiKey{} },
func(n *Group, e *APIKey) { n.Edges.APIKeys = append(n.Edges.APIKeys, e) }); err != nil { func(n *Group, e *ApiKey) { n.Edges.APIKeys = append(n.Edges.APIKeys, e) }); err != nil {
return nil, err return nil, err
} }
} }
...@@ -711,7 +711,7 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group, ...@@ -711,7 +711,7 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return nodes, nil return nodes, nil
} }
func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *APIKeyQuery, nodes []*Group, init func(*Group), assign func(*Group, *APIKey)) error { func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *ApiKeyQuery, nodes []*Group, init func(*Group), assign func(*Group, *ApiKey)) error {
fks := make([]driver.Value, 0, len(nodes)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int64]*Group) nodeids := make(map[int64]*Group)
for i := range nodes { for i := range nodes {
...@@ -724,7 +724,7 @@ func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *APIKeyQuery, nodes ...@@ -724,7 +724,7 @@ func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *APIKeyQuery, nodes
if len(query.ctx.Fields) > 0 { if len(query.ctx.Fields) > 0 {
query.ctx.AppendFieldOnce(apikey.FieldGroupID) query.ctx.AppendFieldOnce(apikey.FieldGroupID)
} }
query.Where(predicate.APIKey(func(s *sql.Selector) { query.Where(predicate.ApiKey(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(group.APIKeysColumn), fks...)) s.Where(sql.InValues(s.C(group.APIKeysColumn), fks...))
})) }))
neighbors, err := query.All(ctx) neighbors, err := query.All(ctx)
......
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