Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
c86d445c
Commit
c86d445c
authored
Jan 04, 2026
by
IanShaw027
Browse files
fix(frontend): sync with main and finalize i18n & component optimizations
parents
6c036d7b
e78c8646
Changes
186
Show whitespace changes
Inline
Side-by-side
.gitignore
View file @
c86d445c
...
...
@@ -48,6 +48,7 @@ pnpm-debug.log*
.env.*.local
*.env
!.env.example
docker-compose.override.yml
# ===================
# IDE / 编辑器
...
...
@@ -118,3 +119,5 @@ docs/
code-reviews/
AGENTS.md
backend/cmd/server/server
deploy/docker-compose.override.yml
.gocache/
backend/.golangci.yml
View file @
c86d445c
...
...
@@ -83,7 +83,14 @@ linters:
# Example (to disable some checks): [ "all", "-SA1000", "-SA1001"]
# Run `GL_DEBUG=staticcheck golangci-lint run --enable=staticcheck` to see all available checks and enabled by config checks.
# Default: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"]
# Temporarily disable style checks to allow CI to pass
checks
:
-
all
-
-ST1000
# Package comment format
-
-ST1003
# Poorly chosen identifier (ApiKey vs APIKey)
-
-ST1020
# Comment on exported method format
-
-ST1021
# Comment on exported type format
-
-ST1022
# Comment on exported variable format
# Invalid regular expression.
# https://staticcheck.dev/docs/checks/#SA1000
-
SA1000
...
...
@@ -369,15 +376,7 @@ linters:
# Ineffectual Go compiler directive.
# https://staticcheck.dev/docs/checks/#SA9009
-
SA9009
# Incorrect or missing package comment.
# https://staticcheck.dev/docs/checks/#ST1000
-
ST1000
# Dot imports are discouraged.
# https://staticcheck.dev/docs/checks/#ST1001
-
ST1001
# Poorly chosen identifier.
# https://staticcheck.dev/docs/checks/#ST1003
-
ST1003
# NOTE: ST1000, ST1001, ST1003, ST1020, ST1021, ST1022 are disabled above
# Incorrectly formatted error string.
# https://staticcheck.dev/docs/checks/#ST1005
-
ST1005
...
...
@@ -411,15 +410,7 @@ linters:
# Importing the same package multiple times.
# https://staticcheck.dev/docs/checks/#ST1019
-
ST1019
# The documentation of an exported function should start with the function's name.
# https://staticcheck.dev/docs/checks/#ST1020
-
ST1020
# The documentation of an exported type should start with type's name.
# https://staticcheck.dev/docs/checks/#ST1021
-
ST1021
# The documentation of an exported variable or constant should start with variable's name.
# https://staticcheck.dev/docs/checks/#ST1022
-
ST1022
# NOTE: ST1020, ST1021, ST1022 removed (disabled above)
# Redundant type in variable declaration.
# https://staticcheck.dev/docs/checks/#ST1023
-
ST1023
...
...
backend/cmd/jwtgen/main.go
0 → 100644
View file @
c86d445c
package
main
import
(
"context"
"flag"
"fmt"
"log"
"time"
_
"github.com/Wei-Shaw/sub2api/ent/runtime"
"github.com/Wei-Shaw/sub2api/internal/config"
"github.com/Wei-Shaw/sub2api/internal/repository"
"github.com/Wei-Shaw/sub2api/internal/service"
)
func
main
()
{
email
:=
flag
.
String
(
"email"
,
""
,
"Admin email to issue a JWT for (defaults to first active admin)"
)
flag
.
Parse
()
cfg
,
err
:=
config
.
Load
()
if
err
!=
nil
{
log
.
Fatalf
(
"failed to load config: %v"
,
err
)
}
client
,
sqlDB
,
err
:=
repository
.
InitEnt
(
cfg
)
if
err
!=
nil
{
log
.
Fatalf
(
"failed to init db: %v"
,
err
)
}
defer
func
()
{
if
err
:=
client
.
Close
();
err
!=
nil
{
log
.
Printf
(
"failed to close db: %v"
,
err
)
}
}()
userRepo
:=
repository
.
NewUserRepository
(
client
,
sqlDB
)
authService
:=
service
.
NewAuthService
(
userRepo
,
cfg
,
nil
,
nil
,
nil
,
nil
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
var
user
*
service
.
User
if
*
email
!=
""
{
user
,
err
=
userRepo
.
GetByEmail
(
ctx
,
*
email
)
}
else
{
user
,
err
=
userRepo
.
GetFirstAdmin
(
ctx
)
}
if
err
!=
nil
{
log
.
Fatalf
(
"failed to resolve admin user: %v"
,
err
)
}
token
,
err
:=
authService
.
GenerateToken
(
user
)
if
err
!=
nil
{
log
.
Fatalf
(
"failed to generate token: %v"
,
err
)
}
fmt
.
Printf
(
"ADMIN_EMAIL=%s
\n
ADMIN_USER_ID=%d
\n
JWT=%s
\n
"
,
user
.
Email
,
user
.
ID
,
token
)
}
backend/cmd/server/wire_gen.go
View file @
c86d445c
...
...
@@ -55,14 +55,14 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
userService
:=
service
.
NewUserService
(
userRepository
)
authHandler
:=
handler
.
NewAuthHandler
(
configConfig
,
authService
,
userService
)
userHandler
:=
handler
.
NewUserHandler
(
userService
)
apiKeyRepository
:=
repository
.
NewA
pi
KeyRepository
(
client
)
apiKeyRepository
:=
repository
.
NewA
PI
KeyRepository
(
client
)
groupRepository
:=
repository
.
NewGroupRepository
(
client
,
db
)
userSubscriptionRepository
:=
repository
.
NewUserSubscriptionRepository
(
client
)
apiKeyCache
:=
repository
.
NewA
pi
KeyCache
(
redisClient
)
apiKeyService
:=
service
.
NewA
pi
KeyService
(
apiKeyRepository
,
userRepository
,
groupRepository
,
userSubscriptionRepository
,
apiKeyCache
,
configConfig
)
apiKeyCache
:=
repository
.
NewA
PI
KeyCache
(
redisClient
)
apiKeyService
:=
service
.
NewA
PI
KeyService
(
apiKeyRepository
,
userRepository
,
groupRepository
,
userSubscriptionRepository
,
apiKeyCache
,
configConfig
)
apiKeyHandler
:=
handler
.
NewAPIKeyHandler
(
apiKeyService
)
usageLogRepository
:=
repository
.
NewUsageLogRepository
(
client
,
db
)
usageService
:=
service
.
NewUsageService
(
usageLogRepository
,
userRepository
)
usageService
:=
service
.
NewUsageService
(
usageLogRepository
,
userRepository
,
client
)
usageHandler
:=
handler
.
NewUsageHandler
(
usageService
,
apiKeyService
)
redeemCodeRepository
:=
repository
.
NewRedeemCodeRepository
(
client
)
billingCache
:=
repository
.
NewBillingCache
(
redisClient
)
...
...
@@ -88,7 +88,8 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
geminiCliCodeAssistClient
:=
repository
.
NewGeminiCliCodeAssistClient
()
geminiOAuthService
:=
service
.
NewGeminiOAuthService
(
proxyRepository
,
geminiOAuthClient
,
geminiCliCodeAssistClient
,
configConfig
)
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
()
antigravityQuotaFetcher
:=
service
.
NewAntigravityQuotaFetcher
(
proxyRepository
)
usageCache
:=
service
.
NewUsageCache
()
...
...
@@ -99,7 +100,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
antigravityOAuthService
:=
service
.
NewAntigravityOAuthService
(
proxyRepository
)
antigravityTokenProvider
:=
service
.
NewAntigravityTokenProvider
(
accountRepository
,
geminiTokenCache
,
antigravityOAuthService
)
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
,
geminiTokenProvider
,
antigravityGatewayService
,
httpUpstream
)
concurrencyCache
:=
repository
.
ProvideConcurrencyCache
(
redisClient
,
configConfig
)
concurrencyService
:=
service
.
ProvideConcurrencyService
(
concurrencyCache
,
accountRepository
,
configConfig
)
...
...
@@ -143,7 +144,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
handlers
:=
handler
.
ProvideHandlers
(
authHandler
,
userHandler
,
apiKeyHandler
,
usageHandler
,
redeemHandler
,
subscriptionHandler
,
adminHandlers
,
gatewayHandler
,
openAIGatewayHandler
,
handlerSettingHandler
)
jwtAuthMiddleware
:=
middleware
.
NewJWTAuthMiddleware
(
authService
,
userService
)
adminAuthMiddleware
:=
middleware
.
NewAdminAuthMiddleware
(
authService
,
userService
,
settingService
)
apiKeyAuthMiddleware
:=
middleware
.
NewA
pi
KeyAuthMiddleware
(
apiKeyService
,
subscriptionService
,
configConfig
)
apiKeyAuthMiddleware
:=
middleware
.
NewA
PI
KeyAuthMiddleware
(
apiKeyService
,
subscriptionService
,
configConfig
)
engine
:=
server
.
ProvideRouter
(
configConfig
,
handlers
,
jwtAuthMiddleware
,
adminAuthMiddleware
,
apiKeyAuthMiddleware
,
apiKeyService
,
subscriptionService
)
httpServer
:=
server
.
ProvideHTTPServer
(
configConfig
,
engine
)
tokenRefreshService
:=
service
.
ProvideTokenRefreshService
(
accountRepository
,
oAuthService
,
openAIOAuthService
,
geminiOAuthService
,
antigravityOAuthService
,
configConfig
)
...
...
backend/ent/apikey.go
View file @
c86d445c
...
...
@@ -14,8 +14,8 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user"
)
// A
pi
Key is the model entity for the A
pi
Key schema.
type
A
pi
Key
struct
{
// A
PI
Key is the model entity for the A
PI
Key schema.
type
A
PI
Key
struct
{
config
`json:"-"`
// ID of the ent.
ID
int64
`json:"id,omitempty"`
...
...
@@ -36,13 +36,13 @@ type ApiKey struct {
// Status holds the value of the "status" field.
Status
string
`json:"status,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the A
pi
KeyQuery when eager-loading is set.
Edges
A
pi
KeyEdges
`json:"edges"`
// The values are being populated by the A
PI
KeyQuery when eager-loading is set.
Edges
A
PI
KeyEdges
`json:"edges"`
selectValues
sql
.
SelectValues
}
// A
pi
KeyEdges holds the relations/edges for other nodes in the graph.
type
A
pi
KeyEdges
struct
{
// A
PI
KeyEdges holds the relations/edges for other nodes in the graph.
type
A
PI
KeyEdges
struct
{
// User holds the value of the user edge.
User
*
User
`json:"user,omitempty"`
// Group holds the value of the group edge.
...
...
@@ -56,7 +56,7 @@ type ApiKeyEdges struct {
// UserOrErr returns the User value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func
(
e
A
pi
KeyEdges
)
UserOrErr
()
(
*
User
,
error
)
{
func
(
e
A
PI
KeyEdges
)
UserOrErr
()
(
*
User
,
error
)
{
if
e
.
User
!=
nil
{
return
e
.
User
,
nil
}
else
if
e
.
loadedTypes
[
0
]
{
...
...
@@ -67,7 +67,7 @@ func (e ApiKeyEdges) UserOrErr() (*User, error) {
// GroupOrErr returns the Group value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func
(
e
A
pi
KeyEdges
)
GroupOrErr
()
(
*
Group
,
error
)
{
func
(
e
A
PI
KeyEdges
)
GroupOrErr
()
(
*
Group
,
error
)
{
if
e
.
Group
!=
nil
{
return
e
.
Group
,
nil
}
else
if
e
.
loadedTypes
[
1
]
{
...
...
@@ -78,7 +78,7 @@ func (e ApiKeyEdges) GroupOrErr() (*Group, error) {
// UsageLogsOrErr returns the UsageLogs value or an error if the edge
// was not loaded in eager-loading.
func
(
e
A
pi
KeyEdges
)
UsageLogsOrErr
()
([]
*
UsageLog
,
error
)
{
func
(
e
A
PI
KeyEdges
)
UsageLogsOrErr
()
([]
*
UsageLog
,
error
)
{
if
e
.
loadedTypes
[
2
]
{
return
e
.
UsageLogs
,
nil
}
...
...
@@ -86,7 +86,7 @@ func (e ApiKeyEdges) UsageLogsOrErr() ([]*UsageLog, error) {
}
// scanValues returns the types for scanning values from sql.Rows.
func
(
*
A
pi
Key
)
scanValues
(
columns
[]
string
)
([]
any
,
error
)
{
func
(
*
A
PI
Key
)
scanValues
(
columns
[]
string
)
([]
any
,
error
)
{
values
:=
make
([]
any
,
len
(
columns
))
for
i
:=
range
columns
{
switch
columns
[
i
]
{
...
...
@@ -104,8 +104,8 @@ func (*ApiKey) scanValues(columns []string) ([]any, error) {
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the A
pi
Key fields.
func
(
_m
*
A
pi
Key
)
assignValues
(
columns
[]
string
,
values
[]
any
)
error
{
// to the A
PI
Key fields.
func
(
_m
*
A
PI
Key
)
assignValues
(
columns
[]
string
,
values
[]
any
)
error
{
if
m
,
n
:=
len
(
values
),
len
(
columns
);
m
<
n
{
return
fmt
.
Errorf
(
"mismatch number of scan values: %d != %d"
,
m
,
n
)
}
...
...
@@ -174,49 +174,49 @@ func (_m *ApiKey) assignValues(columns []string, values []any) error {
return
nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the A
pi
Key.
// Value returns the ent.Value that was dynamically selected and assigned to the A
PI
Key.
// This includes values selected through modifiers, order, etc.
func
(
_m
*
A
pi
Key
)
Value
(
name
string
)
(
ent
.
Value
,
error
)
{
func
(
_m
*
A
PI
Key
)
Value
(
name
string
)
(
ent
.
Value
,
error
)
{
return
_m
.
selectValues
.
Get
(
name
)
}
// QueryUser queries the "user" edge of the A
pi
Key entity.
func
(
_m
*
A
pi
Key
)
QueryUser
()
*
UserQuery
{
return
NewA
pi
KeyClient
(
_m
.
config
)
.
QueryUser
(
_m
)
// QueryUser queries the "user" edge of the A
PI
Key entity.
func
(
_m
*
A
PI
Key
)
QueryUser
()
*
UserQuery
{
return
NewA
PI
KeyClient
(
_m
.
config
)
.
QueryUser
(
_m
)
}
// QueryGroup queries the "group" edge of the A
pi
Key entity.
func
(
_m
*
A
pi
Key
)
QueryGroup
()
*
GroupQuery
{
return
NewA
pi
KeyClient
(
_m
.
config
)
.
QueryGroup
(
_m
)
// QueryGroup queries the "group" edge of the A
PI
Key entity.
func
(
_m
*
A
PI
Key
)
QueryGroup
()
*
GroupQuery
{
return
NewA
PI
KeyClient
(
_m
.
config
)
.
QueryGroup
(
_m
)
}
// QueryUsageLogs queries the "usage_logs" edge of the A
pi
Key entity.
func
(
_m
*
A
pi
Key
)
QueryUsageLogs
()
*
UsageLogQuery
{
return
NewA
pi
KeyClient
(
_m
.
config
)
.
QueryUsageLogs
(
_m
)
// QueryUsageLogs queries the "usage_logs" edge of the A
PI
Key entity.
func
(
_m
*
A
PI
Key
)
QueryUsageLogs
()
*
UsageLogQuery
{
return
NewA
PI
KeyClient
(
_m
.
config
)
.
QueryUsageLogs
(
_m
)
}
// Update returns a builder for updating this A
pi
Key.
// Note that you need to call A
pi
Key.Unwrap() before calling this method if this A
pi
Key
// Update returns a builder for updating this A
PI
Key.
// Note that you need to call A
PI
Key.Unwrap() before calling this method if this A
PI
Key
// was returned from a transaction, and the transaction was committed or rolled back.
func
(
_m
*
A
pi
Key
)
Update
()
*
A
pi
KeyUpdateOne
{
return
NewA
pi
KeyClient
(
_m
.
config
)
.
UpdateOne
(
_m
)
func
(
_m
*
A
PI
Key
)
Update
()
*
A
PI
KeyUpdateOne
{
return
NewA
PI
KeyClient
(
_m
.
config
)
.
UpdateOne
(
_m
)
}
// Unwrap unwraps the A
pi
Key entity that was returned from a transaction after it was closed,
// Unwrap unwraps the A
PI
Key entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func
(
_m
*
A
pi
Key
)
Unwrap
()
*
A
pi
Key
{
func
(
_m
*
A
PI
Key
)
Unwrap
()
*
A
PI
Key
{
_tx
,
ok
:=
_m
.
config
.
driver
.
(
*
txDriver
)
if
!
ok
{
panic
(
"ent: A
pi
Key is not a transactional entity"
)
panic
(
"ent: A
PI
Key is not a transactional entity"
)
}
_m
.
config
.
driver
=
_tx
.
drv
return
_m
}
// String implements the fmt.Stringer.
func
(
_m
*
A
pi
Key
)
String
()
string
{
func
(
_m
*
A
PI
Key
)
String
()
string
{
var
builder
strings
.
Builder
builder
.
WriteString
(
"A
pi
Key("
)
builder
.
WriteString
(
"A
PI
Key("
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"id=%v, "
,
_m
.
ID
))
builder
.
WriteString
(
"created_at="
)
builder
.
WriteString
(
_m
.
CreatedAt
.
Format
(
time
.
ANSIC
))
...
...
@@ -249,5 +249,5 @@ func (_m *ApiKey) String() string {
return
builder
.
String
()
}
// A
pi
Keys is a parsable slice of A
pi
Key.
type
A
pi
Keys
[]
*
A
pi
Key
// A
PI
Keys is a parsable slice of A
PI
Key.
type
A
PI
Keys
[]
*
A
PI
Key
backend/ent/apikey/apikey.go
View file @
c86d445c
...
...
@@ -109,7 +109,7 @@ var (
StatusValidator
func
(
string
)
error
)
// OrderOption defines the ordering options for the A
pi
Key queries.
// OrderOption defines the ordering options for the A
PI
Key queries.
type
OrderOption
func
(
*
sql
.
Selector
)
// ByID orders the results by the id field.
...
...
backend/ent/apikey/where.go
View file @
c86d445c
...
...
@@ -11,468 +11,468 @@ import (
)
// ID filters vertices based on their ID field.
func
ID
(
id
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldID
,
id
))
func
ID
(
id
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldID
,
id
))
}
// IDEQ applies the EQ predicate on the ID field.
func
IDEQ
(
id
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldID
,
id
))
func
IDEQ
(
id
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldID
,
id
))
}
// IDNEQ applies the NEQ predicate on the ID field.
func
IDNEQ
(
id
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldID
,
id
))
func
IDNEQ
(
id
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldID
,
id
))
}
// IDIn applies the In predicate on the ID field.
func
IDIn
(
ids
...
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldID
,
ids
...
))
func
IDIn
(
ids
...
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldID
,
ids
...
))
}
// IDNotIn applies the NotIn predicate on the ID field.
func
IDNotIn
(
ids
...
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldID
,
ids
...
))
func
IDNotIn
(
ids
...
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldID
,
ids
...
))
}
// IDGT applies the GT predicate on the ID field.
func
IDGT
(
id
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGT
(
FieldID
,
id
))
func
IDGT
(
id
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGT
(
FieldID
,
id
))
}
// IDGTE applies the GTE predicate on the ID field.
func
IDGTE
(
id
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGTE
(
FieldID
,
id
))
func
IDGTE
(
id
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGTE
(
FieldID
,
id
))
}
// IDLT applies the LT predicate on the ID field.
func
IDLT
(
id
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLT
(
FieldID
,
id
))
func
IDLT
(
id
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLT
(
FieldID
,
id
))
}
// IDLTE applies the LTE predicate on the ID field.
func
IDLTE
(
id
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLTE
(
FieldID
,
id
))
func
IDLTE
(
id
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLTE
(
FieldID
,
id
))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func
CreatedAt
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
func
CreatedAt
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func
UpdatedAt
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldUpdatedAt
,
v
))
func
UpdatedAt
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldUpdatedAt
,
v
))
}
// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
func
DeletedAt
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldDeletedAt
,
v
))
func
DeletedAt
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldDeletedAt
,
v
))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func
UserID
(
v
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldUserID
,
v
))
func
UserID
(
v
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldUserID
,
v
))
}
// Key applies equality check predicate on the "key" field. It's identical to KeyEQ.
func
Key
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldKey
,
v
))
func
Key
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldKey
,
v
))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func
Name
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldName
,
v
))
func
Name
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldName
,
v
))
}
// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ.
func
GroupID
(
v
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldGroupID
,
v
))
func
GroupID
(
v
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldGroupID
,
v
))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func
Status
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
func
Status
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func
CreatedAtEQ
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
func
CreatedAtEQ
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func
CreatedAtNEQ
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldCreatedAt
,
v
))
func
CreatedAtNEQ
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldCreatedAt
,
v
))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func
CreatedAtIn
(
vs
...
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldCreatedAt
,
vs
...
))
func
CreatedAtIn
(
vs
...
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldCreatedAt
,
vs
...
))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func
CreatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldCreatedAt
,
vs
...
))
func
CreatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldCreatedAt
,
vs
...
))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func
CreatedAtGT
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGT
(
FieldCreatedAt
,
v
))
func
CreatedAtGT
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGT
(
FieldCreatedAt
,
v
))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func
CreatedAtGTE
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGTE
(
FieldCreatedAt
,
v
))
func
CreatedAtGTE
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGTE
(
FieldCreatedAt
,
v
))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func
CreatedAtLT
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLT
(
FieldCreatedAt
,
v
))
func
CreatedAtLT
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLT
(
FieldCreatedAt
,
v
))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func
CreatedAtLTE
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLTE
(
FieldCreatedAt
,
v
))
func
CreatedAtLTE
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLTE
(
FieldCreatedAt
,
v
))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func
UpdatedAtEQ
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldUpdatedAt
,
v
))
func
UpdatedAtEQ
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func
UpdatedAtNEQ
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldUpdatedAt
,
v
))
func
UpdatedAtNEQ
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func
UpdatedAtIn
(
vs
...
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldUpdatedAt
,
vs
...
))
func
UpdatedAtIn
(
vs
...
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldUpdatedAt
,
vs
...
))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func
UpdatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldUpdatedAt
,
vs
...
))
func
UpdatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldUpdatedAt
,
vs
...
))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func
UpdatedAtGT
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGT
(
FieldUpdatedAt
,
v
))
func
UpdatedAtGT
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGT
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func
UpdatedAtGTE
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGTE
(
FieldUpdatedAt
,
v
))
func
UpdatedAtGTE
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGTE
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func
UpdatedAtLT
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLT
(
FieldUpdatedAt
,
v
))
func
UpdatedAtLT
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLT
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func
UpdatedAtLTE
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLTE
(
FieldUpdatedAt
,
v
))
func
UpdatedAtLTE
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLTE
(
FieldUpdatedAt
,
v
))
}
// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
func
DeletedAtEQ
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldDeletedAt
,
v
))
func
DeletedAtEQ
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldDeletedAt
,
v
))
}
// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
func
DeletedAtNEQ
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldDeletedAt
,
v
))
func
DeletedAtNEQ
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldDeletedAt
,
v
))
}
// DeletedAtIn applies the In predicate on the "deleted_at" field.
func
DeletedAtIn
(
vs
...
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldDeletedAt
,
vs
...
))
func
DeletedAtIn
(
vs
...
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldDeletedAt
,
vs
...
))
}
// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
func
DeletedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldDeletedAt
,
vs
...
))
func
DeletedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldDeletedAt
,
vs
...
))
}
// DeletedAtGT applies the GT predicate on the "deleted_at" field.
func
DeletedAtGT
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGT
(
FieldDeletedAt
,
v
))
func
DeletedAtGT
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGT
(
FieldDeletedAt
,
v
))
}
// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
func
DeletedAtGTE
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGTE
(
FieldDeletedAt
,
v
))
func
DeletedAtGTE
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGTE
(
FieldDeletedAt
,
v
))
}
// DeletedAtLT applies the LT predicate on the "deleted_at" field.
func
DeletedAtLT
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLT
(
FieldDeletedAt
,
v
))
func
DeletedAtLT
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLT
(
FieldDeletedAt
,
v
))
}
// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
func
DeletedAtLTE
(
v
time
.
Time
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLTE
(
FieldDeletedAt
,
v
))
func
DeletedAtLTE
(
v
time
.
Time
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLTE
(
FieldDeletedAt
,
v
))
}
// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
func
DeletedAtIsNil
()
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIsNull
(
FieldDeletedAt
))
func
DeletedAtIsNil
()
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIsNull
(
FieldDeletedAt
))
}
// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
func
DeletedAtNotNil
()
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotNull
(
FieldDeletedAt
))
func
DeletedAtNotNil
()
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotNull
(
FieldDeletedAt
))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func
UserIDEQ
(
v
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldUserID
,
v
))
func
UserIDEQ
(
v
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldUserID
,
v
))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func
UserIDNEQ
(
v
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldUserID
,
v
))
func
UserIDNEQ
(
v
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldUserID
,
v
))
}
// UserIDIn applies the In predicate on the "user_id" field.
func
UserIDIn
(
vs
...
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldUserID
,
vs
...
))
func
UserIDIn
(
vs
...
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldUserID
,
vs
...
))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func
UserIDNotIn
(
vs
...
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldUserID
,
vs
...
))
func
UserIDNotIn
(
vs
...
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldUserID
,
vs
...
))
}
// KeyEQ applies the EQ predicate on the "key" field.
func
KeyEQ
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldKey
,
v
))
func
KeyEQ
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldKey
,
v
))
}
// KeyNEQ applies the NEQ predicate on the "key" field.
func
KeyNEQ
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldKey
,
v
))
func
KeyNEQ
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldKey
,
v
))
}
// KeyIn applies the In predicate on the "key" field.
func
KeyIn
(
vs
...
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldKey
,
vs
...
))
func
KeyIn
(
vs
...
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldKey
,
vs
...
))
}
// KeyNotIn applies the NotIn predicate on the "key" field.
func
KeyNotIn
(
vs
...
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldKey
,
vs
...
))
func
KeyNotIn
(
vs
...
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldKey
,
vs
...
))
}
// KeyGT applies the GT predicate on the "key" field.
func
KeyGT
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGT
(
FieldKey
,
v
))
func
KeyGT
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGT
(
FieldKey
,
v
))
}
// KeyGTE applies the GTE predicate on the "key" field.
func
KeyGTE
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGTE
(
FieldKey
,
v
))
func
KeyGTE
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGTE
(
FieldKey
,
v
))
}
// KeyLT applies the LT predicate on the "key" field.
func
KeyLT
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLT
(
FieldKey
,
v
))
func
KeyLT
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLT
(
FieldKey
,
v
))
}
// KeyLTE applies the LTE predicate on the "key" field.
func
KeyLTE
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLTE
(
FieldKey
,
v
))
func
KeyLTE
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLTE
(
FieldKey
,
v
))
}
// KeyContains applies the Contains predicate on the "key" field.
func
KeyContains
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldContains
(
FieldKey
,
v
))
func
KeyContains
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldContains
(
FieldKey
,
v
))
}
// KeyHasPrefix applies the HasPrefix predicate on the "key" field.
func
KeyHasPrefix
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldHasPrefix
(
FieldKey
,
v
))
func
KeyHasPrefix
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldHasPrefix
(
FieldKey
,
v
))
}
// KeyHasSuffix applies the HasSuffix predicate on the "key" field.
func
KeyHasSuffix
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldHasSuffix
(
FieldKey
,
v
))
func
KeyHasSuffix
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldHasSuffix
(
FieldKey
,
v
))
}
// KeyEqualFold applies the EqualFold predicate on the "key" field.
func
KeyEqualFold
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEqualFold
(
FieldKey
,
v
))
func
KeyEqualFold
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEqualFold
(
FieldKey
,
v
))
}
// KeyContainsFold applies the ContainsFold predicate on the "key" field.
func
KeyContainsFold
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldContainsFold
(
FieldKey
,
v
))
func
KeyContainsFold
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldContainsFold
(
FieldKey
,
v
))
}
// NameEQ applies the EQ predicate on the "name" field.
func
NameEQ
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldName
,
v
))
func
NameEQ
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldName
,
v
))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func
NameNEQ
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldName
,
v
))
func
NameNEQ
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldName
,
v
))
}
// NameIn applies the In predicate on the "name" field.
func
NameIn
(
vs
...
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldName
,
vs
...
))
func
NameIn
(
vs
...
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldName
,
vs
...
))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func
NameNotIn
(
vs
...
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldName
,
vs
...
))
func
NameNotIn
(
vs
...
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldName
,
vs
...
))
}
// NameGT applies the GT predicate on the "name" field.
func
NameGT
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGT
(
FieldName
,
v
))
func
NameGT
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGT
(
FieldName
,
v
))
}
// NameGTE applies the GTE predicate on the "name" field.
func
NameGTE
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGTE
(
FieldName
,
v
))
func
NameGTE
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGTE
(
FieldName
,
v
))
}
// NameLT applies the LT predicate on the "name" field.
func
NameLT
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLT
(
FieldName
,
v
))
func
NameLT
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLT
(
FieldName
,
v
))
}
// NameLTE applies the LTE predicate on the "name" field.
func
NameLTE
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLTE
(
FieldName
,
v
))
func
NameLTE
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLTE
(
FieldName
,
v
))
}
// NameContains applies the Contains predicate on the "name" field.
func
NameContains
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldContains
(
FieldName
,
v
))
func
NameContains
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldContains
(
FieldName
,
v
))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func
NameHasPrefix
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldHasPrefix
(
FieldName
,
v
))
func
NameHasPrefix
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldHasPrefix
(
FieldName
,
v
))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func
NameHasSuffix
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldHasSuffix
(
FieldName
,
v
))
func
NameHasSuffix
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldHasSuffix
(
FieldName
,
v
))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func
NameEqualFold
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEqualFold
(
FieldName
,
v
))
func
NameEqualFold
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEqualFold
(
FieldName
,
v
))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func
NameContainsFold
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldContainsFold
(
FieldName
,
v
))
func
NameContainsFold
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldContainsFold
(
FieldName
,
v
))
}
// GroupIDEQ applies the EQ predicate on the "group_id" field.
func
GroupIDEQ
(
v
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldGroupID
,
v
))
func
GroupIDEQ
(
v
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldGroupID
,
v
))
}
// GroupIDNEQ applies the NEQ predicate on the "group_id" field.
func
GroupIDNEQ
(
v
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldGroupID
,
v
))
func
GroupIDNEQ
(
v
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldGroupID
,
v
))
}
// GroupIDIn applies the In predicate on the "group_id" field.
func
GroupIDIn
(
vs
...
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldGroupID
,
vs
...
))
func
GroupIDIn
(
vs
...
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldGroupID
,
vs
...
))
}
// GroupIDNotIn applies the NotIn predicate on the "group_id" field.
func
GroupIDNotIn
(
vs
...
int64
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldGroupID
,
vs
...
))
func
GroupIDNotIn
(
vs
...
int64
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldGroupID
,
vs
...
))
}
// GroupIDIsNil applies the IsNil predicate on the "group_id" field.
func
GroupIDIsNil
()
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIsNull
(
FieldGroupID
))
func
GroupIDIsNil
()
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIsNull
(
FieldGroupID
))
}
// GroupIDNotNil applies the NotNil predicate on the "group_id" field.
func
GroupIDNotNil
()
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotNull
(
FieldGroupID
))
func
GroupIDNotNil
()
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotNull
(
FieldGroupID
))
}
// StatusEQ applies the EQ predicate on the "status" field.
func
StatusEQ
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
func
StatusEQ
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEQ
(
FieldStatus
,
v
))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func
StatusNEQ
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNEQ
(
FieldStatus
,
v
))
func
StatusNEQ
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNEQ
(
FieldStatus
,
v
))
}
// StatusIn applies the In predicate on the "status" field.
func
StatusIn
(
vs
...
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldIn
(
FieldStatus
,
vs
...
))
func
StatusIn
(
vs
...
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldIn
(
FieldStatus
,
vs
...
))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func
StatusNotIn
(
vs
...
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldNotIn
(
FieldStatus
,
vs
...
))
func
StatusNotIn
(
vs
...
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldNotIn
(
FieldStatus
,
vs
...
))
}
// StatusGT applies the GT predicate on the "status" field.
func
StatusGT
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGT
(
FieldStatus
,
v
))
func
StatusGT
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGT
(
FieldStatus
,
v
))
}
// StatusGTE applies the GTE predicate on the "status" field.
func
StatusGTE
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldGTE
(
FieldStatus
,
v
))
func
StatusGTE
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldGTE
(
FieldStatus
,
v
))
}
// StatusLT applies the LT predicate on the "status" field.
func
StatusLT
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLT
(
FieldStatus
,
v
))
func
StatusLT
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLT
(
FieldStatus
,
v
))
}
// StatusLTE applies the LTE predicate on the "status" field.
func
StatusLTE
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldLTE
(
FieldStatus
,
v
))
func
StatusLTE
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldLTE
(
FieldStatus
,
v
))
}
// StatusContains applies the Contains predicate on the "status" field.
func
StatusContains
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldContains
(
FieldStatus
,
v
))
func
StatusContains
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldContains
(
FieldStatus
,
v
))
}
// StatusHasPrefix applies the HasPrefix predicate on the "status" field.
func
StatusHasPrefix
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldHasPrefix
(
FieldStatus
,
v
))
func
StatusHasPrefix
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldHasPrefix
(
FieldStatus
,
v
))
}
// StatusHasSuffix applies the HasSuffix predicate on the "status" field.
func
StatusHasSuffix
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldHasSuffix
(
FieldStatus
,
v
))
func
StatusHasSuffix
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldHasSuffix
(
FieldStatus
,
v
))
}
// StatusEqualFold applies the EqualFold predicate on the "status" field.
func
StatusEqualFold
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldEqualFold
(
FieldStatus
,
v
))
func
StatusEqualFold
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldEqualFold
(
FieldStatus
,
v
))
}
// StatusContainsFold applies the ContainsFold predicate on the "status" field.
func
StatusContainsFold
(
v
string
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
FieldContainsFold
(
FieldStatus
,
v
))
func
StatusContainsFold
(
v
string
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
FieldContainsFold
(
FieldStatus
,
v
))
}
// HasUser applies the HasEdge predicate on the "user" edge.
func
HasUser
()
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
func
(
s
*
sql
.
Selector
)
{
func
HasUser
()
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
func
(
s
*
sql
.
Selector
)
{
step
:=
sqlgraph
.
NewStep
(
sqlgraph
.
From
(
Table
,
FieldID
),
sqlgraph
.
Edge
(
sqlgraph
.
M2O
,
true
,
UserTable
,
UserColumn
),
...
...
@@ -482,8 +482,8 @@ func HasUser() predicate.ApiKey {
}
// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates).
func
HasUserWith
(
preds
...
predicate
.
User
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
func
(
s
*
sql
.
Selector
)
{
func
HasUserWith
(
preds
...
predicate
.
User
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
func
(
s
*
sql
.
Selector
)
{
step
:=
newUserStep
()
sqlgraph
.
HasNeighborsWith
(
s
,
step
,
func
(
s
*
sql
.
Selector
)
{
for
_
,
p
:=
range
preds
{
...
...
@@ -494,8 +494,8 @@ func HasUserWith(preds ...predicate.User) predicate.ApiKey {
}
// HasGroup applies the HasEdge predicate on the "group" edge.
func
HasGroup
()
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
func
(
s
*
sql
.
Selector
)
{
func
HasGroup
()
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
func
(
s
*
sql
.
Selector
)
{
step
:=
sqlgraph
.
NewStep
(
sqlgraph
.
From
(
Table
,
FieldID
),
sqlgraph
.
Edge
(
sqlgraph
.
M2O
,
true
,
GroupTable
,
GroupColumn
),
...
...
@@ -505,8 +505,8 @@ func HasGroup() predicate.ApiKey {
}
// HasGroupWith applies the HasEdge predicate on the "group" edge with a given conditions (other predicates).
func
HasGroupWith
(
preds
...
predicate
.
Group
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
func
(
s
*
sql
.
Selector
)
{
func
HasGroupWith
(
preds
...
predicate
.
Group
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
func
(
s
*
sql
.
Selector
)
{
step
:=
newGroupStep
()
sqlgraph
.
HasNeighborsWith
(
s
,
step
,
func
(
s
*
sql
.
Selector
)
{
for
_
,
p
:=
range
preds
{
...
...
@@ -517,8 +517,8 @@ func HasGroupWith(preds ...predicate.Group) predicate.ApiKey {
}
// HasUsageLogs applies the HasEdge predicate on the "usage_logs" edge.
func
HasUsageLogs
()
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
func
(
s
*
sql
.
Selector
)
{
func
HasUsageLogs
()
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
func
(
s
*
sql
.
Selector
)
{
step
:=
sqlgraph
.
NewStep
(
sqlgraph
.
From
(
Table
,
FieldID
),
sqlgraph
.
Edge
(
sqlgraph
.
O2M
,
false
,
UsageLogsTable
,
UsageLogsColumn
),
...
...
@@ -528,8 +528,8 @@ func HasUsageLogs() predicate.ApiKey {
}
// HasUsageLogsWith applies the HasEdge predicate on the "usage_logs" edge with a given conditions (other predicates).
func
HasUsageLogsWith
(
preds
...
predicate
.
UsageLog
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
func
(
s
*
sql
.
Selector
)
{
func
HasUsageLogsWith
(
preds
...
predicate
.
UsageLog
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
func
(
s
*
sql
.
Selector
)
{
step
:=
newUsageLogsStep
()
sqlgraph
.
HasNeighborsWith
(
s
,
step
,
func
(
s
*
sql
.
Selector
)
{
for
_
,
p
:=
range
preds
{
...
...
@@ -540,16 +540,16 @@ func HasUsageLogsWith(preds ...predicate.UsageLog) predicate.ApiKey {
}
// And groups predicates with the AND operator between them.
func
And
(
predicates
...
predicate
.
A
pi
Key
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
AndPredicates
(
predicates
...
))
func
And
(
predicates
...
predicate
.
A
PI
Key
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
AndPredicates
(
predicates
...
))
}
// Or groups predicates with the OR operator between them.
func
Or
(
predicates
...
predicate
.
A
pi
Key
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
OrPredicates
(
predicates
...
))
func
Or
(
predicates
...
predicate
.
A
PI
Key
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
OrPredicates
(
predicates
...
))
}
// Not applies the not operator on the given predicate.
func
Not
(
p
predicate
.
A
pi
Key
)
predicate
.
A
pi
Key
{
return
predicate
.
A
pi
Key
(
sql
.
NotPredicates
(
p
))
func
Not
(
p
predicate
.
A
PI
Key
)
predicate
.
A
PI
Key
{
return
predicate
.
A
PI
Key
(
sql
.
NotPredicates
(
p
))
}
backend/ent/apikey_create.go
View file @
c86d445c
...
...
@@ -17,22 +17,22 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user"
)
// A
pi
KeyCreate is the builder for creating a A
pi
Key entity.
type
A
pi
KeyCreate
struct
{
// A
PI
KeyCreate is the builder for creating a A
PI
Key entity.
type
A
PI
KeyCreate
struct
{
config
mutation
*
A
pi
KeyMutation
mutation
*
A
PI
KeyMutation
hooks
[]
Hook
conflict
[]
sql
.
ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func
(
_c
*
A
pi
KeyCreate
)
SetCreatedAt
(
v
time
.
Time
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetCreatedAt
(
v
time
.
Time
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
SetCreatedAt
(
v
)
return
_c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func
(
_c
*
A
pi
KeyCreate
)
SetNillableCreatedAt
(
v
*
time
.
Time
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetNillableCreatedAt
(
v
*
time
.
Time
)
*
A
PI
KeyCreate
{
if
v
!=
nil
{
_c
.
SetCreatedAt
(
*
v
)
}
...
...
@@ -40,13 +40,13 @@ func (_c *ApiKeyCreate) SetNillableCreatedAt(v *time.Time) *ApiKeyCreate {
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_c
*
A
pi
KeyCreate
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
SetUpdatedAt
(
v
)
return
_c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func
(
_c
*
A
pi
KeyCreate
)
SetNillableUpdatedAt
(
v
*
time
.
Time
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetNillableUpdatedAt
(
v
*
time
.
Time
)
*
A
PI
KeyCreate
{
if
v
!=
nil
{
_c
.
SetUpdatedAt
(
*
v
)
}
...
...
@@ -54,13 +54,13 @@ func (_c *ApiKeyCreate) SetNillableUpdatedAt(v *time.Time) *ApiKeyCreate {
}
// SetDeletedAt sets the "deleted_at" field.
func
(
_c
*
A
pi
KeyCreate
)
SetDeletedAt
(
v
time
.
Time
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetDeletedAt
(
v
time
.
Time
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
SetDeletedAt
(
v
)
return
_c
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func
(
_c
*
A
pi
KeyCreate
)
SetNillableDeletedAt
(
v
*
time
.
Time
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetNillableDeletedAt
(
v
*
time
.
Time
)
*
A
PI
KeyCreate
{
if
v
!=
nil
{
_c
.
SetDeletedAt
(
*
v
)
}
...
...
@@ -68,31 +68,31 @@ func (_c *ApiKeyCreate) SetNillableDeletedAt(v *time.Time) *ApiKeyCreate {
}
// SetUserID sets the "user_id" field.
func
(
_c
*
A
pi
KeyCreate
)
SetUserID
(
v
int64
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetUserID
(
v
int64
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
SetUserID
(
v
)
return
_c
}
// SetKey sets the "key" field.
func
(
_c
*
A
pi
KeyCreate
)
SetKey
(
v
string
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetKey
(
v
string
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
SetKey
(
v
)
return
_c
}
// SetName sets the "name" field.
func
(
_c
*
A
pi
KeyCreate
)
SetName
(
v
string
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetName
(
v
string
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
SetName
(
v
)
return
_c
}
// SetGroupID sets the "group_id" field.
func
(
_c
*
A
pi
KeyCreate
)
SetGroupID
(
v
int64
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetGroupID
(
v
int64
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
SetGroupID
(
v
)
return
_c
}
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
func
(
_c
*
A
pi
KeyCreate
)
SetNillableGroupID
(
v
*
int64
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetNillableGroupID
(
v
*
int64
)
*
A
PI
KeyCreate
{
if
v
!=
nil
{
_c
.
SetGroupID
(
*
v
)
}
...
...
@@ -100,13 +100,13 @@ func (_c *ApiKeyCreate) SetNillableGroupID(v *int64) *ApiKeyCreate {
}
// SetStatus sets the "status" field.
func
(
_c
*
A
pi
KeyCreate
)
SetStatus
(
v
string
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetStatus
(
v
string
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
SetStatus
(
v
)
return
_c
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func
(
_c
*
A
pi
KeyCreate
)
SetNillableStatus
(
v
*
string
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetNillableStatus
(
v
*
string
)
*
A
PI
KeyCreate
{
if
v
!=
nil
{
_c
.
SetStatus
(
*
v
)
}
...
...
@@ -114,23 +114,23 @@ func (_c *ApiKeyCreate) SetNillableStatus(v *string) *ApiKeyCreate {
}
// SetUser sets the "user" edge to the User entity.
func
(
_c
*
A
pi
KeyCreate
)
SetUser
(
v
*
User
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetUser
(
v
*
User
)
*
A
PI
KeyCreate
{
return
_c
.
SetUserID
(
v
.
ID
)
}
// SetGroup sets the "group" edge to the Group entity.
func
(
_c
*
A
pi
KeyCreate
)
SetGroup
(
v
*
Group
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
SetGroup
(
v
*
Group
)
*
A
PI
KeyCreate
{
return
_c
.
SetGroupID
(
v
.
ID
)
}
// AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
func
(
_c
*
A
pi
KeyCreate
)
AddUsageLogIDs
(
ids
...
int64
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
AddUsageLogIDs
(
ids
...
int64
)
*
A
PI
KeyCreate
{
_c
.
mutation
.
AddUsageLogIDs
(
ids
...
)
return
_c
}
// AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
func
(
_c
*
A
pi
KeyCreate
)
AddUsageLogs
(
v
...*
UsageLog
)
*
A
pi
KeyCreate
{
func
(
_c
*
A
PI
KeyCreate
)
AddUsageLogs
(
v
...*
UsageLog
)
*
A
PI
KeyCreate
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
@@ -138,13 +138,13 @@ func (_c *ApiKeyCreate) AddUsageLogs(v ...*UsageLog) *ApiKeyCreate {
return
_c
.
AddUsageLogIDs
(
ids
...
)
}
// Mutation returns the A
pi
KeyMutation object of the builder.
func
(
_c
*
A
pi
KeyCreate
)
Mutation
()
*
A
pi
KeyMutation
{
// Mutation returns the A
PI
KeyMutation object of the builder.
func
(
_c
*
A
PI
KeyCreate
)
Mutation
()
*
A
PI
KeyMutation
{
return
_c
.
mutation
}
// Save creates the A
pi
Key in the database.
func
(
_c
*
A
pi
KeyCreate
)
Save
(
ctx
context
.
Context
)
(
*
A
pi
Key
,
error
)
{
// Save creates the A
PI
Key in the database.
func
(
_c
*
A
PI
KeyCreate
)
Save
(
ctx
context
.
Context
)
(
*
A
PI
Key
,
error
)
{
if
err
:=
_c
.
defaults
();
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -152,7 +152,7 @@ func (_c *ApiKeyCreate) Save(ctx context.Context) (*ApiKey, error) {
}
// SaveX calls Save and panics if Save returns an error.
func
(
_c
*
A
pi
KeyCreate
)
SaveX
(
ctx
context
.
Context
)
*
A
pi
Key
{
func
(
_c
*
A
PI
KeyCreate
)
SaveX
(
ctx
context
.
Context
)
*
A
PI
Key
{
v
,
err
:=
_c
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -161,20 +161,20 @@ func (_c *ApiKeyCreate) SaveX(ctx context.Context) *ApiKey {
}
// Exec executes the query.
func
(
_c
*
A
pi
KeyCreate
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
_c
*
A
PI
KeyCreate
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_c
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_c
*
A
pi
KeyCreate
)
ExecX
(
ctx
context
.
Context
)
{
func
(
_c
*
A
PI
KeyCreate
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_c
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_c
*
A
pi
KeyCreate
)
defaults
()
error
{
func
(
_c
*
A
PI
KeyCreate
)
defaults
()
error
{
if
_
,
ok
:=
_c
.
mutation
.
CreatedAt
();
!
ok
{
if
apikey
.
DefaultCreatedAt
==
nil
{
return
fmt
.
Errorf
(
"ent: uninitialized apikey.DefaultCreatedAt (forgotten import ent/runtime?)"
)
...
...
@@ -197,47 +197,47 @@ func (_c *ApiKeyCreate) defaults() error {
}
// check runs all checks and user-defined validators on the builder.
func
(
_c
*
A
pi
KeyCreate
)
check
()
error
{
func
(
_c
*
A
PI
KeyCreate
)
check
()
error
{
if
_
,
ok
:=
_c
.
mutation
.
CreatedAt
();
!
ok
{
return
&
ValidationError
{
Name
:
"created_at"
,
err
:
errors
.
New
(
`ent: missing required field "A
pi
Key.created_at"`
)}
return
&
ValidationError
{
Name
:
"created_at"
,
err
:
errors
.
New
(
`ent: missing required field "A
PI
Key.created_at"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
UpdatedAt
();
!
ok
{
return
&
ValidationError
{
Name
:
"updated_at"
,
err
:
errors
.
New
(
`ent: missing required field "A
pi
Key.updated_at"`
)}
return
&
ValidationError
{
Name
:
"updated_at"
,
err
:
errors
.
New
(
`ent: missing required field "A
PI
Key.updated_at"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
UserID
();
!
ok
{
return
&
ValidationError
{
Name
:
"user_id"
,
err
:
errors
.
New
(
`ent: missing required field "A
pi
Key.user_id"`
)}
return
&
ValidationError
{
Name
:
"user_id"
,
err
:
errors
.
New
(
`ent: missing required field "A
PI
Key.user_id"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
Key
();
!
ok
{
return
&
ValidationError
{
Name
:
"key"
,
err
:
errors
.
New
(
`ent: missing required field "A
pi
Key.key"`
)}
return
&
ValidationError
{
Name
:
"key"
,
err
:
errors
.
New
(
`ent: missing required field "A
PI
Key.key"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
Key
();
ok
{
if
err
:=
apikey
.
KeyValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"key"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.key": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"key"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.key": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
Name
();
!
ok
{
return
&
ValidationError
{
Name
:
"name"
,
err
:
errors
.
New
(
`ent: missing required field "A
pi
Key.name"`
)}
return
&
ValidationError
{
Name
:
"name"
,
err
:
errors
.
New
(
`ent: missing required field "A
PI
Key.name"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
Name
();
ok
{
if
err
:=
apikey
.
NameValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.name": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.name": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
Status
();
!
ok
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
errors
.
New
(
`ent: missing required field "A
pi
Key.status"`
)}
return
&
ValidationError
{
Name
:
"status"
,
err
:
errors
.
New
(
`ent: missing required field "A
PI
Key.status"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
Status
();
ok
{
if
err
:=
apikey
.
StatusValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.status": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.status": %w`
,
err
)}
}
}
if
len
(
_c
.
mutation
.
UserIDs
())
==
0
{
return
&
ValidationError
{
Name
:
"user"
,
err
:
errors
.
New
(
`ent: missing required edge "A
pi
Key.user"`
)}
return
&
ValidationError
{
Name
:
"user"
,
err
:
errors
.
New
(
`ent: missing required edge "A
PI
Key.user"`
)}
}
return
nil
}
func
(
_c
*
A
pi
KeyCreate
)
sqlSave
(
ctx
context
.
Context
)
(
*
A
pi
Key
,
error
)
{
func
(
_c
*
A
PI
KeyCreate
)
sqlSave
(
ctx
context
.
Context
)
(
*
A
PI
Key
,
error
)
{
if
err
:=
_c
.
check
();
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -255,9 +255,9 @@ func (_c *ApiKeyCreate) sqlSave(ctx context.Context) (*ApiKey, error) {
return
_node
,
nil
}
func
(
_c
*
A
pi
KeyCreate
)
createSpec
()
(
*
A
pi
Key
,
*
sqlgraph
.
CreateSpec
)
{
func
(
_c
*
A
PI
KeyCreate
)
createSpec
()
(
*
A
PI
Key
,
*
sqlgraph
.
CreateSpec
)
{
var
(
_node
=
&
A
pi
Key
{
config
:
_c
.
config
}
_node
=
&
A
PI
Key
{
config
:
_c
.
config
}
_spec
=
sqlgraph
.
NewCreateSpec
(
apikey
.
Table
,
sqlgraph
.
NewFieldSpec
(
apikey
.
FieldID
,
field
.
TypeInt64
))
)
_spec
.
OnConflict
=
_c
.
conflict
...
...
@@ -341,7 +341,7 @@ func (_c *ApiKeyCreate) createSpec() (*ApiKey, *sqlgraph.CreateSpec) {
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.A
pi
Key.Create().
// client.A
PI
Key.Create().
// SetCreatedAt(v).
// OnConflict(
// // Update the row with the new values
...
...
@@ -350,13 +350,13 @@ func (_c *ApiKeyCreate) createSpec() (*ApiKey, *sqlgraph.CreateSpec) {
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.A
pi
KeyUpsert) {
// Update(func(u *ent.A
PI
KeyUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func
(
_c
*
A
pi
KeyCreate
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
A
pi
KeyUpsertOne
{
func
(
_c
*
A
PI
KeyCreate
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
A
PI
KeyUpsertOne
{
_c
.
conflict
=
opts
return
&
A
pi
KeyUpsertOne
{
return
&
A
PI
KeyUpsertOne
{
create
:
_c
,
}
}
...
...
@@ -364,121 +364,121 @@ func (_c *ApiKeyCreate) OnConflict(opts ...sql.ConflictOption) *ApiKeyUpsertOne
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.A
pi
Key.Create().
// client.A
PI
Key.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func
(
_c
*
A
pi
KeyCreate
)
OnConflictColumns
(
columns
...
string
)
*
A
pi
KeyUpsertOne
{
func
(
_c
*
A
PI
KeyCreate
)
OnConflictColumns
(
columns
...
string
)
*
A
PI
KeyUpsertOne
{
_c
.
conflict
=
append
(
_c
.
conflict
,
sql
.
ConflictColumns
(
columns
...
))
return
&
A
pi
KeyUpsertOne
{
return
&
A
PI
KeyUpsertOne
{
create
:
_c
,
}
}
type
(
// A
pi
KeyUpsertOne is the builder for "upsert"-ing
// one A
pi
Key node.
A
pi
KeyUpsertOne
struct
{
create
*
A
pi
KeyCreate
// A
PI
KeyUpsertOne is the builder for "upsert"-ing
// one A
PI
Key node.
A
PI
KeyUpsertOne
struct
{
create
*
A
PI
KeyCreate
}
// A
pi
KeyUpsert is the "OnConflict" setter.
A
pi
KeyUpsert
struct
{
// A
PI
KeyUpsert is the "OnConflict" setter.
A
PI
KeyUpsert
struct
{
*
sql
.
UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
A
pi
KeyUpsert
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
PI
KeyUpsert
{
u
.
Set
(
apikey
.
FieldUpdatedAt
,
v
)
return
u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsert
)
UpdateUpdatedAt
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
UpdateUpdatedAt
()
*
A
PI
KeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldUpdatedAt
)
return
u
}
// SetDeletedAt sets the "deleted_at" field.
func
(
u
*
A
pi
KeyUpsert
)
SetDeletedAt
(
v
time
.
Time
)
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
SetDeletedAt
(
v
time
.
Time
)
*
A
PI
KeyUpsert
{
u
.
Set
(
apikey
.
FieldDeletedAt
,
v
)
return
u
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsert
)
UpdateDeletedAt
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
UpdateDeletedAt
()
*
A
PI
KeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldDeletedAt
)
return
u
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func
(
u
*
A
pi
KeyUpsert
)
ClearDeletedAt
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
ClearDeletedAt
()
*
A
PI
KeyUpsert
{
u
.
SetNull
(
apikey
.
FieldDeletedAt
)
return
u
}
// SetUserID sets the "user_id" field.
func
(
u
*
A
pi
KeyUpsert
)
SetUserID
(
v
int64
)
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
SetUserID
(
v
int64
)
*
A
PI
KeyUpsert
{
u
.
Set
(
apikey
.
FieldUserID
,
v
)
return
u
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsert
)
UpdateUserID
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
UpdateUserID
()
*
A
PI
KeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldUserID
)
return
u
}
// SetKey sets the "key" field.
func
(
u
*
A
pi
KeyUpsert
)
SetKey
(
v
string
)
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
SetKey
(
v
string
)
*
A
PI
KeyUpsert
{
u
.
Set
(
apikey
.
FieldKey
,
v
)
return
u
}
// UpdateKey sets the "key" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsert
)
UpdateKey
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
UpdateKey
()
*
A
PI
KeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldKey
)
return
u
}
// SetName sets the "name" field.
func
(
u
*
A
pi
KeyUpsert
)
SetName
(
v
string
)
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
SetName
(
v
string
)
*
A
PI
KeyUpsert
{
u
.
Set
(
apikey
.
FieldName
,
v
)
return
u
}
// UpdateName sets the "name" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsert
)
UpdateName
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
UpdateName
()
*
A
PI
KeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldName
)
return
u
}
// SetGroupID sets the "group_id" field.
func
(
u
*
A
pi
KeyUpsert
)
SetGroupID
(
v
int64
)
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
SetGroupID
(
v
int64
)
*
A
PI
KeyUpsert
{
u
.
Set
(
apikey
.
FieldGroupID
,
v
)
return
u
}
// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsert
)
UpdateGroupID
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
UpdateGroupID
()
*
A
PI
KeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldGroupID
)
return
u
}
// ClearGroupID clears the value of the "group_id" field.
func
(
u
*
A
pi
KeyUpsert
)
ClearGroupID
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
ClearGroupID
()
*
A
PI
KeyUpsert
{
u
.
SetNull
(
apikey
.
FieldGroupID
)
return
u
}
// SetStatus sets the "status" field.
func
(
u
*
A
pi
KeyUpsert
)
SetStatus
(
v
string
)
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
SetStatus
(
v
string
)
*
A
PI
KeyUpsert
{
u
.
Set
(
apikey
.
FieldStatus
,
v
)
return
u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsert
)
UpdateStatus
()
*
A
pi
KeyUpsert
{
func
(
u
*
A
PI
KeyUpsert
)
UpdateStatus
()
*
A
PI
KeyUpsert
{
u
.
SetExcluded
(
apikey
.
FieldStatus
)
return
u
}
...
...
@@ -486,12 +486,12 @@ func (u *ApiKeyUpsert) UpdateStatus() *ApiKeyUpsert {
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.A
pi
Key.Create().
// client.A
PI
Key.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func
(
u
*
A
pi
KeyUpsertOne
)
UpdateNewValues
()
*
A
pi
KeyUpsertOne
{
func
(
u
*
A
PI
KeyUpsertOne
)
UpdateNewValues
()
*
A
PI
KeyUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithNewValues
())
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
s
*
sql
.
UpdateSet
)
{
if
_
,
exists
:=
u
.
create
.
mutation
.
CreatedAt
();
exists
{
...
...
@@ -504,159 +504,159 @@ func (u *ApiKeyUpsertOne) UpdateNewValues() *ApiKeyUpsertOne {
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.A
pi
Key.Create().
// client.A
PI
Key.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func
(
u
*
A
pi
KeyUpsertOne
)
Ignore
()
*
A
pi
KeyUpsertOne
{
func
(
u
*
A
PI
KeyUpsertOne
)
Ignore
()
*
A
PI
KeyUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithIgnore
())
return
u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func
(
u
*
A
pi
KeyUpsertOne
)
DoNothing
()
*
A
pi
KeyUpsertOne
{
func
(
u
*
A
PI
KeyUpsertOne
)
DoNothing
()
*
A
PI
KeyUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
DoNothing
())
return
u
}
// Update allows overriding fields `UPDATE` values. See the A
pi
KeyCreate.OnConflict
// Update allows overriding fields `UPDATE` values. See the A
PI
KeyCreate.OnConflict
// documentation for more info.
func
(
u
*
A
pi
KeyUpsertOne
)
Update
(
set
func
(
*
A
pi
KeyUpsert
))
*
A
pi
KeyUpsertOne
{
func
(
u
*
A
PI
KeyUpsertOne
)
Update
(
set
func
(
*
A
PI
KeyUpsert
))
*
A
PI
KeyUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
update
*
sql
.
UpdateSet
)
{
set
(
&
A
pi
KeyUpsert
{
UpdateSet
:
update
})
set
(
&
A
PI
KeyUpsert
{
UpdateSet
:
update
})
}))
return
u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
A
pi
KeyUpsertOne
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetUpdatedAt
(
v
)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertOne
)
UpdateUpdatedAt
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
UpdateUpdatedAt
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateUpdatedAt
()
})
}
// SetDeletedAt sets the "deleted_at" field.
func
(
u
*
A
pi
KeyUpsertOne
)
SetDeletedAt
(
v
time
.
Time
)
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
SetDeletedAt
(
v
time
.
Time
)
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetDeletedAt
(
v
)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertOne
)
UpdateDeletedAt
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
UpdateDeletedAt
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateDeletedAt
()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func
(
u
*
A
pi
KeyUpsertOne
)
ClearDeletedAt
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
ClearDeletedAt
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
ClearDeletedAt
()
})
}
// SetUserID sets the "user_id" field.
func
(
u
*
A
pi
KeyUpsertOne
)
SetUserID
(
v
int64
)
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
SetUserID
(
v
int64
)
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetUserID
(
v
)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertOne
)
UpdateUserID
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
UpdateUserID
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateUserID
()
})
}
// SetKey sets the "key" field.
func
(
u
*
A
pi
KeyUpsertOne
)
SetKey
(
v
string
)
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
SetKey
(
v
string
)
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetKey
(
v
)
})
}
// UpdateKey sets the "key" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertOne
)
UpdateKey
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
UpdateKey
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateKey
()
})
}
// SetName sets the "name" field.
func
(
u
*
A
pi
KeyUpsertOne
)
SetName
(
v
string
)
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
SetName
(
v
string
)
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetName
(
v
)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertOne
)
UpdateName
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
UpdateName
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateName
()
})
}
// SetGroupID sets the "group_id" field.
func
(
u
*
A
pi
KeyUpsertOne
)
SetGroupID
(
v
int64
)
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
SetGroupID
(
v
int64
)
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetGroupID
(
v
)
})
}
// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertOne
)
UpdateGroupID
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
UpdateGroupID
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateGroupID
()
})
}
// ClearGroupID clears the value of the "group_id" field.
func
(
u
*
A
pi
KeyUpsertOne
)
ClearGroupID
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
ClearGroupID
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
ClearGroupID
()
})
}
// SetStatus sets the "status" field.
func
(
u
*
A
pi
KeyUpsertOne
)
SetStatus
(
v
string
)
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
SetStatus
(
v
string
)
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetStatus
(
v
)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertOne
)
UpdateStatus
()
*
A
pi
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
UpdateStatus
()
*
A
PI
KeyUpsertOne
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateStatus
()
})
}
// Exec executes the query.
func
(
u
*
A
pi
KeyUpsertOne
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
u
*
A
PI
KeyUpsertOne
)
Exec
(
ctx
context
.
Context
)
error
{
if
len
(
u
.
create
.
conflict
)
==
0
{
return
errors
.
New
(
"ent: missing options for A
pi
KeyCreate.OnConflict"
)
return
errors
.
New
(
"ent: missing options for A
PI
KeyCreate.OnConflict"
)
}
return
u
.
create
.
Exec
(
ctx
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
u
*
A
pi
KeyUpsertOne
)
ExecX
(
ctx
context
.
Context
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
u
.
create
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func
(
u
*
A
pi
KeyUpsertOne
)
ID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
func
(
u
*
A
PI
KeyUpsertOne
)
ID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
node
,
err
:=
u
.
create
.
Save
(
ctx
)
if
err
!=
nil
{
return
id
,
err
...
...
@@ -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.
func
(
u
*
A
pi
KeyUpsertOne
)
IDX
(
ctx
context
.
Context
)
int64
{
func
(
u
*
A
PI
KeyUpsertOne
)
IDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
u
.
ID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -673,28 +673,28 @@ func (u *ApiKeyUpsertOne) IDX(ctx context.Context) int64 {
return
id
}
// A
pi
KeyCreateBulk is the builder for creating many A
pi
Key entities in bulk.
type
A
pi
KeyCreateBulk
struct
{
// A
PI
KeyCreateBulk is the builder for creating many A
PI
Key entities in bulk.
type
A
PI
KeyCreateBulk
struct
{
config
err
error
builders
[]
*
A
pi
KeyCreate
builders
[]
*
A
PI
KeyCreate
conflict
[]
sql
.
ConflictOption
}
// Save creates the A
pi
Key entities in the database.
func
(
_c
*
A
pi
KeyCreateBulk
)
Save
(
ctx
context
.
Context
)
([]
*
A
pi
Key
,
error
)
{
// Save creates the A
PI
Key entities in the database.
func
(
_c
*
A
PI
KeyCreateBulk
)
Save
(
ctx
context
.
Context
)
([]
*
A
PI
Key
,
error
)
{
if
_c
.
err
!=
nil
{
return
nil
,
_c
.
err
}
specs
:=
make
([]
*
sqlgraph
.
CreateSpec
,
len
(
_c
.
builders
))
nodes
:=
make
([]
*
A
pi
Key
,
len
(
_c
.
builders
))
nodes
:=
make
([]
*
A
PI
Key
,
len
(
_c
.
builders
))
mutators
:=
make
([]
Mutator
,
len
(
_c
.
builders
))
for
i
:=
range
_c
.
builders
{
func
(
i
int
,
root
context
.
Context
)
{
builder
:=
_c
.
builders
[
i
]
builder
.
defaults
()
var
mut
Mutator
=
MutateFunc
(
func
(
ctx
context
.
Context
,
m
Mutation
)
(
Value
,
error
)
{
mutation
,
ok
:=
m
.
(
*
A
pi
KeyMutation
)
mutation
,
ok
:=
m
.
(
*
A
PI
KeyMutation
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T"
,
m
)
}
...
...
@@ -742,7 +742,7 @@ func (_c *ApiKeyCreateBulk) Save(ctx context.Context) ([]*ApiKey, error) {
}
// SaveX is like Save, but panics if an error occurs.
func
(
_c
*
A
pi
KeyCreateBulk
)
SaveX
(
ctx
context
.
Context
)
[]
*
A
pi
Key
{
func
(
_c
*
A
PI
KeyCreateBulk
)
SaveX
(
ctx
context
.
Context
)
[]
*
A
PI
Key
{
v
,
err
:=
_c
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -751,13 +751,13 @@ func (_c *ApiKeyCreateBulk) SaveX(ctx context.Context) []*ApiKey {
}
// Exec executes the query.
func
(
_c
*
A
pi
KeyCreateBulk
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
_c
*
A
PI
KeyCreateBulk
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_c
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_c
*
A
pi
KeyCreateBulk
)
ExecX
(
ctx
context
.
Context
)
{
func
(
_c
*
A
PI
KeyCreateBulk
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_c
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
...
...
@@ -766,7 +766,7 @@ func (_c *ApiKeyCreateBulk) ExecX(ctx context.Context) {
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.A
pi
Key.CreateBulk(builders...).
// client.A
PI
Key.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
...
...
@@ -774,13 +774,13 @@ func (_c *ApiKeyCreateBulk) ExecX(ctx context.Context) {
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.A
pi
KeyUpsert) {
// Update(func(u *ent.A
PI
KeyUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func
(
_c
*
A
pi
KeyCreateBulk
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
A
pi
KeyUpsertBulk
{
func
(
_c
*
A
PI
KeyCreateBulk
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
A
PI
KeyUpsertBulk
{
_c
.
conflict
=
opts
return
&
A
pi
KeyUpsertBulk
{
return
&
A
PI
KeyUpsertBulk
{
create
:
_c
,
}
}
...
...
@@ -788,31 +788,31 @@ func (_c *ApiKeyCreateBulk) OnConflict(opts ...sql.ConflictOption) *ApiKeyUpsert
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.A
pi
Key.Create().
// client.A
PI
Key.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func
(
_c
*
A
pi
KeyCreateBulk
)
OnConflictColumns
(
columns
...
string
)
*
A
pi
KeyUpsertBulk
{
func
(
_c
*
A
PI
KeyCreateBulk
)
OnConflictColumns
(
columns
...
string
)
*
A
PI
KeyUpsertBulk
{
_c
.
conflict
=
append
(
_c
.
conflict
,
sql
.
ConflictColumns
(
columns
...
))
return
&
A
pi
KeyUpsertBulk
{
return
&
A
PI
KeyUpsertBulk
{
create
:
_c
,
}
}
// A
pi
KeyUpsertBulk is the builder for "upsert"-ing
// a bulk of A
pi
Key nodes.
type
A
pi
KeyUpsertBulk
struct
{
create
*
A
pi
KeyCreateBulk
// A
PI
KeyUpsertBulk is the builder for "upsert"-ing
// a bulk of A
PI
Key nodes.
type
A
PI
KeyUpsertBulk
struct
{
create
*
A
PI
KeyCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.A
pi
Key.Create().
// client.A
PI
Key.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func
(
u
*
A
pi
KeyUpsertBulk
)
UpdateNewValues
()
*
A
pi
KeyUpsertBulk
{
func
(
u
*
A
PI
KeyUpsertBulk
)
UpdateNewValues
()
*
A
PI
KeyUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithNewValues
())
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
s
*
sql
.
UpdateSet
)
{
for
_
,
b
:=
range
u
.
create
.
builders
{
...
...
@@ -827,160 +827,160 @@ func (u *ApiKeyUpsertBulk) UpdateNewValues() *ApiKeyUpsertBulk {
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.A
pi
Key.Create().
// client.A
PI
Key.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func
(
u
*
A
pi
KeyUpsertBulk
)
Ignore
()
*
A
pi
KeyUpsertBulk
{
func
(
u
*
A
PI
KeyUpsertBulk
)
Ignore
()
*
A
PI
KeyUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithIgnore
())
return
u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func
(
u
*
A
pi
KeyUpsertBulk
)
DoNothing
()
*
A
pi
KeyUpsertBulk
{
func
(
u
*
A
PI
KeyUpsertBulk
)
DoNothing
()
*
A
PI
KeyUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
DoNothing
())
return
u
}
// Update allows overriding fields `UPDATE` values. See the A
pi
KeyCreateBulk.OnConflict
// Update allows overriding fields `UPDATE` values. See the A
PI
KeyCreateBulk.OnConflict
// documentation for more info.
func
(
u
*
A
pi
KeyUpsertBulk
)
Update
(
set
func
(
*
A
pi
KeyUpsert
))
*
A
pi
KeyUpsertBulk
{
func
(
u
*
A
PI
KeyUpsertBulk
)
Update
(
set
func
(
*
A
PI
KeyUpsert
))
*
A
PI
KeyUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
update
*
sql
.
UpdateSet
)
{
set
(
&
A
pi
KeyUpsert
{
UpdateSet
:
update
})
set
(
&
A
PI
KeyUpsert
{
UpdateSet
:
update
})
}))
return
u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetUpdatedAt
(
v
)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertBulk
)
UpdateUpdatedAt
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
UpdateUpdatedAt
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateUpdatedAt
()
})
}
// SetDeletedAt sets the "deleted_at" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
SetDeletedAt
(
v
time
.
Time
)
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
SetDeletedAt
(
v
time
.
Time
)
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetDeletedAt
(
v
)
})
}
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertBulk
)
UpdateDeletedAt
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
UpdateDeletedAt
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateDeletedAt
()
})
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
ClearDeletedAt
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
ClearDeletedAt
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
ClearDeletedAt
()
})
}
// SetUserID sets the "user_id" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
SetUserID
(
v
int64
)
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
SetUserID
(
v
int64
)
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetUserID
(
v
)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertBulk
)
UpdateUserID
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
UpdateUserID
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateUserID
()
})
}
// SetKey sets the "key" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
SetKey
(
v
string
)
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
SetKey
(
v
string
)
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetKey
(
v
)
})
}
// UpdateKey sets the "key" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertBulk
)
UpdateKey
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
UpdateKey
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateKey
()
})
}
// SetName sets the "name" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
SetName
(
v
string
)
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
SetName
(
v
string
)
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetName
(
v
)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertBulk
)
UpdateName
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
UpdateName
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateName
()
})
}
// SetGroupID sets the "group_id" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
SetGroupID
(
v
int64
)
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
SetGroupID
(
v
int64
)
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetGroupID
(
v
)
})
}
// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertBulk
)
UpdateGroupID
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
UpdateGroupID
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateGroupID
()
})
}
// ClearGroupID clears the value of the "group_id" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
ClearGroupID
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
ClearGroupID
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
ClearGroupID
()
})
}
// SetStatus sets the "status" field.
func
(
u
*
A
pi
KeyUpsertBulk
)
SetStatus
(
v
string
)
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
SetStatus
(
v
string
)
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
SetStatus
(
v
)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func
(
u
*
A
pi
KeyUpsertBulk
)
UpdateStatus
()
*
A
pi
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
pi
KeyUpsert
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
UpdateStatus
()
*
A
PI
KeyUpsertBulk
{
return
u
.
Update
(
func
(
s
*
A
PI
KeyUpsert
)
{
s
.
UpdateStatus
()
})
}
// Exec executes the query.
func
(
u
*
A
pi
KeyUpsertBulk
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
u
*
A
PI
KeyUpsertBulk
)
Exec
(
ctx
context
.
Context
)
error
{
if
u
.
create
.
err
!=
nil
{
return
u
.
create
.
err
}
for
i
,
b
:=
range
u
.
create
.
builders
{
if
len
(
b
.
conflict
)
!=
0
{
return
fmt
.
Errorf
(
"ent: OnConflict was set for builder %d. Set it on the A
pi
KeyCreateBulk instead"
,
i
)
return
fmt
.
Errorf
(
"ent: OnConflict was set for builder %d. Set it on the A
PI
KeyCreateBulk instead"
,
i
)
}
}
if
len
(
u
.
create
.
conflict
)
==
0
{
return
errors
.
New
(
"ent: missing options for A
pi
KeyCreateBulk.OnConflict"
)
return
errors
.
New
(
"ent: missing options for A
PI
KeyCreateBulk.OnConflict"
)
}
return
u
.
create
.
Exec
(
ctx
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
u
*
A
pi
KeyUpsertBulk
)
ExecX
(
ctx
context
.
Context
)
{
func
(
u
*
A
PI
KeyUpsertBulk
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
u
.
create
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
...
...
backend/ent/apikey_delete.go
View file @
c86d445c
...
...
@@ -12,26 +12,26 @@ import (
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// A
pi
KeyDelete is the builder for deleting a A
pi
Key entity.
type
A
pi
KeyDelete
struct
{
// A
PI
KeyDelete is the builder for deleting a A
PI
Key entity.
type
A
PI
KeyDelete
struct
{
config
hooks
[]
Hook
mutation
*
A
pi
KeyMutation
mutation
*
A
PI
KeyMutation
}
// Where appends a list predicates to the A
pi
KeyDelete builder.
func
(
_d
*
A
pi
KeyDelete
)
Where
(
ps
...
predicate
.
A
pi
Key
)
*
A
pi
KeyDelete
{
// Where appends a list predicates to the A
PI
KeyDelete builder.
func
(
_d
*
A
PI
KeyDelete
)
Where
(
ps
...
predicate
.
A
PI
Key
)
*
A
PI
KeyDelete
{
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func
(
_d
*
A
pi
KeyDelete
)
Exec
(
ctx
context
.
Context
)
(
int
,
error
)
{
func
(
_d
*
A
PI
KeyDelete
)
Exec
(
ctx
context
.
Context
)
(
int
,
error
)
{
return
withHooks
(
ctx
,
_d
.
sqlExec
,
_d
.
mutation
,
_d
.
hooks
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
A
pi
KeyDelete
)
ExecX
(
ctx
context
.
Context
)
int
{
func
(
_d
*
A
PI
KeyDelete
)
ExecX
(
ctx
context
.
Context
)
int
{
n
,
err
:=
_d
.
Exec
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -39,7 +39,7 @@ func (_d *ApiKeyDelete) ExecX(ctx context.Context) int {
return
n
}
func
(
_d
*
A
pi
KeyDelete
)
sqlExec
(
ctx
context
.
Context
)
(
int
,
error
)
{
func
(
_d
*
A
PI
KeyDelete
)
sqlExec
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
sqlgraph
.
NewDeleteSpec
(
apikey
.
Table
,
sqlgraph
.
NewFieldSpec
(
apikey
.
FieldID
,
field
.
TypeInt64
))
if
ps
:=
_d
.
mutation
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
...
...
@@ -56,19 +56,19 @@ func (_d *ApiKeyDelete) sqlExec(ctx context.Context) (int, error) {
return
affected
,
err
}
// A
pi
KeyDeleteOne is the builder for deleting a single A
pi
Key entity.
type
A
pi
KeyDeleteOne
struct
{
_d
*
A
pi
KeyDelete
// A
PI
KeyDeleteOne is the builder for deleting a single A
PI
Key entity.
type
A
PI
KeyDeleteOne
struct
{
_d
*
A
PI
KeyDelete
}
// Where appends a list predicates to the A
pi
KeyDelete builder.
func
(
_d
*
A
pi
KeyDeleteOne
)
Where
(
ps
...
predicate
.
A
pi
Key
)
*
A
pi
KeyDeleteOne
{
// Where appends a list predicates to the A
PI
KeyDelete builder.
func
(
_d
*
A
PI
KeyDeleteOne
)
Where
(
ps
...
predicate
.
A
PI
Key
)
*
A
PI
KeyDeleteOne
{
_d
.
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query.
func
(
_d
*
A
pi
KeyDeleteOne
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
_d
*
A
PI
KeyDeleteOne
)
Exec
(
ctx
context
.
Context
)
error
{
n
,
err
:=
_d
.
_d
.
Exec
(
ctx
)
switch
{
case
err
!=
nil
:
...
...
@@ -81,7 +81,7 @@ func (_d *ApiKeyDeleteOne) Exec(ctx context.Context) error {
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
A
pi
KeyDeleteOne
)
ExecX
(
ctx
context
.
Context
)
{
func
(
_d
*
A
PI
KeyDeleteOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_d
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
...
...
backend/ent/apikey_query.go
View file @
c86d445c
...
...
@@ -19,13 +19,13 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user"
)
// A
pi
KeyQuery is the builder for querying A
pi
Key entities.
type
A
pi
KeyQuery
struct
{
// A
PI
KeyQuery is the builder for querying A
PI
Key entities.
type
A
PI
KeyQuery
struct
{
config
ctx
*
QueryContext
order
[]
apikey
.
OrderOption
inters
[]
Interceptor
predicates
[]
predicate
.
A
pi
Key
predicates
[]
predicate
.
A
PI
Key
withUser
*
UserQuery
withGroup
*
GroupQuery
withUsageLogs
*
UsageLogQuery
...
...
@@ -34,39 +34,39 @@ type ApiKeyQuery struct {
path
func
(
context
.
Context
)
(
*
sql
.
Selector
,
error
)
}
// Where adds a new predicate for the A
pi
KeyQuery builder.
func
(
_q
*
A
pi
KeyQuery
)
Where
(
ps
...
predicate
.
A
pi
Key
)
*
A
pi
KeyQuery
{
// Where adds a new predicate for the A
PI
KeyQuery builder.
func
(
_q
*
A
PI
KeyQuery
)
Where
(
ps
...
predicate
.
A
PI
Key
)
*
A
PI
KeyQuery
{
_q
.
predicates
=
append
(
_q
.
predicates
,
ps
...
)
return
_q
}
// Limit the number of records to be returned by this query.
func
(
_q
*
A
pi
KeyQuery
)
Limit
(
limit
int
)
*
A
pi
KeyQuery
{
func
(
_q
*
A
PI
KeyQuery
)
Limit
(
limit
int
)
*
A
PI
KeyQuery
{
_q
.
ctx
.
Limit
=
&
limit
return
_q
}
// Offset to start from.
func
(
_q
*
A
pi
KeyQuery
)
Offset
(
offset
int
)
*
A
pi
KeyQuery
{
func
(
_q
*
A
PI
KeyQuery
)
Offset
(
offset
int
)
*
A
PI
KeyQuery
{
_q
.
ctx
.
Offset
=
&
offset
return
_q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func
(
_q
*
A
pi
KeyQuery
)
Unique
(
unique
bool
)
*
A
pi
KeyQuery
{
func
(
_q
*
A
PI
KeyQuery
)
Unique
(
unique
bool
)
*
A
PI
KeyQuery
{
_q
.
ctx
.
Unique
=
&
unique
return
_q
}
// Order specifies how the records should be ordered.
func
(
_q
*
A
pi
KeyQuery
)
Order
(
o
...
apikey
.
OrderOption
)
*
A
pi
KeyQuery
{
func
(
_q
*
A
PI
KeyQuery
)
Order
(
o
...
apikey
.
OrderOption
)
*
A
PI
KeyQuery
{
_q
.
order
=
append
(
_q
.
order
,
o
...
)
return
_q
}
// QueryUser chains the current query on the "user" edge.
func
(
_q
*
A
pi
KeyQuery
)
QueryUser
()
*
UserQuery
{
func
(
_q
*
A
PI
KeyQuery
)
QueryUser
()
*
UserQuery
{
query
:=
(
&
UserClient
{
config
:
_q
.
config
})
.
Query
()
query
.
path
=
func
(
ctx
context
.
Context
)
(
fromU
*
sql
.
Selector
,
err
error
)
{
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
...
...
@@ -88,7 +88,7 @@ func (_q *ApiKeyQuery) QueryUser() *UserQuery {
}
// QueryGroup chains the current query on the "group" edge.
func
(
_q
*
A
pi
KeyQuery
)
QueryGroup
()
*
GroupQuery
{
func
(
_q
*
A
PI
KeyQuery
)
QueryGroup
()
*
GroupQuery
{
query
:=
(
&
GroupClient
{
config
:
_q
.
config
})
.
Query
()
query
.
path
=
func
(
ctx
context
.
Context
)
(
fromU
*
sql
.
Selector
,
err
error
)
{
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
...
...
@@ -110,7 +110,7 @@ func (_q *ApiKeyQuery) QueryGroup() *GroupQuery {
}
// QueryUsageLogs chains the current query on the "usage_logs" edge.
func
(
_q
*
A
pi
KeyQuery
)
QueryUsageLogs
()
*
UsageLogQuery
{
func
(
_q
*
A
PI
KeyQuery
)
QueryUsageLogs
()
*
UsageLogQuery
{
query
:=
(
&
UsageLogClient
{
config
:
_q
.
config
})
.
Query
()
query
.
path
=
func
(
ctx
context
.
Context
)
(
fromU
*
sql
.
Selector
,
err
error
)
{
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
...
...
@@ -131,9 +131,9 @@ func (_q *ApiKeyQuery) QueryUsageLogs() *UsageLogQuery {
return
query
}
// First returns the first A
pi
Key entity from the query.
// Returns a *NotFoundError when no A
pi
Key was found.
func
(
_q
*
A
pi
KeyQuery
)
First
(
ctx
context
.
Context
)
(
*
A
pi
Key
,
error
)
{
// First returns the first A
PI
Key entity from the query.
// Returns a *NotFoundError when no A
PI
Key was found.
func
(
_q
*
A
PI
KeyQuery
)
First
(
ctx
context
.
Context
)
(
*
A
PI
Key
,
error
)
{
nodes
,
err
:=
_q
.
Limit
(
1
)
.
All
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryFirst
))
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -145,7 +145,7 @@ func (_q *ApiKeyQuery) First(ctx context.Context) (*ApiKey, error) {
}
// FirstX is like First, but panics if an error occurs.
func
(
_q
*
A
pi
KeyQuery
)
FirstX
(
ctx
context
.
Context
)
*
A
pi
Key
{
func
(
_q
*
A
PI
KeyQuery
)
FirstX
(
ctx
context
.
Context
)
*
A
PI
Key
{
node
,
err
:=
_q
.
First
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
...
...
@@ -153,9 +153,9 @@ func (_q *ApiKeyQuery) FirstX(ctx context.Context) *ApiKey {
return
node
}
// FirstID returns the first A
pi
Key ID from the query.
// Returns a *NotFoundError when no A
pi
Key ID was found.
func
(
_q
*
A
pi
KeyQuery
)
FirstID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
// FirstID returns the first A
PI
Key ID from the query.
// Returns a *NotFoundError when no A
PI
Key ID was found.
func
(
_q
*
A
PI
KeyQuery
)
FirstID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
var
ids
[]
int64
if
ids
,
err
=
_q
.
Limit
(
1
)
.
IDs
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryFirstID
));
err
!=
nil
{
return
...
...
@@ -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.
func
(
_q
*
A
pi
KeyQuery
)
FirstIDX
(
ctx
context
.
Context
)
int64
{
func
(
_q
*
A
PI
KeyQuery
)
FirstIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
FirstID
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
...
...
@@ -176,10 +176,10 @@ func (_q *ApiKeyQuery) FirstIDX(ctx context.Context) int64 {
return
id
}
// Only returns a single A
pi
Key entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one A
pi
Key entity is found.
// Returns a *NotFoundError when no A
pi
Key entities are found.
func
(
_q
*
A
pi
KeyQuery
)
Only
(
ctx
context
.
Context
)
(
*
A
pi
Key
,
error
)
{
// Only returns a single A
PI
Key entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one A
PI
Key entity is found.
// Returns a *NotFoundError when no A
PI
Key entities are found.
func
(
_q
*
A
PI
KeyQuery
)
Only
(
ctx
context
.
Context
)
(
*
A
PI
Key
,
error
)
{
nodes
,
err
:=
_q
.
Limit
(
2
)
.
All
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryOnly
))
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -195,7 +195,7 @@ func (_q *ApiKeyQuery) Only(ctx context.Context) (*ApiKey, error) {
}
// OnlyX is like Only, but panics if an error occurs.
func
(
_q
*
A
pi
KeyQuery
)
OnlyX
(
ctx
context
.
Context
)
*
A
pi
Key
{
func
(
_q
*
A
PI
KeyQuery
)
OnlyX
(
ctx
context
.
Context
)
*
A
PI
Key
{
node
,
err
:=
_q
.
Only
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -203,10 +203,10 @@ func (_q *ApiKeyQuery) OnlyX(ctx context.Context) *ApiKey {
return
node
}
// OnlyID is like Only, but returns the only A
pi
Key ID in the query.
// Returns a *NotSingularError when more than one A
pi
Key ID is found.
// OnlyID is like Only, but returns the only A
PI
Key ID in the query.
// Returns a *NotSingularError when more than one A
PI
Key ID is found.
// Returns a *NotFoundError when no entities are found.
func
(
_q
*
A
pi
KeyQuery
)
OnlyID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
func
(
_q
*
A
PI
KeyQuery
)
OnlyID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
var
ids
[]
int64
if
ids
,
err
=
_q
.
Limit
(
2
)
.
IDs
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryOnlyID
));
err
!=
nil
{
return
...
...
@@ -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.
func
(
_q
*
A
pi
KeyQuery
)
OnlyIDX
(
ctx
context
.
Context
)
int64
{
func
(
_q
*
A
PI
KeyQuery
)
OnlyIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
OnlyID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -231,18 +231,18 @@ func (_q *ApiKeyQuery) OnlyIDX(ctx context.Context) int64 {
return
id
}
// All executes the query and returns a list of A
pi
Keys.
func
(
_q
*
A
pi
KeyQuery
)
All
(
ctx
context
.
Context
)
([]
*
A
pi
Key
,
error
)
{
// All executes the query and returns a list of A
PI
Keys.
func
(
_q
*
A
PI
KeyQuery
)
All
(
ctx
context
.
Context
)
([]
*
A
PI
Key
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryAll
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
nil
,
err
}
qr
:=
querierAll
[[]
*
A
pi
Key
,
*
A
pi
KeyQuery
]()
return
withInterceptors
[[]
*
A
pi
Key
](
ctx
,
_q
,
qr
,
_q
.
inters
)
qr
:=
querierAll
[[]
*
A
PI
Key
,
*
A
PI
KeyQuery
]()
return
withInterceptors
[[]
*
A
PI
Key
](
ctx
,
_q
,
qr
,
_q
.
inters
)
}
// AllX is like All, but panics if an error occurs.
func
(
_q
*
A
pi
KeyQuery
)
AllX
(
ctx
context
.
Context
)
[]
*
A
pi
Key
{
func
(
_q
*
A
PI
KeyQuery
)
AllX
(
ctx
context
.
Context
)
[]
*
A
PI
Key
{
nodes
,
err
:=
_q
.
All
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -250,8 +250,8 @@ func (_q *ApiKeyQuery) AllX(ctx context.Context) []*ApiKey {
return
nodes
}
// IDs executes the query and returns a list of A
pi
Key IDs.
func
(
_q
*
A
pi
KeyQuery
)
IDs
(
ctx
context
.
Context
)
(
ids
[]
int64
,
err
error
)
{
// IDs executes the query and returns a list of A
PI
Key IDs.
func
(
_q
*
A
PI
KeyQuery
)
IDs
(
ctx
context
.
Context
)
(
ids
[]
int64
,
err
error
)
{
if
_q
.
ctx
.
Unique
==
nil
&&
_q
.
path
!=
nil
{
_q
.
Unique
(
true
)
}
...
...
@@ -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.
func
(
_q
*
A
pi
KeyQuery
)
IDsX
(
ctx
context
.
Context
)
[]
int64
{
func
(
_q
*
A
PI
KeyQuery
)
IDsX
(
ctx
context
.
Context
)
[]
int64
{
ids
,
err
:=
_q
.
IDs
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -272,16 +272,16 @@ func (_q *ApiKeyQuery) IDsX(ctx context.Context) []int64 {
}
// Count returns the count of the given query.
func
(
_q
*
A
pi
KeyQuery
)
Count
(
ctx
context
.
Context
)
(
int
,
error
)
{
func
(
_q
*
A
PI
KeyQuery
)
Count
(
ctx
context
.
Context
)
(
int
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryCount
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
0
,
err
}
return
withInterceptors
[
int
](
ctx
,
_q
,
querierCount
[
*
A
pi
KeyQuery
](),
_q
.
inters
)
return
withInterceptors
[
int
](
ctx
,
_q
,
querierCount
[
*
A
PI
KeyQuery
](),
_q
.
inters
)
}
// CountX is like Count, but panics if an error occurs.
func
(
_q
*
A
pi
KeyQuery
)
CountX
(
ctx
context
.
Context
)
int
{
func
(
_q
*
A
PI
KeyQuery
)
CountX
(
ctx
context
.
Context
)
int
{
count
,
err
:=
_q
.
Count
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -290,7 +290,7 @@ func (_q *ApiKeyQuery) CountX(ctx context.Context) int {
}
// Exist returns true if the query has elements in the graph.
func
(
_q
*
A
pi
KeyQuery
)
Exist
(
ctx
context
.
Context
)
(
bool
,
error
)
{
func
(
_q
*
A
PI
KeyQuery
)
Exist
(
ctx
context
.
Context
)
(
bool
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryExist
)
switch
_
,
err
:=
_q
.
FirstID
(
ctx
);
{
case
IsNotFound
(
err
)
:
...
...
@@ -303,7 +303,7 @@ func (_q *ApiKeyQuery) Exist(ctx context.Context) (bool, error) {
}
// ExistX is like Exist, but panics if an error occurs.
func
(
_q
*
A
pi
KeyQuery
)
ExistX
(
ctx
context
.
Context
)
bool
{
func
(
_q
*
A
PI
KeyQuery
)
ExistX
(
ctx
context
.
Context
)
bool
{
exist
,
err
:=
_q
.
Exist
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -311,18 +311,18 @@ func (_q *ApiKeyQuery) ExistX(ctx context.Context) bool {
return
exist
}
// Clone returns a duplicate of the A
pi
KeyQuery builder, including all associated steps. It can be
// Clone returns a duplicate of the A
PI
KeyQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func
(
_q
*
A
pi
KeyQuery
)
Clone
()
*
A
pi
KeyQuery
{
func
(
_q
*
A
PI
KeyQuery
)
Clone
()
*
A
PI
KeyQuery
{
if
_q
==
nil
{
return
nil
}
return
&
A
pi
KeyQuery
{
return
&
A
PI
KeyQuery
{
config
:
_q
.
config
,
ctx
:
_q
.
ctx
.
Clone
(),
order
:
append
([]
apikey
.
OrderOption
{},
_q
.
order
...
),
inters
:
append
([]
Interceptor
{},
_q
.
inters
...
),
predicates
:
append
([]
predicate
.
A
pi
Key
{},
_q
.
predicates
...
),
predicates
:
append
([]
predicate
.
A
PI
Key
{},
_q
.
predicates
...
),
withUser
:
_q
.
withUser
.
Clone
(),
withGroup
:
_q
.
withGroup
.
Clone
(),
withUsageLogs
:
_q
.
withUsageLogs
.
Clone
(),
...
...
@@ -334,7 +334,7 @@ func (_q *ApiKeyQuery) Clone() *ApiKeyQuery {
// 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.
func
(
_q
*
A
pi
KeyQuery
)
WithUser
(
opts
...
func
(
*
UserQuery
))
*
A
pi
KeyQuery
{
func
(
_q
*
A
PI
KeyQuery
)
WithUser
(
opts
...
func
(
*
UserQuery
))
*
A
PI
KeyQuery
{
query
:=
(
&
UserClient
{
config
:
_q
.
config
})
.
Query
()
for
_
,
opt
:=
range
opts
{
opt
(
query
)
...
...
@@ -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
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
func
(
_q
*
A
pi
KeyQuery
)
WithGroup
(
opts
...
func
(
*
GroupQuery
))
*
A
pi
KeyQuery
{
func
(
_q
*
A
PI
KeyQuery
)
WithGroup
(
opts
...
func
(
*
GroupQuery
))
*
A
PI
KeyQuery
{
query
:=
(
&
GroupClient
{
config
:
_q
.
config
})
.
Query
()
for
_
,
opt
:=
range
opts
{
opt
(
query
)
...
...
@@ -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
// the "usage_logs" edge. The optional arguments are used to configure the query builder of the edge.
func
(
_q
*
A
pi
KeyQuery
)
WithUsageLogs
(
opts
...
func
(
*
UsageLogQuery
))
*
A
pi
KeyQuery
{
func
(
_q
*
A
PI
KeyQuery
)
WithUsageLogs
(
opts
...
func
(
*
UsageLogQuery
))
*
A
PI
KeyQuery
{
query
:=
(
&
UsageLogClient
{
config
:
_q
.
config
})
.
Query
()
for
_
,
opt
:=
range
opts
{
opt
(
query
)
...
...
@@ -375,13 +375,13 @@ func (_q *ApiKeyQuery) WithUsageLogs(opts ...func(*UsageLogQuery)) *ApiKeyQuery
// Count int `json:"count,omitempty"`
// }
//
// client.A
pi
Key.Query().
// client.A
PI
Key.Query().
// GroupBy(apikey.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func
(
_q
*
A
pi
KeyQuery
)
GroupBy
(
field
string
,
fields
...
string
)
*
A
pi
KeyGroupBy
{
func
(
_q
*
A
PI
KeyQuery
)
GroupBy
(
field
string
,
fields
...
string
)
*
A
PI
KeyGroupBy
{
_q
.
ctx
.
Fields
=
append
([]
string
{
field
},
fields
...
)
grbuild
:=
&
A
pi
KeyGroupBy
{
build
:
_q
}
grbuild
:=
&
A
PI
KeyGroupBy
{
build
:
_q
}
grbuild
.
flds
=
&
_q
.
ctx
.
Fields
grbuild
.
label
=
apikey
.
Label
grbuild
.
scan
=
grbuild
.
Scan
...
...
@@ -397,23 +397,23 @@ func (_q *ApiKeyQuery) GroupBy(field string, fields ...string) *ApiKeyGroupBy {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.A
pi
Key.Query().
// client.A
PI
Key.Query().
// Select(apikey.FieldCreatedAt).
// Scan(ctx, &v)
func
(
_q
*
A
pi
KeyQuery
)
Select
(
fields
...
string
)
*
A
pi
KeySelect
{
func
(
_q
*
A
PI
KeyQuery
)
Select
(
fields
...
string
)
*
A
PI
KeySelect
{
_q
.
ctx
.
Fields
=
append
(
_q
.
ctx
.
Fields
,
fields
...
)
sbuild
:=
&
A
pi
KeySelect
{
A
pi
KeyQuery
:
_q
}
sbuild
:=
&
A
PI
KeySelect
{
A
PI
KeyQuery
:
_q
}
sbuild
.
label
=
apikey
.
Label
sbuild
.
flds
,
sbuild
.
scan
=
&
_q
.
ctx
.
Fields
,
sbuild
.
Scan
return
sbuild
}
// Aggregate returns a A
pi
KeySelect configured with the given aggregations.
func
(
_q
*
A
pi
KeyQuery
)
Aggregate
(
fns
...
AggregateFunc
)
*
A
pi
KeySelect
{
// Aggregate returns a A
PI
KeySelect configured with the given aggregations.
func
(
_q
*
A
PI
KeyQuery
)
Aggregate
(
fns
...
AggregateFunc
)
*
A
PI
KeySelect
{
return
_q
.
Select
()
.
Aggregate
(
fns
...
)
}
func
(
_q
*
A
pi
KeyQuery
)
prepareQuery
(
ctx
context
.
Context
)
error
{
func
(
_q
*
A
PI
KeyQuery
)
prepareQuery
(
ctx
context
.
Context
)
error
{
for
_
,
inter
:=
range
_q
.
inters
{
if
inter
==
nil
{
return
fmt
.
Errorf
(
"ent: uninitialized interceptor (forgotten import ent/runtime?)"
)
...
...
@@ -439,9 +439,9 @@ func (_q *ApiKeyQuery) prepareQuery(ctx context.Context) error {
return
nil
}
func
(
_q
*
A
pi
KeyQuery
)
sqlAll
(
ctx
context
.
Context
,
hooks
...
queryHook
)
([]
*
A
pi
Key
,
error
)
{
func
(
_q
*
A
PI
KeyQuery
)
sqlAll
(
ctx
context
.
Context
,
hooks
...
queryHook
)
([]
*
A
PI
Key
,
error
)
{
var
(
nodes
=
[]
*
A
pi
Key
{}
nodes
=
[]
*
A
PI
Key
{}
_spec
=
_q
.
querySpec
()
loadedTypes
=
[
3
]
bool
{
_q
.
withUser
!=
nil
,
...
...
@@ -450,10 +450,10 @@ func (_q *ApiKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ApiKe
}
)
_spec
.
ScanValues
=
func
(
columns
[]
string
)
([]
any
,
error
)
{
return
(
*
A
pi
Key
)
.
scanValues
(
nil
,
columns
)
return
(
*
A
PI
Key
)
.
scanValues
(
nil
,
columns
)
}
_spec
.
Assign
=
func
(
columns
[]
string
,
values
[]
any
)
error
{
node
:=
&
A
pi
Key
{
config
:
_q
.
config
}
node
:=
&
A
PI
Key
{
config
:
_q
.
config
}
nodes
=
append
(
nodes
,
node
)
node
.
Edges
.
loadedTypes
=
loadedTypes
return
node
.
assignValues
(
columns
,
values
)
...
...
@@ -469,29 +469,29 @@ func (_q *ApiKeyQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ApiKe
}
if
query
:=
_q
.
withUser
;
query
!=
nil
{
if
err
:=
_q
.
loadUser
(
ctx
,
query
,
nodes
,
nil
,
func
(
n
*
A
pi
Key
,
e
*
User
)
{
n
.
Edges
.
User
=
e
});
err
!=
nil
{
func
(
n
*
A
PI
Key
,
e
*
User
)
{
n
.
Edges
.
User
=
e
});
err
!=
nil
{
return
nil
,
err
}
}
if
query
:=
_q
.
withGroup
;
query
!=
nil
{
if
err
:=
_q
.
loadGroup
(
ctx
,
query
,
nodes
,
nil
,
func
(
n
*
A
pi
Key
,
e
*
Group
)
{
n
.
Edges
.
Group
=
e
});
err
!=
nil
{
func
(
n
*
A
PI
Key
,
e
*
Group
)
{
n
.
Edges
.
Group
=
e
});
err
!=
nil
{
return
nil
,
err
}
}
if
query
:=
_q
.
withUsageLogs
;
query
!=
nil
{
if
err
:=
_q
.
loadUsageLogs
(
ctx
,
query
,
nodes
,
func
(
n
*
A
pi
Key
)
{
n
.
Edges
.
UsageLogs
=
[]
*
UsageLog
{}
},
func
(
n
*
A
pi
Key
,
e
*
UsageLog
)
{
n
.
Edges
.
UsageLogs
=
append
(
n
.
Edges
.
UsageLogs
,
e
)
});
err
!=
nil
{
func
(
n
*
A
PI
Key
)
{
n
.
Edges
.
UsageLogs
=
[]
*
UsageLog
{}
},
func
(
n
*
A
PI
Key
,
e
*
UsageLog
)
{
n
.
Edges
.
UsageLogs
=
append
(
n
.
Edges
.
UsageLogs
,
e
)
});
err
!=
nil
{
return
nil
,
err
}
}
return
nodes
,
nil
}
func
(
_q
*
A
pi
KeyQuery
)
loadUser
(
ctx
context
.
Context
,
query
*
UserQuery
,
nodes
[]
*
A
pi
Key
,
init
func
(
*
A
pi
Key
),
assign
func
(
*
A
pi
Key
,
*
User
))
error
{
func
(
_q
*
A
PI
KeyQuery
)
loadUser
(
ctx
context
.
Context
,
query
*
UserQuery
,
nodes
[]
*
A
PI
Key
,
init
func
(
*
A
PI
Key
),
assign
func
(
*
A
PI
Key
,
*
User
))
error
{
ids
:=
make
([]
int64
,
0
,
len
(
nodes
))
nodeids
:=
make
(
map
[
int64
][]
*
A
pi
Key
)
nodeids
:=
make
(
map
[
int64
][]
*
A
PI
Key
)
for
i
:=
range
nodes
{
fk
:=
nodes
[
i
]
.
UserID
if
_
,
ok
:=
nodeids
[
fk
];
!
ok
{
...
...
@@ -518,9 +518,9 @@ func (_q *ApiKeyQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*
}
return
nil
}
func
(
_q
*
A
pi
KeyQuery
)
loadGroup
(
ctx
context
.
Context
,
query
*
GroupQuery
,
nodes
[]
*
A
pi
Key
,
init
func
(
*
A
pi
Key
),
assign
func
(
*
A
pi
Key
,
*
Group
))
error
{
func
(
_q
*
A
PI
KeyQuery
)
loadGroup
(
ctx
context
.
Context
,
query
*
GroupQuery
,
nodes
[]
*
A
PI
Key
,
init
func
(
*
A
PI
Key
),
assign
func
(
*
A
PI
Key
,
*
Group
))
error
{
ids
:=
make
([]
int64
,
0
,
len
(
nodes
))
nodeids
:=
make
(
map
[
int64
][]
*
A
pi
Key
)
nodeids
:=
make
(
map
[
int64
][]
*
A
PI
Key
)
for
i
:=
range
nodes
{
if
nodes
[
i
]
.
GroupID
==
nil
{
continue
...
...
@@ -550,9 +550,9 @@ func (_q *ApiKeyQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes [
}
return
nil
}
func
(
_q
*
A
pi
KeyQuery
)
loadUsageLogs
(
ctx
context
.
Context
,
query
*
UsageLogQuery
,
nodes
[]
*
A
pi
Key
,
init
func
(
*
A
pi
Key
),
assign
func
(
*
A
pi
Key
,
*
UsageLog
))
error
{
func
(
_q
*
A
PI
KeyQuery
)
loadUsageLogs
(
ctx
context
.
Context
,
query
*
UsageLogQuery
,
nodes
[]
*
A
PI
Key
,
init
func
(
*
A
PI
Key
),
assign
func
(
*
A
PI
Key
,
*
UsageLog
))
error
{
fks
:=
make
([]
driver
.
Value
,
0
,
len
(
nodes
))
nodeids
:=
make
(
map
[
int64
]
*
A
pi
Key
)
nodeids
:=
make
(
map
[
int64
]
*
A
PI
Key
)
for
i
:=
range
nodes
{
fks
=
append
(
fks
,
nodes
[
i
]
.
ID
)
nodeids
[
nodes
[
i
]
.
ID
]
=
nodes
[
i
]
...
...
@@ -581,7 +581,7 @@ func (_q *ApiKeyQuery) loadUsageLogs(ctx context.Context, query *UsageLogQuery,
return
nil
}
func
(
_q
*
A
pi
KeyQuery
)
sqlCount
(
ctx
context
.
Context
)
(
int
,
error
)
{
func
(
_q
*
A
PI
KeyQuery
)
sqlCount
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
_q
.
querySpec
()
_spec
.
Node
.
Columns
=
_q
.
ctx
.
Fields
if
len
(
_q
.
ctx
.
Fields
)
>
0
{
...
...
@@ -590,7 +590,7 @@ func (_q *ApiKeyQuery) sqlCount(ctx context.Context) (int, error) {
return
sqlgraph
.
CountNodes
(
ctx
,
_q
.
driver
,
_spec
)
}
func
(
_q
*
A
pi
KeyQuery
)
querySpec
()
*
sqlgraph
.
QuerySpec
{
func
(
_q
*
A
PI
KeyQuery
)
querySpec
()
*
sqlgraph
.
QuerySpec
{
_spec
:=
sqlgraph
.
NewQuerySpec
(
apikey
.
Table
,
apikey
.
Columns
,
sqlgraph
.
NewFieldSpec
(
apikey
.
FieldID
,
field
.
TypeInt64
))
_spec
.
From
=
_q
.
sql
if
unique
:=
_q
.
ctx
.
Unique
;
unique
!=
nil
{
...
...
@@ -636,7 +636,7 @@ func (_q *ApiKeyQuery) querySpec() *sqlgraph.QuerySpec {
return
_spec
}
func
(
_q
*
A
pi
KeyQuery
)
sqlQuery
(
ctx
context
.
Context
)
*
sql
.
Selector
{
func
(
_q
*
A
PI
KeyQuery
)
sqlQuery
(
ctx
context
.
Context
)
*
sql
.
Selector
{
builder
:=
sql
.
Dialect
(
_q
.
driver
.
Dialect
())
t1
:=
builder
.
Table
(
apikey
.
Table
)
columns
:=
_q
.
ctx
.
Fields
...
...
@@ -668,28 +668,28 @@ func (_q *ApiKeyQuery) sqlQuery(ctx context.Context) *sql.Selector {
return
selector
}
// A
pi
KeyGroupBy is the group-by builder for A
pi
Key entities.
type
A
pi
KeyGroupBy
struct
{
// A
PI
KeyGroupBy is the group-by builder for A
PI
Key entities.
type
A
PI
KeyGroupBy
struct
{
selector
build
*
A
pi
KeyQuery
build
*
A
PI
KeyQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func
(
_g
*
A
pi
KeyGroupBy
)
Aggregate
(
fns
...
AggregateFunc
)
*
A
pi
KeyGroupBy
{
func
(
_g
*
A
PI
KeyGroupBy
)
Aggregate
(
fns
...
AggregateFunc
)
*
A
PI
KeyGroupBy
{
_g
.
fns
=
append
(
_g
.
fns
,
fns
...
)
return
_g
}
// Scan applies the selector query and scans the result into the given value.
func
(
_g
*
A
pi
KeyGroupBy
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
func
(
_g
*
A
PI
KeyGroupBy
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
ctx
=
setContextOp
(
ctx
,
_g
.
build
.
ctx
,
ent
.
OpQueryGroupBy
)
if
err
:=
_g
.
build
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
err
}
return
scanWithInterceptors
[
*
A
pi
KeyQuery
,
*
A
pi
KeyGroupBy
](
ctx
,
_g
.
build
,
_g
,
_g
.
build
.
inters
,
v
)
return
scanWithInterceptors
[
*
A
PI
KeyQuery
,
*
A
PI
KeyGroupBy
](
ctx
,
_g
.
build
,
_g
,
_g
.
build
.
inters
,
v
)
}
func
(
_g
*
A
pi
KeyGroupBy
)
sqlScan
(
ctx
context
.
Context
,
root
*
A
pi
KeyQuery
,
v
any
)
error
{
func
(
_g
*
A
PI
KeyGroupBy
)
sqlScan
(
ctx
context
.
Context
,
root
*
A
PI
KeyQuery
,
v
any
)
error
{
selector
:=
root
.
sqlQuery
(
ctx
)
.
Select
()
aggregation
:=
make
([]
string
,
0
,
len
(
_g
.
fns
))
for
_
,
fn
:=
range
_g
.
fns
{
...
...
@@ -716,28 +716,28 @@ func (_g *ApiKeyGroupBy) sqlScan(ctx context.Context, root *ApiKeyQuery, v any)
return
sql
.
ScanSlice
(
rows
,
v
)
}
// A
pi
KeySelect is the builder for selecting fields of A
pi
Key entities.
type
A
pi
KeySelect
struct
{
*
A
pi
KeyQuery
// A
PI
KeySelect is the builder for selecting fields of A
PI
Key entities.
type
A
PI
KeySelect
struct
{
*
A
PI
KeyQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func
(
_s
*
A
pi
KeySelect
)
Aggregate
(
fns
...
AggregateFunc
)
*
A
pi
KeySelect
{
func
(
_s
*
A
PI
KeySelect
)
Aggregate
(
fns
...
AggregateFunc
)
*
A
PI
KeySelect
{
_s
.
fns
=
append
(
_s
.
fns
,
fns
...
)
return
_s
}
// Scan applies the selector query and scans the result into the given value.
func
(
_s
*
A
pi
KeySelect
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
func
(
_s
*
A
PI
KeySelect
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
ctx
=
setContextOp
(
ctx
,
_s
.
ctx
,
ent
.
OpQuerySelect
)
if
err
:=
_s
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
err
}
return
scanWithInterceptors
[
*
A
pi
KeyQuery
,
*
A
pi
KeySelect
](
ctx
,
_s
.
A
pi
KeyQuery
,
_s
,
_s
.
inters
,
v
)
return
scanWithInterceptors
[
*
A
PI
KeyQuery
,
*
A
PI
KeySelect
](
ctx
,
_s
.
A
PI
KeyQuery
,
_s
,
_s
.
inters
,
v
)
}
func
(
_s
*
A
pi
KeySelect
)
sqlScan
(
ctx
context
.
Context
,
root
*
A
pi
KeyQuery
,
v
any
)
error
{
func
(
_s
*
A
PI
KeySelect
)
sqlScan
(
ctx
context
.
Context
,
root
*
A
PI
KeyQuery
,
v
any
)
error
{
selector
:=
root
.
sqlQuery
(
ctx
)
aggregation
:=
make
([]
string
,
0
,
len
(
_s
.
fns
))
for
_
,
fn
:=
range
_s
.
fns
{
...
...
backend/ent/apikey_update.go
View file @
c86d445c
...
...
@@ -18,33 +18,33 @@ import (
"github.com/Wei-Shaw/sub2api/ent/user"
)
// A
pi
KeyUpdate is the builder for updating A
pi
Key entities.
type
A
pi
KeyUpdate
struct
{
// A
PI
KeyUpdate is the builder for updating A
PI
Key entities.
type
A
PI
KeyUpdate
struct
{
config
hooks
[]
Hook
mutation
*
A
pi
KeyMutation
mutation
*
A
PI
KeyMutation
}
// Where appends a list predicates to the A
pi
KeyUpdate builder.
func
(
_u
*
A
pi
KeyUpdate
)
Where
(
ps
...
predicate
.
A
pi
Key
)
*
A
pi
KeyUpdate
{
// Where appends a list predicates to the A
PI
KeyUpdate builder.
func
(
_u
*
A
PI
KeyUpdate
)
Where
(
ps
...
predicate
.
A
PI
Key
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
Where
(
ps
...
)
return
_u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_u
*
A
pi
KeyUpdate
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
SetUpdatedAt
(
v
)
return
_u
}
// SetDeletedAt sets the "deleted_at" field.
func
(
_u
*
A
pi
KeyUpdate
)
SetDeletedAt
(
v
time
.
Time
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetDeletedAt
(
v
time
.
Time
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
SetDeletedAt
(
v
)
return
_u
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdate
)
SetNillableDeletedAt
(
v
*
time
.
Time
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetNillableDeletedAt
(
v
*
time
.
Time
)
*
A
PI
KeyUpdate
{
if
v
!=
nil
{
_u
.
SetDeletedAt
(
*
v
)
}
...
...
@@ -52,19 +52,19 @@ func (_u *ApiKeyUpdate) SetNillableDeletedAt(v *time.Time) *ApiKeyUpdate {
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func
(
_u
*
A
pi
KeyUpdate
)
ClearDeletedAt
()
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
ClearDeletedAt
()
*
A
PI
KeyUpdate
{
_u
.
mutation
.
ClearDeletedAt
()
return
_u
}
// SetUserID sets the "user_id" field.
func
(
_u
*
A
pi
KeyUpdate
)
SetUserID
(
v
int64
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetUserID
(
v
int64
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
SetUserID
(
v
)
return
_u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdate
)
SetNillableUserID
(
v
*
int64
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetNillableUserID
(
v
*
int64
)
*
A
PI
KeyUpdate
{
if
v
!=
nil
{
_u
.
SetUserID
(
*
v
)
}
...
...
@@ -72,13 +72,13 @@ func (_u *ApiKeyUpdate) SetNillableUserID(v *int64) *ApiKeyUpdate {
}
// SetKey sets the "key" field.
func
(
_u
*
A
pi
KeyUpdate
)
SetKey
(
v
string
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetKey
(
v
string
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
SetKey
(
v
)
return
_u
}
// SetNillableKey sets the "key" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdate
)
SetNillableKey
(
v
*
string
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetNillableKey
(
v
*
string
)
*
A
PI
KeyUpdate
{
if
v
!=
nil
{
_u
.
SetKey
(
*
v
)
}
...
...
@@ -86,13 +86,13 @@ func (_u *ApiKeyUpdate) SetNillableKey(v *string) *ApiKeyUpdate {
}
// SetName sets the "name" field.
func
(
_u
*
A
pi
KeyUpdate
)
SetName
(
v
string
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetName
(
v
string
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
SetName
(
v
)
return
_u
}
// SetNillableName sets the "name" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdate
)
SetNillableName
(
v
*
string
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetNillableName
(
v
*
string
)
*
A
PI
KeyUpdate
{
if
v
!=
nil
{
_u
.
SetName
(
*
v
)
}
...
...
@@ -100,13 +100,13 @@ func (_u *ApiKeyUpdate) SetNillableName(v *string) *ApiKeyUpdate {
}
// SetGroupID sets the "group_id" field.
func
(
_u
*
A
pi
KeyUpdate
)
SetGroupID
(
v
int64
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetGroupID
(
v
int64
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
SetGroupID
(
v
)
return
_u
}
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdate
)
SetNillableGroupID
(
v
*
int64
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetNillableGroupID
(
v
*
int64
)
*
A
PI
KeyUpdate
{
if
v
!=
nil
{
_u
.
SetGroupID
(
*
v
)
}
...
...
@@ -114,19 +114,19 @@ func (_u *ApiKeyUpdate) SetNillableGroupID(v *int64) *ApiKeyUpdate {
}
// ClearGroupID clears the value of the "group_id" field.
func
(
_u
*
A
pi
KeyUpdate
)
ClearGroupID
()
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
ClearGroupID
()
*
A
PI
KeyUpdate
{
_u
.
mutation
.
ClearGroupID
()
return
_u
}
// SetStatus sets the "status" field.
func
(
_u
*
A
pi
KeyUpdate
)
SetStatus
(
v
string
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetStatus
(
v
string
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
SetStatus
(
v
)
return
_u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdate
)
SetNillableStatus
(
v
*
string
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetNillableStatus
(
v
*
string
)
*
A
PI
KeyUpdate
{
if
v
!=
nil
{
_u
.
SetStatus
(
*
v
)
}
...
...
@@ -134,23 +134,23 @@ func (_u *ApiKeyUpdate) SetNillableStatus(v *string) *ApiKeyUpdate {
}
// SetUser sets the "user" edge to the User entity.
func
(
_u
*
A
pi
KeyUpdate
)
SetUser
(
v
*
User
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetUser
(
v
*
User
)
*
A
PI
KeyUpdate
{
return
_u
.
SetUserID
(
v
.
ID
)
}
// SetGroup sets the "group" edge to the Group entity.
func
(
_u
*
A
pi
KeyUpdate
)
SetGroup
(
v
*
Group
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
SetGroup
(
v
*
Group
)
*
A
PI
KeyUpdate
{
return
_u
.
SetGroupID
(
v
.
ID
)
}
// AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
func
(
_u
*
A
pi
KeyUpdate
)
AddUsageLogIDs
(
ids
...
int64
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
AddUsageLogIDs
(
ids
...
int64
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
AddUsageLogIDs
(
ids
...
)
return
_u
}
// AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
func
(
_u
*
A
pi
KeyUpdate
)
AddUsageLogs
(
v
...*
UsageLog
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
AddUsageLogs
(
v
...*
UsageLog
)
*
A
PI
KeyUpdate
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
@@ -158,37 +158,37 @@ func (_u *ApiKeyUpdate) AddUsageLogs(v ...*UsageLog) *ApiKeyUpdate {
return
_u
.
AddUsageLogIDs
(
ids
...
)
}
// Mutation returns the A
pi
KeyMutation object of the builder.
func
(
_u
*
A
pi
KeyUpdate
)
Mutation
()
*
A
pi
KeyMutation
{
// Mutation returns the A
PI
KeyMutation object of the builder.
func
(
_u
*
A
PI
KeyUpdate
)
Mutation
()
*
A
PI
KeyMutation
{
return
_u
.
mutation
}
// ClearUser clears the "user" edge to the User entity.
func
(
_u
*
A
pi
KeyUpdate
)
ClearUser
()
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
ClearUser
()
*
A
PI
KeyUpdate
{
_u
.
mutation
.
ClearUser
()
return
_u
}
// ClearGroup clears the "group" edge to the Group entity.
func
(
_u
*
A
pi
KeyUpdate
)
ClearGroup
()
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
ClearGroup
()
*
A
PI
KeyUpdate
{
_u
.
mutation
.
ClearGroup
()
return
_u
}
// ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
func
(
_u
*
A
pi
KeyUpdate
)
ClearUsageLogs
()
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
ClearUsageLogs
()
*
A
PI
KeyUpdate
{
_u
.
mutation
.
ClearUsageLogs
()
return
_u
}
// RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
func
(
_u
*
A
pi
KeyUpdate
)
RemoveUsageLogIDs
(
ids
...
int64
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
RemoveUsageLogIDs
(
ids
...
int64
)
*
A
PI
KeyUpdate
{
_u
.
mutation
.
RemoveUsageLogIDs
(
ids
...
)
return
_u
}
// RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
func
(
_u
*
A
pi
KeyUpdate
)
RemoveUsageLogs
(
v
...*
UsageLog
)
*
A
pi
KeyUpdate
{
func
(
_u
*
A
PI
KeyUpdate
)
RemoveUsageLogs
(
v
...*
UsageLog
)
*
A
PI
KeyUpdate
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
@@ -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.
func
(
_u
*
A
pi
KeyUpdate
)
Save
(
ctx
context
.
Context
)
(
int
,
error
)
{
func
(
_u
*
A
PI
KeyUpdate
)
Save
(
ctx
context
.
Context
)
(
int
,
error
)
{
if
err
:=
_u
.
defaults
();
err
!=
nil
{
return
0
,
err
}
...
...
@@ -205,7 +205,7 @@ func (_u *ApiKeyUpdate) Save(ctx context.Context) (int, error) {
}
// SaveX is like Save, but panics if an error occurs.
func
(
_u
*
A
pi
KeyUpdate
)
SaveX
(
ctx
context
.
Context
)
int
{
func
(
_u
*
A
PI
KeyUpdate
)
SaveX
(
ctx
context
.
Context
)
int
{
affected
,
err
:=
_u
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -214,20 +214,20 @@ func (_u *ApiKeyUpdate) SaveX(ctx context.Context) int {
}
// Exec executes the query.
func
(
_u
*
A
pi
KeyUpdate
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
_u
*
A
PI
KeyUpdate
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_u
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_u
*
A
pi
KeyUpdate
)
ExecX
(
ctx
context
.
Context
)
{
func
(
_u
*
A
PI
KeyUpdate
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_u
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_u
*
A
pi
KeyUpdate
)
defaults
()
error
{
func
(
_u
*
A
PI
KeyUpdate
)
defaults
()
error
{
if
_
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
!
ok
{
if
apikey
.
UpdateDefaultUpdatedAt
==
nil
{
return
fmt
.
Errorf
(
"ent: uninitialized apikey.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)"
)
...
...
@@ -239,29 +239,29 @@ func (_u *ApiKeyUpdate) defaults() error {
}
// check runs all checks and user-defined validators on the builder.
func
(
_u
*
A
pi
KeyUpdate
)
check
()
error
{
func
(
_u
*
A
PI
KeyUpdate
)
check
()
error
{
if
v
,
ok
:=
_u
.
mutation
.
Key
();
ok
{
if
err
:=
apikey
.
KeyValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"key"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.key": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"key"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.key": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
Name
();
ok
{
if
err
:=
apikey
.
NameValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.name": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.name": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
if
err
:=
apikey
.
StatusValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.status": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.status": %w`
,
err
)}
}
}
if
_u
.
mutation
.
UserCleared
()
&&
len
(
_u
.
mutation
.
UserIDs
())
>
0
{
return
errors
.
New
(
`ent: clearing a required unique edge "A
pi
Key.user"`
)
return
errors
.
New
(
`ent: clearing a required unique edge "A
PI
Key.user"`
)
}
return
nil
}
func
(
_u
*
A
pi
KeyUpdate
)
sqlSave
(
ctx
context
.
Context
)
(
_node
int
,
err
error
)
{
func
(
_u
*
A
PI
KeyUpdate
)
sqlSave
(
ctx
context
.
Context
)
(
_node
int
,
err
error
)
{
if
err
:=
_u
.
check
();
err
!=
nil
{
return
_node
,
err
}
...
...
@@ -406,28 +406,28 @@ func (_u *ApiKeyUpdate) sqlSave(ctx context.Context) (_node int, err error) {
return
_node
,
nil
}
// A
pi
KeyUpdateOne is the builder for updating a single A
pi
Key entity.
type
A
pi
KeyUpdateOne
struct
{
// A
PI
KeyUpdateOne is the builder for updating a single A
PI
Key entity.
type
A
PI
KeyUpdateOne
struct
{
config
fields
[]
string
hooks
[]
Hook
mutation
*
A
pi
KeyMutation
mutation
*
A
PI
KeyMutation
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetUpdatedAt
(
v
time
.
Time
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
SetUpdatedAt
(
v
)
return
_u
}
// SetDeletedAt sets the "deleted_at" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetDeletedAt
(
v
time
.
Time
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetDeletedAt
(
v
time
.
Time
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
SetDeletedAt
(
v
)
return
_u
}
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetNillableDeletedAt
(
v
*
time
.
Time
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetNillableDeletedAt
(
v
*
time
.
Time
)
*
A
PI
KeyUpdateOne
{
if
v
!=
nil
{
_u
.
SetDeletedAt
(
*
v
)
}
...
...
@@ -435,19 +435,19 @@ func (_u *ApiKeyUpdateOne) SetNillableDeletedAt(v *time.Time) *ApiKeyUpdateOne {
}
// ClearDeletedAt clears the value of the "deleted_at" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
ClearDeletedAt
()
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
ClearDeletedAt
()
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
ClearDeletedAt
()
return
_u
}
// SetUserID sets the "user_id" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetUserID
(
v
int64
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetUserID
(
v
int64
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
SetUserID
(
v
)
return
_u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetNillableUserID
(
v
*
int64
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetNillableUserID
(
v
*
int64
)
*
A
PI
KeyUpdateOne
{
if
v
!=
nil
{
_u
.
SetUserID
(
*
v
)
}
...
...
@@ -455,13 +455,13 @@ func (_u *ApiKeyUpdateOne) SetNillableUserID(v *int64) *ApiKeyUpdateOne {
}
// SetKey sets the "key" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetKey
(
v
string
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetKey
(
v
string
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
SetKey
(
v
)
return
_u
}
// SetNillableKey sets the "key" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetNillableKey
(
v
*
string
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetNillableKey
(
v
*
string
)
*
A
PI
KeyUpdateOne
{
if
v
!=
nil
{
_u
.
SetKey
(
*
v
)
}
...
...
@@ -469,13 +469,13 @@ func (_u *ApiKeyUpdateOne) SetNillableKey(v *string) *ApiKeyUpdateOne {
}
// SetName sets the "name" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetName
(
v
string
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetName
(
v
string
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
SetName
(
v
)
return
_u
}
// SetNillableName sets the "name" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetNillableName
(
v
*
string
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetNillableName
(
v
*
string
)
*
A
PI
KeyUpdateOne
{
if
v
!=
nil
{
_u
.
SetName
(
*
v
)
}
...
...
@@ -483,13 +483,13 @@ func (_u *ApiKeyUpdateOne) SetNillableName(v *string) *ApiKeyUpdateOne {
}
// SetGroupID sets the "group_id" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetGroupID
(
v
int64
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetGroupID
(
v
int64
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
SetGroupID
(
v
)
return
_u
}
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetNillableGroupID
(
v
*
int64
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetNillableGroupID
(
v
*
int64
)
*
A
PI
KeyUpdateOne
{
if
v
!=
nil
{
_u
.
SetGroupID
(
*
v
)
}
...
...
@@ -497,19 +497,19 @@ func (_u *ApiKeyUpdateOne) SetNillableGroupID(v *int64) *ApiKeyUpdateOne {
}
// ClearGroupID clears the value of the "group_id" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
ClearGroupID
()
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
ClearGroupID
()
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
ClearGroupID
()
return
_u
}
// SetStatus sets the "status" field.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetStatus
(
v
string
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetStatus
(
v
string
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
SetStatus
(
v
)
return
_u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetNillableStatus
(
v
*
string
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetNillableStatus
(
v
*
string
)
*
A
PI
KeyUpdateOne
{
if
v
!=
nil
{
_u
.
SetStatus
(
*
v
)
}
...
...
@@ -517,23 +517,23 @@ func (_u *ApiKeyUpdateOne) SetNillableStatus(v *string) *ApiKeyUpdateOne {
}
// SetUser sets the "user" edge to the User entity.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetUser
(
v
*
User
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetUser
(
v
*
User
)
*
A
PI
KeyUpdateOne
{
return
_u
.
SetUserID
(
v
.
ID
)
}
// SetGroup sets the "group" edge to the Group entity.
func
(
_u
*
A
pi
KeyUpdateOne
)
SetGroup
(
v
*
Group
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SetGroup
(
v
*
Group
)
*
A
PI
KeyUpdateOne
{
return
_u
.
SetGroupID
(
v
.
ID
)
}
// AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
func
(
_u
*
A
pi
KeyUpdateOne
)
AddUsageLogIDs
(
ids
...
int64
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
AddUsageLogIDs
(
ids
...
int64
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
AddUsageLogIDs
(
ids
...
)
return
_u
}
// AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
func
(
_u
*
A
pi
KeyUpdateOne
)
AddUsageLogs
(
v
...*
UsageLog
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
AddUsageLogs
(
v
...*
UsageLog
)
*
A
PI
KeyUpdateOne
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
@@ -541,37 +541,37 @@ func (_u *ApiKeyUpdateOne) AddUsageLogs(v ...*UsageLog) *ApiKeyUpdateOne {
return
_u
.
AddUsageLogIDs
(
ids
...
)
}
// Mutation returns the A
pi
KeyMutation object of the builder.
func
(
_u
*
A
pi
KeyUpdateOne
)
Mutation
()
*
A
pi
KeyMutation
{
// Mutation returns the A
PI
KeyMutation object of the builder.
func
(
_u
*
A
PI
KeyUpdateOne
)
Mutation
()
*
A
PI
KeyMutation
{
return
_u
.
mutation
}
// ClearUser clears the "user" edge to the User entity.
func
(
_u
*
A
pi
KeyUpdateOne
)
ClearUser
()
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
ClearUser
()
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
ClearUser
()
return
_u
}
// ClearGroup clears the "group" edge to the Group entity.
func
(
_u
*
A
pi
KeyUpdateOne
)
ClearGroup
()
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
ClearGroup
()
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
ClearGroup
()
return
_u
}
// ClearUsageLogs clears all "usage_logs" edges to the UsageLog entity.
func
(
_u
*
A
pi
KeyUpdateOne
)
ClearUsageLogs
()
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
ClearUsageLogs
()
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
ClearUsageLogs
()
return
_u
}
// RemoveUsageLogIDs removes the "usage_logs" edge to UsageLog entities by IDs.
func
(
_u
*
A
pi
KeyUpdateOne
)
RemoveUsageLogIDs
(
ids
...
int64
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
RemoveUsageLogIDs
(
ids
...
int64
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
RemoveUsageLogIDs
(
ids
...
)
return
_u
}
// RemoveUsageLogs removes "usage_logs" edges to UsageLog entities.
func
(
_u
*
A
pi
KeyUpdateOne
)
RemoveUsageLogs
(
v
...*
UsageLog
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
RemoveUsageLogs
(
v
...*
UsageLog
)
*
A
PI
KeyUpdateOne
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
@@ -579,21 +579,21 @@ func (_u *ApiKeyUpdateOne) RemoveUsageLogs(v ...*UsageLog) *ApiKeyUpdateOne {
return
_u
.
RemoveUsageLogIDs
(
ids
...
)
}
// Where appends a list predicates to the A
pi
KeyUpdate builder.
func
(
_u
*
A
pi
KeyUpdateOne
)
Where
(
ps
...
predicate
.
A
pi
Key
)
*
A
pi
KeyUpdateOne
{
// Where appends a list predicates to the A
PI
KeyUpdate builder.
func
(
_u
*
A
PI
KeyUpdateOne
)
Where
(
ps
...
predicate
.
A
PI
Key
)
*
A
PI
KeyUpdateOne
{
_u
.
mutation
.
Where
(
ps
...
)
return
_u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func
(
_u
*
A
pi
KeyUpdateOne
)
Select
(
field
string
,
fields
...
string
)
*
A
pi
KeyUpdateOne
{
func
(
_u
*
A
PI
KeyUpdateOne
)
Select
(
field
string
,
fields
...
string
)
*
A
PI
KeyUpdateOne
{
_u
.
fields
=
append
([]
string
{
field
},
fields
...
)
return
_u
}
// Save executes the query and returns the updated A
pi
Key entity.
func
(
_u
*
A
pi
KeyUpdateOne
)
Save
(
ctx
context
.
Context
)
(
*
A
pi
Key
,
error
)
{
// Save executes the query and returns the updated A
PI
Key entity.
func
(
_u
*
A
PI
KeyUpdateOne
)
Save
(
ctx
context
.
Context
)
(
*
A
PI
Key
,
error
)
{
if
err
:=
_u
.
defaults
();
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -601,7 +601,7 @@ func (_u *ApiKeyUpdateOne) Save(ctx context.Context) (*ApiKey, error) {
}
// SaveX is like Save, but panics if an error occurs.
func
(
_u
*
A
pi
KeyUpdateOne
)
SaveX
(
ctx
context
.
Context
)
*
A
pi
Key
{
func
(
_u
*
A
PI
KeyUpdateOne
)
SaveX
(
ctx
context
.
Context
)
*
A
PI
Key
{
node
,
err
:=
_u
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
...
...
@@ -610,20 +610,20 @@ func (_u *ApiKeyUpdateOne) SaveX(ctx context.Context) *ApiKey {
}
// Exec executes the query on the entity.
func
(
_u
*
A
pi
KeyUpdateOne
)
Exec
(
ctx
context
.
Context
)
error
{
func
(
_u
*
A
PI
KeyUpdateOne
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_u
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_u
*
A
pi
KeyUpdateOne
)
ExecX
(
ctx
context
.
Context
)
{
func
(
_u
*
A
PI
KeyUpdateOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_u
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_u
*
A
pi
KeyUpdateOne
)
defaults
()
error
{
func
(
_u
*
A
PI
KeyUpdateOne
)
defaults
()
error
{
if
_
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
!
ok
{
if
apikey
.
UpdateDefaultUpdatedAt
==
nil
{
return
fmt
.
Errorf
(
"ent: uninitialized apikey.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)"
)
...
...
@@ -635,36 +635,36 @@ func (_u *ApiKeyUpdateOne) defaults() error {
}
// check runs all checks and user-defined validators on the builder.
func
(
_u
*
A
pi
KeyUpdateOne
)
check
()
error
{
func
(
_u
*
A
PI
KeyUpdateOne
)
check
()
error
{
if
v
,
ok
:=
_u
.
mutation
.
Key
();
ok
{
if
err
:=
apikey
.
KeyValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"key"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.key": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"key"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.key": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
Name
();
ok
{
if
err
:=
apikey
.
NameValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.name": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.name": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
Status
();
ok
{
if
err
:=
apikey
.
StatusValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
pi
Key.status": %w`
,
err
)}
return
&
ValidationError
{
Name
:
"status"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "A
PI
Key.status": %w`
,
err
)}
}
}
if
_u
.
mutation
.
UserCleared
()
&&
len
(
_u
.
mutation
.
UserIDs
())
>
0
{
return
errors
.
New
(
`ent: clearing a required unique edge "A
pi
Key.user"`
)
return
errors
.
New
(
`ent: clearing a required unique edge "A
PI
Key.user"`
)
}
return
nil
}
func
(
_u
*
A
pi
KeyUpdateOne
)
sqlSave
(
ctx
context
.
Context
)
(
_node
*
A
pi
Key
,
err
error
)
{
func
(
_u
*
A
PI
KeyUpdateOne
)
sqlSave
(
ctx
context
.
Context
)
(
_node
*
A
PI
Key
,
err
error
)
{
if
err
:=
_u
.
check
();
err
!=
nil
{
return
_node
,
err
}
_spec
:=
sqlgraph
.
NewUpdateSpec
(
apikey
.
Table
,
apikey
.
Columns
,
sqlgraph
.
NewFieldSpec
(
apikey
.
FieldID
,
field
.
TypeInt64
))
id
,
ok
:=
_u
.
mutation
.
ID
()
if
!
ok
{
return
nil
,
&
ValidationError
{
Name
:
"id"
,
err
:
errors
.
New
(
`ent: missing "A
pi
Key.id" for update`
)}
return
nil
,
&
ValidationError
{
Name
:
"id"
,
err
:
errors
.
New
(
`ent: missing "A
PI
Key.id" for update`
)}
}
_spec
.
Node
.
ID
.
Value
=
id
if
fields
:=
_u
.
fields
;
len
(
fields
)
>
0
{
...
...
@@ -807,7 +807,7 @@ func (_u *ApiKeyUpdateOne) sqlSave(ctx context.Context) (_node *ApiKey, err erro
}
_spec
.
Edges
.
Add
=
append
(
_spec
.
Edges
.
Add
,
edge
)
}
_node
=
&
A
pi
Key
{
config
:
_u
.
config
}
_node
=
&
A
PI
Key
{
config
:
_u
.
config
}
_spec
.
Assign
=
_node
.
assignValues
_spec
.
ScanValues
=
_node
.
scanValues
if
err
=
sqlgraph
.
UpdateNode
(
ctx
,
_u
.
driver
,
_spec
);
err
!=
nil
{
...
...
backend/ent/client.go
View file @
c86d445c
...
...
@@ -37,12 +37,12 @@ type Client struct {
config
// Schema is the client for creating, migrating and dropping 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
*
AccountClient
// AccountGroup is the client for interacting with the AccountGroup builders.
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
*
GroupClient
// Proxy is the client for interacting with the Proxy builders.
...
...
@@ -74,9 +74,9 @@ func NewClient(opts ...Option) *Client {
func
(
c
*
Client
)
init
()
{
c
.
Schema
=
migrate
.
NewSchema
(
c
.
driver
)
c
.
APIKey
=
NewAPIKeyClient
(
c
.
config
)
c
.
Account
=
NewAccountClient
(
c
.
config
)
c
.
AccountGroup
=
NewAccountGroupClient
(
c
.
config
)
c
.
ApiKey
=
NewApiKeyClient
(
c
.
config
)
c
.
Group
=
NewGroupClient
(
c
.
config
)
c
.
Proxy
=
NewProxyClient
(
c
.
config
)
c
.
RedeemCode
=
NewRedeemCodeClient
(
c
.
config
)
...
...
@@ -179,9 +179,9 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
return
&
Tx
{
ctx
:
ctx
,
config
:
cfg
,
APIKey
:
NewAPIKeyClient
(
cfg
),
Account
:
NewAccountClient
(
cfg
),
AccountGroup
:
NewAccountGroupClient
(
cfg
),
ApiKey
:
NewApiKeyClient
(
cfg
),
Group
:
NewGroupClient
(
cfg
),
Proxy
:
NewProxyClient
(
cfg
),
RedeemCode
:
NewRedeemCodeClient
(
cfg
),
...
...
@@ -211,9 +211,9 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
return
&
Tx
{
ctx
:
ctx
,
config
:
cfg
,
APIKey
:
NewAPIKeyClient
(
cfg
),
Account
:
NewAccountClient
(
cfg
),
AccountGroup
:
NewAccountGroupClient
(
cfg
),
ApiKey
:
NewApiKeyClient
(
cfg
),
Group
:
NewGroupClient
(
cfg
),
Proxy
:
NewProxyClient
(
cfg
),
RedeemCode
:
NewRedeemCodeClient
(
cfg
),
...
...
@@ -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.
//
// client.Debug().
// A
ccount
.
// A
PIKey
.
// Query().
// Count(ctx)
func
(
c
*
Client
)
Debug
()
*
Client
{
...
...
@@ -253,7 +253,7 @@ func (c *Client) Close() error {
// In order to add hooks to a specific client, call: `client.Node.Use(...)`.
func
(
c
*
Client
)
Use
(
hooks
...
Hook
)
{
for
_
,
n
:=
range
[]
interface
{
Use
(
...
Hook
)
}{
c
.
Account
,
c
.
AccountGroup
,
c
.
ApiKey
,
c
.
Group
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
Setting
,
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Group
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
Setting
,
c
.
UsageLog
,
c
.
User
,
c
.
UserAllowedGroup
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
UserSubscription
,
}
{
...
...
@@ -265,7 +265,7 @@ func (c *Client) Use(hooks ...Hook) {
// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
func
(
c
*
Client
)
Intercept
(
interceptors
...
Interceptor
)
{
for
_
,
n
:=
range
[]
interface
{
Intercept
(
...
Interceptor
)
}{
c
.
Account
,
c
.
AccountGroup
,
c
.
ApiKey
,
c
.
Group
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
Setting
,
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Group
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
Setting
,
c
.
UsageLog
,
c
.
User
,
c
.
UserAllowedGroup
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
UserSubscription
,
}
{
...
...
@@ -276,12 +276,12 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
// Mutate implements the ent.Mutator interface.
func
(
c
*
Client
)
Mutate
(
ctx
context
.
Context
,
m
Mutation
)
(
Value
,
error
)
{
switch
m
:=
m
.
(
type
)
{
case
*
APIKeyMutation
:
return
c
.
APIKey
.
mutate
(
ctx
,
m
)
case
*
AccountMutation
:
return
c
.
Account
.
mutate
(
ctx
,
m
)
case
*
AccountGroupMutation
:
return
c
.
AccountGroup
.
mutate
(
ctx
,
m
)
case
*
ApiKeyMutation
:
return
c
.
ApiKey
.
mutate
(
ctx
,
m
)
case
*
GroupMutation
:
return
c
.
Group
.
mutate
(
ctx
,
m
)
case
*
ProxyMutation
:
...
...
@@ -307,6 +307,189 @@ 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.
type
AccountClient
struct
{
config
...
...
@@ -622,189 +805,6 @@ 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.
type
GroupClient
struct
{
config
...
...
@@ -914,8 +914,8 @@ func (c *GroupClient) GetX(ctx context.Context, id int64) *Group {
}
// QueryAPIKeys queries the api_keys edge of a Group.
func
(
c
*
GroupClient
)
QueryAPIKeys
(
_m
*
Group
)
*
A
pi
KeyQuery
{
query
:=
(
&
A
pi
KeyClient
{
config
:
c
.
config
})
.
Query
()
func
(
c
*
GroupClient
)
QueryAPIKeys
(
_m
*
Group
)
*
A
PI
KeyQuery
{
query
:=
(
&
A
PI
KeyClient
{
config
:
c
.
config
})
.
Query
()
query
.
path
=
func
(
context
.
Context
)
(
fromV
*
sql
.
Selector
,
_
error
)
{
id
:=
_m
.
ID
step
:=
sqlgraph
.
NewStep
(
...
...
@@ -1642,8 +1642,8 @@ func (c *UsageLogClient) QueryUser(_m *UsageLog) *UserQuery {
}
// QueryAPIKey queries the api_key edge of a UsageLog.
func
(
c
*
UsageLogClient
)
QueryAPIKey
(
_m
*
UsageLog
)
*
A
pi
KeyQuery
{
query
:=
(
&
A
pi
KeyClient
{
config
:
c
.
config
})
.
Query
()
func
(
c
*
UsageLogClient
)
QueryAPIKey
(
_m
*
UsageLog
)
*
A
PI
KeyQuery
{
query
:=
(
&
A
PI
KeyClient
{
config
:
c
.
config
})
.
Query
()
query
.
path
=
func
(
context
.
Context
)
(
fromV
*
sql
.
Selector
,
_
error
)
{
id
:=
_m
.
ID
step
:=
sqlgraph
.
NewStep
(
...
...
@@ -1839,8 +1839,8 @@ func (c *UserClient) GetX(ctx context.Context, id int64) *User {
}
// QueryAPIKeys queries the api_keys edge of a User.
func
(
c
*
UserClient
)
QueryAPIKeys
(
_m
*
User
)
*
A
pi
KeyQuery
{
query
:=
(
&
A
pi
KeyClient
{
config
:
c
.
config
})
.
Query
()
func
(
c
*
UserClient
)
QueryAPIKeys
(
_m
*
User
)
*
A
PI
KeyQuery
{
query
:=
(
&
A
PI
KeyClient
{
config
:
c
.
config
})
.
Query
()
query
.
path
=
func
(
context
.
Context
)
(
fromV
*
sql
.
Selector
,
_
error
)
{
id
:=
_m
.
ID
step
:=
sqlgraph
.
NewStep
(
...
...
@@ -2627,12 +2627,12 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription
// hooks and interceptors per client, for fast access.
type
(
hooks
struct
{
Account
,
AccountGroup
,
ApiKey
,
Group
,
Proxy
,
RedeemCode
,
Setting
,
UsageLog
,
APIKey
,
Account
,
AccountGroup
,
Group
,
Proxy
,
RedeemCode
,
Setting
,
UsageLog
,
User
,
UserAllowedGroup
,
UserAttributeDefinition
,
UserAttributeValue
,
UserSubscription
[]
ent
.
Hook
}
inters
struct
{
Account
,
AccountGroup
,
ApiKey
,
Group
,
Proxy
,
RedeemCode
,
Setting
,
UsageLog
,
APIKey
,
Account
,
AccountGroup
,
Group
,
Proxy
,
RedeemCode
,
Setting
,
UsageLog
,
User
,
UserAllowedGroup
,
UserAttributeDefinition
,
UserAttributeValue
,
UserSubscription
[]
ent
.
Interceptor
}
...
...
backend/ent/ent.go
View file @
c86d445c
...
...
@@ -85,9 +85,9 @@ var (
func
checkColumn
(
t
,
c
string
)
error
{
initCheck
.
Do
(
func
()
{
columnCheck
=
sql
.
NewColumnCheck
(
map
[
string
]
func
(
string
)
bool
{
apikey
.
Table
:
apikey
.
ValidColumn
,
account
.
Table
:
account
.
ValidColumn
,
accountgroup
.
Table
:
accountgroup
.
ValidColumn
,
apikey
.
Table
:
apikey
.
ValidColumn
,
group
.
Table
:
group
.
ValidColumn
,
proxy
.
Table
:
proxy
.
ValidColumn
,
redeemcode
.
Table
:
redeemcode
.
ValidColumn
,
...
...
backend/ent/generate.go
View file @
c86d445c
// Package ent provides the generated ORM code for database entities.
package
ent
// 启用 sql/execquery 以生成 ExecContext/QueryContext 的透传接口,便于事务内执行原生 SQL。
...
...
backend/ent/group.go
View file @
c86d445c
...
...
@@ -54,7 +54,7 @@ type Group struct {
// GroupEdges holds the relations/edges for other nodes in the graph.
type
GroupEdges
struct
{
// APIKeys holds the value of the api_keys edge.
APIKeys
[]
*
A
pi
Key
`json:"api_keys,omitempty"`
APIKeys
[]
*
A
PI
Key
`json:"api_keys,omitempty"`
// RedeemCodes holds the value of the redeem_codes edge.
RedeemCodes
[]
*
RedeemCode
`json:"redeem_codes,omitempty"`
// Subscriptions holds the value of the subscriptions edge.
...
...
@@ -76,7 +76,7 @@ type GroupEdges struct {
// APIKeysOrErr returns the APIKeys value or an error if the edge
// was not loaded in eager-loading.
func
(
e
GroupEdges
)
APIKeysOrErr
()
([]
*
A
pi
Key
,
error
)
{
func
(
e
GroupEdges
)
APIKeysOrErr
()
([]
*
A
PI
Key
,
error
)
{
if
e
.
loadedTypes
[
0
]
{
return
e
.
APIKeys
,
nil
}
...
...
@@ -285,7 +285,7 @@ func (_m *Group) Value(name string) (ent.Value, error) {
}
// QueryAPIKeys queries the "api_keys" edge of the Group entity.
func
(
_m
*
Group
)
QueryAPIKeys
()
*
A
pi
KeyQuery
{
func
(
_m
*
Group
)
QueryAPIKeys
()
*
A
PI
KeyQuery
{
return
NewGroupClient
(
_m
.
config
)
.
QueryAPIKeys
(
_m
)
}
...
...
backend/ent/group/group.go
View file @
c86d445c
...
...
@@ -63,7 +63,7 @@ const (
Table
=
"groups"
// APIKeysTable is the table that holds the api_keys relation/edge.
APIKeysTable
=
"api_keys"
// APIKeysInverseTable is the table name for the A
pi
Key entity.
// APIKeysInverseTable is the table name for the A
PI
Key entity.
// It exists in this package in order to avoid circular dependency with the "apikey" package.
APIKeysInverseTable
=
"api_keys"
// APIKeysColumn is the table column denoting the api_keys relation/edge.
...
...
backend/ent/group/where.go
View file @
c86d445c
...
...
@@ -842,7 +842,7 @@ func HasAPIKeys() predicate.Group {
}
// HasAPIKeysWith applies the HasEdge predicate on the "api_keys" edge with a given conditions (other predicates).
func
HasAPIKeysWith
(
preds
...
predicate
.
A
pi
Key
)
predicate
.
Group
{
func
HasAPIKeysWith
(
preds
...
predicate
.
A
PI
Key
)
predicate
.
Group
{
return
predicate
.
Group
(
func
(
s
*
sql
.
Selector
)
{
step
:=
newAPIKeysStep
()
sqlgraph
.
HasNeighborsWith
(
s
,
step
,
func
(
s
*
sql
.
Selector
)
{
...
...
backend/ent/group_create.go
View file @
c86d445c
...
...
@@ -216,14 +216,14 @@ func (_c *GroupCreate) SetNillableDefaultValidityDays(v *int) *GroupCreate {
return
_c
}
// AddAPIKeyIDs adds the "api_keys" edge to the A
pi
Key entity by IDs.
// AddAPIKeyIDs adds the "api_keys" edge to the A
PI
Key entity by IDs.
func
(
_c
*
GroupCreate
)
AddAPIKeyIDs
(
ids
...
int64
)
*
GroupCreate
{
_c
.
mutation
.
AddAPIKeyIDs
(
ids
...
)
return
_c
}
// AddAPIKeys adds the "api_keys" edges to the A
pi
Key entity.
func
(
_c
*
GroupCreate
)
AddAPIKeys
(
v
...*
A
pi
Key
)
*
GroupCreate
{
// AddAPIKeys adds the "api_keys" edges to the A
PI
Key entity.
func
(
_c
*
GroupCreate
)
AddAPIKeys
(
v
...*
A
PI
Key
)
*
GroupCreate
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
backend/ent/group_query.go
View file @
c86d445c
...
...
@@ -31,7 +31,7 @@ type GroupQuery struct {
order
[]
group
.
OrderOption
inters
[]
Interceptor
predicates
[]
predicate
.
Group
withAPIKeys
*
A
pi
KeyQuery
withAPIKeys
*
A
PI
KeyQuery
withRedeemCodes
*
RedeemCodeQuery
withSubscriptions
*
UserSubscriptionQuery
withUsageLogs
*
UsageLogQuery
...
...
@@ -76,8 +76,8 @@ func (_q *GroupQuery) Order(o ...group.OrderOption) *GroupQuery {
}
// QueryAPIKeys chains the current query on the "api_keys" edge.
func
(
_q
*
GroupQuery
)
QueryAPIKeys
()
*
A
pi
KeyQuery
{
query
:=
(
&
A
pi
KeyClient
{
config
:
_q
.
config
})
.
Query
()
func
(
_q
*
GroupQuery
)
QueryAPIKeys
()
*
A
PI
KeyQuery
{
query
:=
(
&
A
PI
KeyClient
{
config
:
_q
.
config
})
.
Query
()
query
.
path
=
func
(
ctx
context
.
Context
)
(
fromU
*
sql
.
Selector
,
err
error
)
{
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
nil
,
err
...
...
@@ -459,8 +459,8 @@ func (_q *GroupQuery) Clone() *GroupQuery {
// 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.
func
(
_q
*
GroupQuery
)
WithAPIKeys
(
opts
...
func
(
*
A
pi
KeyQuery
))
*
GroupQuery
{
query
:=
(
&
A
pi
KeyClient
{
config
:
_q
.
config
})
.
Query
()
func
(
_q
*
GroupQuery
)
WithAPIKeys
(
opts
...
func
(
*
A
PI
KeyQuery
))
*
GroupQuery
{
query
:=
(
&
A
PI
KeyClient
{
config
:
_q
.
config
})
.
Query
()
for
_
,
opt
:=
range
opts
{
opt
(
query
)
}
...
...
@@ -654,8 +654,8 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
}
if
query
:=
_q
.
withAPIKeys
;
query
!=
nil
{
if
err
:=
_q
.
loadAPIKeys
(
ctx
,
query
,
nodes
,
func
(
n
*
Group
)
{
n
.
Edges
.
APIKeys
=
[]
*
A
pi
Key
{}
},
func
(
n
*
Group
,
e
*
A
pi
Key
)
{
n
.
Edges
.
APIKeys
=
append
(
n
.
Edges
.
APIKeys
,
e
)
});
err
!=
nil
{
func
(
n
*
Group
)
{
n
.
Edges
.
APIKeys
=
[]
*
A
PI
Key
{}
},
func
(
n
*
Group
,
e
*
A
PI
Key
)
{
n
.
Edges
.
APIKeys
=
append
(
n
.
Edges
.
APIKeys
,
e
)
});
err
!=
nil
{
return
nil
,
err
}
}
...
...
@@ -711,7 +711,7 @@ func (_q *GroupQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Group,
return
nodes
,
nil
}
func
(
_q
*
GroupQuery
)
loadAPIKeys
(
ctx
context
.
Context
,
query
*
A
pi
KeyQuery
,
nodes
[]
*
Group
,
init
func
(
*
Group
),
assign
func
(
*
Group
,
*
A
pi
Key
))
error
{
func
(
_q
*
GroupQuery
)
loadAPIKeys
(
ctx
context
.
Context
,
query
*
A
PI
KeyQuery
,
nodes
[]
*
Group
,
init
func
(
*
Group
),
assign
func
(
*
Group
,
*
A
PI
Key
))
error
{
fks
:=
make
([]
driver
.
Value
,
0
,
len
(
nodes
))
nodeids
:=
make
(
map
[
int64
]
*
Group
)
for
i
:=
range
nodes
{
...
...
@@ -724,7 +724,7 @@ func (_q *GroupQuery) loadAPIKeys(ctx context.Context, query *ApiKeyQuery, nodes
if
len
(
query
.
ctx
.
Fields
)
>
0
{
query
.
ctx
.
AppendFieldOnce
(
apikey
.
FieldGroupID
)
}
query
.
Where
(
predicate
.
A
pi
Key
(
func
(
s
*
sql
.
Selector
)
{
query
.
Where
(
predicate
.
A
PI
Key
(
func
(
s
*
sql
.
Selector
)
{
s
.
Where
(
sql
.
InValues
(
s
.
C
(
group
.
APIKeysColumn
),
fks
...
))
}))
neighbors
,
err
:=
query
.
All
(
ctx
)
...
...
backend/ent/group_update.go
View file @
c86d445c
...
...
@@ -273,14 +273,14 @@ func (_u *GroupUpdate) AddDefaultValidityDays(v int) *GroupUpdate {
return
_u
}
// AddAPIKeyIDs adds the "api_keys" edge to the A
pi
Key entity by IDs.
// AddAPIKeyIDs adds the "api_keys" edge to the A
PI
Key entity by IDs.
func
(
_u
*
GroupUpdate
)
AddAPIKeyIDs
(
ids
...
int64
)
*
GroupUpdate
{
_u
.
mutation
.
AddAPIKeyIDs
(
ids
...
)
return
_u
}
// AddAPIKeys adds the "api_keys" edges to the A
pi
Key entity.
func
(
_u
*
GroupUpdate
)
AddAPIKeys
(
v
...*
A
pi
Key
)
*
GroupUpdate
{
// AddAPIKeys adds the "api_keys" edges to the A
PI
Key entity.
func
(
_u
*
GroupUpdate
)
AddAPIKeys
(
v
...*
A
PI
Key
)
*
GroupUpdate
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
@@ -368,20 +368,20 @@ func (_u *GroupUpdate) Mutation() *GroupMutation {
return
_u
.
mutation
}
// ClearAPIKeys clears all "api_keys" edges to the A
pi
Key entity.
// ClearAPIKeys clears all "api_keys" edges to the A
PI
Key entity.
func
(
_u
*
GroupUpdate
)
ClearAPIKeys
()
*
GroupUpdate
{
_u
.
mutation
.
ClearAPIKeys
()
return
_u
}
// RemoveAPIKeyIDs removes the "api_keys" edge to A
pi
Key entities by IDs.
// RemoveAPIKeyIDs removes the "api_keys" edge to A
PI
Key entities by IDs.
func
(
_u
*
GroupUpdate
)
RemoveAPIKeyIDs
(
ids
...
int64
)
*
GroupUpdate
{
_u
.
mutation
.
RemoveAPIKeyIDs
(
ids
...
)
return
_u
}
// RemoveAPIKeys removes "api_keys" edges to A
pi
Key entities.
func
(
_u
*
GroupUpdate
)
RemoveAPIKeys
(
v
...*
A
pi
Key
)
*
GroupUpdate
{
// RemoveAPIKeys removes "api_keys" edges to A
PI
Key entities.
func
(
_u
*
GroupUpdate
)
RemoveAPIKeys
(
v
...*
A
PI
Key
)
*
GroupUpdate
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
@@ -1195,14 +1195,14 @@ func (_u *GroupUpdateOne) AddDefaultValidityDays(v int) *GroupUpdateOne {
return
_u
}
// AddAPIKeyIDs adds the "api_keys" edge to the A
pi
Key entity by IDs.
// AddAPIKeyIDs adds the "api_keys" edge to the A
PI
Key entity by IDs.
func
(
_u
*
GroupUpdateOne
)
AddAPIKeyIDs
(
ids
...
int64
)
*
GroupUpdateOne
{
_u
.
mutation
.
AddAPIKeyIDs
(
ids
...
)
return
_u
}
// AddAPIKeys adds the "api_keys" edges to the A
pi
Key entity.
func
(
_u
*
GroupUpdateOne
)
AddAPIKeys
(
v
...*
A
pi
Key
)
*
GroupUpdateOne
{
// AddAPIKeys adds the "api_keys" edges to the A
PI
Key entity.
func
(
_u
*
GroupUpdateOne
)
AddAPIKeys
(
v
...*
A
PI
Key
)
*
GroupUpdateOne
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
@@ -1290,20 +1290,20 @@ func (_u *GroupUpdateOne) Mutation() *GroupMutation {
return
_u
.
mutation
}
// ClearAPIKeys clears all "api_keys" edges to the A
pi
Key entity.
// ClearAPIKeys clears all "api_keys" edges to the A
PI
Key entity.
func
(
_u
*
GroupUpdateOne
)
ClearAPIKeys
()
*
GroupUpdateOne
{
_u
.
mutation
.
ClearAPIKeys
()
return
_u
}
// RemoveAPIKeyIDs removes the "api_keys" edge to A
pi
Key entities by IDs.
// RemoveAPIKeyIDs removes the "api_keys" edge to A
PI
Key entities by IDs.
func
(
_u
*
GroupUpdateOne
)
RemoveAPIKeyIDs
(
ids
...
int64
)
*
GroupUpdateOne
{
_u
.
mutation
.
RemoveAPIKeyIDs
(
ids
...
)
return
_u
}
// RemoveAPIKeys removes "api_keys" edges to A
pi
Key entities.
func
(
_u
*
GroupUpdateOne
)
RemoveAPIKeys
(
v
...*
A
pi
Key
)
*
GroupUpdateOne
{
// RemoveAPIKeys removes "api_keys" edges to A
PI
Key entities.
func
(
_u
*
GroupUpdateOne
)
RemoveAPIKeys
(
v
...*
A
PI
Key
)
*
GroupUpdateOne
{
ids
:=
make
([]
int64
,
len
(
v
))
for
i
:=
range
v
{
ids
[
i
]
=
v
[
i
]
.
ID
...
...
Prev
1
2
3
4
5
…
10
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment