|
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
|
|
package db
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"log"
|
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/migrate"
|
|
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
|
|
|
|
"entgo.io/ent/dialect"
|
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/authcode"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/authrequest"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/authsession"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/connector"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/devicerequest"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/devicetoken"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/keys"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/oauth2client"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/offlinesession"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/password"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/refreshtoken"
|
|
|
|
|
"github.com/dexidp/dex/storage/ent/db/useridentity"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Client is the client that holds all ent builders.
|
|
|
|
|
type Client struct {
|
|
|
|
|
config
|
|
|
|
|
// Schema is the client for creating, migrating and dropping schema.
|
|
|
|
|
Schema *migrate.Schema
|
|
|
|
|
// AuthCode is the client for interacting with the AuthCode builders.
|
|
|
|
|
AuthCode *AuthCodeClient
|
|
|
|
|
// AuthRequest is the client for interacting with the AuthRequest builders.
|
|
|
|
|
AuthRequest *AuthRequestClient
|
|
|
|
|
// AuthSession is the client for interacting with the AuthSession builders.
|
|
|
|
|
AuthSession *AuthSessionClient
|
|
|
|
|
// Connector is the client for interacting with the Connector builders.
|
|
|
|
|
Connector *ConnectorClient
|
|
|
|
|
// DeviceRequest is the client for interacting with the DeviceRequest builders.
|
|
|
|
|
DeviceRequest *DeviceRequestClient
|
|
|
|
|
// DeviceToken is the client for interacting with the DeviceToken builders.
|
|
|
|
|
DeviceToken *DeviceTokenClient
|
|
|
|
|
// Keys is the client for interacting with the Keys builders.
|
|
|
|
|
Keys *KeysClient
|
|
|
|
|
// OAuth2Client is the client for interacting with the OAuth2Client builders.
|
|
|
|
|
OAuth2Client *OAuth2ClientClient
|
|
|
|
|
// OfflineSession is the client for interacting with the OfflineSession builders.
|
|
|
|
|
OfflineSession *OfflineSessionClient
|
|
|
|
|
// Password is the client for interacting with the Password builders.
|
|
|
|
|
Password *PasswordClient
|
|
|
|
|
// RefreshToken is the client for interacting with the RefreshToken builders.
|
|
|
|
|
RefreshToken *RefreshTokenClient
|
|
|
|
|
// UserIdentity is the client for interacting with the UserIdentity builders.
|
|
|
|
|
UserIdentity *UserIdentityClient
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewClient creates a new client configured with the given options.
|
|
|
|
|
func NewClient(opts ...Option) *Client {
|
|
|
|
|
client := &Client{config: newConfig(opts...)}
|
|
|
|
|
client.init()
|
|
|
|
|
return client
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *Client) init() {
|
|
|
|
|
c.Schema = migrate.NewSchema(c.driver)
|
|
|
|
|
c.AuthCode = NewAuthCodeClient(c.config)
|
|
|
|
|
c.AuthRequest = NewAuthRequestClient(c.config)
|
|
|
|
|
c.AuthSession = NewAuthSessionClient(c.config)
|
|
|
|
|
c.Connector = NewConnectorClient(c.config)
|
|
|
|
|
c.DeviceRequest = NewDeviceRequestClient(c.config)
|
|
|
|
|
c.DeviceToken = NewDeviceTokenClient(c.config)
|
|
|
|
|
c.Keys = NewKeysClient(c.config)
|
|
|
|
|
c.OAuth2Client = NewOAuth2ClientClient(c.config)
|
|
|
|
|
c.OfflineSession = NewOfflineSessionClient(c.config)
|
|
|
|
|
c.Password = NewPasswordClient(c.config)
|
|
|
|
|
c.RefreshToken = NewRefreshTokenClient(c.config)
|
|
|
|
|
c.UserIdentity = NewUserIdentityClient(c.config)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
// config is the configuration for the client and its builder.
|
|
|
|
|
config struct {
|
|
|
|
|
// driver used for executing database requests.
|
|
|
|
|
driver dialect.Driver
|
|
|
|
|
// debug enable a debug logging.
|
|
|
|
|
debug bool
|
|
|
|
|
// log used for logging on debug mode.
|
|
|
|
|
log func(...any)
|
|
|
|
|
// hooks to execute on mutations.
|
|
|
|
|
hooks *hooks
|
|
|
|
|
// interceptors to execute on queries.
|
|
|
|
|
inters *inters
|
|
|
|
|
}
|
|
|
|
|
// Option function to configure the client.
|
|
|
|
|
Option func(*config)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// newConfig creates a new config for the client.
|
|
|
|
|
func newConfig(opts ...Option) config {
|
|
|
|
|
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
|
|
|
|
|
cfg.options(opts...)
|
|
|
|
|
return cfg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// options applies the options on the config object.
|
|
|
|
|
func (c *config) options(opts ...Option) {
|
|
|
|
|
for _, opt := range opts {
|
|
|
|
|
opt(c)
|
|
|
|
|
}
|
|
|
|
|
if c.debug {
|
|
|
|
|
c.driver = dialect.Debug(c.driver, c.log)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Debug enables debug logging on the ent.Driver.
|
|
|
|
|
func Debug() Option {
|
|
|
|
|
return func(c *config) {
|
|
|
|
|
c.debug = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Log sets the logging function for debug mode.
|
|
|
|
|
func Log(fn func(...any)) Option {
|
|
|
|
|
return func(c *config) {
|
|
|
|
|
c.log = fn
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Driver configures the client driver.
|
|
|
|
|
func Driver(driver dialect.Driver) Option {
|
|
|
|
|
return func(c *config) {
|
|
|
|
|
c.driver = driver
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Open opens a database/sql.DB specified by the driver name and
|
|
|
|
|
// the data source name, and returns a new client attached to it.
|
|
|
|
|
// Optional parameters can be added for configuring the client.
|
|
|
|
|
func Open(driverName, dataSourceName string, options ...Option) (*Client, error) {
|
|
|
|
|
switch driverName {
|
|
|
|
|
case dialect.MySQL, dialect.Postgres, dialect.SQLite:
|
|
|
|
|
drv, err := sql.Open(driverName, dataSourceName)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return NewClient(append(options, Driver(drv))...), nil
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("unsupported driver: %q", driverName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
|
|
|
|
|
var ErrTxStarted = errors.New("db: cannot start a transaction within a transaction")
|
|
|
|
|
|
|
|
|
|
// Tx returns a new transactional client. The provided context
|
|
|
|
|
// is used until the transaction is committed or rolled back.
|
|
|
|
|
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
|
|
|
|
if _, ok := c.driver.(*txDriver); ok {
|
|
|
|
|
return nil, ErrTxStarted
|
|
|
|
|
}
|
|
|
|
|
tx, err := newTx(ctx, c.driver)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("db: starting a transaction: %w", err)
|
|
|
|
|
}
|
|
|
|
|
cfg := c.config
|
|
|
|
|
cfg.driver = tx
|
|
|
|
|
return &Tx{
|
|
|
|
|
ctx: ctx,
|
|
|
|
|
config: cfg,
|
|
|
|
|
AuthCode: NewAuthCodeClient(cfg),
|
|
|
|
|
AuthRequest: NewAuthRequestClient(cfg),
|
|
|
|
|
AuthSession: NewAuthSessionClient(cfg),
|
|
|
|
|
Connector: NewConnectorClient(cfg),
|
|
|
|
|
DeviceRequest: NewDeviceRequestClient(cfg),
|
|
|
|
|
DeviceToken: NewDeviceTokenClient(cfg),
|
|
|
|
|
Keys: NewKeysClient(cfg),
|
|
|
|
|
OAuth2Client: NewOAuth2ClientClient(cfg),
|
|
|
|
|
OfflineSession: NewOfflineSessionClient(cfg),
|
|
|
|
|
Password: NewPasswordClient(cfg),
|
|
|
|
|
RefreshToken: NewRefreshTokenClient(cfg),
|
|
|
|
|
UserIdentity: NewUserIdentityClient(cfg),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BeginTx returns a transactional client with specified options.
|
|
|
|
|
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
|
|
|
|
|
if _, ok := c.driver.(*txDriver); ok {
|
|
|
|
|
return nil, errors.New("ent: cannot start a transaction within a transaction")
|
|
|
|
|
}
|
|
|
|
|
tx, err := c.driver.(interface {
|
|
|
|
|
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
|
|
|
|
|
}).BeginTx(ctx, opts)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, fmt.Errorf("ent: starting a transaction: %w", err)
|
|
|
|
|
}
|
|
|
|
|
cfg := c.config
|
|
|
|
|
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
|
|
|
|
return &Tx{
|
|
|
|
|
ctx: ctx,
|
|
|
|
|
config: cfg,
|
|
|
|
|
AuthCode: NewAuthCodeClient(cfg),
|
|
|
|
|
AuthRequest: NewAuthRequestClient(cfg),
|
|
|
|
|
AuthSession: NewAuthSessionClient(cfg),
|
|
|
|
|
Connector: NewConnectorClient(cfg),
|
|
|
|
|
DeviceRequest: NewDeviceRequestClient(cfg),
|
|
|
|
|
DeviceToken: NewDeviceTokenClient(cfg),
|
|
|
|
|
Keys: NewKeysClient(cfg),
|
|
|
|
|
OAuth2Client: NewOAuth2ClientClient(cfg),
|
|
|
|
|
OfflineSession: NewOfflineSessionClient(cfg),
|
|
|
|
|
Password: NewPasswordClient(cfg),
|
|
|
|
|
RefreshToken: NewRefreshTokenClient(cfg),
|
|
|
|
|
UserIdentity: NewUserIdentityClient(cfg),
|
|
|
|
|
}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
|
|
|
|
//
|
|
|
|
|
// client.Debug().
|
|
|
|
|
// AuthCode.
|
|
|
|
|
// Query().
|
|
|
|
|
// Count(ctx)
|
|
|
|
|
func (c *Client) Debug() *Client {
|
|
|
|
|
if c.debug {
|
|
|
|
|
return c
|
|
|
|
|
}
|
|
|
|
|
cfg := c.config
|
|
|
|
|
cfg.driver = dialect.Debug(c.driver, c.log)
|
|
|
|
|
client := &Client{config: cfg}
|
|
|
|
|
client.init()
|
|
|
|
|
return client
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Close closes the database connection and prevents new queries from starting.
|
|
|
|
|
func (c *Client) Close() error {
|
|
|
|
|
return c.driver.Close()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds the mutation hooks to all the entity clients.
|
|
|
|
|
// 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.AuthCode, c.AuthRequest, c.AuthSession, c.Connector, c.DeviceRequest,
|
|
|
|
|
c.DeviceToken, c.Keys, c.OAuth2Client, c.OfflineSession, c.Password,
|
|
|
|
|
c.RefreshToken, c.UserIdentity,
|
|
|
|
|
} {
|
|
|
|
|
n.Use(hooks...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds the query interceptors to all the entity clients.
|
|
|
|
|
// 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.AuthCode, c.AuthRequest, c.AuthSession, c.Connector, c.DeviceRequest,
|
|
|
|
|
c.DeviceToken, c.Keys, c.OAuth2Client, c.OfflineSession, c.Password,
|
|
|
|
|
c.RefreshToken, c.UserIdentity,
|
|
|
|
|
} {
|
|
|
|
|
n.Intercept(interceptors...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mutate implements the ent.Mutator interface.
|
|
|
|
|
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
|
|
|
|
switch m := m.(type) {
|
|
|
|
|
case *AuthCodeMutation:
|
|
|
|
|
return c.AuthCode.mutate(ctx, m)
|
|
|
|
|
case *AuthRequestMutation:
|
|
|
|
|
return c.AuthRequest.mutate(ctx, m)
|
|
|
|
|
case *AuthSessionMutation:
|
|
|
|
|
return c.AuthSession.mutate(ctx, m)
|
|
|
|
|
case *ConnectorMutation:
|
|
|
|
|
return c.Connector.mutate(ctx, m)
|
|
|
|
|
case *DeviceRequestMutation:
|
|
|
|
|
return c.DeviceRequest.mutate(ctx, m)
|
|
|
|
|
case *DeviceTokenMutation:
|
|
|
|
|
return c.DeviceToken.mutate(ctx, m)
|
|
|
|
|
case *KeysMutation:
|
|
|
|
|
return c.Keys.mutate(ctx, m)
|
|
|
|
|
case *OAuth2ClientMutation:
|
|
|
|
|
return c.OAuth2Client.mutate(ctx, m)
|
|
|
|
|
case *OfflineSessionMutation:
|
|
|
|
|
return c.OfflineSession.mutate(ctx, m)
|
|
|
|
|
case *PasswordMutation:
|
|
|
|
|
return c.Password.mutate(ctx, m)
|
|
|
|
|
case *RefreshTokenMutation:
|
|
|
|
|
return c.RefreshToken.mutate(ctx, m)
|
|
|
|
|
case *UserIdentityMutation:
|
|
|
|
|
return c.UserIdentity.mutate(ctx, m)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown mutation type %T", m)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AuthCodeClient is a client for the AuthCode schema.
|
|
|
|
|
type AuthCodeClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewAuthCodeClient returns a client for the AuthCode from the given config.
|
|
|
|
|
func NewAuthCodeClient(c config) *AuthCodeClient {
|
|
|
|
|
return &AuthCodeClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `authcode.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *AuthCodeClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.AuthCode = append(c.hooks.AuthCode, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `authcode.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *AuthCodeClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.AuthCode = append(c.inters.AuthCode, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a AuthCode entity.
|
|
|
|
|
func (c *AuthCodeClient) Create() *AuthCodeCreate {
|
|
|
|
|
mutation := newAuthCodeMutation(c.config, OpCreate)
|
|
|
|
|
return &AuthCodeCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of AuthCode entities.
|
|
|
|
|
func (c *AuthCodeClient) CreateBulk(builders ...*AuthCodeCreate) *AuthCodeCreateBulk {
|
|
|
|
|
return &AuthCodeCreateBulk{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 *AuthCodeClient) MapCreateBulk(slice any, setFunc func(*AuthCodeCreate, int)) *AuthCodeCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &AuthCodeCreateBulk{err: fmt.Errorf("calling to AuthCodeClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*AuthCodeCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &AuthCodeCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for AuthCode.
|
|
|
|
|
func (c *AuthCodeClient) Update() *AuthCodeUpdate {
|
|
|
|
|
mutation := newAuthCodeMutation(c.config, OpUpdate)
|
|
|
|
|
return &AuthCodeUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *AuthCodeClient) UpdateOne(_m *AuthCode) *AuthCodeUpdateOne {
|
|
|
|
|
mutation := newAuthCodeMutation(c.config, OpUpdateOne, withAuthCode(_m))
|
|
|
|
|
return &AuthCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *AuthCodeClient) UpdateOneID(id string) *AuthCodeUpdateOne {
|
|
|
|
|
mutation := newAuthCodeMutation(c.config, OpUpdateOne, withAuthCodeID(id))
|
|
|
|
|
return &AuthCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for AuthCode.
|
|
|
|
|
func (c *AuthCodeClient) Delete() *AuthCodeDelete {
|
|
|
|
|
mutation := newAuthCodeMutation(c.config, OpDelete)
|
|
|
|
|
return &AuthCodeDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *AuthCodeClient) DeleteOne(_m *AuthCode) *AuthCodeDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *AuthCodeClient) DeleteOneID(id string) *AuthCodeDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(authcode.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &AuthCodeDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for AuthCode.
|
|
|
|
|
func (c *AuthCodeClient) Query() *AuthCodeQuery {
|
|
|
|
|
return &AuthCodeQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeAuthCode},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a AuthCode entity by its id.
|
|
|
|
|
func (c *AuthCodeClient) Get(ctx context.Context, id string) (*AuthCode, error) {
|
|
|
|
|
return c.Query().Where(authcode.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *AuthCodeClient) GetX(ctx context.Context, id string) *AuthCode {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *AuthCodeClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.AuthCode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *AuthCodeClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.AuthCode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *AuthCodeClient) mutate(ctx context.Context, m *AuthCodeMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&AuthCodeCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&AuthCodeUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&AuthCodeUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&AuthCodeDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown AuthCode mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AuthRequestClient is a client for the AuthRequest schema.
|
|
|
|
|
type AuthRequestClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewAuthRequestClient returns a client for the AuthRequest from the given config.
|
|
|
|
|
func NewAuthRequestClient(c config) *AuthRequestClient {
|
|
|
|
|
return &AuthRequestClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `authrequest.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *AuthRequestClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.AuthRequest = append(c.hooks.AuthRequest, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `authrequest.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *AuthRequestClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.AuthRequest = append(c.inters.AuthRequest, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a AuthRequest entity.
|
|
|
|
|
func (c *AuthRequestClient) Create() *AuthRequestCreate {
|
|
|
|
|
mutation := newAuthRequestMutation(c.config, OpCreate)
|
|
|
|
|
return &AuthRequestCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of AuthRequest entities.
|
|
|
|
|
func (c *AuthRequestClient) CreateBulk(builders ...*AuthRequestCreate) *AuthRequestCreateBulk {
|
|
|
|
|
return &AuthRequestCreateBulk{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 *AuthRequestClient) MapCreateBulk(slice any, setFunc func(*AuthRequestCreate, int)) *AuthRequestCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &AuthRequestCreateBulk{err: fmt.Errorf("calling to AuthRequestClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*AuthRequestCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &AuthRequestCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for AuthRequest.
|
|
|
|
|
func (c *AuthRequestClient) Update() *AuthRequestUpdate {
|
|
|
|
|
mutation := newAuthRequestMutation(c.config, OpUpdate)
|
|
|
|
|
return &AuthRequestUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *AuthRequestClient) UpdateOne(_m *AuthRequest) *AuthRequestUpdateOne {
|
|
|
|
|
mutation := newAuthRequestMutation(c.config, OpUpdateOne, withAuthRequest(_m))
|
|
|
|
|
return &AuthRequestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *AuthRequestClient) UpdateOneID(id string) *AuthRequestUpdateOne {
|
|
|
|
|
mutation := newAuthRequestMutation(c.config, OpUpdateOne, withAuthRequestID(id))
|
|
|
|
|
return &AuthRequestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for AuthRequest.
|
|
|
|
|
func (c *AuthRequestClient) Delete() *AuthRequestDelete {
|
|
|
|
|
mutation := newAuthRequestMutation(c.config, OpDelete)
|
|
|
|
|
return &AuthRequestDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *AuthRequestClient) DeleteOne(_m *AuthRequest) *AuthRequestDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *AuthRequestClient) DeleteOneID(id string) *AuthRequestDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(authrequest.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &AuthRequestDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for AuthRequest.
|
|
|
|
|
func (c *AuthRequestClient) Query() *AuthRequestQuery {
|
|
|
|
|
return &AuthRequestQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeAuthRequest},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a AuthRequest entity by its id.
|
|
|
|
|
func (c *AuthRequestClient) Get(ctx context.Context, id string) (*AuthRequest, error) {
|
|
|
|
|
return c.Query().Where(authrequest.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *AuthRequestClient) GetX(ctx context.Context, id string) *AuthRequest {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *AuthRequestClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.AuthRequest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *AuthRequestClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.AuthRequest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *AuthRequestClient) mutate(ctx context.Context, m *AuthRequestMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&AuthRequestCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&AuthRequestUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&AuthRequestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&AuthRequestDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown AuthRequest mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AuthSessionClient is a client for the AuthSession schema.
|
|
|
|
|
type AuthSessionClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewAuthSessionClient returns a client for the AuthSession from the given config.
|
|
|
|
|
func NewAuthSessionClient(c config) *AuthSessionClient {
|
|
|
|
|
return &AuthSessionClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `authsession.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *AuthSessionClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.AuthSession = append(c.hooks.AuthSession, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `authsession.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *AuthSessionClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.AuthSession = append(c.inters.AuthSession, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a AuthSession entity.
|
|
|
|
|
func (c *AuthSessionClient) Create() *AuthSessionCreate {
|
|
|
|
|
mutation := newAuthSessionMutation(c.config, OpCreate)
|
|
|
|
|
return &AuthSessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of AuthSession entities.
|
|
|
|
|
func (c *AuthSessionClient) CreateBulk(builders ...*AuthSessionCreate) *AuthSessionCreateBulk {
|
|
|
|
|
return &AuthSessionCreateBulk{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 *AuthSessionClient) MapCreateBulk(slice any, setFunc func(*AuthSessionCreate, int)) *AuthSessionCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &AuthSessionCreateBulk{err: fmt.Errorf("calling to AuthSessionClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*AuthSessionCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &AuthSessionCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for AuthSession.
|
|
|
|
|
func (c *AuthSessionClient) Update() *AuthSessionUpdate {
|
|
|
|
|
mutation := newAuthSessionMutation(c.config, OpUpdate)
|
|
|
|
|
return &AuthSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *AuthSessionClient) UpdateOne(_m *AuthSession) *AuthSessionUpdateOne {
|
|
|
|
|
mutation := newAuthSessionMutation(c.config, OpUpdateOne, withAuthSession(_m))
|
|
|
|
|
return &AuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *AuthSessionClient) UpdateOneID(id string) *AuthSessionUpdateOne {
|
|
|
|
|
mutation := newAuthSessionMutation(c.config, OpUpdateOne, withAuthSessionID(id))
|
|
|
|
|
return &AuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for AuthSession.
|
|
|
|
|
func (c *AuthSessionClient) Delete() *AuthSessionDelete {
|
|
|
|
|
mutation := newAuthSessionMutation(c.config, OpDelete)
|
|
|
|
|
return &AuthSessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *AuthSessionClient) DeleteOne(_m *AuthSession) *AuthSessionDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *AuthSessionClient) DeleteOneID(id string) *AuthSessionDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(authsession.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &AuthSessionDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for AuthSession.
|
|
|
|
|
func (c *AuthSessionClient) Query() *AuthSessionQuery {
|
|
|
|
|
return &AuthSessionQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeAuthSession},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a AuthSession entity by its id.
|
|
|
|
|
func (c *AuthSessionClient) Get(ctx context.Context, id string) (*AuthSession, error) {
|
|
|
|
|
return c.Query().Where(authsession.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *AuthSessionClient) GetX(ctx context.Context, id string) *AuthSession {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *AuthSessionClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.AuthSession
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *AuthSessionClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.AuthSession
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *AuthSessionClient) mutate(ctx context.Context, m *AuthSessionMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&AuthSessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&AuthSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&AuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&AuthSessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown AuthSession mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ConnectorClient is a client for the Connector schema.
|
|
|
|
|
type ConnectorClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewConnectorClient returns a client for the Connector from the given config.
|
|
|
|
|
func NewConnectorClient(c config) *ConnectorClient {
|
|
|
|
|
return &ConnectorClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `connector.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *ConnectorClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.Connector = append(c.hooks.Connector, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `connector.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *ConnectorClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.Connector = append(c.inters.Connector, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a Connector entity.
|
|
|
|
|
func (c *ConnectorClient) Create() *ConnectorCreate {
|
|
|
|
|
mutation := newConnectorMutation(c.config, OpCreate)
|
|
|
|
|
return &ConnectorCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Connector entities.
|
|
|
|
|
func (c *ConnectorClient) CreateBulk(builders ...*ConnectorCreate) *ConnectorCreateBulk {
|
|
|
|
|
return &ConnectorCreateBulk{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 *ConnectorClient) MapCreateBulk(slice any, setFunc func(*ConnectorCreate, int)) *ConnectorCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &ConnectorCreateBulk{err: fmt.Errorf("calling to ConnectorClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*ConnectorCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &ConnectorCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for Connector.
|
|
|
|
|
func (c *ConnectorClient) Update() *ConnectorUpdate {
|
|
|
|
|
mutation := newConnectorMutation(c.config, OpUpdate)
|
|
|
|
|
return &ConnectorUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *ConnectorClient) UpdateOne(_m *Connector) *ConnectorUpdateOne {
|
|
|
|
|
mutation := newConnectorMutation(c.config, OpUpdateOne, withConnector(_m))
|
|
|
|
|
return &ConnectorUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *ConnectorClient) UpdateOneID(id string) *ConnectorUpdateOne {
|
|
|
|
|
mutation := newConnectorMutation(c.config, OpUpdateOne, withConnectorID(id))
|
|
|
|
|
return &ConnectorUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for Connector.
|
|
|
|
|
func (c *ConnectorClient) Delete() *ConnectorDelete {
|
|
|
|
|
mutation := newConnectorMutation(c.config, OpDelete)
|
|
|
|
|
return &ConnectorDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *ConnectorClient) DeleteOne(_m *Connector) *ConnectorDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *ConnectorClient) DeleteOneID(id string) *ConnectorDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(connector.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &ConnectorDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for Connector.
|
|
|
|
|
func (c *ConnectorClient) Query() *ConnectorQuery {
|
|
|
|
|
return &ConnectorQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeConnector},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a Connector entity by its id.
|
|
|
|
|
func (c *ConnectorClient) Get(ctx context.Context, id string) (*Connector, error) {
|
|
|
|
|
return c.Query().Where(connector.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *ConnectorClient) GetX(ctx context.Context, id string) *Connector {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *ConnectorClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.Connector
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *ConnectorClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.Connector
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *ConnectorClient) mutate(ctx context.Context, m *ConnectorMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&ConnectorCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&ConnectorUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&ConnectorUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&ConnectorDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown Connector mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeviceRequestClient is a client for the DeviceRequest schema.
|
|
|
|
|
type DeviceRequestClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewDeviceRequestClient returns a client for the DeviceRequest from the given config.
|
|
|
|
|
func NewDeviceRequestClient(c config) *DeviceRequestClient {
|
|
|
|
|
return &DeviceRequestClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `devicerequest.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *DeviceRequestClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.DeviceRequest = append(c.hooks.DeviceRequest, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `devicerequest.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *DeviceRequestClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.DeviceRequest = append(c.inters.DeviceRequest, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a DeviceRequest entity.
|
|
|
|
|
func (c *DeviceRequestClient) Create() *DeviceRequestCreate {
|
|
|
|
|
mutation := newDeviceRequestMutation(c.config, OpCreate)
|
|
|
|
|
return &DeviceRequestCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of DeviceRequest entities.
|
|
|
|
|
func (c *DeviceRequestClient) CreateBulk(builders ...*DeviceRequestCreate) *DeviceRequestCreateBulk {
|
|
|
|
|
return &DeviceRequestCreateBulk{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 *DeviceRequestClient) MapCreateBulk(slice any, setFunc func(*DeviceRequestCreate, int)) *DeviceRequestCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &DeviceRequestCreateBulk{err: fmt.Errorf("calling to DeviceRequestClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*DeviceRequestCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &DeviceRequestCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for DeviceRequest.
|
|
|
|
|
func (c *DeviceRequestClient) Update() *DeviceRequestUpdate {
|
|
|
|
|
mutation := newDeviceRequestMutation(c.config, OpUpdate)
|
|
|
|
|
return &DeviceRequestUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *DeviceRequestClient) UpdateOne(_m *DeviceRequest) *DeviceRequestUpdateOne {
|
|
|
|
|
mutation := newDeviceRequestMutation(c.config, OpUpdateOne, withDeviceRequest(_m))
|
|
|
|
|
return &DeviceRequestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *DeviceRequestClient) UpdateOneID(id int) *DeviceRequestUpdateOne {
|
|
|
|
|
mutation := newDeviceRequestMutation(c.config, OpUpdateOne, withDeviceRequestID(id))
|
|
|
|
|
return &DeviceRequestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for DeviceRequest.
|
|
|
|
|
func (c *DeviceRequestClient) Delete() *DeviceRequestDelete {
|
|
|
|
|
mutation := newDeviceRequestMutation(c.config, OpDelete)
|
|
|
|
|
return &DeviceRequestDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *DeviceRequestClient) DeleteOne(_m *DeviceRequest) *DeviceRequestDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *DeviceRequestClient) DeleteOneID(id int) *DeviceRequestDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(devicerequest.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &DeviceRequestDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for DeviceRequest.
|
|
|
|
|
func (c *DeviceRequestClient) Query() *DeviceRequestQuery {
|
|
|
|
|
return &DeviceRequestQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeDeviceRequest},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a DeviceRequest entity by its id.
|
|
|
|
|
func (c *DeviceRequestClient) Get(ctx context.Context, id int) (*DeviceRequest, error) {
|
|
|
|
|
return c.Query().Where(devicerequest.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *DeviceRequestClient) GetX(ctx context.Context, id int) *DeviceRequest {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *DeviceRequestClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.DeviceRequest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *DeviceRequestClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.DeviceRequest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *DeviceRequestClient) mutate(ctx context.Context, m *DeviceRequestMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&DeviceRequestCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&DeviceRequestUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&DeviceRequestUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&DeviceRequestDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown DeviceRequest mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeviceTokenClient is a client for the DeviceToken schema.
|
|
|
|
|
type DeviceTokenClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewDeviceTokenClient returns a client for the DeviceToken from the given config.
|
|
|
|
|
func NewDeviceTokenClient(c config) *DeviceTokenClient {
|
|
|
|
|
return &DeviceTokenClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `devicetoken.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *DeviceTokenClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.DeviceToken = append(c.hooks.DeviceToken, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `devicetoken.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *DeviceTokenClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.DeviceToken = append(c.inters.DeviceToken, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a DeviceToken entity.
|
|
|
|
|
func (c *DeviceTokenClient) Create() *DeviceTokenCreate {
|
|
|
|
|
mutation := newDeviceTokenMutation(c.config, OpCreate)
|
|
|
|
|
return &DeviceTokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of DeviceToken entities.
|
|
|
|
|
func (c *DeviceTokenClient) CreateBulk(builders ...*DeviceTokenCreate) *DeviceTokenCreateBulk {
|
|
|
|
|
return &DeviceTokenCreateBulk{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 *DeviceTokenClient) MapCreateBulk(slice any, setFunc func(*DeviceTokenCreate, int)) *DeviceTokenCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &DeviceTokenCreateBulk{err: fmt.Errorf("calling to DeviceTokenClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*DeviceTokenCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &DeviceTokenCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for DeviceToken.
|
|
|
|
|
func (c *DeviceTokenClient) Update() *DeviceTokenUpdate {
|
|
|
|
|
mutation := newDeviceTokenMutation(c.config, OpUpdate)
|
|
|
|
|
return &DeviceTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *DeviceTokenClient) UpdateOne(_m *DeviceToken) *DeviceTokenUpdateOne {
|
|
|
|
|
mutation := newDeviceTokenMutation(c.config, OpUpdateOne, withDeviceToken(_m))
|
|
|
|
|
return &DeviceTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *DeviceTokenClient) UpdateOneID(id int) *DeviceTokenUpdateOne {
|
|
|
|
|
mutation := newDeviceTokenMutation(c.config, OpUpdateOne, withDeviceTokenID(id))
|
|
|
|
|
return &DeviceTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for DeviceToken.
|
|
|
|
|
func (c *DeviceTokenClient) Delete() *DeviceTokenDelete {
|
|
|
|
|
mutation := newDeviceTokenMutation(c.config, OpDelete)
|
|
|
|
|
return &DeviceTokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *DeviceTokenClient) DeleteOne(_m *DeviceToken) *DeviceTokenDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *DeviceTokenClient) DeleteOneID(id int) *DeviceTokenDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(devicetoken.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &DeviceTokenDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for DeviceToken.
|
|
|
|
|
func (c *DeviceTokenClient) Query() *DeviceTokenQuery {
|
|
|
|
|
return &DeviceTokenQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeDeviceToken},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a DeviceToken entity by its id.
|
|
|
|
|
func (c *DeviceTokenClient) Get(ctx context.Context, id int) (*DeviceToken, error) {
|
|
|
|
|
return c.Query().Where(devicetoken.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *DeviceTokenClient) GetX(ctx context.Context, id int) *DeviceToken {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *DeviceTokenClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.DeviceToken
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *DeviceTokenClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.DeviceToken
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *DeviceTokenClient) mutate(ctx context.Context, m *DeviceTokenMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&DeviceTokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&DeviceTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&DeviceTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&DeviceTokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown DeviceToken mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// KeysClient is a client for the Keys schema.
|
|
|
|
|
type KeysClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewKeysClient returns a client for the Keys from the given config.
|
|
|
|
|
func NewKeysClient(c config) *KeysClient {
|
|
|
|
|
return &KeysClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `keys.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *KeysClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.Keys = append(c.hooks.Keys, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `keys.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *KeysClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.Keys = append(c.inters.Keys, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a Keys entity.
|
|
|
|
|
func (c *KeysClient) Create() *KeysCreate {
|
|
|
|
|
mutation := newKeysMutation(c.config, OpCreate)
|
|
|
|
|
return &KeysCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Keys entities.
|
|
|
|
|
func (c *KeysClient) CreateBulk(builders ...*KeysCreate) *KeysCreateBulk {
|
|
|
|
|
return &KeysCreateBulk{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 *KeysClient) MapCreateBulk(slice any, setFunc func(*KeysCreate, int)) *KeysCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &KeysCreateBulk{err: fmt.Errorf("calling to KeysClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*KeysCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &KeysCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for Keys.
|
|
|
|
|
func (c *KeysClient) Update() *KeysUpdate {
|
|
|
|
|
mutation := newKeysMutation(c.config, OpUpdate)
|
|
|
|
|
return &KeysUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *KeysClient) UpdateOne(_m *Keys) *KeysUpdateOne {
|
|
|
|
|
mutation := newKeysMutation(c.config, OpUpdateOne, withKeys(_m))
|
|
|
|
|
return &KeysUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *KeysClient) UpdateOneID(id string) *KeysUpdateOne {
|
|
|
|
|
mutation := newKeysMutation(c.config, OpUpdateOne, withKeysID(id))
|
|
|
|
|
return &KeysUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for Keys.
|
|
|
|
|
func (c *KeysClient) Delete() *KeysDelete {
|
|
|
|
|
mutation := newKeysMutation(c.config, OpDelete)
|
|
|
|
|
return &KeysDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *KeysClient) DeleteOne(_m *Keys) *KeysDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *KeysClient) DeleteOneID(id string) *KeysDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(keys.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &KeysDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for Keys.
|
|
|
|
|
func (c *KeysClient) Query() *KeysQuery {
|
|
|
|
|
return &KeysQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeKeys},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a Keys entity by its id.
|
|
|
|
|
func (c *KeysClient) Get(ctx context.Context, id string) (*Keys, error) {
|
|
|
|
|
return c.Query().Where(keys.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *KeysClient) GetX(ctx context.Context, id string) *Keys {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *KeysClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.Keys
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *KeysClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.Keys
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *KeysClient) mutate(ctx context.Context, m *KeysMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&KeysCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&KeysUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&KeysUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&KeysDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown Keys mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OAuth2ClientClient is a client for the OAuth2Client schema.
|
|
|
|
|
type OAuth2ClientClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewOAuth2ClientClient returns a client for the OAuth2Client from the given config.
|
|
|
|
|
func NewOAuth2ClientClient(c config) *OAuth2ClientClient {
|
|
|
|
|
return &OAuth2ClientClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `oauth2client.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *OAuth2ClientClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.OAuth2Client = append(c.hooks.OAuth2Client, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `oauth2client.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *OAuth2ClientClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.OAuth2Client = append(c.inters.OAuth2Client, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a OAuth2Client entity.
|
|
|
|
|
func (c *OAuth2ClientClient) Create() *OAuth2ClientCreate {
|
|
|
|
|
mutation := newOAuth2ClientMutation(c.config, OpCreate)
|
|
|
|
|
return &OAuth2ClientCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of OAuth2Client entities.
|
|
|
|
|
func (c *OAuth2ClientClient) CreateBulk(builders ...*OAuth2ClientCreate) *OAuth2ClientCreateBulk {
|
|
|
|
|
return &OAuth2ClientCreateBulk{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 *OAuth2ClientClient) MapCreateBulk(slice any, setFunc func(*OAuth2ClientCreate, int)) *OAuth2ClientCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &OAuth2ClientCreateBulk{err: fmt.Errorf("calling to OAuth2ClientClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*OAuth2ClientCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &OAuth2ClientCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for OAuth2Client.
|
|
|
|
|
func (c *OAuth2ClientClient) Update() *OAuth2ClientUpdate {
|
|
|
|
|
mutation := newOAuth2ClientMutation(c.config, OpUpdate)
|
|
|
|
|
return &OAuth2ClientUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *OAuth2ClientClient) UpdateOne(_m *OAuth2Client) *OAuth2ClientUpdateOne {
|
|
|
|
|
mutation := newOAuth2ClientMutation(c.config, OpUpdateOne, withOAuth2Client(_m))
|
|
|
|
|
return &OAuth2ClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *OAuth2ClientClient) UpdateOneID(id string) *OAuth2ClientUpdateOne {
|
|
|
|
|
mutation := newOAuth2ClientMutation(c.config, OpUpdateOne, withOAuth2ClientID(id))
|
|
|
|
|
return &OAuth2ClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for OAuth2Client.
|
|
|
|
|
func (c *OAuth2ClientClient) Delete() *OAuth2ClientDelete {
|
|
|
|
|
mutation := newOAuth2ClientMutation(c.config, OpDelete)
|
|
|
|
|
return &OAuth2ClientDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *OAuth2ClientClient) DeleteOne(_m *OAuth2Client) *OAuth2ClientDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *OAuth2ClientClient) DeleteOneID(id string) *OAuth2ClientDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(oauth2client.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &OAuth2ClientDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for OAuth2Client.
|
|
|
|
|
func (c *OAuth2ClientClient) Query() *OAuth2ClientQuery {
|
|
|
|
|
return &OAuth2ClientQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeOAuth2Client},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a OAuth2Client entity by its id.
|
|
|
|
|
func (c *OAuth2ClientClient) Get(ctx context.Context, id string) (*OAuth2Client, error) {
|
|
|
|
|
return c.Query().Where(oauth2client.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *OAuth2ClientClient) GetX(ctx context.Context, id string) *OAuth2Client {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *OAuth2ClientClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.OAuth2Client
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *OAuth2ClientClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.OAuth2Client
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *OAuth2ClientClient) mutate(ctx context.Context, m *OAuth2ClientMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&OAuth2ClientCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&OAuth2ClientUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&OAuth2ClientUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&OAuth2ClientDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown OAuth2Client mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// OfflineSessionClient is a client for the OfflineSession schema.
|
|
|
|
|
type OfflineSessionClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewOfflineSessionClient returns a client for the OfflineSession from the given config.
|
|
|
|
|
func NewOfflineSessionClient(c config) *OfflineSessionClient {
|
|
|
|
|
return &OfflineSessionClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `offlinesession.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *OfflineSessionClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.OfflineSession = append(c.hooks.OfflineSession, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `offlinesession.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *OfflineSessionClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.OfflineSession = append(c.inters.OfflineSession, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a OfflineSession entity.
|
|
|
|
|
func (c *OfflineSessionClient) Create() *OfflineSessionCreate {
|
|
|
|
|
mutation := newOfflineSessionMutation(c.config, OpCreate)
|
|
|
|
|
return &OfflineSessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of OfflineSession entities.
|
|
|
|
|
func (c *OfflineSessionClient) CreateBulk(builders ...*OfflineSessionCreate) *OfflineSessionCreateBulk {
|
|
|
|
|
return &OfflineSessionCreateBulk{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 *OfflineSessionClient) MapCreateBulk(slice any, setFunc func(*OfflineSessionCreate, int)) *OfflineSessionCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &OfflineSessionCreateBulk{err: fmt.Errorf("calling to OfflineSessionClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*OfflineSessionCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &OfflineSessionCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for OfflineSession.
|
|
|
|
|
func (c *OfflineSessionClient) Update() *OfflineSessionUpdate {
|
|
|
|
|
mutation := newOfflineSessionMutation(c.config, OpUpdate)
|
|
|
|
|
return &OfflineSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *OfflineSessionClient) UpdateOne(_m *OfflineSession) *OfflineSessionUpdateOne {
|
|
|
|
|
mutation := newOfflineSessionMutation(c.config, OpUpdateOne, withOfflineSession(_m))
|
|
|
|
|
return &OfflineSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *OfflineSessionClient) UpdateOneID(id string) *OfflineSessionUpdateOne {
|
|
|
|
|
mutation := newOfflineSessionMutation(c.config, OpUpdateOne, withOfflineSessionID(id))
|
|
|
|
|
return &OfflineSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for OfflineSession.
|
|
|
|
|
func (c *OfflineSessionClient) Delete() *OfflineSessionDelete {
|
|
|
|
|
mutation := newOfflineSessionMutation(c.config, OpDelete)
|
|
|
|
|
return &OfflineSessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *OfflineSessionClient) DeleteOne(_m *OfflineSession) *OfflineSessionDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *OfflineSessionClient) DeleteOneID(id string) *OfflineSessionDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(offlinesession.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &OfflineSessionDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for OfflineSession.
|
|
|
|
|
func (c *OfflineSessionClient) Query() *OfflineSessionQuery {
|
|
|
|
|
return &OfflineSessionQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeOfflineSession},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a OfflineSession entity by its id.
|
|
|
|
|
func (c *OfflineSessionClient) Get(ctx context.Context, id string) (*OfflineSession, error) {
|
|
|
|
|
return c.Query().Where(offlinesession.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *OfflineSessionClient) GetX(ctx context.Context, id string) *OfflineSession {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *OfflineSessionClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.OfflineSession
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *OfflineSessionClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.OfflineSession
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *OfflineSessionClient) mutate(ctx context.Context, m *OfflineSessionMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&OfflineSessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&OfflineSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&OfflineSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&OfflineSessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown OfflineSession mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PasswordClient is a client for the Password schema.
|
|
|
|
|
type PasswordClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewPasswordClient returns a client for the Password from the given config.
|
|
|
|
|
func NewPasswordClient(c config) *PasswordClient {
|
|
|
|
|
return &PasswordClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `password.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *PasswordClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.Password = append(c.hooks.Password, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `password.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *PasswordClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.Password = append(c.inters.Password, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a Password entity.
|
|
|
|
|
func (c *PasswordClient) Create() *PasswordCreate {
|
|
|
|
|
mutation := newPasswordMutation(c.config, OpCreate)
|
|
|
|
|
return &PasswordCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of Password entities.
|
|
|
|
|
func (c *PasswordClient) CreateBulk(builders ...*PasswordCreate) *PasswordCreateBulk {
|
|
|
|
|
return &PasswordCreateBulk{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 *PasswordClient) MapCreateBulk(slice any, setFunc func(*PasswordCreate, int)) *PasswordCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &PasswordCreateBulk{err: fmt.Errorf("calling to PasswordClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*PasswordCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &PasswordCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for Password.
|
|
|
|
|
func (c *PasswordClient) Update() *PasswordUpdate {
|
|
|
|
|
mutation := newPasswordMutation(c.config, OpUpdate)
|
|
|
|
|
return &PasswordUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *PasswordClient) UpdateOne(_m *Password) *PasswordUpdateOne {
|
|
|
|
|
mutation := newPasswordMutation(c.config, OpUpdateOne, withPassword(_m))
|
|
|
|
|
return &PasswordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *PasswordClient) UpdateOneID(id int) *PasswordUpdateOne {
|
|
|
|
|
mutation := newPasswordMutation(c.config, OpUpdateOne, withPasswordID(id))
|
|
|
|
|
return &PasswordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for Password.
|
|
|
|
|
func (c *PasswordClient) Delete() *PasswordDelete {
|
|
|
|
|
mutation := newPasswordMutation(c.config, OpDelete)
|
|
|
|
|
return &PasswordDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *PasswordClient) DeleteOne(_m *Password) *PasswordDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *PasswordClient) DeleteOneID(id int) *PasswordDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(password.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &PasswordDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for Password.
|
|
|
|
|
func (c *PasswordClient) Query() *PasswordQuery {
|
|
|
|
|
return &PasswordQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypePassword},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a Password entity by its id.
|
|
|
|
|
func (c *PasswordClient) Get(ctx context.Context, id int) (*Password, error) {
|
|
|
|
|
return c.Query().Where(password.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *PasswordClient) GetX(ctx context.Context, id int) *Password {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *PasswordClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.Password
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *PasswordClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.Password
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *PasswordClient) mutate(ctx context.Context, m *PasswordMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&PasswordCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&PasswordUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&PasswordUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&PasswordDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown Password mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RefreshTokenClient is a client for the RefreshToken schema.
|
|
|
|
|
type RefreshTokenClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewRefreshTokenClient returns a client for the RefreshToken from the given config.
|
|
|
|
|
func NewRefreshTokenClient(c config) *RefreshTokenClient {
|
|
|
|
|
return &RefreshTokenClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `refreshtoken.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *RefreshTokenClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.RefreshToken = append(c.hooks.RefreshToken, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `refreshtoken.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *RefreshTokenClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.RefreshToken = append(c.inters.RefreshToken, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a RefreshToken entity.
|
|
|
|
|
func (c *RefreshTokenClient) Create() *RefreshTokenCreate {
|
|
|
|
|
mutation := newRefreshTokenMutation(c.config, OpCreate)
|
|
|
|
|
return &RefreshTokenCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of RefreshToken entities.
|
|
|
|
|
func (c *RefreshTokenClient) CreateBulk(builders ...*RefreshTokenCreate) *RefreshTokenCreateBulk {
|
|
|
|
|
return &RefreshTokenCreateBulk{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 *RefreshTokenClient) MapCreateBulk(slice any, setFunc func(*RefreshTokenCreate, int)) *RefreshTokenCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &RefreshTokenCreateBulk{err: fmt.Errorf("calling to RefreshTokenClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*RefreshTokenCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &RefreshTokenCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for RefreshToken.
|
|
|
|
|
func (c *RefreshTokenClient) Update() *RefreshTokenUpdate {
|
|
|
|
|
mutation := newRefreshTokenMutation(c.config, OpUpdate)
|
|
|
|
|
return &RefreshTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *RefreshTokenClient) UpdateOne(_m *RefreshToken) *RefreshTokenUpdateOne {
|
|
|
|
|
mutation := newRefreshTokenMutation(c.config, OpUpdateOne, withRefreshToken(_m))
|
|
|
|
|
return &RefreshTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *RefreshTokenClient) UpdateOneID(id string) *RefreshTokenUpdateOne {
|
|
|
|
|
mutation := newRefreshTokenMutation(c.config, OpUpdateOne, withRefreshTokenID(id))
|
|
|
|
|
return &RefreshTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for RefreshToken.
|
|
|
|
|
func (c *RefreshTokenClient) Delete() *RefreshTokenDelete {
|
|
|
|
|
mutation := newRefreshTokenMutation(c.config, OpDelete)
|
|
|
|
|
return &RefreshTokenDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *RefreshTokenClient) DeleteOne(_m *RefreshToken) *RefreshTokenDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *RefreshTokenClient) DeleteOneID(id string) *RefreshTokenDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(refreshtoken.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &RefreshTokenDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for RefreshToken.
|
|
|
|
|
func (c *RefreshTokenClient) Query() *RefreshTokenQuery {
|
|
|
|
|
return &RefreshTokenQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeRefreshToken},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a RefreshToken entity by its id.
|
|
|
|
|
func (c *RefreshTokenClient) Get(ctx context.Context, id string) (*RefreshToken, error) {
|
|
|
|
|
return c.Query().Where(refreshtoken.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *RefreshTokenClient) GetX(ctx context.Context, id string) *RefreshToken {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *RefreshTokenClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.RefreshToken
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *RefreshTokenClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.RefreshToken
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *RefreshTokenClient) mutate(ctx context.Context, m *RefreshTokenMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&RefreshTokenCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&RefreshTokenUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&RefreshTokenUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&RefreshTokenDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown RefreshToken mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UserIdentityClient is a client for the UserIdentity schema.
|
|
|
|
|
type UserIdentityClient struct {
|
|
|
|
|
config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewUserIdentityClient returns a client for the UserIdentity from the given config.
|
|
|
|
|
func NewUserIdentityClient(c config) *UserIdentityClient {
|
|
|
|
|
return &UserIdentityClient{config: c}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Use adds a list of mutation hooks to the hooks stack.
|
|
|
|
|
// A call to `Use(f, g, h)` equals to `useridentity.Hooks(f(g(h())))`.
|
|
|
|
|
func (c *UserIdentityClient) Use(hooks ...Hook) {
|
|
|
|
|
c.hooks.UserIdentity = append(c.hooks.UserIdentity, hooks...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
|
|
|
|
// A call to `Intercept(f, g, h)` equals to `useridentity.Intercept(f(g(h())))`.
|
|
|
|
|
func (c *UserIdentityClient) Intercept(interceptors ...Interceptor) {
|
|
|
|
|
c.inters.UserIdentity = append(c.inters.UserIdentity, interceptors...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create returns a builder for creating a UserIdentity entity.
|
|
|
|
|
func (c *UserIdentityClient) Create() *UserIdentityCreate {
|
|
|
|
|
mutation := newUserIdentityMutation(c.config, OpCreate)
|
|
|
|
|
return &UserIdentityCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateBulk returns a builder for creating a bulk of UserIdentity entities.
|
|
|
|
|
func (c *UserIdentityClient) CreateBulk(builders ...*UserIdentityCreate) *UserIdentityCreateBulk {
|
|
|
|
|
return &UserIdentityCreateBulk{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 *UserIdentityClient) MapCreateBulk(slice any, setFunc func(*UserIdentityCreate, int)) *UserIdentityCreateBulk {
|
|
|
|
|
rv := reflect.ValueOf(slice)
|
|
|
|
|
if rv.Kind() != reflect.Slice {
|
|
|
|
|
return &UserIdentityCreateBulk{err: fmt.Errorf("calling to UserIdentityClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
|
|
|
|
}
|
|
|
|
|
builders := make([]*UserIdentityCreate, rv.Len())
|
|
|
|
|
for i := 0; i < rv.Len(); i++ {
|
|
|
|
|
builders[i] = c.Create()
|
|
|
|
|
setFunc(builders[i], i)
|
|
|
|
|
}
|
|
|
|
|
return &UserIdentityCreateBulk{config: c.config, builders: builders}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update returns an update builder for UserIdentity.
|
|
|
|
|
func (c *UserIdentityClient) Update() *UserIdentityUpdate {
|
|
|
|
|
mutation := newUserIdentityMutation(c.config, OpUpdate)
|
|
|
|
|
return &UserIdentityUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOne returns an update builder for the given entity.
|
|
|
|
|
func (c *UserIdentityClient) UpdateOne(_m *UserIdentity) *UserIdentityUpdateOne {
|
|
|
|
|
mutation := newUserIdentityMutation(c.config, OpUpdateOne, withUserIdentity(_m))
|
|
|
|
|
return &UserIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateOneID returns an update builder for the given id.
|
|
|
|
|
func (c *UserIdentityClient) UpdateOneID(id string) *UserIdentityUpdateOne {
|
|
|
|
|
mutation := newUserIdentityMutation(c.config, OpUpdateOne, withUserIdentityID(id))
|
|
|
|
|
return &UserIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Delete returns a delete builder for UserIdentity.
|
|
|
|
|
func (c *UserIdentityClient) Delete() *UserIdentityDelete {
|
|
|
|
|
mutation := newUserIdentityMutation(c.config, OpDelete)
|
|
|
|
|
return &UserIdentityDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOne returns a builder for deleting the given entity.
|
|
|
|
|
func (c *UserIdentityClient) DeleteOne(_m *UserIdentity) *UserIdentityDeleteOne {
|
|
|
|
|
return c.DeleteOneID(_m.ID)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
|
|
|
|
func (c *UserIdentityClient) DeleteOneID(id string) *UserIdentityDeleteOne {
|
|
|
|
|
builder := c.Delete().Where(useridentity.ID(id))
|
|
|
|
|
builder.mutation.id = &id
|
|
|
|
|
builder.mutation.op = OpDeleteOne
|
|
|
|
|
return &UserIdentityDeleteOne{builder}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Query returns a query builder for UserIdentity.
|
|
|
|
|
func (c *UserIdentityClient) Query() *UserIdentityQuery {
|
|
|
|
|
return &UserIdentityQuery{
|
|
|
|
|
config: c.config,
|
|
|
|
|
ctx: &QueryContext{Type: TypeUserIdentity},
|
|
|
|
|
inters: c.Interceptors(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get returns a UserIdentity entity by its id.
|
|
|
|
|
func (c *UserIdentityClient) Get(ctx context.Context, id string) (*UserIdentity, error) {
|
|
|
|
|
return c.Query().Where(useridentity.ID(id)).Only(ctx)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetX is like Get, but panics if an error occurs.
|
|
|
|
|
func (c *UserIdentityClient) GetX(ctx context.Context, id string) *UserIdentity {
|
|
|
|
|
obj, err := c.Get(ctx, id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
return obj
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hooks returns the client hooks.
|
|
|
|
|
func (c *UserIdentityClient) Hooks() []Hook {
|
|
|
|
|
return c.hooks.UserIdentity
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Interceptors returns the client interceptors.
|
|
|
|
|
func (c *UserIdentityClient) Interceptors() []Interceptor {
|
|
|
|
|
return c.inters.UserIdentity
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *UserIdentityClient) mutate(ctx context.Context, m *UserIdentityMutation) (Value, error) {
|
|
|
|
|
switch m.Op() {
|
|
|
|
|
case OpCreate:
|
|
|
|
|
return (&UserIdentityCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdate:
|
|
|
|
|
return (&UserIdentityUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpUpdateOne:
|
|
|
|
|
return (&UserIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
|
|
|
|
case OpDelete, OpDeleteOne:
|
|
|
|
|
return (&UserIdentityDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
|
|
|
|
default:
|
|
|
|
|
return nil, fmt.Errorf("db: unknown UserIdentity mutation op: %q", m.Op())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// hooks and interceptors per client, for fast access.
|
|
|
|
|
type (
|
|
|
|
|
hooks struct {
|
|
|
|
|
AuthCode, AuthRequest, AuthSession, Connector, DeviceRequest, DeviceToken, Keys,
|
|
|
|
|
OAuth2Client, OfflineSession, Password, RefreshToken, UserIdentity []ent.Hook
|
|
|
|
|
}
|
|
|
|
|
inters struct {
|
|
|
|
|
AuthCode, AuthRequest, AuthSession, Connector, DeviceRequest, DeviceToken, Keys,
|
|
|
|
|
OAuth2Client, OfflineSession, Password, RefreshToken,
|
|
|
|
|
UserIdentity []ent.Interceptor
|
|
|
|
|
}
|
|
|
|
|
)
|