12
This commit is contained in:
517
internal/ent/client.go
Normal file
517
internal/ent/client.go
Normal file
@ -0,0 +1,517 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"unR2/internal/ent/migrate"
|
||||
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// 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
|
||||
// CloudflareAccounts is the client for interacting with the CloudflareAccounts builders.
|
||||
CloudflareAccounts *CloudflareAccountsClient
|
||||
// CloudflareR2 is the client for interacting with the CloudflareR2 builders.
|
||||
CloudflareR2 *CloudflareR2Client
|
||||
}
|
||||
|
||||
// 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.CloudflareAccounts = NewCloudflareAccountsClient(c.config)
|
||||
c.CloudflareR2 = NewCloudflareR2Client(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("ent: 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("ent: starting a transaction: %w", err)
|
||||
}
|
||||
cfg := c.config
|
||||
cfg.driver = tx
|
||||
return &Tx{
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
CloudflareAccounts: NewCloudflareAccountsClient(cfg),
|
||||
CloudflareR2: NewCloudflareR2Client(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,
|
||||
CloudflareAccounts: NewCloudflareAccountsClient(cfg),
|
||||
CloudflareR2: NewCloudflareR2Client(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
||||
//
|
||||
// client.Debug().
|
||||
// CloudflareAccounts.
|
||||
// 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) {
|
||||
c.CloudflareAccounts.Use(hooks...)
|
||||
c.CloudflareR2.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) {
|
||||
c.CloudflareAccounts.Intercept(interceptors...)
|
||||
c.CloudflareR2.Intercept(interceptors...)
|
||||
}
|
||||
|
||||
// Mutate implements the ent.Mutator interface.
|
||||
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
switch m := m.(type) {
|
||||
case *CloudflareAccountsMutation:
|
||||
return c.CloudflareAccounts.mutate(ctx, m)
|
||||
case *CloudflareR2Mutation:
|
||||
return c.CloudflareR2.mutate(ctx, m)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
|
||||
}
|
||||
}
|
||||
|
||||
// CloudflareAccountsClient is a client for the CloudflareAccounts schema.
|
||||
type CloudflareAccountsClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewCloudflareAccountsClient returns a client for the CloudflareAccounts from the given config.
|
||||
func NewCloudflareAccountsClient(c config) *CloudflareAccountsClient {
|
||||
return &CloudflareAccountsClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `cloudflareaccounts.Hooks(f(g(h())))`.
|
||||
func (c *CloudflareAccountsClient) Use(hooks ...Hook) {
|
||||
c.hooks.CloudflareAccounts = append(c.hooks.CloudflareAccounts, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `cloudflareaccounts.Intercept(f(g(h())))`.
|
||||
func (c *CloudflareAccountsClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.CloudflareAccounts = append(c.inters.CloudflareAccounts, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a CloudflareAccounts entity.
|
||||
func (c *CloudflareAccountsClient) Create() *CloudflareAccountsCreate {
|
||||
mutation := newCloudflareAccountsMutation(c.config, OpCreate)
|
||||
return &CloudflareAccountsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of CloudflareAccounts entities.
|
||||
func (c *CloudflareAccountsClient) CreateBulk(builders ...*CloudflareAccountsCreate) *CloudflareAccountsCreateBulk {
|
||||
return &CloudflareAccountsCreateBulk{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 *CloudflareAccountsClient) MapCreateBulk(slice any, setFunc func(*CloudflareAccountsCreate, int)) *CloudflareAccountsCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &CloudflareAccountsCreateBulk{err: fmt.Errorf("calling to CloudflareAccountsClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*CloudflareAccountsCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &CloudflareAccountsCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for CloudflareAccounts.
|
||||
func (c *CloudflareAccountsClient) Update() *CloudflareAccountsUpdate {
|
||||
mutation := newCloudflareAccountsMutation(c.config, OpUpdate)
|
||||
return &CloudflareAccountsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *CloudflareAccountsClient) UpdateOne(ca *CloudflareAccounts) *CloudflareAccountsUpdateOne {
|
||||
mutation := newCloudflareAccountsMutation(c.config, OpUpdateOne, withCloudflareAccounts(ca))
|
||||
return &CloudflareAccountsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *CloudflareAccountsClient) UpdateOneID(id int) *CloudflareAccountsUpdateOne {
|
||||
mutation := newCloudflareAccountsMutation(c.config, OpUpdateOne, withCloudflareAccountsID(id))
|
||||
return &CloudflareAccountsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for CloudflareAccounts.
|
||||
func (c *CloudflareAccountsClient) Delete() *CloudflareAccountsDelete {
|
||||
mutation := newCloudflareAccountsMutation(c.config, OpDelete)
|
||||
return &CloudflareAccountsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *CloudflareAccountsClient) DeleteOne(ca *CloudflareAccounts) *CloudflareAccountsDeleteOne {
|
||||
return c.DeleteOneID(ca.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *CloudflareAccountsClient) DeleteOneID(id int) *CloudflareAccountsDeleteOne {
|
||||
builder := c.Delete().Where(cloudflareaccounts.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &CloudflareAccountsDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for CloudflareAccounts.
|
||||
func (c *CloudflareAccountsClient) Query() *CloudflareAccountsQuery {
|
||||
return &CloudflareAccountsQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeCloudflareAccounts},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a CloudflareAccounts entity by its id.
|
||||
func (c *CloudflareAccountsClient) Get(ctx context.Context, id int) (*CloudflareAccounts, error) {
|
||||
return c.Query().Where(cloudflareaccounts.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *CloudflareAccountsClient) GetX(ctx context.Context, id int) *CloudflareAccounts {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryCloudflareBuckets queries the cloudflare_buckets edge of a CloudflareAccounts.
|
||||
func (c *CloudflareAccountsClient) QueryCloudflareBuckets(ca *CloudflareAccounts) *CloudflareR2Query {
|
||||
query := (&CloudflareR2Client{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := ca.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(cloudflareaccounts.Table, cloudflareaccounts.FieldID, id),
|
||||
sqlgraph.To(cloudflarer2.Table, cloudflarer2.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, cloudflareaccounts.CloudflareBucketsTable, cloudflareaccounts.CloudflareBucketsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(ca.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *CloudflareAccountsClient) Hooks() []Hook {
|
||||
return c.hooks.CloudflareAccounts
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *CloudflareAccountsClient) Interceptors() []Interceptor {
|
||||
return c.inters.CloudflareAccounts
|
||||
}
|
||||
|
||||
func (c *CloudflareAccountsClient) mutate(ctx context.Context, m *CloudflareAccountsMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&CloudflareAccountsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&CloudflareAccountsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&CloudflareAccountsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&CloudflareAccountsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown CloudflareAccounts mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// CloudflareR2Client is a client for the CloudflareR2 schema.
|
||||
type CloudflareR2Client struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewCloudflareR2Client returns a client for the CloudflareR2 from the given config.
|
||||
func NewCloudflareR2Client(c config) *CloudflareR2Client {
|
||||
return &CloudflareR2Client{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `cloudflarer2.Hooks(f(g(h())))`.
|
||||
func (c *CloudflareR2Client) Use(hooks ...Hook) {
|
||||
c.hooks.CloudflareR2 = append(c.hooks.CloudflareR2, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `cloudflarer2.Intercept(f(g(h())))`.
|
||||
func (c *CloudflareR2Client) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.CloudflareR2 = append(c.inters.CloudflareR2, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a CloudflareR2 entity.
|
||||
func (c *CloudflareR2Client) Create() *CloudflareR2Create {
|
||||
mutation := newCloudflareR2Mutation(c.config, OpCreate)
|
||||
return &CloudflareR2Create{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of CloudflareR2 entities.
|
||||
func (c *CloudflareR2Client) CreateBulk(builders ...*CloudflareR2Create) *CloudflareR2CreateBulk {
|
||||
return &CloudflareR2CreateBulk{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 *CloudflareR2Client) MapCreateBulk(slice any, setFunc func(*CloudflareR2Create, int)) *CloudflareR2CreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &CloudflareR2CreateBulk{err: fmt.Errorf("calling to CloudflareR2Client.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*CloudflareR2Create, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &CloudflareR2CreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for CloudflareR2.
|
||||
func (c *CloudflareR2Client) Update() *CloudflareR2Update {
|
||||
mutation := newCloudflareR2Mutation(c.config, OpUpdate)
|
||||
return &CloudflareR2Update{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *CloudflareR2Client) UpdateOne(cl *CloudflareR2) *CloudflareR2UpdateOne {
|
||||
mutation := newCloudflareR2Mutation(c.config, OpUpdateOne, withCloudflareR2(cl))
|
||||
return &CloudflareR2UpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *CloudflareR2Client) UpdateOneID(id int) *CloudflareR2UpdateOne {
|
||||
mutation := newCloudflareR2Mutation(c.config, OpUpdateOne, withCloudflareR2ID(id))
|
||||
return &CloudflareR2UpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for CloudflareR2.
|
||||
func (c *CloudflareR2Client) Delete() *CloudflareR2Delete {
|
||||
mutation := newCloudflareR2Mutation(c.config, OpDelete)
|
||||
return &CloudflareR2Delete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *CloudflareR2Client) DeleteOne(cl *CloudflareR2) *CloudflareR2DeleteOne {
|
||||
return c.DeleteOneID(cl.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *CloudflareR2Client) DeleteOneID(id int) *CloudflareR2DeleteOne {
|
||||
builder := c.Delete().Where(cloudflarer2.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &CloudflareR2DeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for CloudflareR2.
|
||||
func (c *CloudflareR2Client) Query() *CloudflareR2Query {
|
||||
return &CloudflareR2Query{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeCloudflareR2},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a CloudflareR2 entity by its id.
|
||||
func (c *CloudflareR2Client) Get(ctx context.Context, id int) (*CloudflareR2, error) {
|
||||
return c.Query().Where(cloudflarer2.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *CloudflareR2Client) GetX(ctx context.Context, id int) *CloudflareR2 {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryCloudflareAccount queries the cloudflare_account edge of a CloudflareR2.
|
||||
func (c *CloudflareR2Client) QueryCloudflareAccount(cl *CloudflareR2) *CloudflareAccountsQuery {
|
||||
query := (&CloudflareAccountsClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := cl.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(cloudflarer2.Table, cloudflarer2.FieldID, id),
|
||||
sqlgraph.To(cloudflareaccounts.Table, cloudflareaccounts.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, cloudflarer2.CloudflareAccountTable, cloudflarer2.CloudflareAccountColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(cl.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *CloudflareR2Client) Hooks() []Hook {
|
||||
return c.hooks.CloudflareR2
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *CloudflareR2Client) Interceptors() []Interceptor {
|
||||
return c.inters.CloudflareR2
|
||||
}
|
||||
|
||||
func (c *CloudflareR2Client) mutate(ctx context.Context, m *CloudflareR2Mutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&CloudflareR2Create{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&CloudflareR2Update{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&CloudflareR2UpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&CloudflareR2Delete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown CloudflareR2 mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
CloudflareAccounts, CloudflareR2 []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
CloudflareAccounts, CloudflareR2 []ent.Interceptor
|
||||
}
|
||||
)
|
||||
208
internal/ent/cloudflareaccounts.go
Normal file
208
internal/ent/cloudflareaccounts.go
Normal file
@ -0,0 +1,208 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// CloudflareAccounts is the model entity for the CloudflareAccounts schema.
|
||||
type CloudflareAccounts struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// 账户名称
|
||||
Name string `json:"name,omitempty"`
|
||||
// Cloudflare Account ID
|
||||
AccountID string `json:"account_id,omitempty"`
|
||||
// Cloudflare API Token
|
||||
APIToken string `json:"-"`
|
||||
// Cloudflare 邮箱(可选)
|
||||
Email string `json:"email,omitempty"`
|
||||
// 状态 1=启用, 0=禁用
|
||||
Status int8 `json:"status,omitempty"`
|
||||
// 备注
|
||||
Remark string `json:"remark,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the CloudflareAccountsQuery when eager-loading is set.
|
||||
Edges CloudflareAccountsEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// CloudflareAccountsEdges holds the relations/edges for other nodes in the graph.
|
||||
type CloudflareAccountsEdges struct {
|
||||
// CloudflareBuckets holds the value of the cloudflare_buckets edge.
|
||||
CloudflareBuckets []*CloudflareR2 `json:"cloudflare_buckets,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// CloudflareBucketsOrErr returns the CloudflareBuckets value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e CloudflareAccountsEdges) CloudflareBucketsOrErr() ([]*CloudflareR2, error) {
|
||||
if e.loadedTypes[0] {
|
||||
return e.CloudflareBuckets, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "cloudflare_buckets"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*CloudflareAccounts) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case cloudflareaccounts.FieldID, cloudflareaccounts.FieldStatus:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case cloudflareaccounts.FieldName, cloudflareaccounts.FieldAccountID, cloudflareaccounts.FieldAPIToken, cloudflareaccounts.FieldEmail, cloudflareaccounts.FieldRemark:
|
||||
values[i] = new(sql.NullString)
|
||||
case cloudflareaccounts.FieldCreatedAt, cloudflareaccounts.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the CloudflareAccounts fields.
|
||||
func (ca *CloudflareAccounts) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case cloudflareaccounts.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
ca.ID = int(value.Int64)
|
||||
case cloudflareaccounts.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
ca.Name = value.String
|
||||
}
|
||||
case cloudflareaccounts.FieldAccountID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field account_id", values[i])
|
||||
} else if value.Valid {
|
||||
ca.AccountID = value.String
|
||||
}
|
||||
case cloudflareaccounts.FieldAPIToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field api_token", values[i])
|
||||
} else if value.Valid {
|
||||
ca.APIToken = value.String
|
||||
}
|
||||
case cloudflareaccounts.FieldEmail:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field email", values[i])
|
||||
} else if value.Valid {
|
||||
ca.Email = value.String
|
||||
}
|
||||
case cloudflareaccounts.FieldStatus:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field status", values[i])
|
||||
} else if value.Valid {
|
||||
ca.Status = int8(value.Int64)
|
||||
}
|
||||
case cloudflareaccounts.FieldRemark:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field remark", values[i])
|
||||
} else if value.Valid {
|
||||
ca.Remark = value.String
|
||||
}
|
||||
case cloudflareaccounts.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
ca.CreatedAt = value.Time
|
||||
}
|
||||
case cloudflareaccounts.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
ca.UpdatedAt = value.Time
|
||||
}
|
||||
default:
|
||||
ca.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the CloudflareAccounts.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (ca *CloudflareAccounts) Value(name string) (ent.Value, error) {
|
||||
return ca.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryCloudflareBuckets queries the "cloudflare_buckets" edge of the CloudflareAccounts entity.
|
||||
func (ca *CloudflareAccounts) QueryCloudflareBuckets() *CloudflareR2Query {
|
||||
return NewCloudflareAccountsClient(ca.config).QueryCloudflareBuckets(ca)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this CloudflareAccounts.
|
||||
// Note that you need to call CloudflareAccounts.Unwrap() before calling this method if this CloudflareAccounts
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (ca *CloudflareAccounts) Update() *CloudflareAccountsUpdateOne {
|
||||
return NewCloudflareAccountsClient(ca.config).UpdateOne(ca)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the CloudflareAccounts 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 (ca *CloudflareAccounts) Unwrap() *CloudflareAccounts {
|
||||
_tx, ok := ca.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: CloudflareAccounts is not a transactional entity")
|
||||
}
|
||||
ca.config.driver = _tx.drv
|
||||
return ca
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (ca *CloudflareAccounts) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("CloudflareAccounts(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", ca.ID))
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(ca.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("account_id=")
|
||||
builder.WriteString(ca.AccountID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("api_token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("email=")
|
||||
builder.WriteString(ca.Email)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("status=")
|
||||
builder.WriteString(fmt.Sprintf("%v", ca.Status))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("remark=")
|
||||
builder.WriteString(ca.Remark)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(ca.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(ca.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// CloudflareAccountsSlice is a parsable slice of CloudflareAccounts.
|
||||
type CloudflareAccountsSlice []*CloudflareAccounts
|
||||
151
internal/ent/cloudflareaccounts/cloudflareaccounts.go
Normal file
151
internal/ent/cloudflareaccounts/cloudflareaccounts.go
Normal file
@ -0,0 +1,151 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package cloudflareaccounts
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the cloudflareaccounts type in the database.
|
||||
Label = "cloudflare_accounts"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldAccountID holds the string denoting the account_id field in the database.
|
||||
FieldAccountID = "account_id"
|
||||
// FieldAPIToken holds the string denoting the api_token field in the database.
|
||||
FieldAPIToken = "api_token"
|
||||
// FieldEmail holds the string denoting the email field in the database.
|
||||
FieldEmail = "email"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// FieldRemark holds the string denoting the remark field in the database.
|
||||
FieldRemark = "remark"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// EdgeCloudflareBuckets holds the string denoting the cloudflare_buckets edge name in mutations.
|
||||
EdgeCloudflareBuckets = "cloudflare_buckets"
|
||||
// Table holds the table name of the cloudflareaccounts in the database.
|
||||
Table = "cloudflare_accounts"
|
||||
// CloudflareBucketsTable is the table that holds the cloudflare_buckets relation/edge.
|
||||
CloudflareBucketsTable = "cloudflare_r2s"
|
||||
// CloudflareBucketsInverseTable is the table name for the CloudflareR2 entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "cloudflarer2" package.
|
||||
CloudflareBucketsInverseTable = "cloudflare_r2s"
|
||||
// CloudflareBucketsColumn is the table column denoting the cloudflare_buckets relation/edge.
|
||||
CloudflareBucketsColumn = "cloudflare_accounts_cloudflare_buckets"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for cloudflareaccounts fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldName,
|
||||
FieldAccountID,
|
||||
FieldAPIToken,
|
||||
FieldEmail,
|
||||
FieldStatus,
|
||||
FieldRemark,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
NameValidator func(string) error
|
||||
// AccountIDValidator is a validator for the "account_id" field. It is called by the builders before save.
|
||||
AccountIDValidator func(string) error
|
||||
// DefaultStatus holds the default value on creation for the "status" field.
|
||||
DefaultStatus int8
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the CloudflareAccounts queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAccountID orders the results by the account_id field.
|
||||
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAPIToken orders the results by the api_token field.
|
||||
func ByAPIToken(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAPIToken, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEmail orders the results by the email field.
|
||||
func ByEmail(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEmail, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStatus orders the results by the status field.
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRemark orders the results by the remark field.
|
||||
func ByRemark(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRemark, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCloudflareBucketsCount orders the results by cloudflare_buckets count.
|
||||
func ByCloudflareBucketsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newCloudflareBucketsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// ByCloudflareBuckets orders the results by cloudflare_buckets terms.
|
||||
func ByCloudflareBuckets(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newCloudflareBucketsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newCloudflareBucketsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(CloudflareBucketsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, CloudflareBucketsTable, CloudflareBucketsColumn),
|
||||
)
|
||||
}
|
||||
599
internal/ent/cloudflareaccounts/where.go
Normal file
599
internal/ent/cloudflareaccounts/where.go
Normal file
@ -0,0 +1,599 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package cloudflareaccounts
|
||||
|
||||
import (
|
||||
"time"
|
||||
"unR2/internal/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ.
|
||||
func AccountID(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// APIToken applies equality check predicate on the "api_token" field. It's identical to APITokenEQ.
|
||||
func APIToken(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// Email applies equality check predicate on the "email" field. It's identical to EmailEQ.
|
||||
func Email(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldEmail, v))
|
||||
}
|
||||
|
||||
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
|
||||
func Status(v int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldStatus, v))
|
||||
}
|
||||
|
||||
// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ.
|
||||
func Remark(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldRemark, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(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.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// AccountIDEQ applies the EQ predicate on the "account_id" field.
|
||||
func AccountIDEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDNEQ applies the NEQ predicate on the "account_id" field.
|
||||
func AccountIDNEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDIn applies the In predicate on the "account_id" field.
|
||||
func AccountIDIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldAccountID, vs...))
|
||||
}
|
||||
|
||||
// AccountIDNotIn applies the NotIn predicate on the "account_id" field.
|
||||
func AccountIDNotIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldAccountID, vs...))
|
||||
}
|
||||
|
||||
// AccountIDGT applies the GT predicate on the "account_id" field.
|
||||
func AccountIDGT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDGTE applies the GTE predicate on the "account_id" field.
|
||||
func AccountIDGTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDLT applies the LT predicate on the "account_id" field.
|
||||
func AccountIDLT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDLTE applies the LTE predicate on the "account_id" field.
|
||||
func AccountIDLTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDContains applies the Contains predicate on the "account_id" field.
|
||||
func AccountIDContains(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContains(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDHasPrefix applies the HasPrefix predicate on the "account_id" field.
|
||||
func AccountIDHasPrefix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasPrefix(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDHasSuffix applies the HasSuffix predicate on the "account_id" field.
|
||||
func AccountIDHasSuffix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasSuffix(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDEqualFold applies the EqualFold predicate on the "account_id" field.
|
||||
func AccountIDEqualFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEqualFold(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// AccountIDContainsFold applies the ContainsFold predicate on the "account_id" field.
|
||||
func AccountIDContainsFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContainsFold(FieldAccountID, v))
|
||||
}
|
||||
|
||||
// APITokenEQ applies the EQ predicate on the "api_token" field.
|
||||
func APITokenEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenNEQ applies the NEQ predicate on the "api_token" field.
|
||||
func APITokenNEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenIn applies the In predicate on the "api_token" field.
|
||||
func APITokenIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldAPIToken, vs...))
|
||||
}
|
||||
|
||||
// APITokenNotIn applies the NotIn predicate on the "api_token" field.
|
||||
func APITokenNotIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldAPIToken, vs...))
|
||||
}
|
||||
|
||||
// APITokenGT applies the GT predicate on the "api_token" field.
|
||||
func APITokenGT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenGTE applies the GTE predicate on the "api_token" field.
|
||||
func APITokenGTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenLT applies the LT predicate on the "api_token" field.
|
||||
func APITokenLT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenLTE applies the LTE predicate on the "api_token" field.
|
||||
func APITokenLTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenContains applies the Contains predicate on the "api_token" field.
|
||||
func APITokenContains(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContains(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenHasPrefix applies the HasPrefix predicate on the "api_token" field.
|
||||
func APITokenHasPrefix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasPrefix(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenHasSuffix applies the HasSuffix predicate on the "api_token" field.
|
||||
func APITokenHasSuffix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasSuffix(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenEqualFold applies the EqualFold predicate on the "api_token" field.
|
||||
func APITokenEqualFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEqualFold(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// APITokenContainsFold applies the ContainsFold predicate on the "api_token" field.
|
||||
func APITokenContainsFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContainsFold(FieldAPIToken, v))
|
||||
}
|
||||
|
||||
// EmailEQ applies the EQ predicate on the "email" field.
|
||||
func EmailEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailNEQ applies the NEQ predicate on the "email" field.
|
||||
func EmailNEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailIn applies the In predicate on the "email" field.
|
||||
func EmailIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldEmail, vs...))
|
||||
}
|
||||
|
||||
// EmailNotIn applies the NotIn predicate on the "email" field.
|
||||
func EmailNotIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldEmail, vs...))
|
||||
}
|
||||
|
||||
// EmailGT applies the GT predicate on the "email" field.
|
||||
func EmailGT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailGTE applies the GTE predicate on the "email" field.
|
||||
func EmailGTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailLT applies the LT predicate on the "email" field.
|
||||
func EmailLT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailLTE applies the LTE predicate on the "email" field.
|
||||
func EmailLTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailContains applies the Contains predicate on the "email" field.
|
||||
func EmailContains(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContains(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailHasPrefix applies the HasPrefix predicate on the "email" field.
|
||||
func EmailHasPrefix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasPrefix(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailHasSuffix applies the HasSuffix predicate on the "email" field.
|
||||
func EmailHasSuffix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasSuffix(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailIsNil applies the IsNil predicate on the "email" field.
|
||||
func EmailIsNil() predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIsNull(FieldEmail))
|
||||
}
|
||||
|
||||
// EmailNotNil applies the NotNil predicate on the "email" field.
|
||||
func EmailNotNil() predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotNull(FieldEmail))
|
||||
}
|
||||
|
||||
// EmailEqualFold applies the EqualFold predicate on the "email" field.
|
||||
func EmailEqualFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEqualFold(FieldEmail, v))
|
||||
}
|
||||
|
||||
// EmailContainsFold applies the ContainsFold predicate on the "email" field.
|
||||
func EmailContainsFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContainsFold(FieldEmail, v))
|
||||
}
|
||||
|
||||
// StatusEQ applies the EQ predicate on the "status" field.
|
||||
func StatusEQ(v int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusNEQ applies the NEQ predicate on the "status" field.
|
||||
func StatusNEQ(v int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusIn applies the In predicate on the "status" field.
|
||||
func StatusIn(vs ...int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldStatus, vs...))
|
||||
}
|
||||
|
||||
// StatusNotIn applies the NotIn predicate on the "status" field.
|
||||
func StatusNotIn(vs ...int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldStatus, vs...))
|
||||
}
|
||||
|
||||
// StatusGT applies the GT predicate on the "status" field.
|
||||
func StatusGT(v int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusGTE applies the GTE predicate on the "status" field.
|
||||
func StatusGTE(v int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusLT applies the LT predicate on the "status" field.
|
||||
func StatusLT(v int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusLTE applies the LTE predicate on the "status" field.
|
||||
func StatusLTE(v int8) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldStatus, v))
|
||||
}
|
||||
|
||||
// RemarkEQ applies the EQ predicate on the "remark" field.
|
||||
func RemarkEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkNEQ applies the NEQ predicate on the "remark" field.
|
||||
func RemarkNEQ(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkIn applies the In predicate on the "remark" field.
|
||||
func RemarkIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldRemark, vs...))
|
||||
}
|
||||
|
||||
// RemarkNotIn applies the NotIn predicate on the "remark" field.
|
||||
func RemarkNotIn(vs ...string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldRemark, vs...))
|
||||
}
|
||||
|
||||
// RemarkGT applies the GT predicate on the "remark" field.
|
||||
func RemarkGT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkGTE applies the GTE predicate on the "remark" field.
|
||||
func RemarkGTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkLT applies the LT predicate on the "remark" field.
|
||||
func RemarkLT(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkLTE applies the LTE predicate on the "remark" field.
|
||||
func RemarkLTE(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkContains applies the Contains predicate on the "remark" field.
|
||||
func RemarkContains(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContains(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field.
|
||||
func RemarkHasPrefix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasPrefix(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field.
|
||||
func RemarkHasSuffix(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldHasSuffix(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkIsNil applies the IsNil predicate on the "remark" field.
|
||||
func RemarkIsNil() predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIsNull(FieldRemark))
|
||||
}
|
||||
|
||||
// RemarkNotNil applies the NotNil predicate on the "remark" field.
|
||||
func RemarkNotNil() predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotNull(FieldRemark))
|
||||
}
|
||||
|
||||
// RemarkEqualFold applies the EqualFold predicate on the "remark" field.
|
||||
func RemarkEqualFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEqualFold(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkContainsFold applies the ContainsFold predicate on the "remark" field.
|
||||
func RemarkContainsFold(v string) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldContainsFold(FieldRemark, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// HasCloudflareBuckets applies the HasEdge predicate on the "cloudflare_buckets" edge.
|
||||
func HasCloudflareBuckets() predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, CloudflareBucketsTable, CloudflareBucketsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasCloudflareBucketsWith applies the HasEdge predicate on the "cloudflare_buckets" edge with a given conditions (other predicates).
|
||||
func HasCloudflareBucketsWith(preds ...predicate.CloudflareR2) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(func(s *sql.Selector) {
|
||||
step := newCloudflareBucketsStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.CloudflareAccounts) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.CloudflareAccounts) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.CloudflareAccounts) predicate.CloudflareAccounts {
|
||||
return predicate.CloudflareAccounts(sql.NotPredicates(p))
|
||||
}
|
||||
369
internal/ent/cloudflareaccounts_create.go
Normal file
369
internal/ent/cloudflareaccounts_create.go
Normal file
@ -0,0 +1,369 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CloudflareAccountsCreate is the builder for creating a CloudflareAccounts entity.
|
||||
type CloudflareAccountsCreate struct {
|
||||
config
|
||||
mutation *CloudflareAccountsMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (cac *CloudflareAccountsCreate) SetName(s string) *CloudflareAccountsCreate {
|
||||
cac.mutation.SetName(s)
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetAccountID sets the "account_id" field.
|
||||
func (cac *CloudflareAccountsCreate) SetAccountID(s string) *CloudflareAccountsCreate {
|
||||
cac.mutation.SetAccountID(s)
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetAPIToken sets the "api_token" field.
|
||||
func (cac *CloudflareAccountsCreate) SetAPIToken(s string) *CloudflareAccountsCreate {
|
||||
cac.mutation.SetAPIToken(s)
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetEmail sets the "email" field.
|
||||
func (cac *CloudflareAccountsCreate) SetEmail(s string) *CloudflareAccountsCreate {
|
||||
cac.mutation.SetEmail(s)
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetNillableEmail sets the "email" field if the given value is not nil.
|
||||
func (cac *CloudflareAccountsCreate) SetNillableEmail(s *string) *CloudflareAccountsCreate {
|
||||
if s != nil {
|
||||
cac.SetEmail(*s)
|
||||
}
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (cac *CloudflareAccountsCreate) SetStatus(i int8) *CloudflareAccountsCreate {
|
||||
cac.mutation.SetStatus(i)
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (cac *CloudflareAccountsCreate) SetNillableStatus(i *int8) *CloudflareAccountsCreate {
|
||||
if i != nil {
|
||||
cac.SetStatus(*i)
|
||||
}
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (cac *CloudflareAccountsCreate) SetRemark(s string) *CloudflareAccountsCreate {
|
||||
cac.mutation.SetRemark(s)
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (cac *CloudflareAccountsCreate) SetNillableRemark(s *string) *CloudflareAccountsCreate {
|
||||
if s != nil {
|
||||
cac.SetRemark(*s)
|
||||
}
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (cac *CloudflareAccountsCreate) SetCreatedAt(t time.Time) *CloudflareAccountsCreate {
|
||||
cac.mutation.SetCreatedAt(t)
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (cac *CloudflareAccountsCreate) SetNillableCreatedAt(t *time.Time) *CloudflareAccountsCreate {
|
||||
if t != nil {
|
||||
cac.SetCreatedAt(*t)
|
||||
}
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (cac *CloudflareAccountsCreate) SetUpdatedAt(t time.Time) *CloudflareAccountsCreate {
|
||||
cac.mutation.SetUpdatedAt(t)
|
||||
return cac
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (cac *CloudflareAccountsCreate) SetNillableUpdatedAt(t *time.Time) *CloudflareAccountsCreate {
|
||||
if t != nil {
|
||||
cac.SetUpdatedAt(*t)
|
||||
}
|
||||
return cac
|
||||
}
|
||||
|
||||
// AddCloudflareBucketIDs adds the "cloudflare_buckets" edge to the CloudflareR2 entity by IDs.
|
||||
func (cac *CloudflareAccountsCreate) AddCloudflareBucketIDs(ids ...int) *CloudflareAccountsCreate {
|
||||
cac.mutation.AddCloudflareBucketIDs(ids...)
|
||||
return cac
|
||||
}
|
||||
|
||||
// AddCloudflareBuckets adds the "cloudflare_buckets" edges to the CloudflareR2 entity.
|
||||
func (cac *CloudflareAccountsCreate) AddCloudflareBuckets(c ...*CloudflareR2) *CloudflareAccountsCreate {
|
||||
ids := make([]int, len(c))
|
||||
for i := range c {
|
||||
ids[i] = c[i].ID
|
||||
}
|
||||
return cac.AddCloudflareBucketIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the CloudflareAccountsMutation object of the builder.
|
||||
func (cac *CloudflareAccountsCreate) Mutation() *CloudflareAccountsMutation {
|
||||
return cac.mutation
|
||||
}
|
||||
|
||||
// Save creates the CloudflareAccounts in the database.
|
||||
func (cac *CloudflareAccountsCreate) Save(ctx context.Context) (*CloudflareAccounts, error) {
|
||||
cac.defaults()
|
||||
return withHooks(ctx, cac.sqlSave, cac.mutation, cac.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (cac *CloudflareAccountsCreate) SaveX(ctx context.Context) *CloudflareAccounts {
|
||||
v, err := cac.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cac *CloudflareAccountsCreate) Exec(ctx context.Context) error {
|
||||
_, err := cac.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cac *CloudflareAccountsCreate) ExecX(ctx context.Context) {
|
||||
if err := cac.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (cac *CloudflareAccountsCreate) defaults() {
|
||||
if _, ok := cac.mutation.Status(); !ok {
|
||||
v := cloudflareaccounts.DefaultStatus
|
||||
cac.mutation.SetStatus(v)
|
||||
}
|
||||
if _, ok := cac.mutation.CreatedAt(); !ok {
|
||||
v := cloudflareaccounts.DefaultCreatedAt()
|
||||
cac.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := cac.mutation.UpdatedAt(); !ok {
|
||||
v := cloudflareaccounts.DefaultUpdatedAt()
|
||||
cac.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cac *CloudflareAccountsCreate) check() error {
|
||||
if _, ok := cac.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "CloudflareAccounts.name"`)}
|
||||
}
|
||||
if v, ok := cac.mutation.Name(); ok {
|
||||
if err := cloudflareaccounts.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "CloudflareAccounts.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := cac.mutation.AccountID(); !ok {
|
||||
return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "CloudflareAccounts.account_id"`)}
|
||||
}
|
||||
if v, ok := cac.mutation.AccountID(); ok {
|
||||
if err := cloudflareaccounts.AccountIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "account_id", err: fmt.Errorf(`ent: validator failed for field "CloudflareAccounts.account_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := cac.mutation.APIToken(); !ok {
|
||||
return &ValidationError{Name: "api_token", err: errors.New(`ent: missing required field "CloudflareAccounts.api_token"`)}
|
||||
}
|
||||
if _, ok := cac.mutation.Status(); !ok {
|
||||
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "CloudflareAccounts.status"`)}
|
||||
}
|
||||
if _, ok := cac.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CloudflareAccounts.created_at"`)}
|
||||
}
|
||||
if _, ok := cac.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CloudflareAccounts.updated_at"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cac *CloudflareAccountsCreate) sqlSave(ctx context.Context) (*CloudflareAccounts, error) {
|
||||
if err := cac.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := cac.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, cac.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
cac.mutation.id = &_node.ID
|
||||
cac.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (cac *CloudflareAccountsCreate) createSpec() (*CloudflareAccounts, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &CloudflareAccounts{config: cac.config}
|
||||
_spec = sqlgraph.NewCreateSpec(cloudflareaccounts.Table, sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := cac.mutation.Name(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := cac.mutation.AccountID(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldAccountID, field.TypeString, value)
|
||||
_node.AccountID = value
|
||||
}
|
||||
if value, ok := cac.mutation.APIToken(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldAPIToken, field.TypeString, value)
|
||||
_node.APIToken = value
|
||||
}
|
||||
if value, ok := cac.mutation.Email(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldEmail, field.TypeString, value)
|
||||
_node.Email = value
|
||||
}
|
||||
if value, ok := cac.mutation.Status(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldStatus, field.TypeInt8, value)
|
||||
_node.Status = value
|
||||
}
|
||||
if value, ok := cac.mutation.Remark(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldRemark, field.TypeString, value)
|
||||
_node.Remark = value
|
||||
}
|
||||
if value, ok := cac.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := cac.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if nodes := cac.mutation.CloudflareBucketsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: cloudflareaccounts.CloudflareBucketsTable,
|
||||
Columns: []string{cloudflareaccounts.CloudflareBucketsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// CloudflareAccountsCreateBulk is the builder for creating many CloudflareAccounts entities in bulk.
|
||||
type CloudflareAccountsCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*CloudflareAccountsCreate
|
||||
}
|
||||
|
||||
// Save creates the CloudflareAccounts entities in the database.
|
||||
func (cacb *CloudflareAccountsCreateBulk) Save(ctx context.Context) ([]*CloudflareAccounts, error) {
|
||||
if cacb.err != nil {
|
||||
return nil, cacb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(cacb.builders))
|
||||
nodes := make([]*CloudflareAccounts, len(cacb.builders))
|
||||
mutators := make([]Mutator, len(cacb.builders))
|
||||
for i := range cacb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := cacb.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*CloudflareAccountsMutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, cacb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, cacb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, cacb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cacb *CloudflareAccountsCreateBulk) SaveX(ctx context.Context) []*CloudflareAccounts {
|
||||
v, err := cacb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cacb *CloudflareAccountsCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := cacb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cacb *CloudflareAccountsCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := cacb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
internal/ent/cloudflareaccounts_delete.go
Normal file
88
internal/ent/cloudflareaccounts_delete.go
Normal file
@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CloudflareAccountsDelete is the builder for deleting a CloudflareAccounts entity.
|
||||
type CloudflareAccountsDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CloudflareAccountsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CloudflareAccountsDelete builder.
|
||||
func (cad *CloudflareAccountsDelete) Where(ps ...predicate.CloudflareAccounts) *CloudflareAccountsDelete {
|
||||
cad.mutation.Where(ps...)
|
||||
return cad
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (cad *CloudflareAccountsDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, cad.sqlExec, cad.mutation, cad.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cad *CloudflareAccountsDelete) ExecX(ctx context.Context) int {
|
||||
n, err := cad.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (cad *CloudflareAccountsDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(cloudflareaccounts.Table, sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt))
|
||||
if ps := cad.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, cad.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
cad.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// CloudflareAccountsDeleteOne is the builder for deleting a single CloudflareAccounts entity.
|
||||
type CloudflareAccountsDeleteOne struct {
|
||||
cad *CloudflareAccountsDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CloudflareAccountsDelete builder.
|
||||
func (cado *CloudflareAccountsDeleteOne) Where(ps ...predicate.CloudflareAccounts) *CloudflareAccountsDeleteOne {
|
||||
cado.cad.mutation.Where(ps...)
|
||||
return cado
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (cado *CloudflareAccountsDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := cado.cad.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{cloudflareaccounts.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cado *CloudflareAccountsDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := cado.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
609
internal/ent/cloudflareaccounts_query.go
Normal file
609
internal/ent/cloudflareaccounts_query.go
Normal file
@ -0,0 +1,609 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
"fmt"
|
||||
"math"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
"unR2/internal/ent/predicate"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CloudflareAccountsQuery is the builder for querying CloudflareAccounts entities.
|
||||
type CloudflareAccountsQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []cloudflareaccounts.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.CloudflareAccounts
|
||||
withCloudflareBuckets *CloudflareR2Query
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the CloudflareAccountsQuery builder.
|
||||
func (caq *CloudflareAccountsQuery) Where(ps ...predicate.CloudflareAccounts) *CloudflareAccountsQuery {
|
||||
caq.predicates = append(caq.predicates, ps...)
|
||||
return caq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (caq *CloudflareAccountsQuery) Limit(limit int) *CloudflareAccountsQuery {
|
||||
caq.ctx.Limit = &limit
|
||||
return caq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (caq *CloudflareAccountsQuery) Offset(offset int) *CloudflareAccountsQuery {
|
||||
caq.ctx.Offset = &offset
|
||||
return caq
|
||||
}
|
||||
|
||||
// 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 (caq *CloudflareAccountsQuery) Unique(unique bool) *CloudflareAccountsQuery {
|
||||
caq.ctx.Unique = &unique
|
||||
return caq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (caq *CloudflareAccountsQuery) Order(o ...cloudflareaccounts.OrderOption) *CloudflareAccountsQuery {
|
||||
caq.order = append(caq.order, o...)
|
||||
return caq
|
||||
}
|
||||
|
||||
// QueryCloudflareBuckets chains the current query on the "cloudflare_buckets" edge.
|
||||
func (caq *CloudflareAccountsQuery) QueryCloudflareBuckets() *CloudflareR2Query {
|
||||
query := (&CloudflareR2Client{config: caq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := caq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := caq.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(cloudflareaccounts.Table, cloudflareaccounts.FieldID, selector),
|
||||
sqlgraph.To(cloudflarer2.Table, cloudflarer2.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, cloudflareaccounts.CloudflareBucketsTable, cloudflareaccounts.CloudflareBucketsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(caq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first CloudflareAccounts entity from the query.
|
||||
// Returns a *NotFoundError when no CloudflareAccounts was found.
|
||||
func (caq *CloudflareAccountsQuery) First(ctx context.Context) (*CloudflareAccounts, error) {
|
||||
nodes, err := caq.Limit(1).All(setContextOp(ctx, caq.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{cloudflareaccounts.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (caq *CloudflareAccountsQuery) FirstX(ctx context.Context) *CloudflareAccounts {
|
||||
node, err := caq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first CloudflareAccounts ID from the query.
|
||||
// Returns a *NotFoundError when no CloudflareAccounts ID was found.
|
||||
func (caq *CloudflareAccountsQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = caq.Limit(1).IDs(setContextOp(ctx, caq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{cloudflareaccounts.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (caq *CloudflareAccountsQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := caq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single CloudflareAccounts entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one CloudflareAccounts entity is found.
|
||||
// Returns a *NotFoundError when no CloudflareAccounts entities are found.
|
||||
func (caq *CloudflareAccountsQuery) Only(ctx context.Context) (*CloudflareAccounts, error) {
|
||||
nodes, err := caq.Limit(2).All(setContextOp(ctx, caq.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{cloudflareaccounts.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{cloudflareaccounts.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (caq *CloudflareAccountsQuery) OnlyX(ctx context.Context) *CloudflareAccounts {
|
||||
node, err := caq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only CloudflareAccounts ID in the query.
|
||||
// Returns a *NotSingularError when more than one CloudflareAccounts ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (caq *CloudflareAccountsQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = caq.Limit(2).IDs(setContextOp(ctx, caq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{cloudflareaccounts.Label}
|
||||
default:
|
||||
err = &NotSingularError{cloudflareaccounts.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (caq *CloudflareAccountsQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := caq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of CloudflareAccountsSlice.
|
||||
func (caq *CloudflareAccountsQuery) All(ctx context.Context) ([]*CloudflareAccounts, error) {
|
||||
ctx = setContextOp(ctx, caq.ctx, ent.OpQueryAll)
|
||||
if err := caq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*CloudflareAccounts, *CloudflareAccountsQuery]()
|
||||
return withInterceptors[[]*CloudflareAccounts](ctx, caq, qr, caq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (caq *CloudflareAccountsQuery) AllX(ctx context.Context) []*CloudflareAccounts {
|
||||
nodes, err := caq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of CloudflareAccounts IDs.
|
||||
func (caq *CloudflareAccountsQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if caq.ctx.Unique == nil && caq.path != nil {
|
||||
caq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, caq.ctx, ent.OpQueryIDs)
|
||||
if err = caq.Select(cloudflareaccounts.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (caq *CloudflareAccountsQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := caq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (caq *CloudflareAccountsQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, caq.ctx, ent.OpQueryCount)
|
||||
if err := caq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, caq, querierCount[*CloudflareAccountsQuery](), caq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (caq *CloudflareAccountsQuery) CountX(ctx context.Context) int {
|
||||
count, err := caq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (caq *CloudflareAccountsQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, caq.ctx, ent.OpQueryExist)
|
||||
switch _, err := caq.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (caq *CloudflareAccountsQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := caq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the CloudflareAccountsQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (caq *CloudflareAccountsQuery) Clone() *CloudflareAccountsQuery {
|
||||
if caq == nil {
|
||||
return nil
|
||||
}
|
||||
return &CloudflareAccountsQuery{
|
||||
config: caq.config,
|
||||
ctx: caq.ctx.Clone(),
|
||||
order: append([]cloudflareaccounts.OrderOption{}, caq.order...),
|
||||
inters: append([]Interceptor{}, caq.inters...),
|
||||
predicates: append([]predicate.CloudflareAccounts{}, caq.predicates...),
|
||||
withCloudflareBuckets: caq.withCloudflareBuckets.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: caq.sql.Clone(),
|
||||
path: caq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithCloudflareBuckets tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "cloudflare_buckets" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (caq *CloudflareAccountsQuery) WithCloudflareBuckets(opts ...func(*CloudflareR2Query)) *CloudflareAccountsQuery {
|
||||
query := (&CloudflareR2Client{config: caq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
caq.withCloudflareBuckets = query
|
||||
return caq
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CloudflareAccounts.Query().
|
||||
// GroupBy(cloudflareaccounts.FieldName).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (caq *CloudflareAccountsQuery) GroupBy(field string, fields ...string) *CloudflareAccountsGroupBy {
|
||||
caq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &CloudflareAccountsGroupBy{build: caq}
|
||||
grbuild.flds = &caq.ctx.Fields
|
||||
grbuild.label = cloudflareaccounts.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CloudflareAccounts.Query().
|
||||
// Select(cloudflareaccounts.FieldName).
|
||||
// Scan(ctx, &v)
|
||||
func (caq *CloudflareAccountsQuery) Select(fields ...string) *CloudflareAccountsSelect {
|
||||
caq.ctx.Fields = append(caq.ctx.Fields, fields...)
|
||||
sbuild := &CloudflareAccountsSelect{CloudflareAccountsQuery: caq}
|
||||
sbuild.label = cloudflareaccounts.Label
|
||||
sbuild.flds, sbuild.scan = &caq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a CloudflareAccountsSelect configured with the given aggregations.
|
||||
func (caq *CloudflareAccountsQuery) Aggregate(fns ...AggregateFunc) *CloudflareAccountsSelect {
|
||||
return caq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (caq *CloudflareAccountsQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range caq.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, caq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range caq.ctx.Fields {
|
||||
if !cloudflareaccounts.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if caq.path != nil {
|
||||
prev, err := caq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
caq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (caq *CloudflareAccountsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CloudflareAccounts, error) {
|
||||
var (
|
||||
nodes = []*CloudflareAccounts{}
|
||||
_spec = caq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
caq.withCloudflareBuckets != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*CloudflareAccounts).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &CloudflareAccounts{config: caq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, caq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := caq.withCloudflareBuckets; query != nil {
|
||||
if err := caq.loadCloudflareBuckets(ctx, query, nodes,
|
||||
func(n *CloudflareAccounts) { n.Edges.CloudflareBuckets = []*CloudflareR2{} },
|
||||
func(n *CloudflareAccounts, e *CloudflareR2) {
|
||||
n.Edges.CloudflareBuckets = append(n.Edges.CloudflareBuckets, e)
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (caq *CloudflareAccountsQuery) loadCloudflareBuckets(ctx context.Context, query *CloudflareR2Query, nodes []*CloudflareAccounts, init func(*CloudflareAccounts), assign func(*CloudflareAccounts, *CloudflareR2)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*CloudflareAccounts)
|
||||
for i := range nodes {
|
||||
fks = append(fks, nodes[i].ID)
|
||||
nodeids[nodes[i].ID] = nodes[i]
|
||||
if init != nil {
|
||||
init(nodes[i])
|
||||
}
|
||||
}
|
||||
query.withFKs = true
|
||||
query.Where(predicate.CloudflareR2(func(s *sql.Selector) {
|
||||
s.Where(sql.InValues(s.C(cloudflareaccounts.CloudflareBucketsColumn), fks...))
|
||||
}))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
fk := n.cloudflare_accounts_cloudflare_buckets
|
||||
if fk == nil {
|
||||
return fmt.Errorf(`foreign-key "cloudflare_accounts_cloudflare_buckets" is nil for node %v`, n.ID)
|
||||
}
|
||||
node, ok := nodeids[*fk]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected referenced foreign-key "cloudflare_accounts_cloudflare_buckets" returned %v for node %v`, *fk, n.ID)
|
||||
}
|
||||
assign(node, n)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (caq *CloudflareAccountsQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := caq.querySpec()
|
||||
_spec.Node.Columns = caq.ctx.Fields
|
||||
if len(caq.ctx.Fields) > 0 {
|
||||
_spec.Unique = caq.ctx.Unique != nil && *caq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, caq.driver, _spec)
|
||||
}
|
||||
|
||||
func (caq *CloudflareAccountsQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(cloudflareaccounts.Table, cloudflareaccounts.Columns, sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt))
|
||||
_spec.From = caq.sql
|
||||
if unique := caq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if caq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := caq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, cloudflareaccounts.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != cloudflareaccounts.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := caq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := caq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := caq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := caq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (caq *CloudflareAccountsQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(caq.driver.Dialect())
|
||||
t1 := builder.Table(cloudflareaccounts.Table)
|
||||
columns := caq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = cloudflareaccounts.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if caq.sql != nil {
|
||||
selector = caq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if caq.ctx.Unique != nil && *caq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range caq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range caq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := caq.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := caq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// CloudflareAccountsGroupBy is the group-by builder for CloudflareAccounts entities.
|
||||
type CloudflareAccountsGroupBy struct {
|
||||
selector
|
||||
build *CloudflareAccountsQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (cagb *CloudflareAccountsGroupBy) Aggregate(fns ...AggregateFunc) *CloudflareAccountsGroupBy {
|
||||
cagb.fns = append(cagb.fns, fns...)
|
||||
return cagb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (cagb *CloudflareAccountsGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, cagb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := cagb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*CloudflareAccountsQuery, *CloudflareAccountsGroupBy](ctx, cagb.build, cagb, cagb.build.inters, v)
|
||||
}
|
||||
|
||||
func (cagb *CloudflareAccountsGroupBy) sqlScan(ctx context.Context, root *CloudflareAccountsQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(cagb.fns))
|
||||
for _, fn := range cagb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*cagb.flds)+len(cagb.fns))
|
||||
for _, f := range *cagb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*cagb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := cagb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// CloudflareAccountsSelect is the builder for selecting fields of CloudflareAccounts entities.
|
||||
type CloudflareAccountsSelect struct {
|
||||
*CloudflareAccountsQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (cas *CloudflareAccountsSelect) Aggregate(fns ...AggregateFunc) *CloudflareAccountsSelect {
|
||||
cas.fns = append(cas.fns, fns...)
|
||||
return cas
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (cas *CloudflareAccountsSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, cas.ctx, ent.OpQuerySelect)
|
||||
if err := cas.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*CloudflareAccountsQuery, *CloudflareAccountsSelect](ctx, cas.CloudflareAccountsQuery, cas, cas.inters, v)
|
||||
}
|
||||
|
||||
func (cas *CloudflareAccountsSelect) sqlScan(ctx context.Context, root *CloudflareAccountsQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(cas.fns))
|
||||
for _, fn := range cas.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*cas.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := cas.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
671
internal/ent/cloudflareaccounts_update.go
Normal file
671
internal/ent/cloudflareaccounts_update.go
Normal file
@ -0,0 +1,671 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
"unR2/internal/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CloudflareAccountsUpdate is the builder for updating CloudflareAccounts entities.
|
||||
type CloudflareAccountsUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CloudflareAccountsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CloudflareAccountsUpdate builder.
|
||||
func (cau *CloudflareAccountsUpdate) Where(ps ...predicate.CloudflareAccounts) *CloudflareAccountsUpdate {
|
||||
cau.mutation.Where(ps...)
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (cau *CloudflareAccountsUpdate) SetName(s string) *CloudflareAccountsUpdate {
|
||||
cau.mutation.SetName(s)
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (cau *CloudflareAccountsUpdate) SetNillableName(s *string) *CloudflareAccountsUpdate {
|
||||
if s != nil {
|
||||
cau.SetName(*s)
|
||||
}
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetAccountID sets the "account_id" field.
|
||||
func (cau *CloudflareAccountsUpdate) SetAccountID(s string) *CloudflareAccountsUpdate {
|
||||
cau.mutation.SetAccountID(s)
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
|
||||
func (cau *CloudflareAccountsUpdate) SetNillableAccountID(s *string) *CloudflareAccountsUpdate {
|
||||
if s != nil {
|
||||
cau.SetAccountID(*s)
|
||||
}
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetAPIToken sets the "api_token" field.
|
||||
func (cau *CloudflareAccountsUpdate) SetAPIToken(s string) *CloudflareAccountsUpdate {
|
||||
cau.mutation.SetAPIToken(s)
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetNillableAPIToken sets the "api_token" field if the given value is not nil.
|
||||
func (cau *CloudflareAccountsUpdate) SetNillableAPIToken(s *string) *CloudflareAccountsUpdate {
|
||||
if s != nil {
|
||||
cau.SetAPIToken(*s)
|
||||
}
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetEmail sets the "email" field.
|
||||
func (cau *CloudflareAccountsUpdate) SetEmail(s string) *CloudflareAccountsUpdate {
|
||||
cau.mutation.SetEmail(s)
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetNillableEmail sets the "email" field if the given value is not nil.
|
||||
func (cau *CloudflareAccountsUpdate) SetNillableEmail(s *string) *CloudflareAccountsUpdate {
|
||||
if s != nil {
|
||||
cau.SetEmail(*s)
|
||||
}
|
||||
return cau
|
||||
}
|
||||
|
||||
// ClearEmail clears the value of the "email" field.
|
||||
func (cau *CloudflareAccountsUpdate) ClearEmail() *CloudflareAccountsUpdate {
|
||||
cau.mutation.ClearEmail()
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (cau *CloudflareAccountsUpdate) SetStatus(i int8) *CloudflareAccountsUpdate {
|
||||
cau.mutation.ResetStatus()
|
||||
cau.mutation.SetStatus(i)
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (cau *CloudflareAccountsUpdate) SetNillableStatus(i *int8) *CloudflareAccountsUpdate {
|
||||
if i != nil {
|
||||
cau.SetStatus(*i)
|
||||
}
|
||||
return cau
|
||||
}
|
||||
|
||||
// AddStatus adds i to the "status" field.
|
||||
func (cau *CloudflareAccountsUpdate) AddStatus(i int8) *CloudflareAccountsUpdate {
|
||||
cau.mutation.AddStatus(i)
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (cau *CloudflareAccountsUpdate) SetRemark(s string) *CloudflareAccountsUpdate {
|
||||
cau.mutation.SetRemark(s)
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (cau *CloudflareAccountsUpdate) SetNillableRemark(s *string) *CloudflareAccountsUpdate {
|
||||
if s != nil {
|
||||
cau.SetRemark(*s)
|
||||
}
|
||||
return cau
|
||||
}
|
||||
|
||||
// ClearRemark clears the value of the "remark" field.
|
||||
func (cau *CloudflareAccountsUpdate) ClearRemark() *CloudflareAccountsUpdate {
|
||||
cau.mutation.ClearRemark()
|
||||
return cau
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (cau *CloudflareAccountsUpdate) SetUpdatedAt(t time.Time) *CloudflareAccountsUpdate {
|
||||
cau.mutation.SetUpdatedAt(t)
|
||||
return cau
|
||||
}
|
||||
|
||||
// AddCloudflareBucketIDs adds the "cloudflare_buckets" edge to the CloudflareR2 entity by IDs.
|
||||
func (cau *CloudflareAccountsUpdate) AddCloudflareBucketIDs(ids ...int) *CloudflareAccountsUpdate {
|
||||
cau.mutation.AddCloudflareBucketIDs(ids...)
|
||||
return cau
|
||||
}
|
||||
|
||||
// AddCloudflareBuckets adds the "cloudflare_buckets" edges to the CloudflareR2 entity.
|
||||
func (cau *CloudflareAccountsUpdate) AddCloudflareBuckets(c ...*CloudflareR2) *CloudflareAccountsUpdate {
|
||||
ids := make([]int, len(c))
|
||||
for i := range c {
|
||||
ids[i] = c[i].ID
|
||||
}
|
||||
return cau.AddCloudflareBucketIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the CloudflareAccountsMutation object of the builder.
|
||||
func (cau *CloudflareAccountsUpdate) Mutation() *CloudflareAccountsMutation {
|
||||
return cau.mutation
|
||||
}
|
||||
|
||||
// ClearCloudflareBuckets clears all "cloudflare_buckets" edges to the CloudflareR2 entity.
|
||||
func (cau *CloudflareAccountsUpdate) ClearCloudflareBuckets() *CloudflareAccountsUpdate {
|
||||
cau.mutation.ClearCloudflareBuckets()
|
||||
return cau
|
||||
}
|
||||
|
||||
// RemoveCloudflareBucketIDs removes the "cloudflare_buckets" edge to CloudflareR2 entities by IDs.
|
||||
func (cau *CloudflareAccountsUpdate) RemoveCloudflareBucketIDs(ids ...int) *CloudflareAccountsUpdate {
|
||||
cau.mutation.RemoveCloudflareBucketIDs(ids...)
|
||||
return cau
|
||||
}
|
||||
|
||||
// RemoveCloudflareBuckets removes "cloudflare_buckets" edges to CloudflareR2 entities.
|
||||
func (cau *CloudflareAccountsUpdate) RemoveCloudflareBuckets(c ...*CloudflareR2) *CloudflareAccountsUpdate {
|
||||
ids := make([]int, len(c))
|
||||
for i := range c {
|
||||
ids[i] = c[i].ID
|
||||
}
|
||||
return cau.RemoveCloudflareBucketIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (cau *CloudflareAccountsUpdate) Save(ctx context.Context) (int, error) {
|
||||
cau.defaults()
|
||||
return withHooks(ctx, cau.sqlSave, cau.mutation, cau.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cau *CloudflareAccountsUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := cau.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cau *CloudflareAccountsUpdate) Exec(ctx context.Context) error {
|
||||
_, err := cau.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cau *CloudflareAccountsUpdate) ExecX(ctx context.Context) {
|
||||
if err := cau.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (cau *CloudflareAccountsUpdate) defaults() {
|
||||
if _, ok := cau.mutation.UpdatedAt(); !ok {
|
||||
v := cloudflareaccounts.UpdateDefaultUpdatedAt()
|
||||
cau.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cau *CloudflareAccountsUpdate) check() error {
|
||||
if v, ok := cau.mutation.Name(); ok {
|
||||
if err := cloudflareaccounts.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "CloudflareAccounts.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := cau.mutation.AccountID(); ok {
|
||||
if err := cloudflareaccounts.AccountIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "account_id", err: fmt.Errorf(`ent: validator failed for field "CloudflareAccounts.account_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cau *CloudflareAccountsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := cau.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(cloudflareaccounts.Table, cloudflareaccounts.Columns, sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt))
|
||||
if ps := cau.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cau.mutation.Name(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cau.mutation.AccountID(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldAccountID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cau.mutation.APIToken(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldAPIToken, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cau.mutation.Email(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldEmail, field.TypeString, value)
|
||||
}
|
||||
if cau.mutation.EmailCleared() {
|
||||
_spec.ClearField(cloudflareaccounts.FieldEmail, field.TypeString)
|
||||
}
|
||||
if value, ok := cau.mutation.Status(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldStatus, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := cau.mutation.AddedStatus(); ok {
|
||||
_spec.AddField(cloudflareaccounts.FieldStatus, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := cau.mutation.Remark(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
if cau.mutation.RemarkCleared() {
|
||||
_spec.ClearField(cloudflareaccounts.FieldRemark, field.TypeString)
|
||||
}
|
||||
if value, ok := cau.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if cau.mutation.CloudflareBucketsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: cloudflareaccounts.CloudflareBucketsTable,
|
||||
Columns: []string{cloudflareaccounts.CloudflareBucketsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cau.mutation.RemovedCloudflareBucketsIDs(); len(nodes) > 0 && !cau.mutation.CloudflareBucketsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: cloudflareaccounts.CloudflareBucketsTable,
|
||||
Columns: []string{cloudflareaccounts.CloudflareBucketsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cau.mutation.CloudflareBucketsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: cloudflareaccounts.CloudflareBucketsTable,
|
||||
Columns: []string{cloudflareaccounts.CloudflareBucketsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, cau.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{cloudflareaccounts.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
cau.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// CloudflareAccountsUpdateOne is the builder for updating a single CloudflareAccounts entity.
|
||||
type CloudflareAccountsUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *CloudflareAccountsMutation
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetName(s string) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.SetName(s)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetNillableName(s *string) *CloudflareAccountsUpdateOne {
|
||||
if s != nil {
|
||||
cauo.SetName(*s)
|
||||
}
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetAccountID sets the "account_id" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetAccountID(s string) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.SetAccountID(s)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetNillableAccountID(s *string) *CloudflareAccountsUpdateOne {
|
||||
if s != nil {
|
||||
cauo.SetAccountID(*s)
|
||||
}
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetAPIToken sets the "api_token" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetAPIToken(s string) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.SetAPIToken(s)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetNillableAPIToken sets the "api_token" field if the given value is not nil.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetNillableAPIToken(s *string) *CloudflareAccountsUpdateOne {
|
||||
if s != nil {
|
||||
cauo.SetAPIToken(*s)
|
||||
}
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetEmail sets the "email" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetEmail(s string) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.SetEmail(s)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetNillableEmail sets the "email" field if the given value is not nil.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetNillableEmail(s *string) *CloudflareAccountsUpdateOne {
|
||||
if s != nil {
|
||||
cauo.SetEmail(*s)
|
||||
}
|
||||
return cauo
|
||||
}
|
||||
|
||||
// ClearEmail clears the value of the "email" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) ClearEmail() *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.ClearEmail()
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetStatus(i int8) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.ResetStatus()
|
||||
cauo.mutation.SetStatus(i)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetNillableStatus(i *int8) *CloudflareAccountsUpdateOne {
|
||||
if i != nil {
|
||||
cauo.SetStatus(*i)
|
||||
}
|
||||
return cauo
|
||||
}
|
||||
|
||||
// AddStatus adds i to the "status" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) AddStatus(i int8) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.AddStatus(i)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetRemark(s string) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.SetRemark(s)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetNillableRemark(s *string) *CloudflareAccountsUpdateOne {
|
||||
if s != nil {
|
||||
cauo.SetRemark(*s)
|
||||
}
|
||||
return cauo
|
||||
}
|
||||
|
||||
// ClearRemark clears the value of the "remark" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) ClearRemark() *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.ClearRemark()
|
||||
return cauo
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SetUpdatedAt(t time.Time) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.SetUpdatedAt(t)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// AddCloudflareBucketIDs adds the "cloudflare_buckets" edge to the CloudflareR2 entity by IDs.
|
||||
func (cauo *CloudflareAccountsUpdateOne) AddCloudflareBucketIDs(ids ...int) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.AddCloudflareBucketIDs(ids...)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// AddCloudflareBuckets adds the "cloudflare_buckets" edges to the CloudflareR2 entity.
|
||||
func (cauo *CloudflareAccountsUpdateOne) AddCloudflareBuckets(c ...*CloudflareR2) *CloudflareAccountsUpdateOne {
|
||||
ids := make([]int, len(c))
|
||||
for i := range c {
|
||||
ids[i] = c[i].ID
|
||||
}
|
||||
return cauo.AddCloudflareBucketIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the CloudflareAccountsMutation object of the builder.
|
||||
func (cauo *CloudflareAccountsUpdateOne) Mutation() *CloudflareAccountsMutation {
|
||||
return cauo.mutation
|
||||
}
|
||||
|
||||
// ClearCloudflareBuckets clears all "cloudflare_buckets" edges to the CloudflareR2 entity.
|
||||
func (cauo *CloudflareAccountsUpdateOne) ClearCloudflareBuckets() *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.ClearCloudflareBuckets()
|
||||
return cauo
|
||||
}
|
||||
|
||||
// RemoveCloudflareBucketIDs removes the "cloudflare_buckets" edge to CloudflareR2 entities by IDs.
|
||||
func (cauo *CloudflareAccountsUpdateOne) RemoveCloudflareBucketIDs(ids ...int) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.RemoveCloudflareBucketIDs(ids...)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// RemoveCloudflareBuckets removes "cloudflare_buckets" edges to CloudflareR2 entities.
|
||||
func (cauo *CloudflareAccountsUpdateOne) RemoveCloudflareBuckets(c ...*CloudflareR2) *CloudflareAccountsUpdateOne {
|
||||
ids := make([]int, len(c))
|
||||
for i := range c {
|
||||
ids[i] = c[i].ID
|
||||
}
|
||||
return cauo.RemoveCloudflareBucketIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CloudflareAccountsUpdate builder.
|
||||
func (cauo *CloudflareAccountsUpdateOne) Where(ps ...predicate.CloudflareAccounts) *CloudflareAccountsUpdateOne {
|
||||
cauo.mutation.Where(ps...)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (cauo *CloudflareAccountsUpdateOne) Select(field string, fields ...string) *CloudflareAccountsUpdateOne {
|
||||
cauo.fields = append([]string{field}, fields...)
|
||||
return cauo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated CloudflareAccounts entity.
|
||||
func (cauo *CloudflareAccountsUpdateOne) Save(ctx context.Context) (*CloudflareAccounts, error) {
|
||||
cauo.defaults()
|
||||
return withHooks(ctx, cauo.sqlSave, cauo.mutation, cauo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cauo *CloudflareAccountsUpdateOne) SaveX(ctx context.Context) *CloudflareAccounts {
|
||||
node, err := cauo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (cauo *CloudflareAccountsUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := cauo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cauo *CloudflareAccountsUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := cauo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (cauo *CloudflareAccountsUpdateOne) defaults() {
|
||||
if _, ok := cauo.mutation.UpdatedAt(); !ok {
|
||||
v := cloudflareaccounts.UpdateDefaultUpdatedAt()
|
||||
cauo.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cauo *CloudflareAccountsUpdateOne) check() error {
|
||||
if v, ok := cauo.mutation.Name(); ok {
|
||||
if err := cloudflareaccounts.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "CloudflareAccounts.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := cauo.mutation.AccountID(); ok {
|
||||
if err := cloudflareaccounts.AccountIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "account_id", err: fmt.Errorf(`ent: validator failed for field "CloudflareAccounts.account_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cauo *CloudflareAccountsUpdateOne) sqlSave(ctx context.Context) (_node *CloudflareAccounts, err error) {
|
||||
if err := cauo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(cloudflareaccounts.Table, cloudflareaccounts.Columns, sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt))
|
||||
id, ok := cauo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CloudflareAccounts.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := cauo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, cloudflareaccounts.FieldID)
|
||||
for _, f := range fields {
|
||||
if !cloudflareaccounts.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != cloudflareaccounts.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := cauo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cauo.mutation.Name(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cauo.mutation.AccountID(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldAccountID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cauo.mutation.APIToken(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldAPIToken, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cauo.mutation.Email(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldEmail, field.TypeString, value)
|
||||
}
|
||||
if cauo.mutation.EmailCleared() {
|
||||
_spec.ClearField(cloudflareaccounts.FieldEmail, field.TypeString)
|
||||
}
|
||||
if value, ok := cauo.mutation.Status(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldStatus, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := cauo.mutation.AddedStatus(); ok {
|
||||
_spec.AddField(cloudflareaccounts.FieldStatus, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := cauo.mutation.Remark(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
if cauo.mutation.RemarkCleared() {
|
||||
_spec.ClearField(cloudflareaccounts.FieldRemark, field.TypeString)
|
||||
}
|
||||
if value, ok := cauo.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(cloudflareaccounts.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if cauo.mutation.CloudflareBucketsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: cloudflareaccounts.CloudflareBucketsTable,
|
||||
Columns: []string{cloudflareaccounts.CloudflareBucketsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cauo.mutation.RemovedCloudflareBucketsIDs(); len(nodes) > 0 && !cauo.mutation.CloudflareBucketsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: cloudflareaccounts.CloudflareBucketsTable,
|
||||
Columns: []string{cloudflareaccounts.CloudflareBucketsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cauo.mutation.CloudflareBucketsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: cloudflareaccounts.CloudflareBucketsTable,
|
||||
Columns: []string{cloudflareaccounts.CloudflareBucketsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &CloudflareAccounts{config: cauo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, cauo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{cloudflareaccounts.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
cauo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
255
internal/ent/cloudflarer2.go
Normal file
255
internal/ent/cloudflarer2.go
Normal file
@ -0,0 +1,255 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// CloudflareR2 is the model entity for the CloudflareR2 schema.
|
||||
type CloudflareR2 struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// 业务归属标识
|
||||
OwnerID string `json:"owner_id,omitempty"`
|
||||
// 桶名称(唯一)
|
||||
Name string `json:"name,omitempty"`
|
||||
// 桶区域,如 apac、eea、us
|
||||
Location string `json:"location,omitempty"`
|
||||
// 存储类型,如 standard、infrequent-access
|
||||
StorageClass string `json:"storage_class,omitempty"`
|
||||
// 状态:1=启用,0=禁用
|
||||
Status int8 `json:"status,omitempty"`
|
||||
// 对象数据体积(payloadSize),单位字节
|
||||
PayloadSize int64 `json:"payload_size,omitempty"`
|
||||
// 对象元数据大小(metadataSize),单位字节
|
||||
MetadataSize int64 `json:"metadata_size,omitempty"`
|
||||
// 存储桶内对象总数
|
||||
ObjectCount int `json:"object_count,omitempty"`
|
||||
// 备注
|
||||
Remark string `json:"remark,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the CloudflareR2Query when eager-loading is set.
|
||||
Edges CloudflareR2Edges `json:"edges"`
|
||||
cloudflare_accounts_cloudflare_buckets *int
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// CloudflareR2Edges holds the relations/edges for other nodes in the graph.
|
||||
type CloudflareR2Edges struct {
|
||||
// 所属 Cloudflare 账户
|
||||
CloudflareAccount *CloudflareAccounts `json:"cloudflare_account,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// CloudflareAccountOrErr returns the CloudflareAccount value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e CloudflareR2Edges) CloudflareAccountOrErr() (*CloudflareAccounts, error) {
|
||||
if e.CloudflareAccount != nil {
|
||||
return e.CloudflareAccount, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: cloudflareaccounts.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "cloudflare_account"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*CloudflareR2) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case cloudflarer2.FieldID, cloudflarer2.FieldStatus, cloudflarer2.FieldPayloadSize, cloudflarer2.FieldMetadataSize, cloudflarer2.FieldObjectCount:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case cloudflarer2.FieldOwnerID, cloudflarer2.FieldName, cloudflarer2.FieldLocation, cloudflarer2.FieldStorageClass, cloudflarer2.FieldRemark:
|
||||
values[i] = new(sql.NullString)
|
||||
case cloudflarer2.FieldCreatedAt, cloudflarer2.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
case cloudflarer2.ForeignKeys[0]: // cloudflare_accounts_cloudflare_buckets
|
||||
values[i] = new(sql.NullInt64)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the CloudflareR2 fields.
|
||||
func (c *CloudflareR2) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case cloudflarer2.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
c.ID = int(value.Int64)
|
||||
case cloudflarer2.FieldOwnerID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field owner_id", values[i])
|
||||
} else if value.Valid {
|
||||
c.OwnerID = value.String
|
||||
}
|
||||
case cloudflarer2.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
c.Name = value.String
|
||||
}
|
||||
case cloudflarer2.FieldLocation:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field location", values[i])
|
||||
} else if value.Valid {
|
||||
c.Location = value.String
|
||||
}
|
||||
case cloudflarer2.FieldStorageClass:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field storage_class", values[i])
|
||||
} else if value.Valid {
|
||||
c.StorageClass = value.String
|
||||
}
|
||||
case cloudflarer2.FieldStatus:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field status", values[i])
|
||||
} else if value.Valid {
|
||||
c.Status = int8(value.Int64)
|
||||
}
|
||||
case cloudflarer2.FieldPayloadSize:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field payload_size", values[i])
|
||||
} else if value.Valid {
|
||||
c.PayloadSize = value.Int64
|
||||
}
|
||||
case cloudflarer2.FieldMetadataSize:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field metadata_size", values[i])
|
||||
} else if value.Valid {
|
||||
c.MetadataSize = value.Int64
|
||||
}
|
||||
case cloudflarer2.FieldObjectCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field object_count", values[i])
|
||||
} else if value.Valid {
|
||||
c.ObjectCount = int(value.Int64)
|
||||
}
|
||||
case cloudflarer2.FieldRemark:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field remark", values[i])
|
||||
} else if value.Valid {
|
||||
c.Remark = value.String
|
||||
}
|
||||
case cloudflarer2.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
} else if value.Valid {
|
||||
c.CreatedAt = value.Time
|
||||
}
|
||||
case cloudflarer2.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
c.UpdatedAt = value.Time
|
||||
}
|
||||
case cloudflarer2.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field cloudflare_accounts_cloudflare_buckets", value)
|
||||
} else if value.Valid {
|
||||
c.cloudflare_accounts_cloudflare_buckets = new(int)
|
||||
*c.cloudflare_accounts_cloudflare_buckets = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
c.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the CloudflareR2.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (c *CloudflareR2) Value(name string) (ent.Value, error) {
|
||||
return c.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryCloudflareAccount queries the "cloudflare_account" edge of the CloudflareR2 entity.
|
||||
func (c *CloudflareR2) QueryCloudflareAccount() *CloudflareAccountsQuery {
|
||||
return NewCloudflareR2Client(c.config).QueryCloudflareAccount(c)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this CloudflareR2.
|
||||
// Note that you need to call CloudflareR2.Unwrap() before calling this method if this CloudflareR2
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (c *CloudflareR2) Update() *CloudflareR2UpdateOne {
|
||||
return NewCloudflareR2Client(c.config).UpdateOne(c)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the CloudflareR2 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 (c *CloudflareR2) Unwrap() *CloudflareR2 {
|
||||
_tx, ok := c.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: CloudflareR2 is not a transactional entity")
|
||||
}
|
||||
c.config.driver = _tx.drv
|
||||
return c
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (c *CloudflareR2) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("CloudflareR2(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", c.ID))
|
||||
builder.WriteString("owner_id=")
|
||||
builder.WriteString(c.OwnerID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(c.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("location=")
|
||||
builder.WriteString(c.Location)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("storage_class=")
|
||||
builder.WriteString(c.StorageClass)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("status=")
|
||||
builder.WriteString(fmt.Sprintf("%v", c.Status))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("payload_size=")
|
||||
builder.WriteString(fmt.Sprintf("%v", c.PayloadSize))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("metadata_size=")
|
||||
builder.WriteString(fmt.Sprintf("%v", c.MetadataSize))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("object_count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", c.ObjectCount))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("remark=")
|
||||
builder.WriteString(c.Remark)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(c.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(c.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// CloudflareR2s is a parsable slice of CloudflareR2.
|
||||
type CloudflareR2s []*CloudflareR2
|
||||
187
internal/ent/cloudflarer2/cloudflarer2.go
Normal file
187
internal/ent/cloudflarer2/cloudflarer2.go
Normal file
@ -0,0 +1,187 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package cloudflarer2
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the cloudflarer2 type in the database.
|
||||
Label = "cloudflare_r2"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldOwnerID holds the string denoting the owner_id field in the database.
|
||||
FieldOwnerID = "owner_id"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldLocation holds the string denoting the location field in the database.
|
||||
FieldLocation = "location"
|
||||
// FieldStorageClass holds the string denoting the storage_class field in the database.
|
||||
FieldStorageClass = "storage_class"
|
||||
// FieldStatus holds the string denoting the status field in the database.
|
||||
FieldStatus = "status"
|
||||
// FieldPayloadSize holds the string denoting the payload_size field in the database.
|
||||
FieldPayloadSize = "payload_size"
|
||||
// FieldMetadataSize holds the string denoting the metadata_size field in the database.
|
||||
FieldMetadataSize = "metadata_size"
|
||||
// FieldObjectCount holds the string denoting the object_count field in the database.
|
||||
FieldObjectCount = "object_count"
|
||||
// FieldRemark holds the string denoting the remark field in the database.
|
||||
FieldRemark = "remark"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
FieldUpdatedAt = "updated_at"
|
||||
// EdgeCloudflareAccount holds the string denoting the cloudflare_account edge name in mutations.
|
||||
EdgeCloudflareAccount = "cloudflare_account"
|
||||
// Table holds the table name of the cloudflarer2 in the database.
|
||||
Table = "cloudflare_r2s"
|
||||
// CloudflareAccountTable is the table that holds the cloudflare_account relation/edge.
|
||||
CloudflareAccountTable = "cloudflare_r2s"
|
||||
// CloudflareAccountInverseTable is the table name for the CloudflareAccounts entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "cloudflareaccounts" package.
|
||||
CloudflareAccountInverseTable = "cloudflare_accounts"
|
||||
// CloudflareAccountColumn is the table column denoting the cloudflare_account relation/edge.
|
||||
CloudflareAccountColumn = "cloudflare_accounts_cloudflare_buckets"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for cloudflarer2 fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldOwnerID,
|
||||
FieldName,
|
||||
FieldLocation,
|
||||
FieldStorageClass,
|
||||
FieldStatus,
|
||||
FieldPayloadSize,
|
||||
FieldMetadataSize,
|
||||
FieldObjectCount,
|
||||
FieldRemark,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
|
||||
// ForeignKeys holds the SQL foreign-keys that are owned by the "cloudflare_r2s"
|
||||
// table and are not defined as standalone fields in the schema.
|
||||
var ForeignKeys = []string{
|
||||
"cloudflare_accounts_cloudflare_buckets",
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
for i := range ForeignKeys {
|
||||
if column == ForeignKeys[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
NameValidator func(string) error
|
||||
// LocationValidator is a validator for the "location" field. It is called by the builders before save.
|
||||
LocationValidator func(string) error
|
||||
// StorageClassValidator is a validator for the "storage_class" field. It is called by the builders before save.
|
||||
StorageClassValidator func(string) error
|
||||
// DefaultStatus holds the default value on creation for the "status" field.
|
||||
DefaultStatus int8
|
||||
// DefaultPayloadSize holds the default value on creation for the "payload_size" field.
|
||||
DefaultPayloadSize int64
|
||||
// DefaultMetadataSize holds the default value on creation for the "metadata_size" field.
|
||||
DefaultMetadataSize int64
|
||||
// DefaultObjectCount holds the default value on creation for the "object_count" field.
|
||||
DefaultObjectCount int
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||
DefaultUpdatedAt func() time.Time
|
||||
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||
UpdateDefaultUpdatedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the CloudflareR2 queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOwnerID orders the results by the owner_id field.
|
||||
func ByOwnerID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldOwnerID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocation orders the results by the location field.
|
||||
func ByLocation(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocation, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStorageClass orders the results by the storage_class field.
|
||||
func ByStorageClass(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStorageClass, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByStatus orders the results by the status field.
|
||||
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPayloadSize orders the results by the payload_size field.
|
||||
func ByPayloadSize(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPayloadSize, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMetadataSize orders the results by the metadata_size field.
|
||||
func ByMetadataSize(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMetadataSize, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByObjectCount orders the results by the object_count field.
|
||||
func ByObjectCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldObjectCount, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRemark orders the results by the remark field.
|
||||
func ByRemark(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRemark, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdatedAt orders the results by the updated_at field.
|
||||
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCloudflareAccountField orders the results by cloudflare_account field.
|
||||
func ByCloudflareAccountField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newCloudflareAccountStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newCloudflareAccountStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(CloudflareAccountInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, CloudflareAccountTable, CloudflareAccountColumn),
|
||||
)
|
||||
}
|
||||
724
internal/ent/cloudflarer2/where.go
Normal file
724
internal/ent/cloudflarer2/where.go
Normal file
@ -0,0 +1,724 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package cloudflarer2
|
||||
|
||||
import (
|
||||
"time"
|
||||
"unR2/internal/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// OwnerID applies equality check predicate on the "owner_id" field. It's identical to OwnerIDEQ.
|
||||
func OwnerID(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Location applies equality check predicate on the "location" field. It's identical to LocationEQ.
|
||||
func Location(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldLocation, v))
|
||||
}
|
||||
|
||||
// StorageClass applies equality check predicate on the "storage_class" field. It's identical to StorageClassEQ.
|
||||
func StorageClass(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
|
||||
func Status(v int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldStatus, v))
|
||||
}
|
||||
|
||||
// PayloadSize applies equality check predicate on the "payload_size" field. It's identical to PayloadSizeEQ.
|
||||
func PayloadSize(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldPayloadSize, v))
|
||||
}
|
||||
|
||||
// MetadataSize applies equality check predicate on the "metadata_size" field. It's identical to MetadataSizeEQ.
|
||||
func MetadataSize(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldMetadataSize, v))
|
||||
}
|
||||
|
||||
// ObjectCount applies equality check predicate on the "object_count" field. It's identical to ObjectCountEQ.
|
||||
func ObjectCount(v int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldObjectCount, v))
|
||||
}
|
||||
|
||||
// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ.
|
||||
func Remark(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldRemark, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(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.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// OwnerIDEQ applies the EQ predicate on the "owner_id" field.
|
||||
func OwnerIDEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDNEQ applies the NEQ predicate on the "owner_id" field.
|
||||
func OwnerIDNEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDIn applies the In predicate on the "owner_id" field.
|
||||
func OwnerIDIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldOwnerID, vs...))
|
||||
}
|
||||
|
||||
// OwnerIDNotIn applies the NotIn predicate on the "owner_id" field.
|
||||
func OwnerIDNotIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldOwnerID, vs...))
|
||||
}
|
||||
|
||||
// OwnerIDGT applies the GT predicate on the "owner_id" field.
|
||||
func OwnerIDGT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDGTE applies the GTE predicate on the "owner_id" field.
|
||||
func OwnerIDGTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDLT applies the LT predicate on the "owner_id" field.
|
||||
func OwnerIDLT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDLTE applies the LTE predicate on the "owner_id" field.
|
||||
func OwnerIDLTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDContains applies the Contains predicate on the "owner_id" field.
|
||||
func OwnerIDContains(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContains(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDHasPrefix applies the HasPrefix predicate on the "owner_id" field.
|
||||
func OwnerIDHasPrefix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasPrefix(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDHasSuffix applies the HasSuffix predicate on the "owner_id" field.
|
||||
func OwnerIDHasSuffix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasSuffix(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDEqualFold applies the EqualFold predicate on the "owner_id" field.
|
||||
func OwnerIDEqualFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEqualFold(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// OwnerIDContainsFold applies the ContainsFold predicate on the "owner_id" field.
|
||||
func OwnerIDContainsFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContainsFold(FieldOwnerID, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// LocationEQ applies the EQ predicate on the "location" field.
|
||||
func LocationEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationNEQ applies the NEQ predicate on the "location" field.
|
||||
func LocationNEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationIn applies the In predicate on the "location" field.
|
||||
func LocationIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldLocation, vs...))
|
||||
}
|
||||
|
||||
// LocationNotIn applies the NotIn predicate on the "location" field.
|
||||
func LocationNotIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldLocation, vs...))
|
||||
}
|
||||
|
||||
// LocationGT applies the GT predicate on the "location" field.
|
||||
func LocationGT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationGTE applies the GTE predicate on the "location" field.
|
||||
func LocationGTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationLT applies the LT predicate on the "location" field.
|
||||
func LocationLT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationLTE applies the LTE predicate on the "location" field.
|
||||
func LocationLTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationContains applies the Contains predicate on the "location" field.
|
||||
func LocationContains(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContains(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationHasPrefix applies the HasPrefix predicate on the "location" field.
|
||||
func LocationHasPrefix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasPrefix(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationHasSuffix applies the HasSuffix predicate on the "location" field.
|
||||
func LocationHasSuffix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasSuffix(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationEqualFold applies the EqualFold predicate on the "location" field.
|
||||
func LocationEqualFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEqualFold(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationContainsFold applies the ContainsFold predicate on the "location" field.
|
||||
func LocationContainsFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContainsFold(FieldLocation, v))
|
||||
}
|
||||
|
||||
// StorageClassEQ applies the EQ predicate on the "storage_class" field.
|
||||
func StorageClassEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassNEQ applies the NEQ predicate on the "storage_class" field.
|
||||
func StorageClassNEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassIn applies the In predicate on the "storage_class" field.
|
||||
func StorageClassIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldStorageClass, vs...))
|
||||
}
|
||||
|
||||
// StorageClassNotIn applies the NotIn predicate on the "storage_class" field.
|
||||
func StorageClassNotIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldStorageClass, vs...))
|
||||
}
|
||||
|
||||
// StorageClassGT applies the GT predicate on the "storage_class" field.
|
||||
func StorageClassGT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassGTE applies the GTE predicate on the "storage_class" field.
|
||||
func StorageClassGTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassLT applies the LT predicate on the "storage_class" field.
|
||||
func StorageClassLT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassLTE applies the LTE predicate on the "storage_class" field.
|
||||
func StorageClassLTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassContains applies the Contains predicate on the "storage_class" field.
|
||||
func StorageClassContains(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContains(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassHasPrefix applies the HasPrefix predicate on the "storage_class" field.
|
||||
func StorageClassHasPrefix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasPrefix(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassHasSuffix applies the HasSuffix predicate on the "storage_class" field.
|
||||
func StorageClassHasSuffix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasSuffix(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassEqualFold applies the EqualFold predicate on the "storage_class" field.
|
||||
func StorageClassEqualFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEqualFold(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StorageClassContainsFold applies the ContainsFold predicate on the "storage_class" field.
|
||||
func StorageClassContainsFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContainsFold(FieldStorageClass, v))
|
||||
}
|
||||
|
||||
// StatusEQ applies the EQ predicate on the "status" field.
|
||||
func StatusEQ(v int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusNEQ applies the NEQ predicate on the "status" field.
|
||||
func StatusNEQ(v int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusIn applies the In predicate on the "status" field.
|
||||
func StatusIn(vs ...int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldStatus, vs...))
|
||||
}
|
||||
|
||||
// StatusNotIn applies the NotIn predicate on the "status" field.
|
||||
func StatusNotIn(vs ...int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldStatus, vs...))
|
||||
}
|
||||
|
||||
// StatusGT applies the GT predicate on the "status" field.
|
||||
func StatusGT(v int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusGTE applies the GTE predicate on the "status" field.
|
||||
func StatusGTE(v int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusLT applies the LT predicate on the "status" field.
|
||||
func StatusLT(v int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldStatus, v))
|
||||
}
|
||||
|
||||
// StatusLTE applies the LTE predicate on the "status" field.
|
||||
func StatusLTE(v int8) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldStatus, v))
|
||||
}
|
||||
|
||||
// PayloadSizeEQ applies the EQ predicate on the "payload_size" field.
|
||||
func PayloadSizeEQ(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldPayloadSize, v))
|
||||
}
|
||||
|
||||
// PayloadSizeNEQ applies the NEQ predicate on the "payload_size" field.
|
||||
func PayloadSizeNEQ(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldPayloadSize, v))
|
||||
}
|
||||
|
||||
// PayloadSizeIn applies the In predicate on the "payload_size" field.
|
||||
func PayloadSizeIn(vs ...int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldPayloadSize, vs...))
|
||||
}
|
||||
|
||||
// PayloadSizeNotIn applies the NotIn predicate on the "payload_size" field.
|
||||
func PayloadSizeNotIn(vs ...int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldPayloadSize, vs...))
|
||||
}
|
||||
|
||||
// PayloadSizeGT applies the GT predicate on the "payload_size" field.
|
||||
func PayloadSizeGT(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldPayloadSize, v))
|
||||
}
|
||||
|
||||
// PayloadSizeGTE applies the GTE predicate on the "payload_size" field.
|
||||
func PayloadSizeGTE(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldPayloadSize, v))
|
||||
}
|
||||
|
||||
// PayloadSizeLT applies the LT predicate on the "payload_size" field.
|
||||
func PayloadSizeLT(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldPayloadSize, v))
|
||||
}
|
||||
|
||||
// PayloadSizeLTE applies the LTE predicate on the "payload_size" field.
|
||||
func PayloadSizeLTE(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldPayloadSize, v))
|
||||
}
|
||||
|
||||
// MetadataSizeEQ applies the EQ predicate on the "metadata_size" field.
|
||||
func MetadataSizeEQ(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldMetadataSize, v))
|
||||
}
|
||||
|
||||
// MetadataSizeNEQ applies the NEQ predicate on the "metadata_size" field.
|
||||
func MetadataSizeNEQ(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldMetadataSize, v))
|
||||
}
|
||||
|
||||
// MetadataSizeIn applies the In predicate on the "metadata_size" field.
|
||||
func MetadataSizeIn(vs ...int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldMetadataSize, vs...))
|
||||
}
|
||||
|
||||
// MetadataSizeNotIn applies the NotIn predicate on the "metadata_size" field.
|
||||
func MetadataSizeNotIn(vs ...int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldMetadataSize, vs...))
|
||||
}
|
||||
|
||||
// MetadataSizeGT applies the GT predicate on the "metadata_size" field.
|
||||
func MetadataSizeGT(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldMetadataSize, v))
|
||||
}
|
||||
|
||||
// MetadataSizeGTE applies the GTE predicate on the "metadata_size" field.
|
||||
func MetadataSizeGTE(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldMetadataSize, v))
|
||||
}
|
||||
|
||||
// MetadataSizeLT applies the LT predicate on the "metadata_size" field.
|
||||
func MetadataSizeLT(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldMetadataSize, v))
|
||||
}
|
||||
|
||||
// MetadataSizeLTE applies the LTE predicate on the "metadata_size" field.
|
||||
func MetadataSizeLTE(v int64) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldMetadataSize, v))
|
||||
}
|
||||
|
||||
// ObjectCountEQ applies the EQ predicate on the "object_count" field.
|
||||
func ObjectCountEQ(v int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldObjectCount, v))
|
||||
}
|
||||
|
||||
// ObjectCountNEQ applies the NEQ predicate on the "object_count" field.
|
||||
func ObjectCountNEQ(v int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldObjectCount, v))
|
||||
}
|
||||
|
||||
// ObjectCountIn applies the In predicate on the "object_count" field.
|
||||
func ObjectCountIn(vs ...int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldObjectCount, vs...))
|
||||
}
|
||||
|
||||
// ObjectCountNotIn applies the NotIn predicate on the "object_count" field.
|
||||
func ObjectCountNotIn(vs ...int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldObjectCount, vs...))
|
||||
}
|
||||
|
||||
// ObjectCountGT applies the GT predicate on the "object_count" field.
|
||||
func ObjectCountGT(v int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldObjectCount, v))
|
||||
}
|
||||
|
||||
// ObjectCountGTE applies the GTE predicate on the "object_count" field.
|
||||
func ObjectCountGTE(v int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldObjectCount, v))
|
||||
}
|
||||
|
||||
// ObjectCountLT applies the LT predicate on the "object_count" field.
|
||||
func ObjectCountLT(v int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldObjectCount, v))
|
||||
}
|
||||
|
||||
// ObjectCountLTE applies the LTE predicate on the "object_count" field.
|
||||
func ObjectCountLTE(v int) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldObjectCount, v))
|
||||
}
|
||||
|
||||
// RemarkEQ applies the EQ predicate on the "remark" field.
|
||||
func RemarkEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkNEQ applies the NEQ predicate on the "remark" field.
|
||||
func RemarkNEQ(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkIn applies the In predicate on the "remark" field.
|
||||
func RemarkIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldRemark, vs...))
|
||||
}
|
||||
|
||||
// RemarkNotIn applies the NotIn predicate on the "remark" field.
|
||||
func RemarkNotIn(vs ...string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldRemark, vs...))
|
||||
}
|
||||
|
||||
// RemarkGT applies the GT predicate on the "remark" field.
|
||||
func RemarkGT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkGTE applies the GTE predicate on the "remark" field.
|
||||
func RemarkGTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkLT applies the LT predicate on the "remark" field.
|
||||
func RemarkLT(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkLTE applies the LTE predicate on the "remark" field.
|
||||
func RemarkLTE(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkContains applies the Contains predicate on the "remark" field.
|
||||
func RemarkContains(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContains(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field.
|
||||
func RemarkHasPrefix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasPrefix(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field.
|
||||
func RemarkHasSuffix(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldHasSuffix(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkIsNil applies the IsNil predicate on the "remark" field.
|
||||
func RemarkIsNil() predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIsNull(FieldRemark))
|
||||
}
|
||||
|
||||
// RemarkNotNil applies the NotNil predicate on the "remark" field.
|
||||
func RemarkNotNil() predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotNull(FieldRemark))
|
||||
}
|
||||
|
||||
// RemarkEqualFold applies the EqualFold predicate on the "remark" field.
|
||||
func RemarkEqualFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEqualFold(FieldRemark, v))
|
||||
}
|
||||
|
||||
// RemarkContainsFold applies the ContainsFold predicate on the "remark" field.
|
||||
func RemarkContainsFold(v string) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldContainsFold(FieldRemark, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// HasCloudflareAccount applies the HasEdge predicate on the "cloudflare_account" edge.
|
||||
func HasCloudflareAccount() predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, CloudflareAccountTable, CloudflareAccountColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasCloudflareAccountWith applies the HasEdge predicate on the "cloudflare_account" edge with a given conditions (other predicates).
|
||||
func HasCloudflareAccountWith(preds ...predicate.CloudflareAccounts) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(func(s *sql.Selector) {
|
||||
step := newCloudflareAccountStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.CloudflareR2) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.CloudflareR2) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.CloudflareR2) predicate.CloudflareR2 {
|
||||
return predicate.CloudflareR2(sql.NotPredicates(p))
|
||||
}
|
||||
444
internal/ent/cloudflarer2_create.go
Normal file
444
internal/ent/cloudflarer2_create.go
Normal file
@ -0,0 +1,444 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CloudflareR2Create is the builder for creating a CloudflareR2 entity.
|
||||
type CloudflareR2Create struct {
|
||||
config
|
||||
mutation *CloudflareR2Mutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner_id" field.
|
||||
func (cr *CloudflareR2Create) SetOwnerID(s string) *CloudflareR2Create {
|
||||
cr.mutation.SetOwnerID(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (cr *CloudflareR2Create) SetName(s string) *CloudflareR2Create {
|
||||
cr.mutation.SetName(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetLocation sets the "location" field.
|
||||
func (cr *CloudflareR2Create) SetLocation(s string) *CloudflareR2Create {
|
||||
cr.mutation.SetLocation(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetStorageClass sets the "storage_class" field.
|
||||
func (cr *CloudflareR2Create) SetStorageClass(s string) *CloudflareR2Create {
|
||||
cr.mutation.SetStorageClass(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (cr *CloudflareR2Create) SetStatus(i int8) *CloudflareR2Create {
|
||||
cr.mutation.SetStatus(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Create) SetNillableStatus(i *int8) *CloudflareR2Create {
|
||||
if i != nil {
|
||||
cr.SetStatus(*i)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetPayloadSize sets the "payload_size" field.
|
||||
func (cr *CloudflareR2Create) SetPayloadSize(i int64) *CloudflareR2Create {
|
||||
cr.mutation.SetPayloadSize(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillablePayloadSize sets the "payload_size" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Create) SetNillablePayloadSize(i *int64) *CloudflareR2Create {
|
||||
if i != nil {
|
||||
cr.SetPayloadSize(*i)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetMetadataSize sets the "metadata_size" field.
|
||||
func (cr *CloudflareR2Create) SetMetadataSize(i int64) *CloudflareR2Create {
|
||||
cr.mutation.SetMetadataSize(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableMetadataSize sets the "metadata_size" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Create) SetNillableMetadataSize(i *int64) *CloudflareR2Create {
|
||||
if i != nil {
|
||||
cr.SetMetadataSize(*i)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetObjectCount sets the "object_count" field.
|
||||
func (cr *CloudflareR2Create) SetObjectCount(i int) *CloudflareR2Create {
|
||||
cr.mutation.SetObjectCount(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableObjectCount sets the "object_count" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Create) SetNillableObjectCount(i *int) *CloudflareR2Create {
|
||||
if i != nil {
|
||||
cr.SetObjectCount(*i)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (cr *CloudflareR2Create) SetRemark(s string) *CloudflareR2Create {
|
||||
cr.mutation.SetRemark(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Create) SetNillableRemark(s *string) *CloudflareR2Create {
|
||||
if s != nil {
|
||||
cr.SetRemark(*s)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (cr *CloudflareR2Create) SetCreatedAt(t time.Time) *CloudflareR2Create {
|
||||
cr.mutation.SetCreatedAt(t)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Create) SetNillableCreatedAt(t *time.Time) *CloudflareR2Create {
|
||||
if t != nil {
|
||||
cr.SetCreatedAt(*t)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (cr *CloudflareR2Create) SetUpdatedAt(t time.Time) *CloudflareR2Create {
|
||||
cr.mutation.SetUpdatedAt(t)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Create) SetNillableUpdatedAt(t *time.Time) *CloudflareR2Create {
|
||||
if t != nil {
|
||||
cr.SetUpdatedAt(*t)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetCloudflareAccountID sets the "cloudflare_account" edge to the CloudflareAccounts entity by ID.
|
||||
func (cr *CloudflareR2Create) SetCloudflareAccountID(id int) *CloudflareR2Create {
|
||||
cr.mutation.SetCloudflareAccountID(id)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetCloudflareAccount sets the "cloudflare_account" edge to the CloudflareAccounts entity.
|
||||
func (cr *CloudflareR2Create) SetCloudflareAccount(c *CloudflareAccounts) *CloudflareR2Create {
|
||||
return cr.SetCloudflareAccountID(c.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the CloudflareR2Mutation object of the builder.
|
||||
func (cr *CloudflareR2Create) Mutation() *CloudflareR2Mutation {
|
||||
return cr.mutation
|
||||
}
|
||||
|
||||
// Save creates the CloudflareR2 in the database.
|
||||
func (cr *CloudflareR2Create) Save(ctx context.Context) (*CloudflareR2, error) {
|
||||
cr.defaults()
|
||||
return withHooks(ctx, cr.sqlSave, cr.mutation, cr.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (cr *CloudflareR2Create) SaveX(ctx context.Context) *CloudflareR2 {
|
||||
v, err := cr.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cr *CloudflareR2Create) Exec(ctx context.Context) error {
|
||||
_, err := cr.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Create) ExecX(ctx context.Context) {
|
||||
if err := cr.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (cr *CloudflareR2Create) defaults() {
|
||||
if _, ok := cr.mutation.Status(); !ok {
|
||||
v := cloudflarer2.DefaultStatus
|
||||
cr.mutation.SetStatus(v)
|
||||
}
|
||||
if _, ok := cr.mutation.PayloadSize(); !ok {
|
||||
v := cloudflarer2.DefaultPayloadSize
|
||||
cr.mutation.SetPayloadSize(v)
|
||||
}
|
||||
if _, ok := cr.mutation.MetadataSize(); !ok {
|
||||
v := cloudflarer2.DefaultMetadataSize
|
||||
cr.mutation.SetMetadataSize(v)
|
||||
}
|
||||
if _, ok := cr.mutation.ObjectCount(); !ok {
|
||||
v := cloudflarer2.DefaultObjectCount
|
||||
cr.mutation.SetObjectCount(v)
|
||||
}
|
||||
if _, ok := cr.mutation.CreatedAt(); !ok {
|
||||
v := cloudflarer2.DefaultCreatedAt()
|
||||
cr.mutation.SetCreatedAt(v)
|
||||
}
|
||||
if _, ok := cr.mutation.UpdatedAt(); !ok {
|
||||
v := cloudflarer2.DefaultUpdatedAt()
|
||||
cr.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cr *CloudflareR2Create) check() error {
|
||||
if _, ok := cr.mutation.OwnerID(); !ok {
|
||||
return &ValidationError{Name: "owner_id", err: errors.New(`ent: missing required field "CloudflareR2.owner_id"`)}
|
||||
}
|
||||
if _, ok := cr.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "CloudflareR2.name"`)}
|
||||
}
|
||||
if v, ok := cr.mutation.Name(); ok {
|
||||
if err := cloudflarer2.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := cr.mutation.Location(); !ok {
|
||||
return &ValidationError{Name: "location", err: errors.New(`ent: missing required field "CloudflareR2.location"`)}
|
||||
}
|
||||
if v, ok := cr.mutation.Location(); ok {
|
||||
if err := cloudflarer2.LocationValidator(v); err != nil {
|
||||
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.location": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := cr.mutation.StorageClass(); !ok {
|
||||
return &ValidationError{Name: "storage_class", err: errors.New(`ent: missing required field "CloudflareR2.storage_class"`)}
|
||||
}
|
||||
if v, ok := cr.mutation.StorageClass(); ok {
|
||||
if err := cloudflarer2.StorageClassValidator(v); err != nil {
|
||||
return &ValidationError{Name: "storage_class", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.storage_class": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := cr.mutation.Status(); !ok {
|
||||
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "CloudflareR2.status"`)}
|
||||
}
|
||||
if _, ok := cr.mutation.PayloadSize(); !ok {
|
||||
return &ValidationError{Name: "payload_size", err: errors.New(`ent: missing required field "CloudflareR2.payload_size"`)}
|
||||
}
|
||||
if _, ok := cr.mutation.MetadataSize(); !ok {
|
||||
return &ValidationError{Name: "metadata_size", err: errors.New(`ent: missing required field "CloudflareR2.metadata_size"`)}
|
||||
}
|
||||
if _, ok := cr.mutation.ObjectCount(); !ok {
|
||||
return &ValidationError{Name: "object_count", err: errors.New(`ent: missing required field "CloudflareR2.object_count"`)}
|
||||
}
|
||||
if _, ok := cr.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "CloudflareR2.created_at"`)}
|
||||
}
|
||||
if _, ok := cr.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "CloudflareR2.updated_at"`)}
|
||||
}
|
||||
if len(cr.mutation.CloudflareAccountIDs()) == 0 {
|
||||
return &ValidationError{Name: "cloudflare_account", err: errors.New(`ent: missing required edge "CloudflareR2.cloudflare_account"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Create) sqlSave(ctx context.Context) (*CloudflareR2, error) {
|
||||
if err := cr.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := cr.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, cr.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
cr.mutation.id = &_node.ID
|
||||
cr.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Create) createSpec() (*CloudflareR2, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &CloudflareR2{config: cr.config}
|
||||
_spec = sqlgraph.NewCreateSpec(cloudflarer2.Table, sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := cr.mutation.OwnerID(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldOwnerID, field.TypeString, value)
|
||||
_node.OwnerID = value
|
||||
}
|
||||
if value, ok := cr.mutation.Name(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := cr.mutation.Location(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldLocation, field.TypeString, value)
|
||||
_node.Location = value
|
||||
}
|
||||
if value, ok := cr.mutation.StorageClass(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldStorageClass, field.TypeString, value)
|
||||
_node.StorageClass = value
|
||||
}
|
||||
if value, ok := cr.mutation.Status(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldStatus, field.TypeInt8, value)
|
||||
_node.Status = value
|
||||
}
|
||||
if value, ok := cr.mutation.PayloadSize(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldPayloadSize, field.TypeInt64, value)
|
||||
_node.PayloadSize = value
|
||||
}
|
||||
if value, ok := cr.mutation.MetadataSize(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldMetadataSize, field.TypeInt64, value)
|
||||
_node.MetadataSize = value
|
||||
}
|
||||
if value, ok := cr.mutation.ObjectCount(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldObjectCount, field.TypeInt, value)
|
||||
_node.ObjectCount = value
|
||||
}
|
||||
if value, ok := cr.mutation.Remark(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldRemark, field.TypeString, value)
|
||||
_node.Remark = value
|
||||
}
|
||||
if value, ok := cr.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
}
|
||||
if value, ok := cr.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldUpdatedAt, field.TypeTime, value)
|
||||
_node.UpdatedAt = value
|
||||
}
|
||||
if nodes := cr.mutation.CloudflareAccountIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: cloudflarer2.CloudflareAccountTable,
|
||||
Columns: []string{cloudflarer2.CloudflareAccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_node.cloudflare_accounts_cloudflare_buckets = &nodes[0]
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// CloudflareR2CreateBulk is the builder for creating many CloudflareR2 entities in bulk.
|
||||
type CloudflareR2CreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*CloudflareR2Create
|
||||
}
|
||||
|
||||
// Save creates the CloudflareR2 entities in the database.
|
||||
func (crb *CloudflareR2CreateBulk) Save(ctx context.Context) ([]*CloudflareR2, error) {
|
||||
if crb.err != nil {
|
||||
return nil, crb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(crb.builders))
|
||||
nodes := make([]*CloudflareR2, len(crb.builders))
|
||||
mutators := make([]Mutator, len(crb.builders))
|
||||
for i := range crb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := crb.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*CloudflareR2Mutation)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
if err := builder.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
builder.mutation = mutation
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, crb.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, crb.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mutation.id = &nodes[i].ID
|
||||
if specs[i].ID.Value != nil {
|
||||
id := specs[i].ID.Value.(int64)
|
||||
nodes[i].ID = int(id)
|
||||
}
|
||||
mutation.done = true
|
||||
return nodes[i], nil
|
||||
})
|
||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||
mut = builder.hooks[i](mut)
|
||||
}
|
||||
mutators[i] = mut
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, crb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (crb *CloudflareR2CreateBulk) SaveX(ctx context.Context) []*CloudflareR2 {
|
||||
v, err := crb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (crb *CloudflareR2CreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := crb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (crb *CloudflareR2CreateBulk) ExecX(ctx context.Context) {
|
||||
if err := crb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
internal/ent/cloudflarer2_delete.go
Normal file
88
internal/ent/cloudflarer2_delete.go
Normal file
@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
"unR2/internal/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CloudflareR2Delete is the builder for deleting a CloudflareR2 entity.
|
||||
type CloudflareR2Delete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CloudflareR2Mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CloudflareR2Delete builder.
|
||||
func (cr *CloudflareR2Delete) Where(ps ...predicate.CloudflareR2) *CloudflareR2Delete {
|
||||
cr.mutation.Where(ps...)
|
||||
return cr
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (cr *CloudflareR2Delete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, cr.sqlExec, cr.mutation, cr.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Delete) ExecX(ctx context.Context) int {
|
||||
n, err := cr.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Delete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(cloudflarer2.Table, sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt))
|
||||
if ps := cr.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, cr.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
cr.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// CloudflareR2DeleteOne is the builder for deleting a single CloudflareR2 entity.
|
||||
type CloudflareR2DeleteOne struct {
|
||||
cr *CloudflareR2Delete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CloudflareR2Delete builder.
|
||||
func (cro *CloudflareR2DeleteOne) Where(ps ...predicate.CloudflareR2) *CloudflareR2DeleteOne {
|
||||
cro.cr.mutation.Where(ps...)
|
||||
return cro
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (cro *CloudflareR2DeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := cro.cr.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{cloudflarer2.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cro *CloudflareR2DeleteOne) ExecX(ctx context.Context) {
|
||||
if err := cro.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
614
internal/ent/cloudflarer2_query.go
Normal file
614
internal/ent/cloudflarer2_query.go
Normal file
@ -0,0 +1,614 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
"unR2/internal/ent/predicate"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CloudflareR2Query is the builder for querying CloudflareR2 entities.
|
||||
type CloudflareR2Query struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []cloudflarer2.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.CloudflareR2
|
||||
withCloudflareAccount *CloudflareAccountsQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the CloudflareR2Query builder.
|
||||
func (cr *CloudflareR2Query) Where(ps ...predicate.CloudflareR2) *CloudflareR2Query {
|
||||
cr.predicates = append(cr.predicates, ps...)
|
||||
return cr
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (cr *CloudflareR2Query) Limit(limit int) *CloudflareR2Query {
|
||||
cr.ctx.Limit = &limit
|
||||
return cr
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (cr *CloudflareR2Query) Offset(offset int) *CloudflareR2Query {
|
||||
cr.ctx.Offset = &offset
|
||||
return cr
|
||||
}
|
||||
|
||||
// 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 (cr *CloudflareR2Query) Unique(unique bool) *CloudflareR2Query {
|
||||
cr.ctx.Unique = &unique
|
||||
return cr
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (cr *CloudflareR2Query) Order(o ...cloudflarer2.OrderOption) *CloudflareR2Query {
|
||||
cr.order = append(cr.order, o...)
|
||||
return cr
|
||||
}
|
||||
|
||||
// QueryCloudflareAccount chains the current query on the "cloudflare_account" edge.
|
||||
func (cr *CloudflareR2Query) QueryCloudflareAccount() *CloudflareAccountsQuery {
|
||||
query := (&CloudflareAccountsClient{config: cr.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := cr.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := cr.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(cloudflarer2.Table, cloudflarer2.FieldID, selector),
|
||||
sqlgraph.To(cloudflareaccounts.Table, cloudflareaccounts.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, cloudflarer2.CloudflareAccountTable, cloudflarer2.CloudflareAccountColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(cr.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// First returns the first CloudflareR2 entity from the query.
|
||||
// Returns a *NotFoundError when no CloudflareR2 was found.
|
||||
func (cr *CloudflareR2Query) First(ctx context.Context) (*CloudflareR2, error) {
|
||||
nodes, err := cr.Limit(1).All(setContextOp(ctx, cr.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{cloudflarer2.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Query) FirstX(ctx context.Context) *CloudflareR2 {
|
||||
node, err := cr.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first CloudflareR2 ID from the query.
|
||||
// Returns a *NotFoundError when no CloudflareR2 ID was found.
|
||||
func (cr *CloudflareR2Query) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = cr.Limit(1).IDs(setContextOp(ctx, cr.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{cloudflarer2.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Query) FirstIDX(ctx context.Context) int {
|
||||
id, err := cr.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single CloudflareR2 entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one CloudflareR2 entity is found.
|
||||
// Returns a *NotFoundError when no CloudflareR2 entities are found.
|
||||
func (cr *CloudflareR2Query) Only(ctx context.Context) (*CloudflareR2, error) {
|
||||
nodes, err := cr.Limit(2).All(setContextOp(ctx, cr.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{cloudflarer2.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{cloudflarer2.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Query) OnlyX(ctx context.Context) *CloudflareR2 {
|
||||
node, err := cr.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only CloudflareR2 ID in the query.
|
||||
// Returns a *NotSingularError when more than one CloudflareR2 ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (cr *CloudflareR2Query) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = cr.Limit(2).IDs(setContextOp(ctx, cr.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{cloudflarer2.Label}
|
||||
default:
|
||||
err = &NotSingularError{cloudflarer2.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Query) OnlyIDX(ctx context.Context) int {
|
||||
id, err := cr.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of CloudflareR2s.
|
||||
func (cr *CloudflareR2Query) All(ctx context.Context) ([]*CloudflareR2, error) {
|
||||
ctx = setContextOp(ctx, cr.ctx, ent.OpQueryAll)
|
||||
if err := cr.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*CloudflareR2, *CloudflareR2Query]()
|
||||
return withInterceptors[[]*CloudflareR2](ctx, cr, qr, cr.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Query) AllX(ctx context.Context) []*CloudflareR2 {
|
||||
nodes, err := cr.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of CloudflareR2 IDs.
|
||||
func (cr *CloudflareR2Query) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if cr.ctx.Unique == nil && cr.path != nil {
|
||||
cr.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, cr.ctx, ent.OpQueryIDs)
|
||||
if err = cr.Select(cloudflarer2.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Query) IDsX(ctx context.Context) []int {
|
||||
ids, err := cr.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (cr *CloudflareR2Query) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, cr.ctx, ent.OpQueryCount)
|
||||
if err := cr.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, cr, querierCount[*CloudflareR2Query](), cr.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Query) CountX(ctx context.Context) int {
|
||||
count, err := cr.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (cr *CloudflareR2Query) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, cr.ctx, ent.OpQueryExist)
|
||||
switch _, err := cr.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||
default:
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Query) ExistX(ctx context.Context) bool {
|
||||
exist, err := cr.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the CloudflareR2Query builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (cr *CloudflareR2Query) Clone() *CloudflareR2Query {
|
||||
if cr == nil {
|
||||
return nil
|
||||
}
|
||||
return &CloudflareR2Query{
|
||||
config: cr.config,
|
||||
ctx: cr.ctx.Clone(),
|
||||
order: append([]cloudflarer2.OrderOption{}, cr.order...),
|
||||
inters: append([]Interceptor{}, cr.inters...),
|
||||
predicates: append([]predicate.CloudflareR2{}, cr.predicates...),
|
||||
withCloudflareAccount: cr.withCloudflareAccount.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: cr.sql.Clone(),
|
||||
path: cr.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithCloudflareAccount tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "cloudflare_account" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (cr *CloudflareR2Query) WithCloudflareAccount(opts ...func(*CloudflareAccountsQuery)) *CloudflareR2Query {
|
||||
query := (&CloudflareAccountsClient{config: cr.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
cr.withCloudflareAccount = query
|
||||
return cr
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// OwnerID string `json:"owner_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CloudflareR2.Query().
|
||||
// GroupBy(cloudflarer2.FieldOwnerID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (cr *CloudflareR2Query) GroupBy(field string, fields ...string) *CloudflareR2GroupBy {
|
||||
cr.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &CloudflareR2GroupBy{build: cr}
|
||||
grbuild.flds = &cr.ctx.Fields
|
||||
grbuild.label = cloudflarer2.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
}
|
||||
|
||||
// Select allows the selection one or more fields/columns for the given query,
|
||||
// instead of selecting all fields in the entity.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// OwnerID string `json:"owner_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CloudflareR2.Query().
|
||||
// Select(cloudflarer2.FieldOwnerID).
|
||||
// Scan(ctx, &v)
|
||||
func (cr *CloudflareR2Query) Select(fields ...string) *CloudflareR2Select {
|
||||
cr.ctx.Fields = append(cr.ctx.Fields, fields...)
|
||||
sbuild := &CloudflareR2Select{CloudflareR2Query: cr}
|
||||
sbuild.label = cloudflarer2.Label
|
||||
sbuild.flds, sbuild.scan = &cr.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a CloudflareR2Select configured with the given aggregations.
|
||||
func (cr *CloudflareR2Query) Aggregate(fns ...AggregateFunc) *CloudflareR2Select {
|
||||
return cr.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Query) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range cr.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, cr); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range cr.ctx.Fields {
|
||||
if !cloudflarer2.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if cr.path != nil {
|
||||
prev, err := cr.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cr.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Query) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CloudflareR2, error) {
|
||||
var (
|
||||
nodes = []*CloudflareR2{}
|
||||
withFKs = cr.withFKs
|
||||
_spec = cr.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
cr.withCloudflareAccount != nil,
|
||||
}
|
||||
)
|
||||
if cr.withCloudflareAccount != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, cloudflarer2.ForeignKeys...)
|
||||
}
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*CloudflareR2).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &CloudflareR2{config: cr.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, cr.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := cr.withCloudflareAccount; query != nil {
|
||||
if err := cr.loadCloudflareAccount(ctx, query, nodes, nil,
|
||||
func(n *CloudflareR2, e *CloudflareAccounts) { n.Edges.CloudflareAccount = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Query) loadCloudflareAccount(ctx context.Context, query *CloudflareAccountsQuery, nodes []*CloudflareR2, init func(*CloudflareR2), assign func(*CloudflareR2, *CloudflareAccounts)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*CloudflareR2)
|
||||
for i := range nodes {
|
||||
if nodes[i].cloudflare_accounts_cloudflare_buckets == nil {
|
||||
continue
|
||||
}
|
||||
fk := *nodes[i].cloudflare_accounts_cloudflare_buckets
|
||||
if _, ok := nodeids[fk]; !ok {
|
||||
ids = append(ids, fk)
|
||||
}
|
||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
query.Where(cloudflareaccounts.IDIn(ids...))
|
||||
neighbors, err := query.All(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, n := range neighbors {
|
||||
nodes, ok := nodeids[n.ID]
|
||||
if !ok {
|
||||
return fmt.Errorf(`unexpected foreign-key "cloudflare_accounts_cloudflare_buckets" returned %v`, n.ID)
|
||||
}
|
||||
for i := range nodes {
|
||||
assign(nodes[i], n)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Query) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := cr.querySpec()
|
||||
_spec.Node.Columns = cr.ctx.Fields
|
||||
if len(cr.ctx.Fields) > 0 {
|
||||
_spec.Unique = cr.ctx.Unique != nil && *cr.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, cr.driver, _spec)
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Query) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(cloudflarer2.Table, cloudflarer2.Columns, sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt))
|
||||
_spec.From = cr.sql
|
||||
if unique := cr.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if cr.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := cr.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, cloudflarer2.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != cloudflarer2.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := cr.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := cr.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := cr.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := cr.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Query) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(cr.driver.Dialect())
|
||||
t1 := builder.Table(cloudflarer2.Table)
|
||||
columns := cr.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = cloudflarer2.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if cr.sql != nil {
|
||||
selector = cr.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if cr.ctx.Unique != nil && *cr.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range cr.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range cr.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := cr.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := cr.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// CloudflareR2GroupBy is the group-by builder for CloudflareR2 entities.
|
||||
type CloudflareR2GroupBy struct {
|
||||
selector
|
||||
build *CloudflareR2Query
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (crb *CloudflareR2GroupBy) Aggregate(fns ...AggregateFunc) *CloudflareR2GroupBy {
|
||||
crb.fns = append(crb.fns, fns...)
|
||||
return crb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (crb *CloudflareR2GroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, crb.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := crb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*CloudflareR2Query, *CloudflareR2GroupBy](ctx, crb.build, crb, crb.build.inters, v)
|
||||
}
|
||||
|
||||
func (crb *CloudflareR2GroupBy) sqlScan(ctx context.Context, root *CloudflareR2Query, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(crb.fns))
|
||||
for _, fn := range crb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*crb.flds)+len(crb.fns))
|
||||
for _, f := range *crb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*crb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := crb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// CloudflareR2Select is the builder for selecting fields of CloudflareR2 entities.
|
||||
type CloudflareR2Select struct {
|
||||
*CloudflareR2Query
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (cr *CloudflareR2Select) Aggregate(fns ...AggregateFunc) *CloudflareR2Select {
|
||||
cr.fns = append(cr.fns, fns...)
|
||||
return cr
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (cr *CloudflareR2Select) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, cr.ctx, ent.OpQuerySelect)
|
||||
if err := cr.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*CloudflareR2Query, *CloudflareR2Select](ctx, cr.CloudflareR2Query, cr, cr.inters, v)
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Select) sqlScan(ctx context.Context, root *CloudflareR2Query, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(cr.fns))
|
||||
for _, fn := range cr.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*cr.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
selector.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := cr.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
761
internal/ent/cloudflarer2_update.go
Normal file
761
internal/ent/cloudflarer2_update.go
Normal file
@ -0,0 +1,761 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
"unR2/internal/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// CloudflareR2Update is the builder for updating CloudflareR2 entities.
|
||||
type CloudflareR2Update struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *CloudflareR2Mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CloudflareR2Update builder.
|
||||
func (cr *CloudflareR2Update) Where(ps ...predicate.CloudflareR2) *CloudflareR2Update {
|
||||
cr.mutation.Where(ps...)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner_id" field.
|
||||
func (cr *CloudflareR2Update) SetOwnerID(s string) *CloudflareR2Update {
|
||||
cr.mutation.SetOwnerID(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableOwnerID sets the "owner_id" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillableOwnerID(s *string) *CloudflareR2Update {
|
||||
if s != nil {
|
||||
cr.SetOwnerID(*s)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (cr *CloudflareR2Update) SetName(s string) *CloudflareR2Update {
|
||||
cr.mutation.SetName(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillableName(s *string) *CloudflareR2Update {
|
||||
if s != nil {
|
||||
cr.SetName(*s)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetLocation sets the "location" field.
|
||||
func (cr *CloudflareR2Update) SetLocation(s string) *CloudflareR2Update {
|
||||
cr.mutation.SetLocation(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableLocation sets the "location" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillableLocation(s *string) *CloudflareR2Update {
|
||||
if s != nil {
|
||||
cr.SetLocation(*s)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetStorageClass sets the "storage_class" field.
|
||||
func (cr *CloudflareR2Update) SetStorageClass(s string) *CloudflareR2Update {
|
||||
cr.mutation.SetStorageClass(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableStorageClass sets the "storage_class" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillableStorageClass(s *string) *CloudflareR2Update {
|
||||
if s != nil {
|
||||
cr.SetStorageClass(*s)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (cr *CloudflareR2Update) SetStatus(i int8) *CloudflareR2Update {
|
||||
cr.mutation.ResetStatus()
|
||||
cr.mutation.SetStatus(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillableStatus(i *int8) *CloudflareR2Update {
|
||||
if i != nil {
|
||||
cr.SetStatus(*i)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// AddStatus adds i to the "status" field.
|
||||
func (cr *CloudflareR2Update) AddStatus(i int8) *CloudflareR2Update {
|
||||
cr.mutation.AddStatus(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetPayloadSize sets the "payload_size" field.
|
||||
func (cr *CloudflareR2Update) SetPayloadSize(i int64) *CloudflareR2Update {
|
||||
cr.mutation.ResetPayloadSize()
|
||||
cr.mutation.SetPayloadSize(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillablePayloadSize sets the "payload_size" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillablePayloadSize(i *int64) *CloudflareR2Update {
|
||||
if i != nil {
|
||||
cr.SetPayloadSize(*i)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// AddPayloadSize adds i to the "payload_size" field.
|
||||
func (cr *CloudflareR2Update) AddPayloadSize(i int64) *CloudflareR2Update {
|
||||
cr.mutation.AddPayloadSize(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetMetadataSize sets the "metadata_size" field.
|
||||
func (cr *CloudflareR2Update) SetMetadataSize(i int64) *CloudflareR2Update {
|
||||
cr.mutation.ResetMetadataSize()
|
||||
cr.mutation.SetMetadataSize(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableMetadataSize sets the "metadata_size" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillableMetadataSize(i *int64) *CloudflareR2Update {
|
||||
if i != nil {
|
||||
cr.SetMetadataSize(*i)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// AddMetadataSize adds i to the "metadata_size" field.
|
||||
func (cr *CloudflareR2Update) AddMetadataSize(i int64) *CloudflareR2Update {
|
||||
cr.mutation.AddMetadataSize(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetObjectCount sets the "object_count" field.
|
||||
func (cr *CloudflareR2Update) SetObjectCount(i int) *CloudflareR2Update {
|
||||
cr.mutation.ResetObjectCount()
|
||||
cr.mutation.SetObjectCount(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableObjectCount sets the "object_count" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillableObjectCount(i *int) *CloudflareR2Update {
|
||||
if i != nil {
|
||||
cr.SetObjectCount(*i)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// AddObjectCount adds i to the "object_count" field.
|
||||
func (cr *CloudflareR2Update) AddObjectCount(i int) *CloudflareR2Update {
|
||||
cr.mutation.AddObjectCount(i)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (cr *CloudflareR2Update) SetRemark(s string) *CloudflareR2Update {
|
||||
cr.mutation.SetRemark(s)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (cr *CloudflareR2Update) SetNillableRemark(s *string) *CloudflareR2Update {
|
||||
if s != nil {
|
||||
cr.SetRemark(*s)
|
||||
}
|
||||
return cr
|
||||
}
|
||||
|
||||
// ClearRemark clears the value of the "remark" field.
|
||||
func (cr *CloudflareR2Update) ClearRemark() *CloudflareR2Update {
|
||||
cr.mutation.ClearRemark()
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (cr *CloudflareR2Update) SetUpdatedAt(t time.Time) *CloudflareR2Update {
|
||||
cr.mutation.SetUpdatedAt(t)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetCloudflareAccountID sets the "cloudflare_account" edge to the CloudflareAccounts entity by ID.
|
||||
func (cr *CloudflareR2Update) SetCloudflareAccountID(id int) *CloudflareR2Update {
|
||||
cr.mutation.SetCloudflareAccountID(id)
|
||||
return cr
|
||||
}
|
||||
|
||||
// SetCloudflareAccount sets the "cloudflare_account" edge to the CloudflareAccounts entity.
|
||||
func (cr *CloudflareR2Update) SetCloudflareAccount(c *CloudflareAccounts) *CloudflareR2Update {
|
||||
return cr.SetCloudflareAccountID(c.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the CloudflareR2Mutation object of the builder.
|
||||
func (cr *CloudflareR2Update) Mutation() *CloudflareR2Mutation {
|
||||
return cr.mutation
|
||||
}
|
||||
|
||||
// ClearCloudflareAccount clears the "cloudflare_account" edge to the CloudflareAccounts entity.
|
||||
func (cr *CloudflareR2Update) ClearCloudflareAccount() *CloudflareR2Update {
|
||||
cr.mutation.ClearCloudflareAccount()
|
||||
return cr
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (cr *CloudflareR2Update) Save(ctx context.Context) (int, error) {
|
||||
cr.defaults()
|
||||
return withHooks(ctx, cr.sqlSave, cr.mutation, cr.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Update) SaveX(ctx context.Context) int {
|
||||
affected, err := cr.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cr *CloudflareR2Update) Exec(ctx context.Context) error {
|
||||
_, err := cr.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cr *CloudflareR2Update) ExecX(ctx context.Context) {
|
||||
if err := cr.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (cr *CloudflareR2Update) defaults() {
|
||||
if _, ok := cr.mutation.UpdatedAt(); !ok {
|
||||
v := cloudflarer2.UpdateDefaultUpdatedAt()
|
||||
cr.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cr *CloudflareR2Update) check() error {
|
||||
if v, ok := cr.mutation.Name(); ok {
|
||||
if err := cloudflarer2.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := cr.mutation.Location(); ok {
|
||||
if err := cloudflarer2.LocationValidator(v); err != nil {
|
||||
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.location": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := cr.mutation.StorageClass(); ok {
|
||||
if err := cloudflarer2.StorageClassValidator(v); err != nil {
|
||||
return &ValidationError{Name: "storage_class", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.storage_class": %w`, err)}
|
||||
}
|
||||
}
|
||||
if cr.mutation.CloudflareAccountCleared() && len(cr.mutation.CloudflareAccountIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "CloudflareR2.cloudflare_account"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cr *CloudflareR2Update) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := cr.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(cloudflarer2.Table, cloudflarer2.Columns, sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt))
|
||||
if ps := cr.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cr.mutation.OwnerID(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldOwnerID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cr.mutation.Name(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cr.mutation.Location(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldLocation, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cr.mutation.StorageClass(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldStorageClass, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cr.mutation.Status(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldStatus, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := cr.mutation.AddedStatus(); ok {
|
||||
_spec.AddField(cloudflarer2.FieldStatus, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := cr.mutation.PayloadSize(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldPayloadSize, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := cr.mutation.AddedPayloadSize(); ok {
|
||||
_spec.AddField(cloudflarer2.FieldPayloadSize, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := cr.mutation.MetadataSize(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldMetadataSize, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := cr.mutation.AddedMetadataSize(); ok {
|
||||
_spec.AddField(cloudflarer2.FieldMetadataSize, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := cr.mutation.ObjectCount(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldObjectCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := cr.mutation.AddedObjectCount(); ok {
|
||||
_spec.AddField(cloudflarer2.FieldObjectCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := cr.mutation.Remark(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
if cr.mutation.RemarkCleared() {
|
||||
_spec.ClearField(cloudflarer2.FieldRemark, field.TypeString)
|
||||
}
|
||||
if value, ok := cr.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if cr.mutation.CloudflareAccountCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: cloudflarer2.CloudflareAccountTable,
|
||||
Columns: []string{cloudflarer2.CloudflareAccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cr.mutation.CloudflareAccountIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: cloudflarer2.CloudflareAccountTable,
|
||||
Columns: []string{cloudflarer2.CloudflareAccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, cr.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{cloudflarer2.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
cr.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// CloudflareR2UpdateOne is the builder for updating a single CloudflareR2 entity.
|
||||
type CloudflareR2UpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *CloudflareR2Mutation
|
||||
}
|
||||
|
||||
// SetOwnerID sets the "owner_id" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetOwnerID(s string) *CloudflareR2UpdateOne {
|
||||
cro.mutation.SetOwnerID(s)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillableOwnerID sets the "owner_id" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillableOwnerID(s *string) *CloudflareR2UpdateOne {
|
||||
if s != nil {
|
||||
cro.SetOwnerID(*s)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetName(s string) *CloudflareR2UpdateOne {
|
||||
cro.mutation.SetName(s)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillableName(s *string) *CloudflareR2UpdateOne {
|
||||
if s != nil {
|
||||
cro.SetName(*s)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetLocation sets the "location" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetLocation(s string) *CloudflareR2UpdateOne {
|
||||
cro.mutation.SetLocation(s)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillableLocation sets the "location" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillableLocation(s *string) *CloudflareR2UpdateOne {
|
||||
if s != nil {
|
||||
cro.SetLocation(*s)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetStorageClass sets the "storage_class" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetStorageClass(s string) *CloudflareR2UpdateOne {
|
||||
cro.mutation.SetStorageClass(s)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillableStorageClass sets the "storage_class" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillableStorageClass(s *string) *CloudflareR2UpdateOne {
|
||||
if s != nil {
|
||||
cro.SetStorageClass(*s)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetStatus sets the "status" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetStatus(i int8) *CloudflareR2UpdateOne {
|
||||
cro.mutation.ResetStatus()
|
||||
cro.mutation.SetStatus(i)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillableStatus(i *int8) *CloudflareR2UpdateOne {
|
||||
if i != nil {
|
||||
cro.SetStatus(*i)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// AddStatus adds i to the "status" field.
|
||||
func (cro *CloudflareR2UpdateOne) AddStatus(i int8) *CloudflareR2UpdateOne {
|
||||
cro.mutation.AddStatus(i)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetPayloadSize sets the "payload_size" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetPayloadSize(i int64) *CloudflareR2UpdateOne {
|
||||
cro.mutation.ResetPayloadSize()
|
||||
cro.mutation.SetPayloadSize(i)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillablePayloadSize sets the "payload_size" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillablePayloadSize(i *int64) *CloudflareR2UpdateOne {
|
||||
if i != nil {
|
||||
cro.SetPayloadSize(*i)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// AddPayloadSize adds i to the "payload_size" field.
|
||||
func (cro *CloudflareR2UpdateOne) AddPayloadSize(i int64) *CloudflareR2UpdateOne {
|
||||
cro.mutation.AddPayloadSize(i)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetMetadataSize sets the "metadata_size" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetMetadataSize(i int64) *CloudflareR2UpdateOne {
|
||||
cro.mutation.ResetMetadataSize()
|
||||
cro.mutation.SetMetadataSize(i)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillableMetadataSize sets the "metadata_size" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillableMetadataSize(i *int64) *CloudflareR2UpdateOne {
|
||||
if i != nil {
|
||||
cro.SetMetadataSize(*i)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// AddMetadataSize adds i to the "metadata_size" field.
|
||||
func (cro *CloudflareR2UpdateOne) AddMetadataSize(i int64) *CloudflareR2UpdateOne {
|
||||
cro.mutation.AddMetadataSize(i)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetObjectCount sets the "object_count" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetObjectCount(i int) *CloudflareR2UpdateOne {
|
||||
cro.mutation.ResetObjectCount()
|
||||
cro.mutation.SetObjectCount(i)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillableObjectCount sets the "object_count" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillableObjectCount(i *int) *CloudflareR2UpdateOne {
|
||||
if i != nil {
|
||||
cro.SetObjectCount(*i)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// AddObjectCount adds i to the "object_count" field.
|
||||
func (cro *CloudflareR2UpdateOne) AddObjectCount(i int) *CloudflareR2UpdateOne {
|
||||
cro.mutation.AddObjectCount(i)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetRemark sets the "remark" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetRemark(s string) *CloudflareR2UpdateOne {
|
||||
cro.mutation.SetRemark(s)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
||||
func (cro *CloudflareR2UpdateOne) SetNillableRemark(s *string) *CloudflareR2UpdateOne {
|
||||
if s != nil {
|
||||
cro.SetRemark(*s)
|
||||
}
|
||||
return cro
|
||||
}
|
||||
|
||||
// ClearRemark clears the value of the "remark" field.
|
||||
func (cro *CloudflareR2UpdateOne) ClearRemark() *CloudflareR2UpdateOne {
|
||||
cro.mutation.ClearRemark()
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (cro *CloudflareR2UpdateOne) SetUpdatedAt(t time.Time) *CloudflareR2UpdateOne {
|
||||
cro.mutation.SetUpdatedAt(t)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetCloudflareAccountID sets the "cloudflare_account" edge to the CloudflareAccounts entity by ID.
|
||||
func (cro *CloudflareR2UpdateOne) SetCloudflareAccountID(id int) *CloudflareR2UpdateOne {
|
||||
cro.mutation.SetCloudflareAccountID(id)
|
||||
return cro
|
||||
}
|
||||
|
||||
// SetCloudflareAccount sets the "cloudflare_account" edge to the CloudflareAccounts entity.
|
||||
func (cro *CloudflareR2UpdateOne) SetCloudflareAccount(c *CloudflareAccounts) *CloudflareR2UpdateOne {
|
||||
return cro.SetCloudflareAccountID(c.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the CloudflareR2Mutation object of the builder.
|
||||
func (cro *CloudflareR2UpdateOne) Mutation() *CloudflareR2Mutation {
|
||||
return cro.mutation
|
||||
}
|
||||
|
||||
// ClearCloudflareAccount clears the "cloudflare_account" edge to the CloudflareAccounts entity.
|
||||
func (cro *CloudflareR2UpdateOne) ClearCloudflareAccount() *CloudflareR2UpdateOne {
|
||||
cro.mutation.ClearCloudflareAccount()
|
||||
return cro
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the CloudflareR2Update builder.
|
||||
func (cro *CloudflareR2UpdateOne) Where(ps ...predicate.CloudflareR2) *CloudflareR2UpdateOne {
|
||||
cro.mutation.Where(ps...)
|
||||
return cro
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (cro *CloudflareR2UpdateOne) Select(field string, fields ...string) *CloudflareR2UpdateOne {
|
||||
cro.fields = append([]string{field}, fields...)
|
||||
return cro
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated CloudflareR2 entity.
|
||||
func (cro *CloudflareR2UpdateOne) Save(ctx context.Context) (*CloudflareR2, error) {
|
||||
cro.defaults()
|
||||
return withHooks(ctx, cro.sqlSave, cro.mutation, cro.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cro *CloudflareR2UpdateOne) SaveX(ctx context.Context) *CloudflareR2 {
|
||||
node, err := cro.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (cro *CloudflareR2UpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := cro.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cro *CloudflareR2UpdateOne) ExecX(ctx context.Context) {
|
||||
if err := cro.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (cro *CloudflareR2UpdateOne) defaults() {
|
||||
if _, ok := cro.mutation.UpdatedAt(); !ok {
|
||||
v := cloudflarer2.UpdateDefaultUpdatedAt()
|
||||
cro.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cro *CloudflareR2UpdateOne) check() error {
|
||||
if v, ok := cro.mutation.Name(); ok {
|
||||
if err := cloudflarer2.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := cro.mutation.Location(); ok {
|
||||
if err := cloudflarer2.LocationValidator(v); err != nil {
|
||||
return &ValidationError{Name: "location", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.location": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := cro.mutation.StorageClass(); ok {
|
||||
if err := cloudflarer2.StorageClassValidator(v); err != nil {
|
||||
return &ValidationError{Name: "storage_class", err: fmt.Errorf(`ent: validator failed for field "CloudflareR2.storage_class": %w`, err)}
|
||||
}
|
||||
}
|
||||
if cro.mutation.CloudflareAccountCleared() && len(cro.mutation.CloudflareAccountIDs()) > 0 {
|
||||
return errors.New(`ent: clearing a required unique edge "CloudflareR2.cloudflare_account"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cro *CloudflareR2UpdateOne) sqlSave(ctx context.Context) (_node *CloudflareR2, err error) {
|
||||
if err := cro.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(cloudflarer2.Table, cloudflarer2.Columns, sqlgraph.NewFieldSpec(cloudflarer2.FieldID, field.TypeInt))
|
||||
id, ok := cro.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CloudflareR2.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := cro.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, cloudflarer2.FieldID)
|
||||
for _, f := range fields {
|
||||
if !cloudflarer2.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != cloudflarer2.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := cro.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cro.mutation.OwnerID(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldOwnerID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cro.mutation.Name(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cro.mutation.Location(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldLocation, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cro.mutation.StorageClass(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldStorageClass, field.TypeString, value)
|
||||
}
|
||||
if value, ok := cro.mutation.Status(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldStatus, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := cro.mutation.AddedStatus(); ok {
|
||||
_spec.AddField(cloudflarer2.FieldStatus, field.TypeInt8, value)
|
||||
}
|
||||
if value, ok := cro.mutation.PayloadSize(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldPayloadSize, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := cro.mutation.AddedPayloadSize(); ok {
|
||||
_spec.AddField(cloudflarer2.FieldPayloadSize, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := cro.mutation.MetadataSize(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldMetadataSize, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := cro.mutation.AddedMetadataSize(); ok {
|
||||
_spec.AddField(cloudflarer2.FieldMetadataSize, field.TypeInt64, value)
|
||||
}
|
||||
if value, ok := cro.mutation.ObjectCount(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldObjectCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := cro.mutation.AddedObjectCount(); ok {
|
||||
_spec.AddField(cloudflarer2.FieldObjectCount, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := cro.mutation.Remark(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldRemark, field.TypeString, value)
|
||||
}
|
||||
if cro.mutation.RemarkCleared() {
|
||||
_spec.ClearField(cloudflarer2.FieldRemark, field.TypeString)
|
||||
}
|
||||
if value, ok := cro.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(cloudflarer2.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if cro.mutation.CloudflareAccountCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: cloudflarer2.CloudflareAccountTable,
|
||||
Columns: []string{cloudflarer2.CloudflareAccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cro.mutation.CloudflareAccountIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: cloudflarer2.CloudflareAccountTable,
|
||||
Columns: []string{cloudflarer2.CloudflareAccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(cloudflareaccounts.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &CloudflareR2{config: cro.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, cro.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{cloudflarer2.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
cro.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
610
internal/ent/ent.go
Normal file
610
internal/ent/ent.go
Normal file
@ -0,0 +1,610 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
|
||||
// ent aliases to avoid import conflicts in user's code.
|
||||
type (
|
||||
Op = ent.Op
|
||||
Hook = ent.Hook
|
||||
Value = ent.Value
|
||||
Query = ent.Query
|
||||
QueryContext = ent.QueryContext
|
||||
Querier = ent.Querier
|
||||
QuerierFunc = ent.QuerierFunc
|
||||
Interceptor = ent.Interceptor
|
||||
InterceptFunc = ent.InterceptFunc
|
||||
Traverser = ent.Traverser
|
||||
TraverseFunc = ent.TraverseFunc
|
||||
Policy = ent.Policy
|
||||
Mutator = ent.Mutator
|
||||
Mutation = ent.Mutation
|
||||
MutateFunc = ent.MutateFunc
|
||||
)
|
||||
|
||||
type clientCtxKey struct{}
|
||||
|
||||
// FromContext returns a Client stored inside a context, or nil if there isn't one.
|
||||
func FromContext(ctx context.Context) *Client {
|
||||
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewContext returns a new context with the given Client attached.
|
||||
func NewContext(parent context.Context, c *Client) context.Context {
|
||||
return context.WithValue(parent, clientCtxKey{}, c)
|
||||
}
|
||||
|
||||
type txCtxKey struct{}
|
||||
|
||||
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
|
||||
func TxFromContext(ctx context.Context) *Tx {
|
||||
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||
return tx
|
||||
}
|
||||
|
||||
// NewTxContext returns a new context with the given Tx attached.
|
||||
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||
return context.WithValue(parent, txCtxKey{}, tx)
|
||||
}
|
||||
|
||||
// OrderFunc applies an ordering on the sql selector.
|
||||
// Deprecated: Use Asc/Desc functions or the package builders instead.
|
||||
type OrderFunc func(*sql.Selector)
|
||||
|
||||
var (
|
||||
initCheck sync.Once
|
||||
columnCheck sql.ColumnCheck
|
||||
)
|
||||
|
||||
// checkColumn checks if the column exists in the given table.
|
||||
func checkColumn(table, column string) error {
|
||||
initCheck.Do(func() {
|
||||
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||
cloudflareaccounts.Table: cloudflareaccounts.ValidColumn,
|
||||
cloudflarer2.Table: cloudflarer2.ValidColumn,
|
||||
})
|
||||
})
|
||||
return columnCheck(table, column)
|
||||
}
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
func Asc(fields ...string) func(*sql.Selector) {
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Asc(s.C(f)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Desc applies the given fields in DESC order.
|
||||
func Desc(fields ...string) func(*sql.Selector) {
|
||||
return func(s *sql.Selector) {
|
||||
for _, f := range fields {
|
||||
if err := checkColumn(s.TableName(), f); err != nil {
|
||||
s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)})
|
||||
}
|
||||
s.OrderBy(sql.Desc(s.C(f)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// AggregateFunc applies an aggregation step on the group-by traversal/selector.
|
||||
type AggregateFunc func(*sql.Selector) string
|
||||
|
||||
// As is a pseudo aggregation function for renaming another other functions with custom names. For example:
|
||||
//
|
||||
// GroupBy(field1, field2).
|
||||
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
|
||||
// Scan(ctx, &v)
|
||||
func As(fn AggregateFunc, end string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.As(fn(s), end)
|
||||
}
|
||||
}
|
||||
|
||||
// Count applies the "count" aggregation function on each group.
|
||||
func Count() AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
return sql.Count("*")
|
||||
}
|
||||
}
|
||||
|
||||
// Max applies the "max" aggregation function on the given field of each group.
|
||||
func Max(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Max(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Mean applies the "mean" aggregation function on the given field of each group.
|
||||
func Mean(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Avg(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Min applies the "min" aggregation function on the given field of each group.
|
||||
func Min(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Min(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// Sum applies the "sum" aggregation function on the given field of each group.
|
||||
func Sum(field string) AggregateFunc {
|
||||
return func(s *sql.Selector) string {
|
||||
if err := checkColumn(s.TableName(), field); err != nil {
|
||||
s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)})
|
||||
return ""
|
||||
}
|
||||
return sql.Sum(s.C(field))
|
||||
}
|
||||
}
|
||||
|
||||
// ValidationError returns when validating a field or edge fails.
|
||||
type ValidationError struct {
|
||||
Name string // Field or edge name.
|
||||
err error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *ValidationError) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ValidationError) Unwrap() error {
|
||||
return e.err
|
||||
}
|
||||
|
||||
// IsValidationError returns a boolean indicating whether the error is a validation error.
|
||||
func IsValidationError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ValidationError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotFoundError returns when trying to fetch a specific entity and it was not found in the database.
|
||||
type NotFoundError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotFoundError) Error() string {
|
||||
return "ent: " + e.label + " not found"
|
||||
}
|
||||
|
||||
// IsNotFound returns a boolean indicating whether the error is a not found error.
|
||||
func IsNotFound(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotFoundError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// MaskNotFound masks not found error.
|
||||
func MaskNotFound(err error) error {
|
||||
if IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database.
|
||||
type NotSingularError struct {
|
||||
label string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotSingularError) Error() string {
|
||||
return "ent: " + e.label + " not singular"
|
||||
}
|
||||
|
||||
// IsNotSingular returns a boolean indicating whether the error is a not singular error.
|
||||
func IsNotSingular(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotSingularError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// NotLoadedError returns when trying to get a node that was not loaded by the query.
|
||||
type NotLoadedError struct {
|
||||
edge string
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e *NotLoadedError) Error() string {
|
||||
return "ent: " + e.edge + " edge was not loaded"
|
||||
}
|
||||
|
||||
// IsNotLoaded returns a boolean indicating whether the error is a not loaded error.
|
||||
func IsNotLoaded(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *NotLoadedError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// ConstraintError returns when trying to create/update one or more entities and
|
||||
// one or more of their constraints failed. For example, violation of edge or
|
||||
// field uniqueness.
|
||||
type ConstraintError struct {
|
||||
msg string
|
||||
wrap error
|
||||
}
|
||||
|
||||
// Error implements the error interface.
|
||||
func (e ConstraintError) Error() string {
|
||||
return "ent: constraint failed: " + e.msg
|
||||
}
|
||||
|
||||
// Unwrap implements the errors.Wrapper interface.
|
||||
func (e *ConstraintError) Unwrap() error {
|
||||
return e.wrap
|
||||
}
|
||||
|
||||
// IsConstraintError returns a boolean indicating whether the error is a constraint failure.
|
||||
func IsConstraintError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
var e *ConstraintError
|
||||
return errors.As(err, &e)
|
||||
}
|
||||
|
||||
// selector embedded by the different Select/GroupBy builders.
|
||||
type selector struct {
|
||||
label string
|
||||
flds *[]string
|
||||
fns []AggregateFunc
|
||||
scan func(context.Context, any) error
|
||||
}
|
||||
|
||||
// ScanX is like Scan, but panics if an error occurs.
|
||||
func (s *selector) ScanX(ctx context.Context, v any) {
|
||||
if err := s.scan(ctx, v); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Strings(ctx context.Context) ([]string, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []string
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// StringsX is like Strings, but panics if an error occurs.
|
||||
func (s *selector) StringsX(ctx context.Context) []string {
|
||||
v, err := s.Strings(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) String(ctx context.Context) (_ string, err error) {
|
||||
var v []string
|
||||
if v, err = s.Strings(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// StringX is like String, but panics if an error occurs.
|
||||
func (s *selector) StringX(ctx context.Context) string {
|
||||
v, err := s.String(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Ints(ctx context.Context) ([]int, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []int
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// IntsX is like Ints, but panics if an error occurs.
|
||||
func (s *selector) IntsX(ctx context.Context) []int {
|
||||
v, err := s.Ints(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Int(ctx context.Context) (_ int, err error) {
|
||||
var v []int
|
||||
if v, err = s.Ints(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// IntX is like Int, but panics if an error occurs.
|
||||
func (s *selector) IntX(ctx context.Context) int {
|
||||
v, err := s.Int(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []float64
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// Float64sX is like Float64s, but panics if an error occurs.
|
||||
func (s *selector) Float64sX(ctx context.Context) []float64 {
|
||||
v, err := s.Float64s(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
|
||||
var v []float64
|
||||
if v, err = s.Float64s(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Float64X is like Float64, but panics if an error occurs.
|
||||
func (s *selector) Float64X(ctx context.Context) float64 {
|
||||
v, err := s.Float64(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Bools(ctx context.Context) ([]bool, error) {
|
||||
if len(*s.flds) > 1 {
|
||||
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
|
||||
}
|
||||
var v []bool
|
||||
if err := s.scan(ctx, &v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
// BoolsX is like Bools, but panics if an error occurs.
|
||||
func (s *selector) BoolsX(ctx context.Context) []bool {
|
||||
v, err := s.Bools(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
||||
func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
|
||||
var v []bool
|
||||
if v, err = s.Bools(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(v) {
|
||||
case 1:
|
||||
return v[0], nil
|
||||
case 0:
|
||||
err = &NotFoundError{s.label}
|
||||
default:
|
||||
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// BoolX is like Bool, but panics if an error occurs.
|
||||
func (s *selector) BoolX(ctx context.Context) bool {
|
||||
v, err := s.Bool(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// withHooks invokes the builder operation with the given hooks, if any.
|
||||
func withHooks[V Value, M any, PM interface {
|
||||
*M
|
||||
Mutation
|
||||
}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) {
|
||||
if len(hooks) == 0 {
|
||||
return exec(ctx)
|
||||
}
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutationT, ok := any(m).(PM)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||
}
|
||||
// Set the mutation to the builder.
|
||||
*mutation = *mutationT
|
||||
return exec(ctx)
|
||||
})
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
if hooks[i] == nil {
|
||||
return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)")
|
||||
}
|
||||
mut = hooks[i](mut)
|
||||
}
|
||||
v, err := mut.Mutate(ctx, mutation)
|
||||
if err != nil {
|
||||
return value, err
|
||||
}
|
||||
nv, ok := v.(V)
|
||||
if !ok {
|
||||
return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation)
|
||||
}
|
||||
return nv, nil
|
||||
}
|
||||
|
||||
// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist.
|
||||
func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context {
|
||||
if ent.QueryFromContext(ctx) == nil {
|
||||
qc.Op = op
|
||||
ctx = ent.NewQueryContext(ctx, qc)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func querierAll[V Value, Q interface {
|
||||
sqlAll(context.Context, ...queryHook) (V, error)
|
||||
}]() Querier {
|
||||
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
return query.sqlAll(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func querierCount[Q interface {
|
||||
sqlCount(context.Context) (int, error)
|
||||
}]() Querier {
|
||||
return QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
return query.sqlCount(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) {
|
||||
for i := len(inters) - 1; i >= 0; i-- {
|
||||
qr = inters[i].Intercept(qr)
|
||||
}
|
||||
rv, err := qr.Query(ctx, q)
|
||||
if err != nil {
|
||||
return v, err
|
||||
}
|
||||
vt, ok := rv.(V)
|
||||
if !ok {
|
||||
return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v)
|
||||
}
|
||||
return vt, nil
|
||||
}
|
||||
|
||||
func scanWithInterceptors[Q1 ent.Query, Q2 interface {
|
||||
sqlScan(context.Context, Q1, any) error
|
||||
}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error {
|
||||
rv := reflect.ValueOf(v)
|
||||
var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) {
|
||||
query, ok := q.(Q1)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected query type %T", q)
|
||||
}
|
||||
if err := selectOrGroup.sqlScan(ctx, query, v); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() {
|
||||
return rv.Elem().Interface(), nil
|
||||
}
|
||||
return v, nil
|
||||
})
|
||||
for i := len(inters) - 1; i >= 0; i-- {
|
||||
qr = inters[i].Intercept(qr)
|
||||
}
|
||||
vv, err := qr.Query(ctx, rootQuery)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch rv2 := reflect.ValueOf(vv); {
|
||||
case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer:
|
||||
case rv.Type() == rv2.Type():
|
||||
rv.Elem().Set(rv2.Elem())
|
||||
case rv.Elem().Type() == rv2.Type():
|
||||
rv.Elem().Set(rv2)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// queryHook describes an internal hook for the different sqlAll methods.
|
||||
type queryHook func(context.Context, *sqlgraph.QuerySpec)
|
||||
85
internal/ent/enttest/enttest.go
Normal file
85
internal/ent/enttest/enttest.go
Normal file
@ -0,0 +1,85 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package enttest
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"unR2/internal/ent"
|
||||
// required by schema hooks.
|
||||
_ "unR2/internal/ent/runtime"
|
||||
|
||||
"unR2/internal/ent/migrate"
|
||||
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
type (
|
||||
// TestingT is the interface that is shared between
|
||||
// testing.T and testing.B and used by enttest.
|
||||
TestingT interface {
|
||||
FailNow()
|
||||
Error(...any)
|
||||
}
|
||||
|
||||
// Option configures client creation.
|
||||
Option func(*options)
|
||||
|
||||
options struct {
|
||||
opts []ent.Option
|
||||
migrateOpts []schema.MigrateOption
|
||||
}
|
||||
)
|
||||
|
||||
// WithOptions forwards options to client creation.
|
||||
func WithOptions(opts ...ent.Option) Option {
|
||||
return func(o *options) {
|
||||
o.opts = append(o.opts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithMigrateOptions forwards options to auto migration.
|
||||
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
|
||||
return func(o *options) {
|
||||
o.migrateOpts = append(o.migrateOpts, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
func newOptions(opts []Option) *options {
|
||||
o := &options{}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
}
|
||||
return o
|
||||
}
|
||||
|
||||
// Open calls ent.Open and auto-run migration.
|
||||
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c, err := ent.Open(driverName, dataSourceName, o.opts...)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
migrateSchema(t, c, o)
|
||||
return c
|
||||
}
|
||||
|
||||
// NewClient calls ent.NewClient and auto-run migration.
|
||||
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
||||
o := newOptions(opts)
|
||||
c := ent.NewClient(o.opts...)
|
||||
migrateSchema(t, c, o)
|
||||
return c
|
||||
}
|
||||
func migrateSchema(t TestingT, c *ent.Client, o *options) {
|
||||
tables, err := schema.CopyTables(migrate.Tables)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
|
||||
t.Error(err)
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
3
internal/ent/generate.go
Normal file
3
internal/ent/generate.go
Normal file
@ -0,0 +1,3 @@
|
||||
package ent
|
||||
|
||||
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema
|
||||
210
internal/ent/hook/hook.go
Normal file
210
internal/ent/hook/hook.go
Normal file
@ -0,0 +1,210 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"unR2/internal/ent"
|
||||
)
|
||||
|
||||
// The CloudflareAccountsFunc type is an adapter to allow the use of ordinary
|
||||
// function as CloudflareAccounts mutator.
|
||||
type CloudflareAccountsFunc func(context.Context, *ent.CloudflareAccountsMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f CloudflareAccountsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.CloudflareAccountsMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CloudflareAccountsMutation", m)
|
||||
}
|
||||
|
||||
// The CloudflareR2Func type is an adapter to allow the use of ordinary
|
||||
// function as CloudflareR2 mutator.
|
||||
type CloudflareR2Func func(context.Context, *ent.CloudflareR2Mutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f CloudflareR2Func) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.CloudflareR2Mutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CloudflareR2Mutation", m)
|
||||
}
|
||||
|
||||
// Condition is a hook condition function.
|
||||
type Condition func(context.Context, ent.Mutation) bool
|
||||
|
||||
// And groups conditions with the AND operator.
|
||||
func And(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if !first(ctx, m) || !second(ctx, m) {
|
||||
return false
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if !cond(ctx, m) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Or groups conditions with the OR operator.
|
||||
func Or(first, second Condition, rest ...Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
if first(ctx, m) || second(ctx, m) {
|
||||
return true
|
||||
}
|
||||
for _, cond := range rest {
|
||||
if cond(ctx, m) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Not negates a given condition.
|
||||
func Not(cond Condition) Condition {
|
||||
return func(ctx context.Context, m ent.Mutation) bool {
|
||||
return !cond(ctx, m)
|
||||
}
|
||||
}
|
||||
|
||||
// HasOp is a condition testing mutation operation.
|
||||
func HasOp(op ent.Op) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
return m.Op().Is(op)
|
||||
}
|
||||
}
|
||||
|
||||
// HasAddedFields is a condition validating `.AddedField` on fields.
|
||||
func HasAddedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.AddedField(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasClearedFields is a condition validating `.FieldCleared` on fields.
|
||||
func HasClearedFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if exists := m.FieldCleared(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// HasFields is a condition validating `.Field` on fields.
|
||||
func HasFields(field string, fields ...string) Condition {
|
||||
return func(_ context.Context, m ent.Mutation) bool {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
for _, field := range fields {
|
||||
if _, exists := m.Field(field); !exists {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// If executes the given hook under condition.
|
||||
//
|
||||
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||
func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||
return func(next ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if cond(ctx, m) {
|
||||
return hk(next).Mutate(ctx, m)
|
||||
}
|
||||
return next.Mutate(ctx, m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// On executes the given hook only for the given operation.
|
||||
//
|
||||
// hook.On(Log, ent.Delete|ent.Create)
|
||||
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, HasOp(op))
|
||||
}
|
||||
|
||||
// Unless skips the given hook only for the given operation.
|
||||
//
|
||||
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
||||
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
||||
return If(hk, Not(HasOp(op)))
|
||||
}
|
||||
|
||||
// FixedError is a hook returning a fixed error.
|
||||
func FixedError(err error) ent.Hook {
|
||||
return func(ent.Mutator) ent.Mutator {
|
||||
return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) {
|
||||
return nil, err
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Reject returns a hook that rejects all operations that match op.
|
||||
//
|
||||
// func (T) Hooks() []ent.Hook {
|
||||
// return []ent.Hook{
|
||||
// Reject(ent.Delete|ent.Update),
|
||||
// }
|
||||
// }
|
||||
func Reject(op ent.Op) ent.Hook {
|
||||
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
||||
return On(hk, op)
|
||||
}
|
||||
|
||||
// Chain acts as a list of hooks and is effectively immutable.
|
||||
// Once created, it will always hold the same set of hooks in the same order.
|
||||
type Chain struct {
|
||||
hooks []ent.Hook
|
||||
}
|
||||
|
||||
// NewChain creates a new chain of hooks.
|
||||
func NewChain(hooks ...ent.Hook) Chain {
|
||||
return Chain{append([]ent.Hook(nil), hooks...)}
|
||||
}
|
||||
|
||||
// Hook chains the list of hooks and returns the final hook.
|
||||
func (c Chain) Hook() ent.Hook {
|
||||
return func(mutator ent.Mutator) ent.Mutator {
|
||||
for i := len(c.hooks) - 1; i >= 0; i-- {
|
||||
mutator = c.hooks[i](mutator)
|
||||
}
|
||||
return mutator
|
||||
}
|
||||
}
|
||||
|
||||
// Append extends a chain, adding the specified hook
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Append(hooks ...ent.Hook) Chain {
|
||||
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
|
||||
newHooks = append(newHooks, c.hooks...)
|
||||
newHooks = append(newHooks, hooks...)
|
||||
return Chain{newHooks}
|
||||
}
|
||||
|
||||
// Extend extends a chain, adding the specified chain
|
||||
// as the last ones in the mutation flow.
|
||||
func (c Chain) Extend(chain Chain) Chain {
|
||||
return c.Append(chain.hooks...)
|
||||
}
|
||||
64
internal/ent/migrate/migrate.go
Normal file
64
internal/ent/migrate/migrate.go
Normal file
@ -0,0 +1,64 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
)
|
||||
|
||||
var (
|
||||
// WithGlobalUniqueID sets the universal ids options to the migration.
|
||||
// If this option is enabled, ent migration will allocate a 1<<32 range
|
||||
// for the ids of each entity (table).
|
||||
// Note that this option cannot be applied on tables that already exist.
|
||||
WithGlobalUniqueID = schema.WithGlobalUniqueID
|
||||
// WithDropColumn sets the drop column option to the migration.
|
||||
// If this option is enabled, ent migration will drop old columns
|
||||
// that were used for both fields and edges. This defaults to false.
|
||||
WithDropColumn = schema.WithDropColumn
|
||||
// WithDropIndex sets the drop index option to the migration.
|
||||
// If this option is enabled, ent migration will drop old indexes
|
||||
// that were defined in the schema. This defaults to false.
|
||||
// Note that unique constraints are defined using `UNIQUE INDEX`,
|
||||
// and therefore, it's recommended to enable this option to get more
|
||||
// flexibility in the schema changes.
|
||||
WithDropIndex = schema.WithDropIndex
|
||||
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
|
||||
WithForeignKeys = schema.WithForeignKeys
|
||||
)
|
||||
|
||||
// Schema is the API for creating, migrating and dropping a schema.
|
||||
type Schema struct {
|
||||
drv dialect.Driver
|
||||
}
|
||||
|
||||
// NewSchema creates a new schema client.
|
||||
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||
|
||||
// Create creates all schema resources.
|
||||
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, s, Tables, opts...)
|
||||
}
|
||||
|
||||
// Create creates all table resources using the given schema driver.
|
||||
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
|
||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("ent/migrate: %w", err)
|
||||
}
|
||||
return migrate.Create(ctx, tables...)
|
||||
}
|
||||
|
||||
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||
//
|
||||
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
|
||||
}
|
||||
68
internal/ent/migrate/schema.go
Normal file
68
internal/ent/migrate/schema.go
Normal file
@ -0,0 +1,68 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// CloudflareAccountsColumns holds the columns for the "cloudflare_accounts" table.
|
||||
CloudflareAccountsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "account_id", Type: field.TypeString},
|
||||
{Name: "api_token", Type: field.TypeString, Size: 2147483647},
|
||||
{Name: "email", Type: field.TypeString, Nullable: true},
|
||||
{Name: "status", Type: field.TypeInt8, Default: 1},
|
||||
{Name: "remark", Type: field.TypeString, Nullable: true, Size: 2147483647},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
}
|
||||
// CloudflareAccountsTable holds the schema information for the "cloudflare_accounts" table.
|
||||
CloudflareAccountsTable = &schema.Table{
|
||||
Name: "cloudflare_accounts",
|
||||
Columns: CloudflareAccountsColumns,
|
||||
PrimaryKey: []*schema.Column{CloudflareAccountsColumns[0]},
|
||||
}
|
||||
// CloudflareR2sColumns holds the columns for the "cloudflare_r2s" table.
|
||||
CloudflareR2sColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "owner_id", Type: field.TypeString},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "location", Type: field.TypeString},
|
||||
{Name: "storage_class", Type: field.TypeString},
|
||||
{Name: "status", Type: field.TypeInt8, Default: 1},
|
||||
{Name: "payload_size", Type: field.TypeInt64, Default: 0},
|
||||
{Name: "metadata_size", Type: field.TypeInt64, Default: 0},
|
||||
{Name: "object_count", Type: field.TypeInt, Default: 0},
|
||||
{Name: "remark", Type: field.TypeString, Nullable: true, Size: 2147483647},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "cloudflare_accounts_cloudflare_buckets", Type: field.TypeInt},
|
||||
}
|
||||
// CloudflareR2sTable holds the schema information for the "cloudflare_r2s" table.
|
||||
CloudflareR2sTable = &schema.Table{
|
||||
Name: "cloudflare_r2s",
|
||||
Columns: CloudflareR2sColumns,
|
||||
PrimaryKey: []*schema.Column{CloudflareR2sColumns[0]},
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "cloudflare_r2s_cloudflare_accounts_cloudflare_buckets",
|
||||
Columns: []*schema.Column{CloudflareR2sColumns[12]},
|
||||
RefColumns: []*schema.Column{CloudflareAccountsColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
CloudflareAccountsTable,
|
||||
CloudflareR2sTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
CloudflareR2sTable.ForeignKeys[0].RefTable = CloudflareAccountsTable
|
||||
}
|
||||
1994
internal/ent/mutation.go
Normal file
1994
internal/ent/mutation.go
Normal file
File diff suppressed because it is too large
Load Diff
13
internal/ent/predicate/predicate.go
Normal file
13
internal/ent/predicate/predicate.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package predicate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// CloudflareAccounts is the predicate function for cloudflareaccounts builders.
|
||||
type CloudflareAccounts func(*sql.Selector)
|
||||
|
||||
// CloudflareR2 is the predicate function for cloudflarer2 builders.
|
||||
type CloudflareR2 func(*sql.Selector)
|
||||
80
internal/ent/runtime.go
Normal file
80
internal/ent/runtime.go
Normal file
@ -0,0 +1,80 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"time"
|
||||
"unR2/internal/ent/cloudflareaccounts"
|
||||
"unR2/internal/ent/cloudflarer2"
|
||||
"unR2/internal/ent/schema"
|
||||
)
|
||||
|
||||
// The init function reads all schema descriptors with runtime code
|
||||
// (default values, validators, hooks and policies) and stitches it
|
||||
// to their package variables.
|
||||
func init() {
|
||||
cloudflareaccountsFields := schema.CloudflareAccounts{}.Fields()
|
||||
_ = cloudflareaccountsFields
|
||||
// cloudflareaccountsDescName is the schema descriptor for name field.
|
||||
cloudflareaccountsDescName := cloudflareaccountsFields[0].Descriptor()
|
||||
// cloudflareaccounts.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
cloudflareaccounts.NameValidator = cloudflareaccountsDescName.Validators[0].(func(string) error)
|
||||
// cloudflareaccountsDescAccountID is the schema descriptor for account_id field.
|
||||
cloudflareaccountsDescAccountID := cloudflareaccountsFields[1].Descriptor()
|
||||
// cloudflareaccounts.AccountIDValidator is a validator for the "account_id" field. It is called by the builders before save.
|
||||
cloudflareaccounts.AccountIDValidator = cloudflareaccountsDescAccountID.Validators[0].(func(string) error)
|
||||
// cloudflareaccountsDescStatus is the schema descriptor for status field.
|
||||
cloudflareaccountsDescStatus := cloudflareaccountsFields[4].Descriptor()
|
||||
// cloudflareaccounts.DefaultStatus holds the default value on creation for the status field.
|
||||
cloudflareaccounts.DefaultStatus = cloudflareaccountsDescStatus.Default.(int8)
|
||||
// cloudflareaccountsDescCreatedAt is the schema descriptor for created_at field.
|
||||
cloudflareaccountsDescCreatedAt := cloudflareaccountsFields[6].Descriptor()
|
||||
// cloudflareaccounts.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
cloudflareaccounts.DefaultCreatedAt = cloudflareaccountsDescCreatedAt.Default.(func() time.Time)
|
||||
// cloudflareaccountsDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
cloudflareaccountsDescUpdatedAt := cloudflareaccountsFields[7].Descriptor()
|
||||
// cloudflareaccounts.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
cloudflareaccounts.DefaultUpdatedAt = cloudflareaccountsDescUpdatedAt.Default.(func() time.Time)
|
||||
// cloudflareaccounts.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
cloudflareaccounts.UpdateDefaultUpdatedAt = cloudflareaccountsDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
cloudflarer2Fields := schema.CloudflareR2{}.Fields()
|
||||
_ = cloudflarer2Fields
|
||||
// cloudflarer2DescName is the schema descriptor for name field.
|
||||
cloudflarer2DescName := cloudflarer2Fields[1].Descriptor()
|
||||
// cloudflarer2.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||
cloudflarer2.NameValidator = cloudflarer2DescName.Validators[0].(func(string) error)
|
||||
// cloudflarer2DescLocation is the schema descriptor for location field.
|
||||
cloudflarer2DescLocation := cloudflarer2Fields[2].Descriptor()
|
||||
// cloudflarer2.LocationValidator is a validator for the "location" field. It is called by the builders before save.
|
||||
cloudflarer2.LocationValidator = cloudflarer2DescLocation.Validators[0].(func(string) error)
|
||||
// cloudflarer2DescStorageClass is the schema descriptor for storage_class field.
|
||||
cloudflarer2DescStorageClass := cloudflarer2Fields[3].Descriptor()
|
||||
// cloudflarer2.StorageClassValidator is a validator for the "storage_class" field. It is called by the builders before save.
|
||||
cloudflarer2.StorageClassValidator = cloudflarer2DescStorageClass.Validators[0].(func(string) error)
|
||||
// cloudflarer2DescStatus is the schema descriptor for status field.
|
||||
cloudflarer2DescStatus := cloudflarer2Fields[4].Descriptor()
|
||||
// cloudflarer2.DefaultStatus holds the default value on creation for the status field.
|
||||
cloudflarer2.DefaultStatus = cloudflarer2DescStatus.Default.(int8)
|
||||
// cloudflarer2DescPayloadSize is the schema descriptor for payload_size field.
|
||||
cloudflarer2DescPayloadSize := cloudflarer2Fields[5].Descriptor()
|
||||
// cloudflarer2.DefaultPayloadSize holds the default value on creation for the payload_size field.
|
||||
cloudflarer2.DefaultPayloadSize = cloudflarer2DescPayloadSize.Default.(int64)
|
||||
// cloudflarer2DescMetadataSize is the schema descriptor for metadata_size field.
|
||||
cloudflarer2DescMetadataSize := cloudflarer2Fields[6].Descriptor()
|
||||
// cloudflarer2.DefaultMetadataSize holds the default value on creation for the metadata_size field.
|
||||
cloudflarer2.DefaultMetadataSize = cloudflarer2DescMetadataSize.Default.(int64)
|
||||
// cloudflarer2DescObjectCount is the schema descriptor for object_count field.
|
||||
cloudflarer2DescObjectCount := cloudflarer2Fields[7].Descriptor()
|
||||
// cloudflarer2.DefaultObjectCount holds the default value on creation for the object_count field.
|
||||
cloudflarer2.DefaultObjectCount = cloudflarer2DescObjectCount.Default.(int)
|
||||
// cloudflarer2DescCreatedAt is the schema descriptor for created_at field.
|
||||
cloudflarer2DescCreatedAt := cloudflarer2Fields[9].Descriptor()
|
||||
// cloudflarer2.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
cloudflarer2.DefaultCreatedAt = cloudflarer2DescCreatedAt.Default.(func() time.Time)
|
||||
// cloudflarer2DescUpdatedAt is the schema descriptor for updated_at field.
|
||||
cloudflarer2DescUpdatedAt := cloudflarer2Fields[10].Descriptor()
|
||||
// cloudflarer2.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
cloudflarer2.DefaultUpdatedAt = cloudflarer2DescUpdatedAt.Default.(func() time.Time)
|
||||
// cloudflarer2.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
cloudflarer2.UpdateDefaultUpdatedAt = cloudflarer2DescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||
}
|
||||
10
internal/ent/runtime/runtime.go
Normal file
10
internal/ent/runtime/runtime.go
Normal file
@ -0,0 +1,10 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package runtime
|
||||
|
||||
// The schema-stitching logic is generated in unR2/internal/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.14.4" // Version of ent codegen.
|
||||
Sum = "h1:/DhDraSLXIkBhyiVoJeSshr4ZYi7femzhj6/TckzZuI=" // Sum of ent codegen.
|
||||
)
|
||||
34
internal/ent/schema/cloudflareaccounts.go
Normal file
34
internal/ent/schema/cloudflareaccounts.go
Normal file
@ -0,0 +1,34 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CloudflareAccounts holds the schema definition for the CloudflareAccounts entity.
|
||||
type CloudflareAccounts struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the CloudflareAccounts.
|
||||
func (CloudflareAccounts) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name").NotEmpty().Comment("账户名称"),
|
||||
field.String("account_id").NotEmpty().Comment("Cloudflare Account ID"),
|
||||
field.Text("api_token").Sensitive().Comment("Cloudflare API Token"),
|
||||
field.String("email").Optional().Comment("Cloudflare 邮箱(可选)"),
|
||||
field.Int8("status").Default(1).Comment("状态 1=启用, 0=禁用"),
|
||||
field.Text("remark").Optional().Comment("备注"),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the CloudflareAccounts.
|
||||
func (CloudflareAccounts) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("cloudflare_buckets", CloudflareR2.Type),
|
||||
}
|
||||
}
|
||||
62
internal/ent/schema/cloudflarer2.go
Normal file
62
internal/ent/schema/cloudflarer2.go
Normal file
@ -0,0 +1,62 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"time"
|
||||
)
|
||||
|
||||
// CloudflareR2 holds the schema definition for the CloudflareR2 entity.
|
||||
type CloudflareR2 struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the CloudflareR2.
|
||||
func (CloudflareR2) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("owner_id").Comment("业务归属标识"),
|
||||
field.String("name").
|
||||
NotEmpty().
|
||||
Comment("桶名称(唯一)"),
|
||||
field.String("location").
|
||||
NotEmpty().
|
||||
Comment("桶区域,如 apac、eea、us"),
|
||||
field.String("storage_class").
|
||||
NotEmpty().
|
||||
Comment("存储类型,如 standard、infrequent-access"),
|
||||
field.Int8("status").
|
||||
Default(1).
|
||||
Comment("状态:1=启用,0=禁用"),
|
||||
field.Int64("payload_size").
|
||||
Default(0).
|
||||
Comment("对象数据体积(payloadSize),单位字节"),
|
||||
|
||||
field.Int64("metadata_size").
|
||||
Default(0).
|
||||
Comment("对象元数据大小(metadataSize),单位字节"),
|
||||
field.Int("object_count").
|
||||
Default(0).
|
||||
Comment("存储桶内对象总数"),
|
||||
field.Text("remark").
|
||||
Optional().
|
||||
Comment("备注"),
|
||||
field.Time("created_at").
|
||||
Default(time.Now).
|
||||
Immutable(),
|
||||
field.Time("updated_at").
|
||||
Default(time.Now).
|
||||
UpdateDefault(time.Now),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the CloudflareR2.
|
||||
func (CloudflareR2) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("cloudflare_account", CloudflareAccounts.Type).
|
||||
Ref("cloudflare_buckets").
|
||||
Unique().
|
||||
Required().
|
||||
Comment("所属 Cloudflare 账户"),
|
||||
}
|
||||
}
|
||||
213
internal/ent/tx.go
Normal file
213
internal/ent/tx.go
Normal file
@ -0,0 +1,213 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
)
|
||||
|
||||
// Tx is a transactional client that is created by calling Client.Tx().
|
||||
type Tx struct {
|
||||
config
|
||||
// CloudflareAccounts is the client for interacting with the CloudflareAccounts builders.
|
||||
CloudflareAccounts *CloudflareAccountsClient
|
||||
// CloudflareR2 is the client for interacting with the CloudflareR2 builders.
|
||||
CloudflareR2 *CloudflareR2Client
|
||||
|
||||
// lazily loaded.
|
||||
client *Client
|
||||
clientOnce sync.Once
|
||||
// ctx lives for the life of the transaction. It is
|
||||
// the same context used by the underlying connection.
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
type (
|
||||
// Committer is the interface that wraps the Commit method.
|
||||
Committer interface {
|
||||
Commit(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The CommitFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Committer. If f is a function with the appropriate
|
||||
// signature, CommitFunc(f) is a Committer that calls f.
|
||||
CommitFunc func(context.Context, *Tx) error
|
||||
|
||||
// CommitHook defines the "commit middleware". A function that gets a Committer
|
||||
// and returns a Committer. For example:
|
||||
//
|
||||
// hook := func(next ent.Committer) ent.Committer {
|
||||
// return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Commit(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
CommitHook func(Committer) Committer
|
||||
)
|
||||
|
||||
// Commit calls f(ctx, m).
|
||||
func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Commit commits the transaction.
|
||||
func (tx *Tx) Commit() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Committer = CommitFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Commit()
|
||||
})
|
||||
txDriver.mu.Lock()
|
||||
hooks := append([]CommitHook(nil), txDriver.onCommit...)
|
||||
txDriver.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Commit(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnCommit adds a hook to call on commit.
|
||||
func (tx *Tx) OnCommit(f CommitHook) {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
txDriver.mu.Lock()
|
||||
txDriver.onCommit = append(txDriver.onCommit, f)
|
||||
txDriver.mu.Unlock()
|
||||
}
|
||||
|
||||
type (
|
||||
// Rollbacker is the interface that wraps the Rollback method.
|
||||
Rollbacker interface {
|
||||
Rollback(context.Context, *Tx) error
|
||||
}
|
||||
|
||||
// The RollbackFunc type is an adapter to allow the use of ordinary
|
||||
// function as a Rollbacker. If f is a function with the appropriate
|
||||
// signature, RollbackFunc(f) is a Rollbacker that calls f.
|
||||
RollbackFunc func(context.Context, *Tx) error
|
||||
|
||||
// RollbackHook defines the "rollback middleware". A function that gets a Rollbacker
|
||||
// and returns a Rollbacker. For example:
|
||||
//
|
||||
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
||||
// return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error {
|
||||
// // Do some stuff before.
|
||||
// if err := next.Rollback(ctx, tx); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// // Do some stuff after.
|
||||
// return nil
|
||||
// })
|
||||
// }
|
||||
//
|
||||
RollbackHook func(Rollbacker) Rollbacker
|
||||
)
|
||||
|
||||
// Rollback calls f(ctx, m).
|
||||
func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error {
|
||||
return f(ctx, tx)
|
||||
}
|
||||
|
||||
// Rollback rollbacks the transaction.
|
||||
func (tx *Tx) Rollback() error {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error {
|
||||
return txDriver.tx.Rollback()
|
||||
})
|
||||
txDriver.mu.Lock()
|
||||
hooks := append([]RollbackHook(nil), txDriver.onRollback...)
|
||||
txDriver.mu.Unlock()
|
||||
for i := len(hooks) - 1; i >= 0; i-- {
|
||||
fn = hooks[i](fn)
|
||||
}
|
||||
return fn.Rollback(tx.ctx, tx)
|
||||
}
|
||||
|
||||
// OnRollback adds a hook to call on rollback.
|
||||
func (tx *Tx) OnRollback(f RollbackHook) {
|
||||
txDriver := tx.config.driver.(*txDriver)
|
||||
txDriver.mu.Lock()
|
||||
txDriver.onRollback = append(txDriver.onRollback, f)
|
||||
txDriver.mu.Unlock()
|
||||
}
|
||||
|
||||
// Client returns a Client that binds to current transaction.
|
||||
func (tx *Tx) Client() *Client {
|
||||
tx.clientOnce.Do(func() {
|
||||
tx.client = &Client{config: tx.config}
|
||||
tx.client.init()
|
||||
})
|
||||
return tx.client
|
||||
}
|
||||
|
||||
func (tx *Tx) init() {
|
||||
tx.CloudflareAccounts = NewCloudflareAccountsClient(tx.config)
|
||||
tx.CloudflareR2 = NewCloudflareR2Client(tx.config)
|
||||
}
|
||||
|
||||
// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation.
|
||||
// The idea is to support transactions without adding any extra code to the builders.
|
||||
// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance.
|
||||
// Commit and Rollback are nop for the internal builders and the user must call one
|
||||
// of them in order to commit or rollback the transaction.
|
||||
//
|
||||
// If a closed transaction is embedded in one of the generated entities, and the entity
|
||||
// applies a query, for example: CloudflareAccounts.QueryXXX(), the query will be executed
|
||||
// through the driver which created this transaction.
|
||||
//
|
||||
// Note that txDriver is not goroutine safe.
|
||||
type txDriver struct {
|
||||
// the driver we started the transaction from.
|
||||
drv dialect.Driver
|
||||
// tx is the underlying transaction.
|
||||
tx dialect.Tx
|
||||
// completion hooks.
|
||||
mu sync.Mutex
|
||||
onCommit []CommitHook
|
||||
onRollback []RollbackHook
|
||||
}
|
||||
|
||||
// newTx creates a new transactional driver.
|
||||
func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) {
|
||||
tx, err := drv.Tx(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &txDriver{tx: tx, drv: drv}, nil
|
||||
}
|
||||
|
||||
// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls
|
||||
// from the internal builders. Should be called only by the internal builders.
|
||||
func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil }
|
||||
|
||||
// Dialect returns the dialect of the driver we started the transaction from.
|
||||
func (tx *txDriver) Dialect() string { return tx.drv.Dialect() }
|
||||
|
||||
// Close is a nop close.
|
||||
func (*txDriver) Close() error { return nil }
|
||||
|
||||
// Commit is a nop commit for the internal builders.
|
||||
// User must call `Tx.Commit` in order to commit the transaction.
|
||||
func (*txDriver) Commit() error { return nil }
|
||||
|
||||
// Rollback is a nop rollback for the internal builders.
|
||||
// User must call `Tx.Rollback` in order to rollback the transaction.
|
||||
func (*txDriver) Rollback() error { return nil }
|
||||
|
||||
// Exec calls tx.Exec.
|
||||
func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error {
|
||||
return tx.tx.Exec(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// Query calls tx.Query.
|
||||
func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error {
|
||||
return tx.tx.Query(ctx, query, args, v)
|
||||
}
|
||||
|
||||
var _ dialect.Driver = (*txDriver)(nil)
|
||||
Reference in New Issue
Block a user