mirror of
https://github.com/simon-ding/polaris.git
synced 2026-05-10 04:27:29 +08:00
first draft version
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -10,6 +10,7 @@
|
||||
*.yml
|
||||
.idea/
|
||||
.DS_Store
|
||||
*.db
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
19
cmd/main.go
Normal file
19
cmd/main.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"polaris/db"
|
||||
"polaris/log"
|
||||
"polaris/server"
|
||||
)
|
||||
|
||||
func main() {
|
||||
dbClient, err := db.Open()
|
||||
if err != nil {
|
||||
log.Panicf("init db error: %v", err)
|
||||
}
|
||||
|
||||
s := server.NewServer(dbClient)
|
||||
if err := s.Serve(); err != nil {
|
||||
log.Errorf("server start error: %v", err)
|
||||
}
|
||||
}
|
||||
6
db/const.go
Normal file
6
db/const.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package db
|
||||
|
||||
const (
|
||||
SettingTmdbApiKey = "tmdb_api_key"
|
||||
SettingLanguage = "language"
|
||||
)
|
||||
80
db/db.go
Normal file
80
db/db.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent"
|
||||
"polaris/ent/settings"
|
||||
"polaris/log"
|
||||
|
||||
tmdb "github.com/cyruzin/golang-tmdb"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
ent *ent.Client
|
||||
}
|
||||
|
||||
func Open() (*Client, error) {
|
||||
client, err := ent.Open("sqlite3", "file:polaris.db?cache=shared&_fk=1")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed opening connection to sqlite")
|
||||
}
|
||||
//defer client.Close()
|
||||
// Run the auto migration tool.
|
||||
if err := client.Schema.Create(context.Background()); err != nil {
|
||||
return nil, errors.Wrap(err, "failed creating schema resources")
|
||||
}
|
||||
return &Client{
|
||||
ent: client,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetSetting(key string) string {
|
||||
v, err := c.ent.Settings.Query().Where(settings.Key(key)).Only(context.TODO())
|
||||
if err != nil {
|
||||
log.Errorf("get setting by key: %s error: %v", key, err)
|
||||
return ""
|
||||
}
|
||||
return v.Value
|
||||
}
|
||||
|
||||
func (c *Client) SetSetting(key, value string) error {
|
||||
v, err := c.ent.Settings.Query().Where(settings.Key(key)).Only(context.TODO())
|
||||
if err != nil {
|
||||
log.Infof("create new setting")
|
||||
_, err := c.ent.Settings.Create().SetKey(key).SetValue(value).Save(context.TODO())
|
||||
return err
|
||||
}
|
||||
_, err = c.ent.Settings.UpdateOneID(v.ID).SetValue(value).Save(context.TODO())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) GetLanguage() string {
|
||||
lang := c.GetSetting(SettingLanguage)
|
||||
log.Infof("get application language: %s", lang)
|
||||
if lang == "" {
|
||||
return "zh_CN"
|
||||
}
|
||||
return lang
|
||||
}
|
||||
|
||||
func (c *Client) AddWatchlist(path string, detail *tmdb.TVDetails) error {
|
||||
_, err := c.ent.Series.Create().
|
||||
SetTmdbID(int(detail.ID)).
|
||||
SetPath(path).
|
||||
SetOverview(detail.Overview).
|
||||
SetTitle(detail.Name).
|
||||
SetOriginalName(detail.OriginalName).
|
||||
Save(context.TODO())
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) GetWatchlist() []*ent.Series {
|
||||
list, err := c.ent.Series.Query().All(context.TODO())
|
||||
if err != nil {
|
||||
log.Infof("query wtach list error: %v", err)
|
||||
return nil
|
||||
}
|
||||
return list
|
||||
}
|
||||
913
ent/client.go
Normal file
913
ent/client.go
Normal file
@@ -0,0 +1,913 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"polaris/ent/migrate"
|
||||
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/epidodes"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/series"
|
||||
"polaris/ent/settings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// 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
|
||||
// DownloadClients is the client for interacting with the DownloadClients builders.
|
||||
DownloadClients *DownloadClientsClient
|
||||
// Epidodes is the client for interacting with the Epidodes builders.
|
||||
Epidodes *EpidodesClient
|
||||
// Indexers is the client for interacting with the Indexers builders.
|
||||
Indexers *IndexersClient
|
||||
// Series is the client for interacting with the Series builders.
|
||||
Series *SeriesClient
|
||||
// Settings is the client for interacting with the Settings builders.
|
||||
Settings *SettingsClient
|
||||
}
|
||||
|
||||
// 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.DownloadClients = NewDownloadClientsClient(c.config)
|
||||
c.Epidodes = NewEpidodesClient(c.config)
|
||||
c.Indexers = NewIndexersClient(c.config)
|
||||
c.Series = NewSeriesClient(c.config)
|
||||
c.Settings = NewSettingsClient(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,
|
||||
DownloadClients: NewDownloadClientsClient(cfg),
|
||||
Epidodes: NewEpidodesClient(cfg),
|
||||
Indexers: NewIndexersClient(cfg),
|
||||
Series: NewSeriesClient(cfg),
|
||||
Settings: NewSettingsClient(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,
|
||||
DownloadClients: NewDownloadClientsClient(cfg),
|
||||
Epidodes: NewEpidodesClient(cfg),
|
||||
Indexers: NewIndexersClient(cfg),
|
||||
Series: NewSeriesClient(cfg),
|
||||
Settings: NewSettingsClient(cfg),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Debug returns a new debug-client. It's used to get verbose logging on specific operations.
|
||||
//
|
||||
// client.Debug().
|
||||
// DownloadClients.
|
||||
// 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.DownloadClients.Use(hooks...)
|
||||
c.Epidodes.Use(hooks...)
|
||||
c.Indexers.Use(hooks...)
|
||||
c.Series.Use(hooks...)
|
||||
c.Settings.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.DownloadClients.Intercept(interceptors...)
|
||||
c.Epidodes.Intercept(interceptors...)
|
||||
c.Indexers.Intercept(interceptors...)
|
||||
c.Series.Intercept(interceptors...)
|
||||
c.Settings.Intercept(interceptors...)
|
||||
}
|
||||
|
||||
// Mutate implements the ent.Mutator interface.
|
||||
func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||
switch m := m.(type) {
|
||||
case *DownloadClientsMutation:
|
||||
return c.DownloadClients.mutate(ctx, m)
|
||||
case *EpidodesMutation:
|
||||
return c.Epidodes.mutate(ctx, m)
|
||||
case *IndexersMutation:
|
||||
return c.Indexers.mutate(ctx, m)
|
||||
case *SeriesMutation:
|
||||
return c.Series.mutate(ctx, m)
|
||||
case *SettingsMutation:
|
||||
return c.Settings.mutate(ctx, m)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown mutation type %T", m)
|
||||
}
|
||||
}
|
||||
|
||||
// DownloadClientsClient is a client for the DownloadClients schema.
|
||||
type DownloadClientsClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewDownloadClientsClient returns a client for the DownloadClients from the given config.
|
||||
func NewDownloadClientsClient(c config) *DownloadClientsClient {
|
||||
return &DownloadClientsClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `downloadclients.Hooks(f(g(h())))`.
|
||||
func (c *DownloadClientsClient) Use(hooks ...Hook) {
|
||||
c.hooks.DownloadClients = append(c.hooks.DownloadClients, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `downloadclients.Intercept(f(g(h())))`.
|
||||
func (c *DownloadClientsClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.DownloadClients = append(c.inters.DownloadClients, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a DownloadClients entity.
|
||||
func (c *DownloadClientsClient) Create() *DownloadClientsCreate {
|
||||
mutation := newDownloadClientsMutation(c.config, OpCreate)
|
||||
return &DownloadClientsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of DownloadClients entities.
|
||||
func (c *DownloadClientsClient) CreateBulk(builders ...*DownloadClientsCreate) *DownloadClientsCreateBulk {
|
||||
return &DownloadClientsCreateBulk{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 *DownloadClientsClient) MapCreateBulk(slice any, setFunc func(*DownloadClientsCreate, int)) *DownloadClientsCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &DownloadClientsCreateBulk{err: fmt.Errorf("calling to DownloadClientsClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*DownloadClientsCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &DownloadClientsCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for DownloadClients.
|
||||
func (c *DownloadClientsClient) Update() *DownloadClientsUpdate {
|
||||
mutation := newDownloadClientsMutation(c.config, OpUpdate)
|
||||
return &DownloadClientsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *DownloadClientsClient) UpdateOne(dc *DownloadClients) *DownloadClientsUpdateOne {
|
||||
mutation := newDownloadClientsMutation(c.config, OpUpdateOne, withDownloadClients(dc))
|
||||
return &DownloadClientsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *DownloadClientsClient) UpdateOneID(id int) *DownloadClientsUpdateOne {
|
||||
mutation := newDownloadClientsMutation(c.config, OpUpdateOne, withDownloadClientsID(id))
|
||||
return &DownloadClientsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for DownloadClients.
|
||||
func (c *DownloadClientsClient) Delete() *DownloadClientsDelete {
|
||||
mutation := newDownloadClientsMutation(c.config, OpDelete)
|
||||
return &DownloadClientsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *DownloadClientsClient) DeleteOne(dc *DownloadClients) *DownloadClientsDeleteOne {
|
||||
return c.DeleteOneID(dc.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *DownloadClientsClient) DeleteOneID(id int) *DownloadClientsDeleteOne {
|
||||
builder := c.Delete().Where(downloadclients.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &DownloadClientsDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for DownloadClients.
|
||||
func (c *DownloadClientsClient) Query() *DownloadClientsQuery {
|
||||
return &DownloadClientsQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeDownloadClients},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a DownloadClients entity by its id.
|
||||
func (c *DownloadClientsClient) Get(ctx context.Context, id int) (*DownloadClients, error) {
|
||||
return c.Query().Where(downloadclients.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *DownloadClientsClient) GetX(ctx context.Context, id int) *DownloadClients {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *DownloadClientsClient) Hooks() []Hook {
|
||||
return c.hooks.DownloadClients
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *DownloadClientsClient) Interceptors() []Interceptor {
|
||||
return c.inters.DownloadClients
|
||||
}
|
||||
|
||||
func (c *DownloadClientsClient) mutate(ctx context.Context, m *DownloadClientsMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&DownloadClientsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&DownloadClientsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&DownloadClientsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&DownloadClientsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown DownloadClients mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// EpidodesClient is a client for the Epidodes schema.
|
||||
type EpidodesClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewEpidodesClient returns a client for the Epidodes from the given config.
|
||||
func NewEpidodesClient(c config) *EpidodesClient {
|
||||
return &EpidodesClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `epidodes.Hooks(f(g(h())))`.
|
||||
func (c *EpidodesClient) Use(hooks ...Hook) {
|
||||
c.hooks.Epidodes = append(c.hooks.Epidodes, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `epidodes.Intercept(f(g(h())))`.
|
||||
func (c *EpidodesClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Epidodes = append(c.inters.Epidodes, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Epidodes entity.
|
||||
func (c *EpidodesClient) Create() *EpidodesCreate {
|
||||
mutation := newEpidodesMutation(c.config, OpCreate)
|
||||
return &EpidodesCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Epidodes entities.
|
||||
func (c *EpidodesClient) CreateBulk(builders ...*EpidodesCreate) *EpidodesCreateBulk {
|
||||
return &EpidodesCreateBulk{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 *EpidodesClient) MapCreateBulk(slice any, setFunc func(*EpidodesCreate, int)) *EpidodesCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &EpidodesCreateBulk{err: fmt.Errorf("calling to EpidodesClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*EpidodesCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &EpidodesCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Epidodes.
|
||||
func (c *EpidodesClient) Update() *EpidodesUpdate {
|
||||
mutation := newEpidodesMutation(c.config, OpUpdate)
|
||||
return &EpidodesUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *EpidodesClient) UpdateOne(e *Epidodes) *EpidodesUpdateOne {
|
||||
mutation := newEpidodesMutation(c.config, OpUpdateOne, withEpidodes(e))
|
||||
return &EpidodesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *EpidodesClient) UpdateOneID(id int) *EpidodesUpdateOne {
|
||||
mutation := newEpidodesMutation(c.config, OpUpdateOne, withEpidodesID(id))
|
||||
return &EpidodesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Epidodes.
|
||||
func (c *EpidodesClient) Delete() *EpidodesDelete {
|
||||
mutation := newEpidodesMutation(c.config, OpDelete)
|
||||
return &EpidodesDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *EpidodesClient) DeleteOne(e *Epidodes) *EpidodesDeleteOne {
|
||||
return c.DeleteOneID(e.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *EpidodesClient) DeleteOneID(id int) *EpidodesDeleteOne {
|
||||
builder := c.Delete().Where(epidodes.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &EpidodesDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Epidodes.
|
||||
func (c *EpidodesClient) Query() *EpidodesQuery {
|
||||
return &EpidodesQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeEpidodes},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Epidodes entity by its id.
|
||||
func (c *EpidodesClient) Get(ctx context.Context, id int) (*Epidodes, error) {
|
||||
return c.Query().Where(epidodes.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *EpidodesClient) GetX(ctx context.Context, id int) *Epidodes {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *EpidodesClient) Hooks() []Hook {
|
||||
return c.hooks.Epidodes
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *EpidodesClient) Interceptors() []Interceptor {
|
||||
return c.inters.Epidodes
|
||||
}
|
||||
|
||||
func (c *EpidodesClient) mutate(ctx context.Context, m *EpidodesMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&EpidodesCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&EpidodesUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&EpidodesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&EpidodesDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Epidodes mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// IndexersClient is a client for the Indexers schema.
|
||||
type IndexersClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewIndexersClient returns a client for the Indexers from the given config.
|
||||
func NewIndexersClient(c config) *IndexersClient {
|
||||
return &IndexersClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `indexers.Hooks(f(g(h())))`.
|
||||
func (c *IndexersClient) Use(hooks ...Hook) {
|
||||
c.hooks.Indexers = append(c.hooks.Indexers, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `indexers.Intercept(f(g(h())))`.
|
||||
func (c *IndexersClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Indexers = append(c.inters.Indexers, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Indexers entity.
|
||||
func (c *IndexersClient) Create() *IndexersCreate {
|
||||
mutation := newIndexersMutation(c.config, OpCreate)
|
||||
return &IndexersCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Indexers entities.
|
||||
func (c *IndexersClient) CreateBulk(builders ...*IndexersCreate) *IndexersCreateBulk {
|
||||
return &IndexersCreateBulk{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 *IndexersClient) MapCreateBulk(slice any, setFunc func(*IndexersCreate, int)) *IndexersCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &IndexersCreateBulk{err: fmt.Errorf("calling to IndexersClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*IndexersCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &IndexersCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Indexers.
|
||||
func (c *IndexersClient) Update() *IndexersUpdate {
|
||||
mutation := newIndexersMutation(c.config, OpUpdate)
|
||||
return &IndexersUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *IndexersClient) UpdateOne(i *Indexers) *IndexersUpdateOne {
|
||||
mutation := newIndexersMutation(c.config, OpUpdateOne, withIndexers(i))
|
||||
return &IndexersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *IndexersClient) UpdateOneID(id int) *IndexersUpdateOne {
|
||||
mutation := newIndexersMutation(c.config, OpUpdateOne, withIndexersID(id))
|
||||
return &IndexersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Indexers.
|
||||
func (c *IndexersClient) Delete() *IndexersDelete {
|
||||
mutation := newIndexersMutation(c.config, OpDelete)
|
||||
return &IndexersDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *IndexersClient) DeleteOne(i *Indexers) *IndexersDeleteOne {
|
||||
return c.DeleteOneID(i.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *IndexersClient) DeleteOneID(id int) *IndexersDeleteOne {
|
||||
builder := c.Delete().Where(indexers.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &IndexersDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Indexers.
|
||||
func (c *IndexersClient) Query() *IndexersQuery {
|
||||
return &IndexersQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeIndexers},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Indexers entity by its id.
|
||||
func (c *IndexersClient) Get(ctx context.Context, id int) (*Indexers, error) {
|
||||
return c.Query().Where(indexers.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *IndexersClient) GetX(ctx context.Context, id int) *Indexers {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *IndexersClient) Hooks() []Hook {
|
||||
return c.hooks.Indexers
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *IndexersClient) Interceptors() []Interceptor {
|
||||
return c.inters.Indexers
|
||||
}
|
||||
|
||||
func (c *IndexersClient) mutate(ctx context.Context, m *IndexersMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&IndexersCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&IndexersUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&IndexersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&IndexersDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Indexers mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// SeriesClient is a client for the Series schema.
|
||||
type SeriesClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewSeriesClient returns a client for the Series from the given config.
|
||||
func NewSeriesClient(c config) *SeriesClient {
|
||||
return &SeriesClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `series.Hooks(f(g(h())))`.
|
||||
func (c *SeriesClient) Use(hooks ...Hook) {
|
||||
c.hooks.Series = append(c.hooks.Series, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `series.Intercept(f(g(h())))`.
|
||||
func (c *SeriesClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Series = append(c.inters.Series, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Series entity.
|
||||
func (c *SeriesClient) Create() *SeriesCreate {
|
||||
mutation := newSeriesMutation(c.config, OpCreate)
|
||||
return &SeriesCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Series entities.
|
||||
func (c *SeriesClient) CreateBulk(builders ...*SeriesCreate) *SeriesCreateBulk {
|
||||
return &SeriesCreateBulk{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 *SeriesClient) MapCreateBulk(slice any, setFunc func(*SeriesCreate, int)) *SeriesCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &SeriesCreateBulk{err: fmt.Errorf("calling to SeriesClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*SeriesCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &SeriesCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Series.
|
||||
func (c *SeriesClient) Update() *SeriesUpdate {
|
||||
mutation := newSeriesMutation(c.config, OpUpdate)
|
||||
return &SeriesUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *SeriesClient) UpdateOne(s *Series) *SeriesUpdateOne {
|
||||
mutation := newSeriesMutation(c.config, OpUpdateOne, withSeries(s))
|
||||
return &SeriesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *SeriesClient) UpdateOneID(id int) *SeriesUpdateOne {
|
||||
mutation := newSeriesMutation(c.config, OpUpdateOne, withSeriesID(id))
|
||||
return &SeriesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Series.
|
||||
func (c *SeriesClient) Delete() *SeriesDelete {
|
||||
mutation := newSeriesMutation(c.config, OpDelete)
|
||||
return &SeriesDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *SeriesClient) DeleteOne(s *Series) *SeriesDeleteOne {
|
||||
return c.DeleteOneID(s.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *SeriesClient) DeleteOneID(id int) *SeriesDeleteOne {
|
||||
builder := c.Delete().Where(series.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &SeriesDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Series.
|
||||
func (c *SeriesClient) Query() *SeriesQuery {
|
||||
return &SeriesQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeSeries},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Series entity by its id.
|
||||
func (c *SeriesClient) Get(ctx context.Context, id int) (*Series, error) {
|
||||
return c.Query().Where(series.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *SeriesClient) GetX(ctx context.Context, id int) *Series {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *SeriesClient) Hooks() []Hook {
|
||||
return c.hooks.Series
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *SeriesClient) Interceptors() []Interceptor {
|
||||
return c.inters.Series
|
||||
}
|
||||
|
||||
func (c *SeriesClient) mutate(ctx context.Context, m *SeriesMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&SeriesCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&SeriesUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&SeriesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&SeriesDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Series mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// SettingsClient is a client for the Settings schema.
|
||||
type SettingsClient struct {
|
||||
config
|
||||
}
|
||||
|
||||
// NewSettingsClient returns a client for the Settings from the given config.
|
||||
func NewSettingsClient(c config) *SettingsClient {
|
||||
return &SettingsClient{config: c}
|
||||
}
|
||||
|
||||
// Use adds a list of mutation hooks to the hooks stack.
|
||||
// A call to `Use(f, g, h)` equals to `settings.Hooks(f(g(h())))`.
|
||||
func (c *SettingsClient) Use(hooks ...Hook) {
|
||||
c.hooks.Settings = append(c.hooks.Settings, hooks...)
|
||||
}
|
||||
|
||||
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||
// A call to `Intercept(f, g, h)` equals to `settings.Intercept(f(g(h())))`.
|
||||
func (c *SettingsClient) Intercept(interceptors ...Interceptor) {
|
||||
c.inters.Settings = append(c.inters.Settings, interceptors...)
|
||||
}
|
||||
|
||||
// Create returns a builder for creating a Settings entity.
|
||||
func (c *SettingsClient) Create() *SettingsCreate {
|
||||
mutation := newSettingsMutation(c.config, OpCreate)
|
||||
return &SettingsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// CreateBulk returns a builder for creating a bulk of Settings entities.
|
||||
func (c *SettingsClient) CreateBulk(builders ...*SettingsCreate) *SettingsCreateBulk {
|
||||
return &SettingsCreateBulk{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 *SettingsClient) MapCreateBulk(slice any, setFunc func(*SettingsCreate, int)) *SettingsCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &SettingsCreateBulk{err: fmt.Errorf("calling to SettingsClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*SettingsCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &SettingsCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Settings.
|
||||
func (c *SettingsClient) Update() *SettingsUpdate {
|
||||
mutation := newSettingsMutation(c.config, OpUpdate)
|
||||
return &SettingsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *SettingsClient) UpdateOne(s *Settings) *SettingsUpdateOne {
|
||||
mutation := newSettingsMutation(c.config, OpUpdateOne, withSettings(s))
|
||||
return &SettingsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// UpdateOneID returns an update builder for the given id.
|
||||
func (c *SettingsClient) UpdateOneID(id int) *SettingsUpdateOne {
|
||||
mutation := newSettingsMutation(c.config, OpUpdateOne, withSettingsID(id))
|
||||
return &SettingsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// Delete returns a delete builder for Settings.
|
||||
func (c *SettingsClient) Delete() *SettingsDelete {
|
||||
mutation := newSettingsMutation(c.config, OpDelete)
|
||||
return &SettingsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *SettingsClient) DeleteOne(s *Settings) *SettingsDeleteOne {
|
||||
return c.DeleteOneID(s.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
func (c *SettingsClient) DeleteOneID(id int) *SettingsDeleteOne {
|
||||
builder := c.Delete().Where(settings.ID(id))
|
||||
builder.mutation.id = &id
|
||||
builder.mutation.op = OpDeleteOne
|
||||
return &SettingsDeleteOne{builder}
|
||||
}
|
||||
|
||||
// Query returns a query builder for Settings.
|
||||
func (c *SettingsClient) Query() *SettingsQuery {
|
||||
return &SettingsQuery{
|
||||
config: c.config,
|
||||
ctx: &QueryContext{Type: TypeSettings},
|
||||
inters: c.Interceptors(),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns a Settings entity by its id.
|
||||
func (c *SettingsClient) Get(ctx context.Context, id int) (*Settings, error) {
|
||||
return c.Query().Where(settings.ID(id)).Only(ctx)
|
||||
}
|
||||
|
||||
// GetX is like Get, but panics if an error occurs.
|
||||
func (c *SettingsClient) GetX(ctx context.Context, id int) *Settings {
|
||||
obj, err := c.Get(ctx, id)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *SettingsClient) Hooks() []Hook {
|
||||
return c.hooks.Settings
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
func (c *SettingsClient) Interceptors() []Interceptor {
|
||||
return c.inters.Settings
|
||||
}
|
||||
|
||||
func (c *SettingsClient) mutate(ctx context.Context, m *SettingsMutation) (Value, error) {
|
||||
switch m.Op() {
|
||||
case OpCreate:
|
||||
return (&SettingsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdate:
|
||||
return (&SettingsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpUpdateOne:
|
||||
return (&SettingsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||
case OpDelete, OpDeleteOne:
|
||||
return (&SettingsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("ent: unknown Settings mutation op: %q", m.Op())
|
||||
}
|
||||
}
|
||||
|
||||
// hooks and interceptors per client, for fast access.
|
||||
type (
|
||||
hooks struct {
|
||||
DownloadClients, Epidodes, Indexers, Series, Settings []ent.Hook
|
||||
}
|
||||
inters struct {
|
||||
DownloadClients, Epidodes, Indexers, Series, Settings []ent.Interceptor
|
||||
}
|
||||
)
|
||||
182
ent/downloadclients.go
Normal file
182
ent/downloadclients.go
Normal file
@@ -0,0 +1,182 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/ent/downloadclients"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// DownloadClients is the model entity for the DownloadClients schema.
|
||||
type DownloadClients struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Enable holds the value of the "enable" field.
|
||||
Enable bool `json:"enable,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Implementation holds the value of the "implementation" field.
|
||||
Implementation string `json:"implementation,omitempty"`
|
||||
// Settings holds the value of the "settings" field.
|
||||
Settings string `json:"settings,omitempty"`
|
||||
// Priority holds the value of the "priority" field.
|
||||
Priority string `json:"priority,omitempty"`
|
||||
// RemoveCompletedDownloads holds the value of the "remove_completed_downloads" field.
|
||||
RemoveCompletedDownloads bool `json:"remove_completed_downloads,omitempty"`
|
||||
// RemoveFailedDownloads holds the value of the "remove_failed_downloads" field.
|
||||
RemoveFailedDownloads bool `json:"remove_failed_downloads,omitempty"`
|
||||
// Tags holds the value of the "tags" field.
|
||||
Tags string `json:"tags,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*DownloadClients) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case downloadclients.FieldEnable, downloadclients.FieldRemoveCompletedDownloads, downloadclients.FieldRemoveFailedDownloads:
|
||||
values[i] = new(sql.NullBool)
|
||||
case downloadclients.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case downloadclients.FieldName, downloadclients.FieldImplementation, downloadclients.FieldSettings, downloadclients.FieldPriority, downloadclients.FieldTags:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the DownloadClients fields.
|
||||
func (dc *DownloadClients) 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 downloadclients.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
dc.ID = int(value.Int64)
|
||||
case downloadclients.FieldEnable:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field enable", values[i])
|
||||
} else if value.Valid {
|
||||
dc.Enable = value.Bool
|
||||
}
|
||||
case downloadclients.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
dc.Name = value.String
|
||||
}
|
||||
case downloadclients.FieldImplementation:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field implementation", values[i])
|
||||
} else if value.Valid {
|
||||
dc.Implementation = value.String
|
||||
}
|
||||
case downloadclients.FieldSettings:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field settings", values[i])
|
||||
} else if value.Valid {
|
||||
dc.Settings = value.String
|
||||
}
|
||||
case downloadclients.FieldPriority:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field priority", values[i])
|
||||
} else if value.Valid {
|
||||
dc.Priority = value.String
|
||||
}
|
||||
case downloadclients.FieldRemoveCompletedDownloads:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field remove_completed_downloads", values[i])
|
||||
} else if value.Valid {
|
||||
dc.RemoveCompletedDownloads = value.Bool
|
||||
}
|
||||
case downloadclients.FieldRemoveFailedDownloads:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field remove_failed_downloads", values[i])
|
||||
} else if value.Valid {
|
||||
dc.RemoveFailedDownloads = value.Bool
|
||||
}
|
||||
case downloadclients.FieldTags:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field tags", values[i])
|
||||
} else if value.Valid {
|
||||
dc.Tags = value.String
|
||||
}
|
||||
default:
|
||||
dc.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the DownloadClients.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (dc *DownloadClients) Value(name string) (ent.Value, error) {
|
||||
return dc.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this DownloadClients.
|
||||
// Note that you need to call DownloadClients.Unwrap() before calling this method if this DownloadClients
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (dc *DownloadClients) Update() *DownloadClientsUpdateOne {
|
||||
return NewDownloadClientsClient(dc.config).UpdateOne(dc)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the DownloadClients 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 (dc *DownloadClients) Unwrap() *DownloadClients {
|
||||
_tx, ok := dc.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: DownloadClients is not a transactional entity")
|
||||
}
|
||||
dc.config.driver = _tx.drv
|
||||
return dc
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (dc *DownloadClients) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("DownloadClients(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", dc.ID))
|
||||
builder.WriteString("enable=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.Enable))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(dc.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("implementation=")
|
||||
builder.WriteString(dc.Implementation)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("settings=")
|
||||
builder.WriteString(dc.Settings)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("priority=")
|
||||
builder.WriteString(dc.Priority)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("remove_completed_downloads=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.RemoveCompletedDownloads))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("remove_failed_downloads=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dc.RemoveFailedDownloads))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("tags=")
|
||||
builder.WriteString(dc.Tags)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// DownloadClientsSlice is a parsable slice of DownloadClients.
|
||||
type DownloadClientsSlice []*DownloadClients
|
||||
103
ent/downloadclients/downloadclients.go
Normal file
103
ent/downloadclients/downloadclients.go
Normal file
@@ -0,0 +1,103 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package downloadclients
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the downloadclients type in the database.
|
||||
Label = "download_clients"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldEnable holds the string denoting the enable field in the database.
|
||||
FieldEnable = "enable"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldImplementation holds the string denoting the implementation field in the database.
|
||||
FieldImplementation = "implementation"
|
||||
// FieldSettings holds the string denoting the settings field in the database.
|
||||
FieldSettings = "settings"
|
||||
// FieldPriority holds the string denoting the priority field in the database.
|
||||
FieldPriority = "priority"
|
||||
// FieldRemoveCompletedDownloads holds the string denoting the remove_completed_downloads field in the database.
|
||||
FieldRemoveCompletedDownloads = "remove_completed_downloads"
|
||||
// FieldRemoveFailedDownloads holds the string denoting the remove_failed_downloads field in the database.
|
||||
FieldRemoveFailedDownloads = "remove_failed_downloads"
|
||||
// FieldTags holds the string denoting the tags field in the database.
|
||||
FieldTags = "tags"
|
||||
// Table holds the table name of the downloadclients in the database.
|
||||
Table = "download_clients"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for downloadclients fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldEnable,
|
||||
FieldName,
|
||||
FieldImplementation,
|
||||
FieldSettings,
|
||||
FieldPriority,
|
||||
FieldRemoveCompletedDownloads,
|
||||
FieldRemoveFailedDownloads,
|
||||
FieldTags,
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the DownloadClients 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()
|
||||
}
|
||||
|
||||
// ByEnable orders the results by the enable field.
|
||||
func ByEnable(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEnable, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByImplementation orders the results by the implementation field.
|
||||
func ByImplementation(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImplementation, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySettings orders the results by the settings field.
|
||||
func BySettings(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSettings, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPriority orders the results by the priority field.
|
||||
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPriority, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRemoveCompletedDownloads orders the results by the remove_completed_downloads field.
|
||||
func ByRemoveCompletedDownloads(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRemoveCompletedDownloads, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByRemoveFailedDownloads orders the results by the remove_failed_downloads field.
|
||||
func ByRemoveFailedDownloads(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldRemoveFailedDownloads, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTags orders the results by the tags field.
|
||||
func ByTags(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTags, opts...).ToFunc()
|
||||
}
|
||||
464
ent/downloadclients/where.go
Normal file
464
ent/downloadclients/where.go
Normal file
@@ -0,0 +1,464 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package downloadclients
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Enable applies equality check predicate on the "enable" field. It's identical to EnableEQ.
|
||||
func Enable(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldEnable, v))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Implementation applies equality check predicate on the "implementation" field. It's identical to ImplementationEQ.
|
||||
func Implementation(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// Settings applies equality check predicate on the "settings" field. It's identical to SettingsEQ.
|
||||
func Settings(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// Priority applies equality check predicate on the "priority" field. It's identical to PriorityEQ.
|
||||
func Priority(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldPriority, v))
|
||||
}
|
||||
|
||||
// RemoveCompletedDownloads applies equality check predicate on the "remove_completed_downloads" field. It's identical to RemoveCompletedDownloadsEQ.
|
||||
func RemoveCompletedDownloads(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldRemoveCompletedDownloads, v))
|
||||
}
|
||||
|
||||
// RemoveFailedDownloads applies equality check predicate on the "remove_failed_downloads" field. It's identical to RemoveFailedDownloadsEQ.
|
||||
func RemoveFailedDownloads(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldRemoveFailedDownloads, v))
|
||||
}
|
||||
|
||||
// Tags applies equality check predicate on the "tags" field. It's identical to TagsEQ.
|
||||
func Tags(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldTags, v))
|
||||
}
|
||||
|
||||
// EnableEQ applies the EQ predicate on the "enable" field.
|
||||
func EnableEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldEnable, v))
|
||||
}
|
||||
|
||||
// EnableNEQ applies the NEQ predicate on the "enable" field.
|
||||
func EnableNEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldEnable, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// ImplementationEQ applies the EQ predicate on the "implementation" field.
|
||||
func ImplementationEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationNEQ applies the NEQ predicate on the "implementation" field.
|
||||
func ImplementationNEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationIn applies the In predicate on the "implementation" field.
|
||||
func ImplementationIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldImplementation, vs...))
|
||||
}
|
||||
|
||||
// ImplementationNotIn applies the NotIn predicate on the "implementation" field.
|
||||
func ImplementationNotIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldImplementation, vs...))
|
||||
}
|
||||
|
||||
// ImplementationGT applies the GT predicate on the "implementation" field.
|
||||
func ImplementationGT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationGTE applies the GTE predicate on the "implementation" field.
|
||||
func ImplementationGTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationLT applies the LT predicate on the "implementation" field.
|
||||
func ImplementationLT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationLTE applies the LTE predicate on the "implementation" field.
|
||||
func ImplementationLTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationContains applies the Contains predicate on the "implementation" field.
|
||||
func ImplementationContains(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContains(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationHasPrefix applies the HasPrefix predicate on the "implementation" field.
|
||||
func ImplementationHasPrefix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasPrefix(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationHasSuffix applies the HasSuffix predicate on the "implementation" field.
|
||||
func ImplementationHasSuffix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasSuffix(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationEqualFold applies the EqualFold predicate on the "implementation" field.
|
||||
func ImplementationEqualFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEqualFold(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationContainsFold applies the ContainsFold predicate on the "implementation" field.
|
||||
func ImplementationContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// SettingsEQ applies the EQ predicate on the "settings" field.
|
||||
func SettingsEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsNEQ applies the NEQ predicate on the "settings" field.
|
||||
func SettingsNEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsIn applies the In predicate on the "settings" field.
|
||||
func SettingsIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldSettings, vs...))
|
||||
}
|
||||
|
||||
// SettingsNotIn applies the NotIn predicate on the "settings" field.
|
||||
func SettingsNotIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldSettings, vs...))
|
||||
}
|
||||
|
||||
// SettingsGT applies the GT predicate on the "settings" field.
|
||||
func SettingsGT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsGTE applies the GTE predicate on the "settings" field.
|
||||
func SettingsGTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsLT applies the LT predicate on the "settings" field.
|
||||
func SettingsLT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsLTE applies the LTE predicate on the "settings" field.
|
||||
func SettingsLTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsContains applies the Contains predicate on the "settings" field.
|
||||
func SettingsContains(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContains(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsHasPrefix applies the HasPrefix predicate on the "settings" field.
|
||||
func SettingsHasPrefix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasPrefix(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsHasSuffix applies the HasSuffix predicate on the "settings" field.
|
||||
func SettingsHasSuffix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasSuffix(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsEqualFold applies the EqualFold predicate on the "settings" field.
|
||||
func SettingsEqualFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEqualFold(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsContainsFold applies the ContainsFold predicate on the "settings" field.
|
||||
func SettingsContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldSettings, v))
|
||||
}
|
||||
|
||||
// PriorityEQ applies the EQ predicate on the "priority" field.
|
||||
func PriorityEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityNEQ applies the NEQ predicate on the "priority" field.
|
||||
func PriorityNEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityIn applies the In predicate on the "priority" field.
|
||||
func PriorityIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldPriority, vs...))
|
||||
}
|
||||
|
||||
// PriorityNotIn applies the NotIn predicate on the "priority" field.
|
||||
func PriorityNotIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldPriority, vs...))
|
||||
}
|
||||
|
||||
// PriorityGT applies the GT predicate on the "priority" field.
|
||||
func PriorityGT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityGTE applies the GTE predicate on the "priority" field.
|
||||
func PriorityGTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityLT applies the LT predicate on the "priority" field.
|
||||
func PriorityLT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityLTE applies the LTE predicate on the "priority" field.
|
||||
func PriorityLTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityContains applies the Contains predicate on the "priority" field.
|
||||
func PriorityContains(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContains(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityHasPrefix applies the HasPrefix predicate on the "priority" field.
|
||||
func PriorityHasPrefix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasPrefix(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityHasSuffix applies the HasSuffix predicate on the "priority" field.
|
||||
func PriorityHasSuffix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasSuffix(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityEqualFold applies the EqualFold predicate on the "priority" field.
|
||||
func PriorityEqualFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEqualFold(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityContainsFold applies the ContainsFold predicate on the "priority" field.
|
||||
func PriorityContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldPriority, v))
|
||||
}
|
||||
|
||||
// RemoveCompletedDownloadsEQ applies the EQ predicate on the "remove_completed_downloads" field.
|
||||
func RemoveCompletedDownloadsEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldRemoveCompletedDownloads, v))
|
||||
}
|
||||
|
||||
// RemoveCompletedDownloadsNEQ applies the NEQ predicate on the "remove_completed_downloads" field.
|
||||
func RemoveCompletedDownloadsNEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldRemoveCompletedDownloads, v))
|
||||
}
|
||||
|
||||
// RemoveFailedDownloadsEQ applies the EQ predicate on the "remove_failed_downloads" field.
|
||||
func RemoveFailedDownloadsEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldRemoveFailedDownloads, v))
|
||||
}
|
||||
|
||||
// RemoveFailedDownloadsNEQ applies the NEQ predicate on the "remove_failed_downloads" field.
|
||||
func RemoveFailedDownloadsNEQ(v bool) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldRemoveFailedDownloads, v))
|
||||
}
|
||||
|
||||
// TagsEQ applies the EQ predicate on the "tags" field.
|
||||
func TagsEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEQ(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsNEQ applies the NEQ predicate on the "tags" field.
|
||||
func TagsNEQ(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNEQ(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsIn applies the In predicate on the "tags" field.
|
||||
func TagsIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldIn(FieldTags, vs...))
|
||||
}
|
||||
|
||||
// TagsNotIn applies the NotIn predicate on the "tags" field.
|
||||
func TagsNotIn(vs ...string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldNotIn(FieldTags, vs...))
|
||||
}
|
||||
|
||||
// TagsGT applies the GT predicate on the "tags" field.
|
||||
func TagsGT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGT(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsGTE applies the GTE predicate on the "tags" field.
|
||||
func TagsGTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldGTE(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsLT applies the LT predicate on the "tags" field.
|
||||
func TagsLT(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLT(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsLTE applies the LTE predicate on the "tags" field.
|
||||
func TagsLTE(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldLTE(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsContains applies the Contains predicate on the "tags" field.
|
||||
func TagsContains(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContains(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsHasPrefix applies the HasPrefix predicate on the "tags" field.
|
||||
func TagsHasPrefix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasPrefix(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsHasSuffix applies the HasSuffix predicate on the "tags" field.
|
||||
func TagsHasSuffix(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldHasSuffix(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsEqualFold applies the EqualFold predicate on the "tags" field.
|
||||
func TagsEqualFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldEqualFold(FieldTags, v))
|
||||
}
|
||||
|
||||
// TagsContainsFold applies the ContainsFold predicate on the "tags" field.
|
||||
func TagsContainsFold(v string) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.FieldContainsFold(FieldTags, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.DownloadClients) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.DownloadClients) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.DownloadClients) predicate.DownloadClients {
|
||||
return predicate.DownloadClients(sql.NotPredicates(p))
|
||||
}
|
||||
274
ent/downloadclients_create.go
Normal file
274
ent/downloadclients_create.go
Normal file
@@ -0,0 +1,274 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/downloadclients"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// DownloadClientsCreate is the builder for creating a DownloadClients entity.
|
||||
type DownloadClientsCreate struct {
|
||||
config
|
||||
mutation *DownloadClientsMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetEnable sets the "enable" field.
|
||||
func (dcc *DownloadClientsCreate) SetEnable(b bool) *DownloadClientsCreate {
|
||||
dcc.mutation.SetEnable(b)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (dcc *DownloadClientsCreate) SetName(s string) *DownloadClientsCreate {
|
||||
dcc.mutation.SetName(s)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (dcc *DownloadClientsCreate) SetImplementation(s string) *DownloadClientsCreate {
|
||||
dcc.mutation.SetImplementation(s)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (dcc *DownloadClientsCreate) SetSettings(s string) *DownloadClientsCreate {
|
||||
dcc.mutation.SetSettings(s)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (dcc *DownloadClientsCreate) SetPriority(s string) *DownloadClientsCreate {
|
||||
dcc.mutation.SetPriority(s)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
||||
func (dcc *DownloadClientsCreate) SetRemoveCompletedDownloads(b bool) *DownloadClientsCreate {
|
||||
dcc.mutation.SetRemoveCompletedDownloads(b)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetRemoveFailedDownloads sets the "remove_failed_downloads" field.
|
||||
func (dcc *DownloadClientsCreate) SetRemoveFailedDownloads(b bool) *DownloadClientsCreate {
|
||||
dcc.mutation.SetRemoveFailedDownloads(b)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// SetTags sets the "tags" field.
|
||||
func (dcc *DownloadClientsCreate) SetTags(s string) *DownloadClientsCreate {
|
||||
dcc.mutation.SetTags(s)
|
||||
return dcc
|
||||
}
|
||||
|
||||
// Mutation returns the DownloadClientsMutation object of the builder.
|
||||
func (dcc *DownloadClientsCreate) Mutation() *DownloadClientsMutation {
|
||||
return dcc.mutation
|
||||
}
|
||||
|
||||
// Save creates the DownloadClients in the database.
|
||||
func (dcc *DownloadClientsCreate) Save(ctx context.Context) (*DownloadClients, error) {
|
||||
return withHooks(ctx, dcc.sqlSave, dcc.mutation, dcc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (dcc *DownloadClientsCreate) SaveX(ctx context.Context) *DownloadClients {
|
||||
v, err := dcc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (dcc *DownloadClientsCreate) Exec(ctx context.Context) error {
|
||||
_, err := dcc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (dcc *DownloadClientsCreate) ExecX(ctx context.Context) {
|
||||
if err := dcc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (dcc *DownloadClientsCreate) check() error {
|
||||
if _, ok := dcc.mutation.Enable(); !ok {
|
||||
return &ValidationError{Name: "enable", err: errors.New(`ent: missing required field "DownloadClients.enable"`)}
|
||||
}
|
||||
if _, ok := dcc.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "DownloadClients.name"`)}
|
||||
}
|
||||
if _, ok := dcc.mutation.Implementation(); !ok {
|
||||
return &ValidationError{Name: "implementation", err: errors.New(`ent: missing required field "DownloadClients.implementation"`)}
|
||||
}
|
||||
if _, ok := dcc.mutation.Settings(); !ok {
|
||||
return &ValidationError{Name: "settings", err: errors.New(`ent: missing required field "DownloadClients.settings"`)}
|
||||
}
|
||||
if _, ok := dcc.mutation.Priority(); !ok {
|
||||
return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "DownloadClients.priority"`)}
|
||||
}
|
||||
if _, ok := dcc.mutation.RemoveCompletedDownloads(); !ok {
|
||||
return &ValidationError{Name: "remove_completed_downloads", err: errors.New(`ent: missing required field "DownloadClients.remove_completed_downloads"`)}
|
||||
}
|
||||
if _, ok := dcc.mutation.RemoveFailedDownloads(); !ok {
|
||||
return &ValidationError{Name: "remove_failed_downloads", err: errors.New(`ent: missing required field "DownloadClients.remove_failed_downloads"`)}
|
||||
}
|
||||
if _, ok := dcc.mutation.Tags(); !ok {
|
||||
return &ValidationError{Name: "tags", err: errors.New(`ent: missing required field "DownloadClients.tags"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dcc *DownloadClientsCreate) sqlSave(ctx context.Context) (*DownloadClients, error) {
|
||||
if err := dcc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := dcc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, dcc.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)
|
||||
dcc.mutation.id = &_node.ID
|
||||
dcc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (dcc *DownloadClientsCreate) createSpec() (*DownloadClients, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &DownloadClients{config: dcc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(downloadclients.Table, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := dcc.mutation.Enable(); ok {
|
||||
_spec.SetField(downloadclients.FieldEnable, field.TypeBool, value)
|
||||
_node.Enable = value
|
||||
}
|
||||
if value, ok := dcc.mutation.Name(); ok {
|
||||
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := dcc.mutation.Implementation(); ok {
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
|
||||
_node.Implementation = value
|
||||
}
|
||||
if value, ok := dcc.mutation.Settings(); ok {
|
||||
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
|
||||
_node.Settings = value
|
||||
}
|
||||
if value, ok := dcc.mutation.Priority(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
|
||||
_node.Priority = value
|
||||
}
|
||||
if value, ok := dcc.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
_node.RemoveCompletedDownloads = value
|
||||
}
|
||||
if value, ok := dcc.mutation.RemoveFailedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveFailedDownloads, field.TypeBool, value)
|
||||
_node.RemoveFailedDownloads = value
|
||||
}
|
||||
if value, ok := dcc.mutation.Tags(); ok {
|
||||
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
|
||||
_node.Tags = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// DownloadClientsCreateBulk is the builder for creating many DownloadClients entities in bulk.
|
||||
type DownloadClientsCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*DownloadClientsCreate
|
||||
}
|
||||
|
||||
// Save creates the DownloadClients entities in the database.
|
||||
func (dccb *DownloadClientsCreateBulk) Save(ctx context.Context) ([]*DownloadClients, error) {
|
||||
if dccb.err != nil {
|
||||
return nil, dccb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(dccb.builders))
|
||||
nodes := make([]*DownloadClients, len(dccb.builders))
|
||||
mutators := make([]Mutator, len(dccb.builders))
|
||||
for i := range dccb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := dccb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*DownloadClientsMutation)
|
||||
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, dccb.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, dccb.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, dccb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (dccb *DownloadClientsCreateBulk) SaveX(ctx context.Context) []*DownloadClients {
|
||||
v, err := dccb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (dccb *DownloadClientsCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := dccb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (dccb *DownloadClientsCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := dccb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/downloadclients_delete.go
Normal file
88
ent/downloadclients_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// DownloadClientsDelete is the builder for deleting a DownloadClients entity.
|
||||
type DownloadClientsDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *DownloadClientsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the DownloadClientsDelete builder.
|
||||
func (dcd *DownloadClientsDelete) Where(ps ...predicate.DownloadClients) *DownloadClientsDelete {
|
||||
dcd.mutation.Where(ps...)
|
||||
return dcd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (dcd *DownloadClientsDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, dcd.sqlExec, dcd.mutation, dcd.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (dcd *DownloadClientsDelete) ExecX(ctx context.Context) int {
|
||||
n, err := dcd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (dcd *DownloadClientsDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(downloadclients.Table, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
||||
if ps := dcd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, dcd.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
dcd.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// DownloadClientsDeleteOne is the builder for deleting a single DownloadClients entity.
|
||||
type DownloadClientsDeleteOne struct {
|
||||
dcd *DownloadClientsDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the DownloadClientsDelete builder.
|
||||
func (dcdo *DownloadClientsDeleteOne) Where(ps ...predicate.DownloadClients) *DownloadClientsDeleteOne {
|
||||
dcdo.dcd.mutation.Where(ps...)
|
||||
return dcdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (dcdo *DownloadClientsDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := dcdo.dcd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{downloadclients.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (dcdo *DownloadClientsDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := dcdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
526
ent/downloadclients_query.go
Normal file
526
ent/downloadclients_query.go
Normal file
@@ -0,0 +1,526 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// DownloadClientsQuery is the builder for querying DownloadClients entities.
|
||||
type DownloadClientsQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []downloadclients.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.DownloadClients
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the DownloadClientsQuery builder.
|
||||
func (dcq *DownloadClientsQuery) Where(ps ...predicate.DownloadClients) *DownloadClientsQuery {
|
||||
dcq.predicates = append(dcq.predicates, ps...)
|
||||
return dcq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (dcq *DownloadClientsQuery) Limit(limit int) *DownloadClientsQuery {
|
||||
dcq.ctx.Limit = &limit
|
||||
return dcq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (dcq *DownloadClientsQuery) Offset(offset int) *DownloadClientsQuery {
|
||||
dcq.ctx.Offset = &offset
|
||||
return dcq
|
||||
}
|
||||
|
||||
// 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 (dcq *DownloadClientsQuery) Unique(unique bool) *DownloadClientsQuery {
|
||||
dcq.ctx.Unique = &unique
|
||||
return dcq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (dcq *DownloadClientsQuery) Order(o ...downloadclients.OrderOption) *DownloadClientsQuery {
|
||||
dcq.order = append(dcq.order, o...)
|
||||
return dcq
|
||||
}
|
||||
|
||||
// First returns the first DownloadClients entity from the query.
|
||||
// Returns a *NotFoundError when no DownloadClients was found.
|
||||
func (dcq *DownloadClientsQuery) First(ctx context.Context) (*DownloadClients, error) {
|
||||
nodes, err := dcq.Limit(1).All(setContextOp(ctx, dcq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{downloadclients.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (dcq *DownloadClientsQuery) FirstX(ctx context.Context) *DownloadClients {
|
||||
node, err := dcq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first DownloadClients ID from the query.
|
||||
// Returns a *NotFoundError when no DownloadClients ID was found.
|
||||
func (dcq *DownloadClientsQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = dcq.Limit(1).IDs(setContextOp(ctx, dcq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{downloadclients.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (dcq *DownloadClientsQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := dcq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single DownloadClients entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one DownloadClients entity is found.
|
||||
// Returns a *NotFoundError when no DownloadClients entities are found.
|
||||
func (dcq *DownloadClientsQuery) Only(ctx context.Context) (*DownloadClients, error) {
|
||||
nodes, err := dcq.Limit(2).All(setContextOp(ctx, dcq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{downloadclients.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{downloadclients.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (dcq *DownloadClientsQuery) OnlyX(ctx context.Context) *DownloadClients {
|
||||
node, err := dcq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only DownloadClients ID in the query.
|
||||
// Returns a *NotSingularError when more than one DownloadClients ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (dcq *DownloadClientsQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = dcq.Limit(2).IDs(setContextOp(ctx, dcq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{downloadclients.Label}
|
||||
default:
|
||||
err = &NotSingularError{downloadclients.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (dcq *DownloadClientsQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := dcq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of DownloadClientsSlice.
|
||||
func (dcq *DownloadClientsQuery) All(ctx context.Context) ([]*DownloadClients, error) {
|
||||
ctx = setContextOp(ctx, dcq.ctx, "All")
|
||||
if err := dcq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*DownloadClients, *DownloadClientsQuery]()
|
||||
return withInterceptors[[]*DownloadClients](ctx, dcq, qr, dcq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (dcq *DownloadClientsQuery) AllX(ctx context.Context) []*DownloadClients {
|
||||
nodes, err := dcq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of DownloadClients IDs.
|
||||
func (dcq *DownloadClientsQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if dcq.ctx.Unique == nil && dcq.path != nil {
|
||||
dcq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, dcq.ctx, "IDs")
|
||||
if err = dcq.Select(downloadclients.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (dcq *DownloadClientsQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := dcq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (dcq *DownloadClientsQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, dcq.ctx, "Count")
|
||||
if err := dcq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, dcq, querierCount[*DownloadClientsQuery](), dcq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (dcq *DownloadClientsQuery) CountX(ctx context.Context) int {
|
||||
count, err := dcq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (dcq *DownloadClientsQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, dcq.ctx, "Exist")
|
||||
switch _, err := dcq.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 (dcq *DownloadClientsQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := dcq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the DownloadClientsQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (dcq *DownloadClientsQuery) Clone() *DownloadClientsQuery {
|
||||
if dcq == nil {
|
||||
return nil
|
||||
}
|
||||
return &DownloadClientsQuery{
|
||||
config: dcq.config,
|
||||
ctx: dcq.ctx.Clone(),
|
||||
order: append([]downloadclients.OrderOption{}, dcq.order...),
|
||||
inters: append([]Interceptor{}, dcq.inters...),
|
||||
predicates: append([]predicate.DownloadClients{}, dcq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: dcq.sql.Clone(),
|
||||
path: dcq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// Enable bool `json:"enable,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.DownloadClients.Query().
|
||||
// GroupBy(downloadclients.FieldEnable).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (dcq *DownloadClientsQuery) GroupBy(field string, fields ...string) *DownloadClientsGroupBy {
|
||||
dcq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &DownloadClientsGroupBy{build: dcq}
|
||||
grbuild.flds = &dcq.ctx.Fields
|
||||
grbuild.label = downloadclients.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 {
|
||||
// Enable bool `json:"enable,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.DownloadClients.Query().
|
||||
// Select(downloadclients.FieldEnable).
|
||||
// Scan(ctx, &v)
|
||||
func (dcq *DownloadClientsQuery) Select(fields ...string) *DownloadClientsSelect {
|
||||
dcq.ctx.Fields = append(dcq.ctx.Fields, fields...)
|
||||
sbuild := &DownloadClientsSelect{DownloadClientsQuery: dcq}
|
||||
sbuild.label = downloadclients.Label
|
||||
sbuild.flds, sbuild.scan = &dcq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a DownloadClientsSelect configured with the given aggregations.
|
||||
func (dcq *DownloadClientsQuery) Aggregate(fns ...AggregateFunc) *DownloadClientsSelect {
|
||||
return dcq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (dcq *DownloadClientsQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range dcq.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, dcq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range dcq.ctx.Fields {
|
||||
if !downloadclients.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if dcq.path != nil {
|
||||
prev, err := dcq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dcq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dcq *DownloadClientsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*DownloadClients, error) {
|
||||
var (
|
||||
nodes = []*DownloadClients{}
|
||||
_spec = dcq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*DownloadClients).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &DownloadClients{config: dcq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, dcq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (dcq *DownloadClientsQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := dcq.querySpec()
|
||||
_spec.Node.Columns = dcq.ctx.Fields
|
||||
if len(dcq.ctx.Fields) > 0 {
|
||||
_spec.Unique = dcq.ctx.Unique != nil && *dcq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, dcq.driver, _spec)
|
||||
}
|
||||
|
||||
func (dcq *DownloadClientsQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
||||
_spec.From = dcq.sql
|
||||
if unique := dcq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if dcq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := dcq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, downloadclients.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != downloadclients.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := dcq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := dcq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := dcq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := dcq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (dcq *DownloadClientsQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(dcq.driver.Dialect())
|
||||
t1 := builder.Table(downloadclients.Table)
|
||||
columns := dcq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = downloadclients.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if dcq.sql != nil {
|
||||
selector = dcq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if dcq.ctx.Unique != nil && *dcq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range dcq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range dcq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := dcq.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 := dcq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// DownloadClientsGroupBy is the group-by builder for DownloadClients entities.
|
||||
type DownloadClientsGroupBy struct {
|
||||
selector
|
||||
build *DownloadClientsQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (dcgb *DownloadClientsGroupBy) Aggregate(fns ...AggregateFunc) *DownloadClientsGroupBy {
|
||||
dcgb.fns = append(dcgb.fns, fns...)
|
||||
return dcgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (dcgb *DownloadClientsGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, dcgb.build.ctx, "GroupBy")
|
||||
if err := dcgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*DownloadClientsQuery, *DownloadClientsGroupBy](ctx, dcgb.build, dcgb, dcgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (dcgb *DownloadClientsGroupBy) sqlScan(ctx context.Context, root *DownloadClientsQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(dcgb.fns))
|
||||
for _, fn := range dcgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*dcgb.flds)+len(dcgb.fns))
|
||||
for _, f := range *dcgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*dcgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := dcgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// DownloadClientsSelect is the builder for selecting fields of DownloadClients entities.
|
||||
type DownloadClientsSelect struct {
|
||||
*DownloadClientsQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (dcs *DownloadClientsSelect) Aggregate(fns ...AggregateFunc) *DownloadClientsSelect {
|
||||
dcs.fns = append(dcs.fns, fns...)
|
||||
return dcs
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (dcs *DownloadClientsSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, dcs.ctx, "Select")
|
||||
if err := dcs.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*DownloadClientsQuery, *DownloadClientsSelect](ctx, dcs.DownloadClientsQuery, dcs, dcs.inters, v)
|
||||
}
|
||||
|
||||
func (dcs *DownloadClientsSelect) sqlScan(ctx context.Context, root *DownloadClientsQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(dcs.fns))
|
||||
for _, fn := range dcs.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*dcs.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 := dcs.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
447
ent/downloadclients_update.go
Normal file
447
ent/downloadclients_update.go
Normal file
@@ -0,0 +1,447 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// DownloadClientsUpdate is the builder for updating DownloadClients entities.
|
||||
type DownloadClientsUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *DownloadClientsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the DownloadClientsUpdate builder.
|
||||
func (dcu *DownloadClientsUpdate) Where(ps ...predicate.DownloadClients) *DownloadClientsUpdate {
|
||||
dcu.mutation.Where(ps...)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetEnable sets the "enable" field.
|
||||
func (dcu *DownloadClientsUpdate) SetEnable(b bool) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetEnable(b)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableEnable sets the "enable" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableEnable(b *bool) *DownloadClientsUpdate {
|
||||
if b != nil {
|
||||
dcu.SetEnable(*b)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (dcu *DownloadClientsUpdate) SetName(s string) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetName(s)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableName(s *string) *DownloadClientsUpdate {
|
||||
if s != nil {
|
||||
dcu.SetName(*s)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (dcu *DownloadClientsUpdate) SetImplementation(s string) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetImplementation(s)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableImplementation(s *string) *DownloadClientsUpdate {
|
||||
if s != nil {
|
||||
dcu.SetImplementation(*s)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (dcu *DownloadClientsUpdate) SetSettings(s string) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetSettings(s)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableSettings(s *string) *DownloadClientsUpdate {
|
||||
if s != nil {
|
||||
dcu.SetSettings(*s)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (dcu *DownloadClientsUpdate) SetPriority(s string) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetPriority(s)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillablePriority(s *string) *DownloadClientsUpdate {
|
||||
if s != nil {
|
||||
dcu.SetPriority(*s)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
||||
func (dcu *DownloadClientsUpdate) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetRemoveCompletedDownloads(b)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableRemoveCompletedDownloads sets the "remove_completed_downloads" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableRemoveCompletedDownloads(b *bool) *DownloadClientsUpdate {
|
||||
if b != nil {
|
||||
dcu.SetRemoveCompletedDownloads(*b)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetRemoveFailedDownloads sets the "remove_failed_downloads" field.
|
||||
func (dcu *DownloadClientsUpdate) SetRemoveFailedDownloads(b bool) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetRemoveFailedDownloads(b)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableRemoveFailedDownloads sets the "remove_failed_downloads" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableRemoveFailedDownloads(b *bool) *DownloadClientsUpdate {
|
||||
if b != nil {
|
||||
dcu.SetRemoveFailedDownloads(*b)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetTags sets the "tags" field.
|
||||
func (dcu *DownloadClientsUpdate) SetTags(s string) *DownloadClientsUpdate {
|
||||
dcu.mutation.SetTags(s)
|
||||
return dcu
|
||||
}
|
||||
|
||||
// SetNillableTags sets the "tags" field if the given value is not nil.
|
||||
func (dcu *DownloadClientsUpdate) SetNillableTags(s *string) *DownloadClientsUpdate {
|
||||
if s != nil {
|
||||
dcu.SetTags(*s)
|
||||
}
|
||||
return dcu
|
||||
}
|
||||
|
||||
// Mutation returns the DownloadClientsMutation object of the builder.
|
||||
func (dcu *DownloadClientsUpdate) Mutation() *DownloadClientsMutation {
|
||||
return dcu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (dcu *DownloadClientsUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, dcu.sqlSave, dcu.mutation, dcu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (dcu *DownloadClientsUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := dcu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (dcu *DownloadClientsUpdate) Exec(ctx context.Context) error {
|
||||
_, err := dcu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (dcu *DownloadClientsUpdate) ExecX(ctx context.Context) {
|
||||
if err := dcu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (dcu *DownloadClientsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
||||
if ps := dcu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := dcu.mutation.Enable(); ok {
|
||||
_spec.SetField(downloadclients.FieldEnable, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.Name(); ok {
|
||||
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.Implementation(); ok {
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.Settings(); ok {
|
||||
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.Priority(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.RemoveFailedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveFailedDownloads, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := dcu.mutation.Tags(); ok {
|
||||
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, dcu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{downloadclients.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
dcu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// DownloadClientsUpdateOne is the builder for updating a single DownloadClients entity.
|
||||
type DownloadClientsUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *DownloadClientsMutation
|
||||
}
|
||||
|
||||
// SetEnable sets the "enable" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetEnable(b bool) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetEnable(b)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableEnable sets the "enable" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableEnable(b *bool) *DownloadClientsUpdateOne {
|
||||
if b != nil {
|
||||
dcuo.SetEnable(*b)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetName(s string) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetName(s)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableName(s *string) *DownloadClientsUpdateOne {
|
||||
if s != nil {
|
||||
dcuo.SetName(*s)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetImplementation(s string) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetImplementation(s)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableImplementation(s *string) *DownloadClientsUpdateOne {
|
||||
if s != nil {
|
||||
dcuo.SetImplementation(*s)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetSettings(s string) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetSettings(s)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableSettings(s *string) *DownloadClientsUpdateOne {
|
||||
if s != nil {
|
||||
dcuo.SetSettings(*s)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetPriority(s string) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetPriority(s)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillablePriority(s *string) *DownloadClientsUpdateOne {
|
||||
if s != nil {
|
||||
dcuo.SetPriority(*s)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetRemoveCompletedDownloads sets the "remove_completed_downloads" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetRemoveCompletedDownloads(b bool) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetRemoveCompletedDownloads(b)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableRemoveCompletedDownloads sets the "remove_completed_downloads" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableRemoveCompletedDownloads(b *bool) *DownloadClientsUpdateOne {
|
||||
if b != nil {
|
||||
dcuo.SetRemoveCompletedDownloads(*b)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetRemoveFailedDownloads sets the "remove_failed_downloads" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetRemoveFailedDownloads(b bool) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetRemoveFailedDownloads(b)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableRemoveFailedDownloads sets the "remove_failed_downloads" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableRemoveFailedDownloads(b *bool) *DownloadClientsUpdateOne {
|
||||
if b != nil {
|
||||
dcuo.SetRemoveFailedDownloads(*b)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetTags sets the "tags" field.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetTags(s string) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.SetTags(s)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// SetNillableTags sets the "tags" field if the given value is not nil.
|
||||
func (dcuo *DownloadClientsUpdateOne) SetNillableTags(s *string) *DownloadClientsUpdateOne {
|
||||
if s != nil {
|
||||
dcuo.SetTags(*s)
|
||||
}
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// Mutation returns the DownloadClientsMutation object of the builder.
|
||||
func (dcuo *DownloadClientsUpdateOne) Mutation() *DownloadClientsMutation {
|
||||
return dcuo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the DownloadClientsUpdate builder.
|
||||
func (dcuo *DownloadClientsUpdateOne) Where(ps ...predicate.DownloadClients) *DownloadClientsUpdateOne {
|
||||
dcuo.mutation.Where(ps...)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (dcuo *DownloadClientsUpdateOne) Select(field string, fields ...string) *DownloadClientsUpdateOne {
|
||||
dcuo.fields = append([]string{field}, fields...)
|
||||
return dcuo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated DownloadClients entity.
|
||||
func (dcuo *DownloadClientsUpdateOne) Save(ctx context.Context) (*DownloadClients, error) {
|
||||
return withHooks(ctx, dcuo.sqlSave, dcuo.mutation, dcuo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (dcuo *DownloadClientsUpdateOne) SaveX(ctx context.Context) *DownloadClients {
|
||||
node, err := dcuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (dcuo *DownloadClientsUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := dcuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (dcuo *DownloadClientsUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := dcuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (dcuo *DownloadClientsUpdateOne) sqlSave(ctx context.Context) (_node *DownloadClients, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(downloadclients.Table, downloadclients.Columns, sqlgraph.NewFieldSpec(downloadclients.FieldID, field.TypeInt))
|
||||
id, ok := dcuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "DownloadClients.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := dcuo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, downloadclients.FieldID)
|
||||
for _, f := range fields {
|
||||
if !downloadclients.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != downloadclients.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := dcuo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := dcuo.mutation.Enable(); ok {
|
||||
_spec.SetField(downloadclients.FieldEnable, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.Name(); ok {
|
||||
_spec.SetField(downloadclients.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.Implementation(); ok {
|
||||
_spec.SetField(downloadclients.FieldImplementation, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.Settings(); ok {
|
||||
_spec.SetField(downloadclients.FieldSettings, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.Priority(); ok {
|
||||
_spec.SetField(downloadclients.FieldPriority, field.TypeString, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.RemoveCompletedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveCompletedDownloads, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.RemoveFailedDownloads(); ok {
|
||||
_spec.SetField(downloadclients.FieldRemoveFailedDownloads, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := dcuo.mutation.Tags(); ok {
|
||||
_spec.SetField(downloadclients.FieldTags, field.TypeString, value)
|
||||
}
|
||||
_node = &DownloadClients{config: dcuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, dcuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{downloadclients.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
dcuo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
616
ent/ent.go
Normal file
616
ent/ent.go
Normal file
@@ -0,0 +1,616 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/downloadclients"
|
||||
"polaris/ent/epidodes"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/series"
|
||||
"polaris/ent/settings"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"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
|
||||
)
|
||||
|
||||
// columnChecker 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{
|
||||
downloadclients.Table: downloadclients.ValidColumn,
|
||||
epidodes.Table: epidodes.ValidColumn,
|
||||
indexers.Table: indexers.ValidColumn,
|
||||
series.Table: series.ValidColumn,
|
||||
settings.Table: settings.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)
|
||||
84
ent/enttest/enttest.go
Normal file
84
ent/enttest/enttest.go
Normal file
@@ -0,0 +1,84 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package enttest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent"
|
||||
// required by schema hooks.
|
||||
_ "polaris/ent/runtime"
|
||||
|
||||
"polaris/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()
|
||||
}
|
||||
}
|
||||
161
ent/epidodes.go
Normal file
161
ent/epidodes.go
Normal file
@@ -0,0 +1,161 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/ent/epidodes"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Epidodes is the model entity for the Epidodes schema.
|
||||
type Epidodes struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// SeriesID holds the value of the "series_id" field.
|
||||
SeriesID int `json:"series_id,omitempty"`
|
||||
// SeasonNumber holds the value of the "season_number" field.
|
||||
SeasonNumber int `json:"season_number,omitempty"`
|
||||
// EpisodeNumber holds the value of the "episode_number" field.
|
||||
EpisodeNumber int `json:"episode_number,omitempty"`
|
||||
// Title holds the value of the "title" field.
|
||||
Title string `json:"title,omitempty"`
|
||||
// Overview holds the value of the "overview" field.
|
||||
Overview string `json:"overview,omitempty"`
|
||||
// AirDate holds the value of the "air_date" field.
|
||||
AirDate time.Time `json:"air_date,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Epidodes) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case epidodes.FieldID, epidodes.FieldSeriesID, epidodes.FieldSeasonNumber, epidodes.FieldEpisodeNumber:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case epidodes.FieldTitle, epidodes.FieldOverview:
|
||||
values[i] = new(sql.NullString)
|
||||
case epidodes.FieldAirDate:
|
||||
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 Epidodes fields.
|
||||
func (e *Epidodes) 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 epidodes.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
e.ID = int(value.Int64)
|
||||
case epidodes.FieldSeriesID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field series_id", values[i])
|
||||
} else if value.Valid {
|
||||
e.SeriesID = int(value.Int64)
|
||||
}
|
||||
case epidodes.FieldSeasonNumber:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field season_number", values[i])
|
||||
} else if value.Valid {
|
||||
e.SeasonNumber = int(value.Int64)
|
||||
}
|
||||
case epidodes.FieldEpisodeNumber:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field episode_number", values[i])
|
||||
} else if value.Valid {
|
||||
e.EpisodeNumber = int(value.Int64)
|
||||
}
|
||||
case epidodes.FieldTitle:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field title", values[i])
|
||||
} else if value.Valid {
|
||||
e.Title = value.String
|
||||
}
|
||||
case epidodes.FieldOverview:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field overview", values[i])
|
||||
} else if value.Valid {
|
||||
e.Overview = value.String
|
||||
}
|
||||
case epidodes.FieldAirDate:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field air_date", values[i])
|
||||
} else if value.Valid {
|
||||
e.AirDate = value.Time
|
||||
}
|
||||
default:
|
||||
e.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Epidodes.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (e *Epidodes) Value(name string) (ent.Value, error) {
|
||||
return e.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Epidodes.
|
||||
// Note that you need to call Epidodes.Unwrap() before calling this method if this Epidodes
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (e *Epidodes) Update() *EpidodesUpdateOne {
|
||||
return NewEpidodesClient(e.config).UpdateOne(e)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Epidodes 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 (e *Epidodes) Unwrap() *Epidodes {
|
||||
_tx, ok := e.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Epidodes is not a transactional entity")
|
||||
}
|
||||
e.config.driver = _tx.drv
|
||||
return e
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (e *Epidodes) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Epidodes(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", e.ID))
|
||||
builder.WriteString("series_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.SeriesID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("season_number=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.SeasonNumber))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("episode_number=")
|
||||
builder.WriteString(fmt.Sprintf("%v", e.EpisodeNumber))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("title=")
|
||||
builder.WriteString(e.Title)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("overview=")
|
||||
builder.WriteString(e.Overview)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("air_date=")
|
||||
builder.WriteString(e.AirDate.Format(time.ANSIC))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// EpidodesSlice is a parsable slice of Epidodes.
|
||||
type EpidodesSlice []*Epidodes
|
||||
87
ent/epidodes/epidodes.go
Normal file
87
ent/epidodes/epidodes.go
Normal file
@@ -0,0 +1,87 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package epidodes
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the epidodes type in the database.
|
||||
Label = "epidodes"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldSeriesID holds the string denoting the series_id field in the database.
|
||||
FieldSeriesID = "series_id"
|
||||
// FieldSeasonNumber holds the string denoting the season_number field in the database.
|
||||
FieldSeasonNumber = "season_number"
|
||||
// FieldEpisodeNumber holds the string denoting the episode_number field in the database.
|
||||
FieldEpisodeNumber = "episode_number"
|
||||
// FieldTitle holds the string denoting the title field in the database.
|
||||
FieldTitle = "title"
|
||||
// FieldOverview holds the string denoting the overview field in the database.
|
||||
FieldOverview = "overview"
|
||||
// FieldAirDate holds the string denoting the air_date field in the database.
|
||||
FieldAirDate = "air_date"
|
||||
// Table holds the table name of the epidodes in the database.
|
||||
Table = "epidodes"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for epidodes fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldSeriesID,
|
||||
FieldSeasonNumber,
|
||||
FieldEpisodeNumber,
|
||||
FieldTitle,
|
||||
FieldOverview,
|
||||
FieldAirDate,
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the Epidodes 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()
|
||||
}
|
||||
|
||||
// BySeriesID orders the results by the series_id field.
|
||||
func BySeriesID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSeriesID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySeasonNumber orders the results by the season_number field.
|
||||
func BySeasonNumber(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSeasonNumber, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEpisodeNumber orders the results by the episode_number field.
|
||||
func ByEpisodeNumber(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEpisodeNumber, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTitle orders the results by the title field.
|
||||
func ByTitle(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTitle, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOverview orders the results by the overview field.
|
||||
func ByOverview(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldOverview, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAirDate orders the results by the air_date field.
|
||||
func ByAirDate(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAirDate, opts...).ToFunc()
|
||||
}
|
||||
390
ent/epidodes/where.go
Normal file
390
ent/epidodes/where.go
Normal file
@@ -0,0 +1,390 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package epidodes
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// SeriesID applies equality check predicate on the "series_id" field. It's identical to SeriesIDEQ.
|
||||
func SeriesID(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldSeriesID, v))
|
||||
}
|
||||
|
||||
// SeasonNumber applies equality check predicate on the "season_number" field. It's identical to SeasonNumberEQ.
|
||||
func SeasonNumber(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldSeasonNumber, v))
|
||||
}
|
||||
|
||||
// EpisodeNumber applies equality check predicate on the "episode_number" field. It's identical to EpisodeNumberEQ.
|
||||
func EpisodeNumber(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldEpisodeNumber, v))
|
||||
}
|
||||
|
||||
// Title applies equality check predicate on the "title" field. It's identical to TitleEQ.
|
||||
func Title(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldTitle, v))
|
||||
}
|
||||
|
||||
// Overview applies equality check predicate on the "overview" field. It's identical to OverviewEQ.
|
||||
func Overview(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldOverview, v))
|
||||
}
|
||||
|
||||
// AirDate applies equality check predicate on the "air_date" field. It's identical to AirDateEQ.
|
||||
func AirDate(v time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// SeriesIDEQ applies the EQ predicate on the "series_id" field.
|
||||
func SeriesIDEQ(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldSeriesID, v))
|
||||
}
|
||||
|
||||
// SeriesIDNEQ applies the NEQ predicate on the "series_id" field.
|
||||
func SeriesIDNEQ(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNEQ(FieldSeriesID, v))
|
||||
}
|
||||
|
||||
// SeriesIDIn applies the In predicate on the "series_id" field.
|
||||
func SeriesIDIn(vs ...int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldIn(FieldSeriesID, vs...))
|
||||
}
|
||||
|
||||
// SeriesIDNotIn applies the NotIn predicate on the "series_id" field.
|
||||
func SeriesIDNotIn(vs ...int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNotIn(FieldSeriesID, vs...))
|
||||
}
|
||||
|
||||
// SeriesIDGT applies the GT predicate on the "series_id" field.
|
||||
func SeriesIDGT(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGT(FieldSeriesID, v))
|
||||
}
|
||||
|
||||
// SeriesIDGTE applies the GTE predicate on the "series_id" field.
|
||||
func SeriesIDGTE(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGTE(FieldSeriesID, v))
|
||||
}
|
||||
|
||||
// SeriesIDLT applies the LT predicate on the "series_id" field.
|
||||
func SeriesIDLT(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLT(FieldSeriesID, v))
|
||||
}
|
||||
|
||||
// SeriesIDLTE applies the LTE predicate on the "series_id" field.
|
||||
func SeriesIDLTE(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLTE(FieldSeriesID, v))
|
||||
}
|
||||
|
||||
// SeasonNumberEQ applies the EQ predicate on the "season_number" field.
|
||||
func SeasonNumberEQ(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldSeasonNumber, v))
|
||||
}
|
||||
|
||||
// SeasonNumberNEQ applies the NEQ predicate on the "season_number" field.
|
||||
func SeasonNumberNEQ(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNEQ(FieldSeasonNumber, v))
|
||||
}
|
||||
|
||||
// SeasonNumberIn applies the In predicate on the "season_number" field.
|
||||
func SeasonNumberIn(vs ...int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldIn(FieldSeasonNumber, vs...))
|
||||
}
|
||||
|
||||
// SeasonNumberNotIn applies the NotIn predicate on the "season_number" field.
|
||||
func SeasonNumberNotIn(vs ...int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNotIn(FieldSeasonNumber, vs...))
|
||||
}
|
||||
|
||||
// SeasonNumberGT applies the GT predicate on the "season_number" field.
|
||||
func SeasonNumberGT(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGT(FieldSeasonNumber, v))
|
||||
}
|
||||
|
||||
// SeasonNumberGTE applies the GTE predicate on the "season_number" field.
|
||||
func SeasonNumberGTE(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGTE(FieldSeasonNumber, v))
|
||||
}
|
||||
|
||||
// SeasonNumberLT applies the LT predicate on the "season_number" field.
|
||||
func SeasonNumberLT(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLT(FieldSeasonNumber, v))
|
||||
}
|
||||
|
||||
// SeasonNumberLTE applies the LTE predicate on the "season_number" field.
|
||||
func SeasonNumberLTE(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLTE(FieldSeasonNumber, v))
|
||||
}
|
||||
|
||||
// EpisodeNumberEQ applies the EQ predicate on the "episode_number" field.
|
||||
func EpisodeNumberEQ(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldEpisodeNumber, v))
|
||||
}
|
||||
|
||||
// EpisodeNumberNEQ applies the NEQ predicate on the "episode_number" field.
|
||||
func EpisodeNumberNEQ(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNEQ(FieldEpisodeNumber, v))
|
||||
}
|
||||
|
||||
// EpisodeNumberIn applies the In predicate on the "episode_number" field.
|
||||
func EpisodeNumberIn(vs ...int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldIn(FieldEpisodeNumber, vs...))
|
||||
}
|
||||
|
||||
// EpisodeNumberNotIn applies the NotIn predicate on the "episode_number" field.
|
||||
func EpisodeNumberNotIn(vs ...int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNotIn(FieldEpisodeNumber, vs...))
|
||||
}
|
||||
|
||||
// EpisodeNumberGT applies the GT predicate on the "episode_number" field.
|
||||
func EpisodeNumberGT(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGT(FieldEpisodeNumber, v))
|
||||
}
|
||||
|
||||
// EpisodeNumberGTE applies the GTE predicate on the "episode_number" field.
|
||||
func EpisodeNumberGTE(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGTE(FieldEpisodeNumber, v))
|
||||
}
|
||||
|
||||
// EpisodeNumberLT applies the LT predicate on the "episode_number" field.
|
||||
func EpisodeNumberLT(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLT(FieldEpisodeNumber, v))
|
||||
}
|
||||
|
||||
// EpisodeNumberLTE applies the LTE predicate on the "episode_number" field.
|
||||
func EpisodeNumberLTE(v int) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLTE(FieldEpisodeNumber, v))
|
||||
}
|
||||
|
||||
// TitleEQ applies the EQ predicate on the "title" field.
|
||||
func TitleEQ(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleNEQ applies the NEQ predicate on the "title" field.
|
||||
func TitleNEQ(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNEQ(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleIn applies the In predicate on the "title" field.
|
||||
func TitleIn(vs ...string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldIn(FieldTitle, vs...))
|
||||
}
|
||||
|
||||
// TitleNotIn applies the NotIn predicate on the "title" field.
|
||||
func TitleNotIn(vs ...string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNotIn(FieldTitle, vs...))
|
||||
}
|
||||
|
||||
// TitleGT applies the GT predicate on the "title" field.
|
||||
func TitleGT(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGT(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleGTE applies the GTE predicate on the "title" field.
|
||||
func TitleGTE(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGTE(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleLT applies the LT predicate on the "title" field.
|
||||
func TitleLT(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLT(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleLTE applies the LTE predicate on the "title" field.
|
||||
func TitleLTE(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLTE(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleContains applies the Contains predicate on the "title" field.
|
||||
func TitleContains(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldContains(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleHasPrefix applies the HasPrefix predicate on the "title" field.
|
||||
func TitleHasPrefix(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldHasPrefix(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleHasSuffix applies the HasSuffix predicate on the "title" field.
|
||||
func TitleHasSuffix(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldHasSuffix(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleEqualFold applies the EqualFold predicate on the "title" field.
|
||||
func TitleEqualFold(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEqualFold(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleContainsFold applies the ContainsFold predicate on the "title" field.
|
||||
func TitleContainsFold(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldContainsFold(FieldTitle, v))
|
||||
}
|
||||
|
||||
// OverviewEQ applies the EQ predicate on the "overview" field.
|
||||
func OverviewEQ(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewNEQ applies the NEQ predicate on the "overview" field.
|
||||
func OverviewNEQ(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNEQ(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewIn applies the In predicate on the "overview" field.
|
||||
func OverviewIn(vs ...string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldIn(FieldOverview, vs...))
|
||||
}
|
||||
|
||||
// OverviewNotIn applies the NotIn predicate on the "overview" field.
|
||||
func OverviewNotIn(vs ...string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNotIn(FieldOverview, vs...))
|
||||
}
|
||||
|
||||
// OverviewGT applies the GT predicate on the "overview" field.
|
||||
func OverviewGT(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGT(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewGTE applies the GTE predicate on the "overview" field.
|
||||
func OverviewGTE(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGTE(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewLT applies the LT predicate on the "overview" field.
|
||||
func OverviewLT(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLT(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewLTE applies the LTE predicate on the "overview" field.
|
||||
func OverviewLTE(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLTE(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewContains applies the Contains predicate on the "overview" field.
|
||||
func OverviewContains(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldContains(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewHasPrefix applies the HasPrefix predicate on the "overview" field.
|
||||
func OverviewHasPrefix(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldHasPrefix(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewHasSuffix applies the HasSuffix predicate on the "overview" field.
|
||||
func OverviewHasSuffix(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldHasSuffix(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewEqualFold applies the EqualFold predicate on the "overview" field.
|
||||
func OverviewEqualFold(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEqualFold(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewContainsFold applies the ContainsFold predicate on the "overview" field.
|
||||
func OverviewContainsFold(v string) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldContainsFold(FieldOverview, v))
|
||||
}
|
||||
|
||||
// AirDateEQ applies the EQ predicate on the "air_date" field.
|
||||
func AirDateEQ(v time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldEQ(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// AirDateNEQ applies the NEQ predicate on the "air_date" field.
|
||||
func AirDateNEQ(v time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNEQ(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// AirDateIn applies the In predicate on the "air_date" field.
|
||||
func AirDateIn(vs ...time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldIn(FieldAirDate, vs...))
|
||||
}
|
||||
|
||||
// AirDateNotIn applies the NotIn predicate on the "air_date" field.
|
||||
func AirDateNotIn(vs ...time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldNotIn(FieldAirDate, vs...))
|
||||
}
|
||||
|
||||
// AirDateGT applies the GT predicate on the "air_date" field.
|
||||
func AirDateGT(v time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGT(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// AirDateGTE applies the GTE predicate on the "air_date" field.
|
||||
func AirDateGTE(v time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldGTE(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// AirDateLT applies the LT predicate on the "air_date" field.
|
||||
func AirDateLT(v time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLT(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// AirDateLTE applies the LTE predicate on the "air_date" field.
|
||||
func AirDateLTE(v time.Time) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.FieldLTE(FieldAirDate, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Epidodes) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Epidodes) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Epidodes) predicate.Epidodes {
|
||||
return predicate.Epidodes(sql.NotPredicates(p))
|
||||
}
|
||||
249
ent/epidodes_create.go
Normal file
249
ent/epidodes_create.go
Normal file
@@ -0,0 +1,249 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/epidodes"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// EpidodesCreate is the builder for creating a Epidodes entity.
|
||||
type EpidodesCreate struct {
|
||||
config
|
||||
mutation *EpidodesMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetSeriesID sets the "series_id" field.
|
||||
func (ec *EpidodesCreate) SetSeriesID(i int) *EpidodesCreate {
|
||||
ec.mutation.SetSeriesID(i)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetSeasonNumber sets the "season_number" field.
|
||||
func (ec *EpidodesCreate) SetSeasonNumber(i int) *EpidodesCreate {
|
||||
ec.mutation.SetSeasonNumber(i)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetEpisodeNumber sets the "episode_number" field.
|
||||
func (ec *EpidodesCreate) SetEpisodeNumber(i int) *EpidodesCreate {
|
||||
ec.mutation.SetEpisodeNumber(i)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (ec *EpidodesCreate) SetTitle(s string) *EpidodesCreate {
|
||||
ec.mutation.SetTitle(s)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetOverview sets the "overview" field.
|
||||
func (ec *EpidodesCreate) SetOverview(s string) *EpidodesCreate {
|
||||
ec.mutation.SetOverview(s)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetAirDate sets the "air_date" field.
|
||||
func (ec *EpidodesCreate) SetAirDate(t time.Time) *EpidodesCreate {
|
||||
ec.mutation.SetAirDate(t)
|
||||
return ec
|
||||
}
|
||||
|
||||
// Mutation returns the EpidodesMutation object of the builder.
|
||||
func (ec *EpidodesCreate) Mutation() *EpidodesMutation {
|
||||
return ec.mutation
|
||||
}
|
||||
|
||||
// Save creates the Epidodes in the database.
|
||||
func (ec *EpidodesCreate) Save(ctx context.Context) (*Epidodes, error) {
|
||||
return withHooks(ctx, ec.sqlSave, ec.mutation, ec.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (ec *EpidodesCreate) SaveX(ctx context.Context) *Epidodes {
|
||||
v, err := ec.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ec *EpidodesCreate) Exec(ctx context.Context) error {
|
||||
_, err := ec.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ec *EpidodesCreate) ExecX(ctx context.Context) {
|
||||
if err := ec.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ec *EpidodesCreate) check() error {
|
||||
if _, ok := ec.mutation.SeriesID(); !ok {
|
||||
return &ValidationError{Name: "series_id", err: errors.New(`ent: missing required field "Epidodes.series_id"`)}
|
||||
}
|
||||
if _, ok := ec.mutation.SeasonNumber(); !ok {
|
||||
return &ValidationError{Name: "season_number", err: errors.New(`ent: missing required field "Epidodes.season_number"`)}
|
||||
}
|
||||
if _, ok := ec.mutation.EpisodeNumber(); !ok {
|
||||
return &ValidationError{Name: "episode_number", err: errors.New(`ent: missing required field "Epidodes.episode_number"`)}
|
||||
}
|
||||
if _, ok := ec.mutation.Title(); !ok {
|
||||
return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Epidodes.title"`)}
|
||||
}
|
||||
if _, ok := ec.mutation.Overview(); !ok {
|
||||
return &ValidationError{Name: "overview", err: errors.New(`ent: missing required field "Epidodes.overview"`)}
|
||||
}
|
||||
if _, ok := ec.mutation.AirDate(); !ok {
|
||||
return &ValidationError{Name: "air_date", err: errors.New(`ent: missing required field "Epidodes.air_date"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ec *EpidodesCreate) sqlSave(ctx context.Context) (*Epidodes, error) {
|
||||
if err := ec.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := ec.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, ec.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)
|
||||
ec.mutation.id = &_node.ID
|
||||
ec.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (ec *EpidodesCreate) createSpec() (*Epidodes, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Epidodes{config: ec.config}
|
||||
_spec = sqlgraph.NewCreateSpec(epidodes.Table, sqlgraph.NewFieldSpec(epidodes.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := ec.mutation.SeriesID(); ok {
|
||||
_spec.SetField(epidodes.FieldSeriesID, field.TypeInt, value)
|
||||
_node.SeriesID = value
|
||||
}
|
||||
if value, ok := ec.mutation.SeasonNumber(); ok {
|
||||
_spec.SetField(epidodes.FieldSeasonNumber, field.TypeInt, value)
|
||||
_node.SeasonNumber = value
|
||||
}
|
||||
if value, ok := ec.mutation.EpisodeNumber(); ok {
|
||||
_spec.SetField(epidodes.FieldEpisodeNumber, field.TypeInt, value)
|
||||
_node.EpisodeNumber = value
|
||||
}
|
||||
if value, ok := ec.mutation.Title(); ok {
|
||||
_spec.SetField(epidodes.FieldTitle, field.TypeString, value)
|
||||
_node.Title = value
|
||||
}
|
||||
if value, ok := ec.mutation.Overview(); ok {
|
||||
_spec.SetField(epidodes.FieldOverview, field.TypeString, value)
|
||||
_node.Overview = value
|
||||
}
|
||||
if value, ok := ec.mutation.AirDate(); ok {
|
||||
_spec.SetField(epidodes.FieldAirDate, field.TypeTime, value)
|
||||
_node.AirDate = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// EpidodesCreateBulk is the builder for creating many Epidodes entities in bulk.
|
||||
type EpidodesCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*EpidodesCreate
|
||||
}
|
||||
|
||||
// Save creates the Epidodes entities in the database.
|
||||
func (ecb *EpidodesCreateBulk) Save(ctx context.Context) ([]*Epidodes, error) {
|
||||
if ecb.err != nil {
|
||||
return nil, ecb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(ecb.builders))
|
||||
nodes := make([]*Epidodes, len(ecb.builders))
|
||||
mutators := make([]Mutator, len(ecb.builders))
|
||||
for i := range ecb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := ecb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*EpidodesMutation)
|
||||
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, ecb.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, ecb.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, ecb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (ecb *EpidodesCreateBulk) SaveX(ctx context.Context) []*Epidodes {
|
||||
v, err := ecb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ecb *EpidodesCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := ecb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ecb *EpidodesCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := ecb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/epidodes_delete.go
Normal file
88
ent/epidodes_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent/epidodes"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// EpidodesDelete is the builder for deleting a Epidodes entity.
|
||||
type EpidodesDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *EpidodesMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EpidodesDelete builder.
|
||||
func (ed *EpidodesDelete) Where(ps ...predicate.Epidodes) *EpidodesDelete {
|
||||
ed.mutation.Where(ps...)
|
||||
return ed
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (ed *EpidodesDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, ed.sqlExec, ed.mutation, ed.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ed *EpidodesDelete) ExecX(ctx context.Context) int {
|
||||
n, err := ed.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (ed *EpidodesDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(epidodes.Table, sqlgraph.NewFieldSpec(epidodes.FieldID, field.TypeInt))
|
||||
if ps := ed.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, ed.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
ed.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// EpidodesDeleteOne is the builder for deleting a single Epidodes entity.
|
||||
type EpidodesDeleteOne struct {
|
||||
ed *EpidodesDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EpidodesDelete builder.
|
||||
func (edo *EpidodesDeleteOne) Where(ps ...predicate.Epidodes) *EpidodesDeleteOne {
|
||||
edo.ed.mutation.Where(ps...)
|
||||
return edo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (edo *EpidodesDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := edo.ed.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{epidodes.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (edo *EpidodesDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := edo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
526
ent/epidodes_query.go
Normal file
526
ent/epidodes_query.go
Normal file
@@ -0,0 +1,526 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"polaris/ent/epidodes"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// EpidodesQuery is the builder for querying Epidodes entities.
|
||||
type EpidodesQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []epidodes.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Epidodes
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the EpidodesQuery builder.
|
||||
func (eq *EpidodesQuery) Where(ps ...predicate.Epidodes) *EpidodesQuery {
|
||||
eq.predicates = append(eq.predicates, ps...)
|
||||
return eq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (eq *EpidodesQuery) Limit(limit int) *EpidodesQuery {
|
||||
eq.ctx.Limit = &limit
|
||||
return eq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (eq *EpidodesQuery) Offset(offset int) *EpidodesQuery {
|
||||
eq.ctx.Offset = &offset
|
||||
return eq
|
||||
}
|
||||
|
||||
// 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 (eq *EpidodesQuery) Unique(unique bool) *EpidodesQuery {
|
||||
eq.ctx.Unique = &unique
|
||||
return eq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (eq *EpidodesQuery) Order(o ...epidodes.OrderOption) *EpidodesQuery {
|
||||
eq.order = append(eq.order, o...)
|
||||
return eq
|
||||
}
|
||||
|
||||
// First returns the first Epidodes entity from the query.
|
||||
// Returns a *NotFoundError when no Epidodes was found.
|
||||
func (eq *EpidodesQuery) First(ctx context.Context) (*Epidodes, error) {
|
||||
nodes, err := eq.Limit(1).All(setContextOp(ctx, eq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{epidodes.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (eq *EpidodesQuery) FirstX(ctx context.Context) *Epidodes {
|
||||
node, err := eq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Epidodes ID from the query.
|
||||
// Returns a *NotFoundError when no Epidodes ID was found.
|
||||
func (eq *EpidodesQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = eq.Limit(1).IDs(setContextOp(ctx, eq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{epidodes.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (eq *EpidodesQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := eq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Epidodes entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Epidodes entity is found.
|
||||
// Returns a *NotFoundError when no Epidodes entities are found.
|
||||
func (eq *EpidodesQuery) Only(ctx context.Context) (*Epidodes, error) {
|
||||
nodes, err := eq.Limit(2).All(setContextOp(ctx, eq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{epidodes.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{epidodes.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (eq *EpidodesQuery) OnlyX(ctx context.Context) *Epidodes {
|
||||
node, err := eq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Epidodes ID in the query.
|
||||
// Returns a *NotSingularError when more than one Epidodes ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (eq *EpidodesQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = eq.Limit(2).IDs(setContextOp(ctx, eq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{epidodes.Label}
|
||||
default:
|
||||
err = &NotSingularError{epidodes.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (eq *EpidodesQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := eq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of EpidodesSlice.
|
||||
func (eq *EpidodesQuery) All(ctx context.Context) ([]*Epidodes, error) {
|
||||
ctx = setContextOp(ctx, eq.ctx, "All")
|
||||
if err := eq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Epidodes, *EpidodesQuery]()
|
||||
return withInterceptors[[]*Epidodes](ctx, eq, qr, eq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (eq *EpidodesQuery) AllX(ctx context.Context) []*Epidodes {
|
||||
nodes, err := eq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Epidodes IDs.
|
||||
func (eq *EpidodesQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if eq.ctx.Unique == nil && eq.path != nil {
|
||||
eq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, eq.ctx, "IDs")
|
||||
if err = eq.Select(epidodes.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (eq *EpidodesQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := eq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (eq *EpidodesQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, eq.ctx, "Count")
|
||||
if err := eq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, eq, querierCount[*EpidodesQuery](), eq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (eq *EpidodesQuery) CountX(ctx context.Context) int {
|
||||
count, err := eq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (eq *EpidodesQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, eq.ctx, "Exist")
|
||||
switch _, err := eq.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 (eq *EpidodesQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := eq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the EpidodesQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (eq *EpidodesQuery) Clone() *EpidodesQuery {
|
||||
if eq == nil {
|
||||
return nil
|
||||
}
|
||||
return &EpidodesQuery{
|
||||
config: eq.config,
|
||||
ctx: eq.ctx.Clone(),
|
||||
order: append([]epidodes.OrderOption{}, eq.order...),
|
||||
inters: append([]Interceptor{}, eq.inters...),
|
||||
predicates: append([]predicate.Epidodes{}, eq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: eq.sql.Clone(),
|
||||
path: eq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// SeriesID int `json:"series_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Epidodes.Query().
|
||||
// GroupBy(epidodes.FieldSeriesID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (eq *EpidodesQuery) GroupBy(field string, fields ...string) *EpidodesGroupBy {
|
||||
eq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &EpidodesGroupBy{build: eq}
|
||||
grbuild.flds = &eq.ctx.Fields
|
||||
grbuild.label = epidodes.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 {
|
||||
// SeriesID int `json:"series_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Epidodes.Query().
|
||||
// Select(epidodes.FieldSeriesID).
|
||||
// Scan(ctx, &v)
|
||||
func (eq *EpidodesQuery) Select(fields ...string) *EpidodesSelect {
|
||||
eq.ctx.Fields = append(eq.ctx.Fields, fields...)
|
||||
sbuild := &EpidodesSelect{EpidodesQuery: eq}
|
||||
sbuild.label = epidodes.Label
|
||||
sbuild.flds, sbuild.scan = &eq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a EpidodesSelect configured with the given aggregations.
|
||||
func (eq *EpidodesQuery) Aggregate(fns ...AggregateFunc) *EpidodesSelect {
|
||||
return eq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (eq *EpidodesQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range eq.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, eq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range eq.ctx.Fields {
|
||||
if !epidodes.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if eq.path != nil {
|
||||
prev, err := eq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
eq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (eq *EpidodesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Epidodes, error) {
|
||||
var (
|
||||
nodes = []*Epidodes{}
|
||||
_spec = eq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Epidodes).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Epidodes{config: eq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, eq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (eq *EpidodesQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := eq.querySpec()
|
||||
_spec.Node.Columns = eq.ctx.Fields
|
||||
if len(eq.ctx.Fields) > 0 {
|
||||
_spec.Unique = eq.ctx.Unique != nil && *eq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, eq.driver, _spec)
|
||||
}
|
||||
|
||||
func (eq *EpidodesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(epidodes.Table, epidodes.Columns, sqlgraph.NewFieldSpec(epidodes.FieldID, field.TypeInt))
|
||||
_spec.From = eq.sql
|
||||
if unique := eq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if eq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := eq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, epidodes.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != epidodes.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := eq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := eq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := eq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := eq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (eq *EpidodesQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(eq.driver.Dialect())
|
||||
t1 := builder.Table(epidodes.Table)
|
||||
columns := eq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = epidodes.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if eq.sql != nil {
|
||||
selector = eq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if eq.ctx.Unique != nil && *eq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range eq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range eq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := eq.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 := eq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// EpidodesGroupBy is the group-by builder for Epidodes entities.
|
||||
type EpidodesGroupBy struct {
|
||||
selector
|
||||
build *EpidodesQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (egb *EpidodesGroupBy) Aggregate(fns ...AggregateFunc) *EpidodesGroupBy {
|
||||
egb.fns = append(egb.fns, fns...)
|
||||
return egb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (egb *EpidodesGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, egb.build.ctx, "GroupBy")
|
||||
if err := egb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*EpidodesQuery, *EpidodesGroupBy](ctx, egb.build, egb, egb.build.inters, v)
|
||||
}
|
||||
|
||||
func (egb *EpidodesGroupBy) sqlScan(ctx context.Context, root *EpidodesQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(egb.fns))
|
||||
for _, fn := range egb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*egb.flds)+len(egb.fns))
|
||||
for _, f := range *egb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*egb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := egb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// EpidodesSelect is the builder for selecting fields of Epidodes entities.
|
||||
type EpidodesSelect struct {
|
||||
*EpidodesQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (es *EpidodesSelect) Aggregate(fns ...AggregateFunc) *EpidodesSelect {
|
||||
es.fns = append(es.fns, fns...)
|
||||
return es
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (es *EpidodesSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, es.ctx, "Select")
|
||||
if err := es.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*EpidodesQuery, *EpidodesSelect](ctx, es.EpidodesQuery, es, es.inters, v)
|
||||
}
|
||||
|
||||
func (es *EpidodesSelect) sqlScan(ctx context.Context, root *EpidodesQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(es.fns))
|
||||
for _, fn := range es.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*es.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 := es.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
440
ent/epidodes_update.go
Normal file
440
ent/epidodes_update.go
Normal file
@@ -0,0 +1,440 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/epidodes"
|
||||
"polaris/ent/predicate"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// EpidodesUpdate is the builder for updating Epidodes entities.
|
||||
type EpidodesUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *EpidodesMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EpidodesUpdate builder.
|
||||
func (eu *EpidodesUpdate) Where(ps ...predicate.Epidodes) *EpidodesUpdate {
|
||||
eu.mutation.Where(ps...)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetSeriesID sets the "series_id" field.
|
||||
func (eu *EpidodesUpdate) SetSeriesID(i int) *EpidodesUpdate {
|
||||
eu.mutation.ResetSeriesID()
|
||||
eu.mutation.SetSeriesID(i)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableSeriesID sets the "series_id" field if the given value is not nil.
|
||||
func (eu *EpidodesUpdate) SetNillableSeriesID(i *int) *EpidodesUpdate {
|
||||
if i != nil {
|
||||
eu.SetSeriesID(*i)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// AddSeriesID adds i to the "series_id" field.
|
||||
func (eu *EpidodesUpdate) AddSeriesID(i int) *EpidodesUpdate {
|
||||
eu.mutation.AddSeriesID(i)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetSeasonNumber sets the "season_number" field.
|
||||
func (eu *EpidodesUpdate) SetSeasonNumber(i int) *EpidodesUpdate {
|
||||
eu.mutation.ResetSeasonNumber()
|
||||
eu.mutation.SetSeasonNumber(i)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableSeasonNumber sets the "season_number" field if the given value is not nil.
|
||||
func (eu *EpidodesUpdate) SetNillableSeasonNumber(i *int) *EpidodesUpdate {
|
||||
if i != nil {
|
||||
eu.SetSeasonNumber(*i)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// AddSeasonNumber adds i to the "season_number" field.
|
||||
func (eu *EpidodesUpdate) AddSeasonNumber(i int) *EpidodesUpdate {
|
||||
eu.mutation.AddSeasonNumber(i)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetEpisodeNumber sets the "episode_number" field.
|
||||
func (eu *EpidodesUpdate) SetEpisodeNumber(i int) *EpidodesUpdate {
|
||||
eu.mutation.ResetEpisodeNumber()
|
||||
eu.mutation.SetEpisodeNumber(i)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableEpisodeNumber sets the "episode_number" field if the given value is not nil.
|
||||
func (eu *EpidodesUpdate) SetNillableEpisodeNumber(i *int) *EpidodesUpdate {
|
||||
if i != nil {
|
||||
eu.SetEpisodeNumber(*i)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// AddEpisodeNumber adds i to the "episode_number" field.
|
||||
func (eu *EpidodesUpdate) AddEpisodeNumber(i int) *EpidodesUpdate {
|
||||
eu.mutation.AddEpisodeNumber(i)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (eu *EpidodesUpdate) SetTitle(s string) *EpidodesUpdate {
|
||||
eu.mutation.SetTitle(s)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableTitle sets the "title" field if the given value is not nil.
|
||||
func (eu *EpidodesUpdate) SetNillableTitle(s *string) *EpidodesUpdate {
|
||||
if s != nil {
|
||||
eu.SetTitle(*s)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetOverview sets the "overview" field.
|
||||
func (eu *EpidodesUpdate) SetOverview(s string) *EpidodesUpdate {
|
||||
eu.mutation.SetOverview(s)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableOverview sets the "overview" field if the given value is not nil.
|
||||
func (eu *EpidodesUpdate) SetNillableOverview(s *string) *EpidodesUpdate {
|
||||
if s != nil {
|
||||
eu.SetOverview(*s)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetAirDate sets the "air_date" field.
|
||||
func (eu *EpidodesUpdate) SetAirDate(t time.Time) *EpidodesUpdate {
|
||||
eu.mutation.SetAirDate(t)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableAirDate sets the "air_date" field if the given value is not nil.
|
||||
func (eu *EpidodesUpdate) SetNillableAirDate(t *time.Time) *EpidodesUpdate {
|
||||
if t != nil {
|
||||
eu.SetAirDate(*t)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// Mutation returns the EpidodesMutation object of the builder.
|
||||
func (eu *EpidodesUpdate) Mutation() *EpidodesMutation {
|
||||
return eu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (eu *EpidodesUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, eu.sqlSave, eu.mutation, eu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (eu *EpidodesUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := eu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (eu *EpidodesUpdate) Exec(ctx context.Context) error {
|
||||
_, err := eu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (eu *EpidodesUpdate) ExecX(ctx context.Context) {
|
||||
if err := eu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (eu *EpidodesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(epidodes.Table, epidodes.Columns, sqlgraph.NewFieldSpec(epidodes.FieldID, field.TypeInt))
|
||||
if ps := eu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := eu.mutation.SeriesID(); ok {
|
||||
_spec.SetField(epidodes.FieldSeriesID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := eu.mutation.AddedSeriesID(); ok {
|
||||
_spec.AddField(epidodes.FieldSeriesID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := eu.mutation.SeasonNumber(); ok {
|
||||
_spec.SetField(epidodes.FieldSeasonNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := eu.mutation.AddedSeasonNumber(); ok {
|
||||
_spec.AddField(epidodes.FieldSeasonNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := eu.mutation.EpisodeNumber(); ok {
|
||||
_spec.SetField(epidodes.FieldEpisodeNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := eu.mutation.AddedEpisodeNumber(); ok {
|
||||
_spec.AddField(epidodes.FieldEpisodeNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := eu.mutation.Title(); ok {
|
||||
_spec.SetField(epidodes.FieldTitle, field.TypeString, value)
|
||||
}
|
||||
if value, ok := eu.mutation.Overview(); ok {
|
||||
_spec.SetField(epidodes.FieldOverview, field.TypeString, value)
|
||||
}
|
||||
if value, ok := eu.mutation.AirDate(); ok {
|
||||
_spec.SetField(epidodes.FieldAirDate, field.TypeTime, value)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, eu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{epidodes.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
eu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// EpidodesUpdateOne is the builder for updating a single Epidodes entity.
|
||||
type EpidodesUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *EpidodesMutation
|
||||
}
|
||||
|
||||
// SetSeriesID sets the "series_id" field.
|
||||
func (euo *EpidodesUpdateOne) SetSeriesID(i int) *EpidodesUpdateOne {
|
||||
euo.mutation.ResetSeriesID()
|
||||
euo.mutation.SetSeriesID(i)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableSeriesID sets the "series_id" field if the given value is not nil.
|
||||
func (euo *EpidodesUpdateOne) SetNillableSeriesID(i *int) *EpidodesUpdateOne {
|
||||
if i != nil {
|
||||
euo.SetSeriesID(*i)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// AddSeriesID adds i to the "series_id" field.
|
||||
func (euo *EpidodesUpdateOne) AddSeriesID(i int) *EpidodesUpdateOne {
|
||||
euo.mutation.AddSeriesID(i)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetSeasonNumber sets the "season_number" field.
|
||||
func (euo *EpidodesUpdateOne) SetSeasonNumber(i int) *EpidodesUpdateOne {
|
||||
euo.mutation.ResetSeasonNumber()
|
||||
euo.mutation.SetSeasonNumber(i)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableSeasonNumber sets the "season_number" field if the given value is not nil.
|
||||
func (euo *EpidodesUpdateOne) SetNillableSeasonNumber(i *int) *EpidodesUpdateOne {
|
||||
if i != nil {
|
||||
euo.SetSeasonNumber(*i)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// AddSeasonNumber adds i to the "season_number" field.
|
||||
func (euo *EpidodesUpdateOne) AddSeasonNumber(i int) *EpidodesUpdateOne {
|
||||
euo.mutation.AddSeasonNumber(i)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetEpisodeNumber sets the "episode_number" field.
|
||||
func (euo *EpidodesUpdateOne) SetEpisodeNumber(i int) *EpidodesUpdateOne {
|
||||
euo.mutation.ResetEpisodeNumber()
|
||||
euo.mutation.SetEpisodeNumber(i)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableEpisodeNumber sets the "episode_number" field if the given value is not nil.
|
||||
func (euo *EpidodesUpdateOne) SetNillableEpisodeNumber(i *int) *EpidodesUpdateOne {
|
||||
if i != nil {
|
||||
euo.SetEpisodeNumber(*i)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// AddEpisodeNumber adds i to the "episode_number" field.
|
||||
func (euo *EpidodesUpdateOne) AddEpisodeNumber(i int) *EpidodesUpdateOne {
|
||||
euo.mutation.AddEpisodeNumber(i)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (euo *EpidodesUpdateOne) SetTitle(s string) *EpidodesUpdateOne {
|
||||
euo.mutation.SetTitle(s)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableTitle sets the "title" field if the given value is not nil.
|
||||
func (euo *EpidodesUpdateOne) SetNillableTitle(s *string) *EpidodesUpdateOne {
|
||||
if s != nil {
|
||||
euo.SetTitle(*s)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetOverview sets the "overview" field.
|
||||
func (euo *EpidodesUpdateOne) SetOverview(s string) *EpidodesUpdateOne {
|
||||
euo.mutation.SetOverview(s)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableOverview sets the "overview" field if the given value is not nil.
|
||||
func (euo *EpidodesUpdateOne) SetNillableOverview(s *string) *EpidodesUpdateOne {
|
||||
if s != nil {
|
||||
euo.SetOverview(*s)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetAirDate sets the "air_date" field.
|
||||
func (euo *EpidodesUpdateOne) SetAirDate(t time.Time) *EpidodesUpdateOne {
|
||||
euo.mutation.SetAirDate(t)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableAirDate sets the "air_date" field if the given value is not nil.
|
||||
func (euo *EpidodesUpdateOne) SetNillableAirDate(t *time.Time) *EpidodesUpdateOne {
|
||||
if t != nil {
|
||||
euo.SetAirDate(*t)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// Mutation returns the EpidodesMutation object of the builder.
|
||||
func (euo *EpidodesUpdateOne) Mutation() *EpidodesMutation {
|
||||
return euo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EpidodesUpdate builder.
|
||||
func (euo *EpidodesUpdateOne) Where(ps ...predicate.Epidodes) *EpidodesUpdateOne {
|
||||
euo.mutation.Where(ps...)
|
||||
return euo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (euo *EpidodesUpdateOne) Select(field string, fields ...string) *EpidodesUpdateOne {
|
||||
euo.fields = append([]string{field}, fields...)
|
||||
return euo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Epidodes entity.
|
||||
func (euo *EpidodesUpdateOne) Save(ctx context.Context) (*Epidodes, error) {
|
||||
return withHooks(ctx, euo.sqlSave, euo.mutation, euo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (euo *EpidodesUpdateOne) SaveX(ctx context.Context) *Epidodes {
|
||||
node, err := euo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (euo *EpidodesUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := euo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (euo *EpidodesUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := euo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (euo *EpidodesUpdateOne) sqlSave(ctx context.Context) (_node *Epidodes, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(epidodes.Table, epidodes.Columns, sqlgraph.NewFieldSpec(epidodes.FieldID, field.TypeInt))
|
||||
id, ok := euo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Epidodes.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := euo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, epidodes.FieldID)
|
||||
for _, f := range fields {
|
||||
if !epidodes.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != epidodes.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := euo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := euo.mutation.SeriesID(); ok {
|
||||
_spec.SetField(epidodes.FieldSeriesID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := euo.mutation.AddedSeriesID(); ok {
|
||||
_spec.AddField(epidodes.FieldSeriesID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := euo.mutation.SeasonNumber(); ok {
|
||||
_spec.SetField(epidodes.FieldSeasonNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := euo.mutation.AddedSeasonNumber(); ok {
|
||||
_spec.AddField(epidodes.FieldSeasonNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := euo.mutation.EpisodeNumber(); ok {
|
||||
_spec.SetField(epidodes.FieldEpisodeNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := euo.mutation.AddedEpisodeNumber(); ok {
|
||||
_spec.AddField(epidodes.FieldEpisodeNumber, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := euo.mutation.Title(); ok {
|
||||
_spec.SetField(epidodes.FieldTitle, field.TypeString, value)
|
||||
}
|
||||
if value, ok := euo.mutation.Overview(); ok {
|
||||
_spec.SetField(epidodes.FieldOverview, field.TypeString, value)
|
||||
}
|
||||
if value, ok := euo.mutation.AirDate(); ok {
|
||||
_spec.SetField(epidodes.FieldAirDate, field.TypeTime, value)
|
||||
}
|
||||
_node = &Epidodes{config: euo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, euo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{epidodes.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
euo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
3
ent/generate.go
Normal file
3
ent/generate.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package ent
|
||||
|
||||
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema
|
||||
246
ent/hook/hook.go
Normal file
246
ent/hook/hook.go
Normal file
@@ -0,0 +1,246 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package hook
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"polaris/ent"
|
||||
)
|
||||
|
||||
// The DownloadClientsFunc type is an adapter to allow the use of ordinary
|
||||
// function as DownloadClients mutator.
|
||||
type DownloadClientsFunc func(context.Context, *ent.DownloadClientsMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f DownloadClientsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.DownloadClientsMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DownloadClientsMutation", m)
|
||||
}
|
||||
|
||||
// The EpidodesFunc type is an adapter to allow the use of ordinary
|
||||
// function as Epidodes mutator.
|
||||
type EpidodesFunc func(context.Context, *ent.EpidodesMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f EpidodesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.EpidodesMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.EpidodesMutation", m)
|
||||
}
|
||||
|
||||
// The IndexersFunc type is an adapter to allow the use of ordinary
|
||||
// function as Indexers mutator.
|
||||
type IndexersFunc func(context.Context, *ent.IndexersMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f IndexersFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.IndexersMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.IndexersMutation", m)
|
||||
}
|
||||
|
||||
// The SeriesFunc type is an adapter to allow the use of ordinary
|
||||
// function as Series mutator.
|
||||
type SeriesFunc func(context.Context, *ent.SeriesMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f SeriesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.SeriesMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SeriesMutation", m)
|
||||
}
|
||||
|
||||
// The SettingsFunc type is an adapter to allow the use of ordinary
|
||||
// function as Settings mutator.
|
||||
type SettingsFunc func(context.Context, *ent.SettingsMutation) (ent.Value, error)
|
||||
|
||||
// Mutate calls f(ctx, m).
|
||||
func (f SettingsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||
if mv, ok := m.(*ent.SettingsMutation); ok {
|
||||
return f(ctx, mv)
|
||||
}
|
||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SettingsMutation", 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...)
|
||||
}
|
||||
149
ent/indexers.go
Normal file
149
ent/indexers.go
Normal file
@@ -0,0 +1,149 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/ent/indexers"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Indexers is the model entity for the Indexers schema.
|
||||
type Indexers struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Implementation holds the value of the "implementation" field.
|
||||
Implementation string `json:"implementation,omitempty"`
|
||||
// Settings holds the value of the "settings" field.
|
||||
Settings string `json:"settings,omitempty"`
|
||||
// EnableRss holds the value of the "enable_rss" field.
|
||||
EnableRss bool `json:"enable_rss,omitempty"`
|
||||
// Priority holds the value of the "priority" field.
|
||||
Priority int `json:"priority,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Indexers) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case indexers.FieldEnableRss:
|
||||
values[i] = new(sql.NullBool)
|
||||
case indexers.FieldID, indexers.FieldPriority:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case indexers.FieldName, indexers.FieldImplementation, indexers.FieldSettings:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Indexers fields.
|
||||
func (i *Indexers) 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 j := range columns {
|
||||
switch columns[j] {
|
||||
case indexers.FieldID:
|
||||
value, ok := values[j].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
i.ID = int(value.Int64)
|
||||
case indexers.FieldName:
|
||||
if value, ok := values[j].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[j])
|
||||
} else if value.Valid {
|
||||
i.Name = value.String
|
||||
}
|
||||
case indexers.FieldImplementation:
|
||||
if value, ok := values[j].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field implementation", values[j])
|
||||
} else if value.Valid {
|
||||
i.Implementation = value.String
|
||||
}
|
||||
case indexers.FieldSettings:
|
||||
if value, ok := values[j].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field settings", values[j])
|
||||
} else if value.Valid {
|
||||
i.Settings = value.String
|
||||
}
|
||||
case indexers.FieldEnableRss:
|
||||
if value, ok := values[j].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field enable_rss", values[j])
|
||||
} else if value.Valid {
|
||||
i.EnableRss = value.Bool
|
||||
}
|
||||
case indexers.FieldPriority:
|
||||
if value, ok := values[j].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field priority", values[j])
|
||||
} else if value.Valid {
|
||||
i.Priority = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
i.selectValues.Set(columns[j], values[j])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Indexers.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (i *Indexers) Value(name string) (ent.Value, error) {
|
||||
return i.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Indexers.
|
||||
// Note that you need to call Indexers.Unwrap() before calling this method if this Indexers
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (i *Indexers) Update() *IndexersUpdateOne {
|
||||
return NewIndexersClient(i.config).UpdateOne(i)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Indexers 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 (i *Indexers) Unwrap() *Indexers {
|
||||
_tx, ok := i.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Indexers is not a transactional entity")
|
||||
}
|
||||
i.config.driver = _tx.drv
|
||||
return i
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (i *Indexers) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Indexers(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", i.ID))
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(i.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("implementation=")
|
||||
builder.WriteString(i.Implementation)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("settings=")
|
||||
builder.WriteString(i.Settings)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("enable_rss=")
|
||||
builder.WriteString(fmt.Sprintf("%v", i.EnableRss))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("priority=")
|
||||
builder.WriteString(fmt.Sprintf("%v", i.Priority))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// IndexersSlice is a parsable slice of Indexers.
|
||||
type IndexersSlice []*Indexers
|
||||
79
ent/indexers/indexers.go
Normal file
79
ent/indexers/indexers.go
Normal file
@@ -0,0 +1,79 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package indexers
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the indexers type in the database.
|
||||
Label = "indexers"
|
||||
// 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"
|
||||
// FieldImplementation holds the string denoting the implementation field in the database.
|
||||
FieldImplementation = "implementation"
|
||||
// FieldSettings holds the string denoting the settings field in the database.
|
||||
FieldSettings = "settings"
|
||||
// FieldEnableRss holds the string denoting the enable_rss field in the database.
|
||||
FieldEnableRss = "enable_rss"
|
||||
// FieldPriority holds the string denoting the priority field in the database.
|
||||
FieldPriority = "priority"
|
||||
// Table holds the table name of the indexers in the database.
|
||||
Table = "indexers"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for indexers fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldName,
|
||||
FieldImplementation,
|
||||
FieldSettings,
|
||||
FieldEnableRss,
|
||||
FieldPriority,
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the Indexers 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()
|
||||
}
|
||||
|
||||
// ByImplementation orders the results by the implementation field.
|
||||
func ByImplementation(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImplementation, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySettings orders the results by the settings field.
|
||||
func BySettings(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSettings, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEnableRss orders the results by the enable_rss field.
|
||||
func ByEnableRss(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEnableRss, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPriority orders the results by the priority field.
|
||||
func ByPriority(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPriority, opts...).ToFunc()
|
||||
}
|
||||
339
ent/indexers/where.go
Normal file
339
ent/indexers/where.go
Normal file
@@ -0,0 +1,339 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package indexers
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// Implementation applies equality check predicate on the "implementation" field. It's identical to ImplementationEQ.
|
||||
func Implementation(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// Settings applies equality check predicate on the "settings" field. It's identical to SettingsEQ.
|
||||
func Settings(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// EnableRss applies equality check predicate on the "enable_rss" field. It's identical to EnableRssEQ.
|
||||
func EnableRss(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldEnableRss, v))
|
||||
}
|
||||
|
||||
// Priority applies equality check predicate on the "priority" field. It's identical to PriorityEQ.
|
||||
func Priority(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldPriority, v))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||
func NameNEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIn applies the In predicate on the "name" field.
|
||||
func NameIn(vs ...string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||
func NameNotIn(vs ...string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotIn(FieldName, vs...))
|
||||
}
|
||||
|
||||
// NameGT applies the GT predicate on the "name" field.
|
||||
func NameGT(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameGTE applies the GTE predicate on the "name" field.
|
||||
func NameGTE(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLT applies the LT predicate on the "name" field.
|
||||
func NameLT(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLT(FieldName, v))
|
||||
}
|
||||
|
||||
// NameLTE applies the LTE predicate on the "name" field.
|
||||
func NameLTE(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContains applies the Contains predicate on the "name" field.
|
||||
func NameContains(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldContains(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||
func NameHasPrefix(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldHasPrefix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||
func NameHasSuffix(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEqualFold(FieldName, v))
|
||||
}
|
||||
|
||||
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||
func NameContainsFold(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldContainsFold(FieldName, v))
|
||||
}
|
||||
|
||||
// ImplementationEQ applies the EQ predicate on the "implementation" field.
|
||||
func ImplementationEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationNEQ applies the NEQ predicate on the "implementation" field.
|
||||
func ImplementationNEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationIn applies the In predicate on the "implementation" field.
|
||||
func ImplementationIn(vs ...string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIn(FieldImplementation, vs...))
|
||||
}
|
||||
|
||||
// ImplementationNotIn applies the NotIn predicate on the "implementation" field.
|
||||
func ImplementationNotIn(vs ...string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotIn(FieldImplementation, vs...))
|
||||
}
|
||||
|
||||
// ImplementationGT applies the GT predicate on the "implementation" field.
|
||||
func ImplementationGT(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGT(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationGTE applies the GTE predicate on the "implementation" field.
|
||||
func ImplementationGTE(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGTE(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationLT applies the LT predicate on the "implementation" field.
|
||||
func ImplementationLT(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLT(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationLTE applies the LTE predicate on the "implementation" field.
|
||||
func ImplementationLTE(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationContains applies the Contains predicate on the "implementation" field.
|
||||
func ImplementationContains(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldContains(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationHasPrefix applies the HasPrefix predicate on the "implementation" field.
|
||||
func ImplementationHasPrefix(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldHasPrefix(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationHasSuffix applies the HasSuffix predicate on the "implementation" field.
|
||||
func ImplementationHasSuffix(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldHasSuffix(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationEqualFold applies the EqualFold predicate on the "implementation" field.
|
||||
func ImplementationEqualFold(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEqualFold(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// ImplementationContainsFold applies the ContainsFold predicate on the "implementation" field.
|
||||
func ImplementationContainsFold(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldContainsFold(FieldImplementation, v))
|
||||
}
|
||||
|
||||
// SettingsEQ applies the EQ predicate on the "settings" field.
|
||||
func SettingsEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsNEQ applies the NEQ predicate on the "settings" field.
|
||||
func SettingsNEQ(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsIn applies the In predicate on the "settings" field.
|
||||
func SettingsIn(vs ...string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIn(FieldSettings, vs...))
|
||||
}
|
||||
|
||||
// SettingsNotIn applies the NotIn predicate on the "settings" field.
|
||||
func SettingsNotIn(vs ...string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotIn(FieldSettings, vs...))
|
||||
}
|
||||
|
||||
// SettingsGT applies the GT predicate on the "settings" field.
|
||||
func SettingsGT(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGT(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsGTE applies the GTE predicate on the "settings" field.
|
||||
func SettingsGTE(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGTE(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsLT applies the LT predicate on the "settings" field.
|
||||
func SettingsLT(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLT(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsLTE applies the LTE predicate on the "settings" field.
|
||||
func SettingsLTE(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsContains applies the Contains predicate on the "settings" field.
|
||||
func SettingsContains(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldContains(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsHasPrefix applies the HasPrefix predicate on the "settings" field.
|
||||
func SettingsHasPrefix(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldHasPrefix(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsHasSuffix applies the HasSuffix predicate on the "settings" field.
|
||||
func SettingsHasSuffix(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldHasSuffix(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsEqualFold applies the EqualFold predicate on the "settings" field.
|
||||
func SettingsEqualFold(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEqualFold(FieldSettings, v))
|
||||
}
|
||||
|
||||
// SettingsContainsFold applies the ContainsFold predicate on the "settings" field.
|
||||
func SettingsContainsFold(v string) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldContainsFold(FieldSettings, v))
|
||||
}
|
||||
|
||||
// EnableRssEQ applies the EQ predicate on the "enable_rss" field.
|
||||
func EnableRssEQ(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldEnableRss, v))
|
||||
}
|
||||
|
||||
// EnableRssNEQ applies the NEQ predicate on the "enable_rss" field.
|
||||
func EnableRssNEQ(v bool) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldEnableRss, v))
|
||||
}
|
||||
|
||||
// PriorityEQ applies the EQ predicate on the "priority" field.
|
||||
func PriorityEQ(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldEQ(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityNEQ applies the NEQ predicate on the "priority" field.
|
||||
func PriorityNEQ(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNEQ(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityIn applies the In predicate on the "priority" field.
|
||||
func PriorityIn(vs ...int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldIn(FieldPriority, vs...))
|
||||
}
|
||||
|
||||
// PriorityNotIn applies the NotIn predicate on the "priority" field.
|
||||
func PriorityNotIn(vs ...int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldNotIn(FieldPriority, vs...))
|
||||
}
|
||||
|
||||
// PriorityGT applies the GT predicate on the "priority" field.
|
||||
func PriorityGT(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGT(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityGTE applies the GTE predicate on the "priority" field.
|
||||
func PriorityGTE(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldGTE(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityLT applies the LT predicate on the "priority" field.
|
||||
func PriorityLT(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLT(FieldPriority, v))
|
||||
}
|
||||
|
||||
// PriorityLTE applies the LTE predicate on the "priority" field.
|
||||
func PriorityLTE(v int) predicate.Indexers {
|
||||
return predicate.Indexers(sql.FieldLTE(FieldPriority, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Indexers) predicate.Indexers {
|
||||
return predicate.Indexers(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Indexers) predicate.Indexers {
|
||||
return predicate.Indexers(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Indexers) predicate.Indexers {
|
||||
return predicate.Indexers(sql.NotPredicates(p))
|
||||
}
|
||||
235
ent/indexers_create.go
Normal file
235
ent/indexers_create.go
Normal file
@@ -0,0 +1,235 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/indexers"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// IndexersCreate is the builder for creating a Indexers entity.
|
||||
type IndexersCreate struct {
|
||||
config
|
||||
mutation *IndexersMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ic *IndexersCreate) SetName(s string) *IndexersCreate {
|
||||
ic.mutation.SetName(s)
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (ic *IndexersCreate) SetImplementation(s string) *IndexersCreate {
|
||||
ic.mutation.SetImplementation(s)
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (ic *IndexersCreate) SetSettings(s string) *IndexersCreate {
|
||||
ic.mutation.SetSettings(s)
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetEnableRss sets the "enable_rss" field.
|
||||
func (ic *IndexersCreate) SetEnableRss(b bool) *IndexersCreate {
|
||||
ic.mutation.SetEnableRss(b)
|
||||
return ic
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (ic *IndexersCreate) SetPriority(i int) *IndexersCreate {
|
||||
ic.mutation.SetPriority(i)
|
||||
return ic
|
||||
}
|
||||
|
||||
// Mutation returns the IndexersMutation object of the builder.
|
||||
func (ic *IndexersCreate) Mutation() *IndexersMutation {
|
||||
return ic.mutation
|
||||
}
|
||||
|
||||
// Save creates the Indexers in the database.
|
||||
func (ic *IndexersCreate) Save(ctx context.Context) (*Indexers, error) {
|
||||
return withHooks(ctx, ic.sqlSave, ic.mutation, ic.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (ic *IndexersCreate) SaveX(ctx context.Context) *Indexers {
|
||||
v, err := ic.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (ic *IndexersCreate) Exec(ctx context.Context) error {
|
||||
_, err := ic.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ic *IndexersCreate) ExecX(ctx context.Context) {
|
||||
if err := ic.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ic *IndexersCreate) check() error {
|
||||
if _, ok := ic.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Indexers.name"`)}
|
||||
}
|
||||
if _, ok := ic.mutation.Implementation(); !ok {
|
||||
return &ValidationError{Name: "implementation", err: errors.New(`ent: missing required field "Indexers.implementation"`)}
|
||||
}
|
||||
if _, ok := ic.mutation.Settings(); !ok {
|
||||
return &ValidationError{Name: "settings", err: errors.New(`ent: missing required field "Indexers.settings"`)}
|
||||
}
|
||||
if _, ok := ic.mutation.EnableRss(); !ok {
|
||||
return &ValidationError{Name: "enable_rss", err: errors.New(`ent: missing required field "Indexers.enable_rss"`)}
|
||||
}
|
||||
if _, ok := ic.mutation.Priority(); !ok {
|
||||
return &ValidationError{Name: "priority", err: errors.New(`ent: missing required field "Indexers.priority"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ic *IndexersCreate) sqlSave(ctx context.Context) (*Indexers, error) {
|
||||
if err := ic.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := ic.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, ic.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)
|
||||
ic.mutation.id = &_node.ID
|
||||
ic.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (ic *IndexersCreate) createSpec() (*Indexers, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Indexers{config: ic.config}
|
||||
_spec = sqlgraph.NewCreateSpec(indexers.Table, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := ic.mutation.Name(); ok {
|
||||
_spec.SetField(indexers.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := ic.mutation.Implementation(); ok {
|
||||
_spec.SetField(indexers.FieldImplementation, field.TypeString, value)
|
||||
_node.Implementation = value
|
||||
}
|
||||
if value, ok := ic.mutation.Settings(); ok {
|
||||
_spec.SetField(indexers.FieldSettings, field.TypeString, value)
|
||||
_node.Settings = value
|
||||
}
|
||||
if value, ok := ic.mutation.EnableRss(); ok {
|
||||
_spec.SetField(indexers.FieldEnableRss, field.TypeBool, value)
|
||||
_node.EnableRss = value
|
||||
}
|
||||
if value, ok := ic.mutation.Priority(); ok {
|
||||
_spec.SetField(indexers.FieldPriority, field.TypeInt, value)
|
||||
_node.Priority = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// IndexersCreateBulk is the builder for creating many Indexers entities in bulk.
|
||||
type IndexersCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*IndexersCreate
|
||||
}
|
||||
|
||||
// Save creates the Indexers entities in the database.
|
||||
func (icb *IndexersCreateBulk) Save(ctx context.Context) ([]*Indexers, error) {
|
||||
if icb.err != nil {
|
||||
return nil, icb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(icb.builders))
|
||||
nodes := make([]*Indexers, len(icb.builders))
|
||||
mutators := make([]Mutator, len(icb.builders))
|
||||
for i := range icb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := icb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*IndexersMutation)
|
||||
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, icb.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, icb.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, icb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (icb *IndexersCreateBulk) SaveX(ctx context.Context) []*Indexers {
|
||||
v, err := icb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (icb *IndexersCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := icb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (icb *IndexersCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := icb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/indexers_delete.go
Normal file
88
ent/indexers_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// IndexersDelete is the builder for deleting a Indexers entity.
|
||||
type IndexersDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *IndexersMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the IndexersDelete builder.
|
||||
func (id *IndexersDelete) Where(ps ...predicate.Indexers) *IndexersDelete {
|
||||
id.mutation.Where(ps...)
|
||||
return id
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (id *IndexersDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, id.sqlExec, id.mutation, id.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (id *IndexersDelete) ExecX(ctx context.Context) int {
|
||||
n, err := id.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (id *IndexersDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(indexers.Table, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
|
||||
if ps := id.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, id.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
id.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// IndexersDeleteOne is the builder for deleting a single Indexers entity.
|
||||
type IndexersDeleteOne struct {
|
||||
id *IndexersDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the IndexersDelete builder.
|
||||
func (ido *IndexersDeleteOne) Where(ps ...predicate.Indexers) *IndexersDeleteOne {
|
||||
ido.id.mutation.Where(ps...)
|
||||
return ido
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (ido *IndexersDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := ido.id.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{indexers.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (ido *IndexersDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := ido.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
526
ent/indexers_query.go
Normal file
526
ent/indexers_query.go
Normal file
@@ -0,0 +1,526 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// IndexersQuery is the builder for querying Indexers entities.
|
||||
type IndexersQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []indexers.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Indexers
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the IndexersQuery builder.
|
||||
func (iq *IndexersQuery) Where(ps ...predicate.Indexers) *IndexersQuery {
|
||||
iq.predicates = append(iq.predicates, ps...)
|
||||
return iq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (iq *IndexersQuery) Limit(limit int) *IndexersQuery {
|
||||
iq.ctx.Limit = &limit
|
||||
return iq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (iq *IndexersQuery) Offset(offset int) *IndexersQuery {
|
||||
iq.ctx.Offset = &offset
|
||||
return iq
|
||||
}
|
||||
|
||||
// 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 (iq *IndexersQuery) Unique(unique bool) *IndexersQuery {
|
||||
iq.ctx.Unique = &unique
|
||||
return iq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (iq *IndexersQuery) Order(o ...indexers.OrderOption) *IndexersQuery {
|
||||
iq.order = append(iq.order, o...)
|
||||
return iq
|
||||
}
|
||||
|
||||
// First returns the first Indexers entity from the query.
|
||||
// Returns a *NotFoundError when no Indexers was found.
|
||||
func (iq *IndexersQuery) First(ctx context.Context) (*Indexers, error) {
|
||||
nodes, err := iq.Limit(1).All(setContextOp(ctx, iq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{indexers.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (iq *IndexersQuery) FirstX(ctx context.Context) *Indexers {
|
||||
node, err := iq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Indexers ID from the query.
|
||||
// Returns a *NotFoundError when no Indexers ID was found.
|
||||
func (iq *IndexersQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = iq.Limit(1).IDs(setContextOp(ctx, iq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{indexers.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (iq *IndexersQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := iq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Indexers entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Indexers entity is found.
|
||||
// Returns a *NotFoundError when no Indexers entities are found.
|
||||
func (iq *IndexersQuery) Only(ctx context.Context) (*Indexers, error) {
|
||||
nodes, err := iq.Limit(2).All(setContextOp(ctx, iq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{indexers.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{indexers.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (iq *IndexersQuery) OnlyX(ctx context.Context) *Indexers {
|
||||
node, err := iq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Indexers ID in the query.
|
||||
// Returns a *NotSingularError when more than one Indexers ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (iq *IndexersQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = iq.Limit(2).IDs(setContextOp(ctx, iq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{indexers.Label}
|
||||
default:
|
||||
err = &NotSingularError{indexers.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (iq *IndexersQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := iq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of IndexersSlice.
|
||||
func (iq *IndexersQuery) All(ctx context.Context) ([]*Indexers, error) {
|
||||
ctx = setContextOp(ctx, iq.ctx, "All")
|
||||
if err := iq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Indexers, *IndexersQuery]()
|
||||
return withInterceptors[[]*Indexers](ctx, iq, qr, iq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (iq *IndexersQuery) AllX(ctx context.Context) []*Indexers {
|
||||
nodes, err := iq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Indexers IDs.
|
||||
func (iq *IndexersQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if iq.ctx.Unique == nil && iq.path != nil {
|
||||
iq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, iq.ctx, "IDs")
|
||||
if err = iq.Select(indexers.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (iq *IndexersQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := iq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (iq *IndexersQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, iq.ctx, "Count")
|
||||
if err := iq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, iq, querierCount[*IndexersQuery](), iq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (iq *IndexersQuery) CountX(ctx context.Context) int {
|
||||
count, err := iq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (iq *IndexersQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, iq.ctx, "Exist")
|
||||
switch _, err := iq.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 (iq *IndexersQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := iq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the IndexersQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (iq *IndexersQuery) Clone() *IndexersQuery {
|
||||
if iq == nil {
|
||||
return nil
|
||||
}
|
||||
return &IndexersQuery{
|
||||
config: iq.config,
|
||||
ctx: iq.ctx.Clone(),
|
||||
order: append([]indexers.OrderOption{}, iq.order...),
|
||||
inters: append([]Interceptor{}, iq.inters...),
|
||||
predicates: append([]predicate.Indexers{}, iq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: iq.sql.Clone(),
|
||||
path: iq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// 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.Indexers.Query().
|
||||
// GroupBy(indexers.FieldName).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (iq *IndexersQuery) GroupBy(field string, fields ...string) *IndexersGroupBy {
|
||||
iq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &IndexersGroupBy{build: iq}
|
||||
grbuild.flds = &iq.ctx.Fields
|
||||
grbuild.label = indexers.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.Indexers.Query().
|
||||
// Select(indexers.FieldName).
|
||||
// Scan(ctx, &v)
|
||||
func (iq *IndexersQuery) Select(fields ...string) *IndexersSelect {
|
||||
iq.ctx.Fields = append(iq.ctx.Fields, fields...)
|
||||
sbuild := &IndexersSelect{IndexersQuery: iq}
|
||||
sbuild.label = indexers.Label
|
||||
sbuild.flds, sbuild.scan = &iq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a IndexersSelect configured with the given aggregations.
|
||||
func (iq *IndexersQuery) Aggregate(fns ...AggregateFunc) *IndexersSelect {
|
||||
return iq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (iq *IndexersQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range iq.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, iq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range iq.ctx.Fields {
|
||||
if !indexers.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if iq.path != nil {
|
||||
prev, err := iq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
iq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (iq *IndexersQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Indexers, error) {
|
||||
var (
|
||||
nodes = []*Indexers{}
|
||||
_spec = iq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Indexers).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Indexers{config: iq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, iq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (iq *IndexersQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := iq.querySpec()
|
||||
_spec.Node.Columns = iq.ctx.Fields
|
||||
if len(iq.ctx.Fields) > 0 {
|
||||
_spec.Unique = iq.ctx.Unique != nil && *iq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, iq.driver, _spec)
|
||||
}
|
||||
|
||||
func (iq *IndexersQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(indexers.Table, indexers.Columns, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
|
||||
_spec.From = iq.sql
|
||||
if unique := iq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if iq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := iq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, indexers.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != indexers.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := iq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := iq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := iq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := iq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (iq *IndexersQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(iq.driver.Dialect())
|
||||
t1 := builder.Table(indexers.Table)
|
||||
columns := iq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = indexers.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if iq.sql != nil {
|
||||
selector = iq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if iq.ctx.Unique != nil && *iq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range iq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range iq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := iq.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 := iq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// IndexersGroupBy is the group-by builder for Indexers entities.
|
||||
type IndexersGroupBy struct {
|
||||
selector
|
||||
build *IndexersQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (igb *IndexersGroupBy) Aggregate(fns ...AggregateFunc) *IndexersGroupBy {
|
||||
igb.fns = append(igb.fns, fns...)
|
||||
return igb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (igb *IndexersGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, igb.build.ctx, "GroupBy")
|
||||
if err := igb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*IndexersQuery, *IndexersGroupBy](ctx, igb.build, igb, igb.build.inters, v)
|
||||
}
|
||||
|
||||
func (igb *IndexersGroupBy) sqlScan(ctx context.Context, root *IndexersQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(igb.fns))
|
||||
for _, fn := range igb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*igb.flds)+len(igb.fns))
|
||||
for _, f := range *igb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*igb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := igb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// IndexersSelect is the builder for selecting fields of Indexers entities.
|
||||
type IndexersSelect struct {
|
||||
*IndexersQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (is *IndexersSelect) Aggregate(fns ...AggregateFunc) *IndexersSelect {
|
||||
is.fns = append(is.fns, fns...)
|
||||
return is
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (is *IndexersSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, is.ctx, "Select")
|
||||
if err := is.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*IndexersQuery, *IndexersSelect](ctx, is.IndexersQuery, is, is.inters, v)
|
||||
}
|
||||
|
||||
func (is *IndexersSelect) sqlScan(ctx context.Context, root *IndexersQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(is.fns))
|
||||
for _, fn := range is.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*is.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 := is.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
365
ent/indexers_update.go
Normal file
365
ent/indexers_update.go
Normal file
@@ -0,0 +1,365 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/indexers"
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// IndexersUpdate is the builder for updating Indexers entities.
|
||||
type IndexersUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *IndexersMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the IndexersUpdate builder.
|
||||
func (iu *IndexersUpdate) Where(ps ...predicate.Indexers) *IndexersUpdate {
|
||||
iu.mutation.Where(ps...)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (iu *IndexersUpdate) SetName(s string) *IndexersUpdate {
|
||||
iu.mutation.SetName(s)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (iu *IndexersUpdate) SetNillableName(s *string) *IndexersUpdate {
|
||||
if s != nil {
|
||||
iu.SetName(*s)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (iu *IndexersUpdate) SetImplementation(s string) *IndexersUpdate {
|
||||
iu.mutation.SetImplementation(s)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
|
||||
func (iu *IndexersUpdate) SetNillableImplementation(s *string) *IndexersUpdate {
|
||||
if s != nil {
|
||||
iu.SetImplementation(*s)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (iu *IndexersUpdate) SetSettings(s string) *IndexersUpdate {
|
||||
iu.mutation.SetSettings(s)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (iu *IndexersUpdate) SetNillableSettings(s *string) *IndexersUpdate {
|
||||
if s != nil {
|
||||
iu.SetSettings(*s)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetEnableRss sets the "enable_rss" field.
|
||||
func (iu *IndexersUpdate) SetEnableRss(b bool) *IndexersUpdate {
|
||||
iu.mutation.SetEnableRss(b)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillableEnableRss sets the "enable_rss" field if the given value is not nil.
|
||||
func (iu *IndexersUpdate) SetNillableEnableRss(b *bool) *IndexersUpdate {
|
||||
if b != nil {
|
||||
iu.SetEnableRss(*b)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (iu *IndexersUpdate) SetPriority(i int) *IndexersUpdate {
|
||||
iu.mutation.ResetPriority()
|
||||
iu.mutation.SetPriority(i)
|
||||
return iu
|
||||
}
|
||||
|
||||
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
||||
func (iu *IndexersUpdate) SetNillablePriority(i *int) *IndexersUpdate {
|
||||
if i != nil {
|
||||
iu.SetPriority(*i)
|
||||
}
|
||||
return iu
|
||||
}
|
||||
|
||||
// AddPriority adds i to the "priority" field.
|
||||
func (iu *IndexersUpdate) AddPriority(i int) *IndexersUpdate {
|
||||
iu.mutation.AddPriority(i)
|
||||
return iu
|
||||
}
|
||||
|
||||
// Mutation returns the IndexersMutation object of the builder.
|
||||
func (iu *IndexersUpdate) Mutation() *IndexersMutation {
|
||||
return iu.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (iu *IndexersUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, iu.sqlSave, iu.mutation, iu.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (iu *IndexersUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := iu.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (iu *IndexersUpdate) Exec(ctx context.Context) error {
|
||||
_, err := iu.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (iu *IndexersUpdate) ExecX(ctx context.Context) {
|
||||
if err := iu.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (iu *IndexersUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(indexers.Table, indexers.Columns, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
|
||||
if ps := iu.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := iu.mutation.Name(); ok {
|
||||
_spec.SetField(indexers.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iu.mutation.Implementation(); ok {
|
||||
_spec.SetField(indexers.FieldImplementation, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iu.mutation.Settings(); ok {
|
||||
_spec.SetField(indexers.FieldSettings, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iu.mutation.EnableRss(); ok {
|
||||
_spec.SetField(indexers.FieldEnableRss, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := iu.mutation.Priority(); ok {
|
||||
_spec.SetField(indexers.FieldPriority, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iu.mutation.AddedPriority(); ok {
|
||||
_spec.AddField(indexers.FieldPriority, field.TypeInt, value)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, iu.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{indexers.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
iu.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// IndexersUpdateOne is the builder for updating a single Indexers entity.
|
||||
type IndexersUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *IndexersMutation
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (iuo *IndexersUpdateOne) SetName(s string) *IndexersUpdateOne {
|
||||
iuo.mutation.SetName(s)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (iuo *IndexersUpdateOne) SetNillableName(s *string) *IndexersUpdateOne {
|
||||
if s != nil {
|
||||
iuo.SetName(*s)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetImplementation sets the "implementation" field.
|
||||
func (iuo *IndexersUpdateOne) SetImplementation(s string) *IndexersUpdateOne {
|
||||
iuo.mutation.SetImplementation(s)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillableImplementation sets the "implementation" field if the given value is not nil.
|
||||
func (iuo *IndexersUpdateOne) SetNillableImplementation(s *string) *IndexersUpdateOne {
|
||||
if s != nil {
|
||||
iuo.SetImplementation(*s)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetSettings sets the "settings" field.
|
||||
func (iuo *IndexersUpdateOne) SetSettings(s string) *IndexersUpdateOne {
|
||||
iuo.mutation.SetSettings(s)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillableSettings sets the "settings" field if the given value is not nil.
|
||||
func (iuo *IndexersUpdateOne) SetNillableSettings(s *string) *IndexersUpdateOne {
|
||||
if s != nil {
|
||||
iuo.SetSettings(*s)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetEnableRss sets the "enable_rss" field.
|
||||
func (iuo *IndexersUpdateOne) SetEnableRss(b bool) *IndexersUpdateOne {
|
||||
iuo.mutation.SetEnableRss(b)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillableEnableRss sets the "enable_rss" field if the given value is not nil.
|
||||
func (iuo *IndexersUpdateOne) SetNillableEnableRss(b *bool) *IndexersUpdateOne {
|
||||
if b != nil {
|
||||
iuo.SetEnableRss(*b)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetPriority sets the "priority" field.
|
||||
func (iuo *IndexersUpdateOne) SetPriority(i int) *IndexersUpdateOne {
|
||||
iuo.mutation.ResetPriority()
|
||||
iuo.mutation.SetPriority(i)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// SetNillablePriority sets the "priority" field if the given value is not nil.
|
||||
func (iuo *IndexersUpdateOne) SetNillablePriority(i *int) *IndexersUpdateOne {
|
||||
if i != nil {
|
||||
iuo.SetPriority(*i)
|
||||
}
|
||||
return iuo
|
||||
}
|
||||
|
||||
// AddPriority adds i to the "priority" field.
|
||||
func (iuo *IndexersUpdateOne) AddPriority(i int) *IndexersUpdateOne {
|
||||
iuo.mutation.AddPriority(i)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// Mutation returns the IndexersMutation object of the builder.
|
||||
func (iuo *IndexersUpdateOne) Mutation() *IndexersMutation {
|
||||
return iuo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the IndexersUpdate builder.
|
||||
func (iuo *IndexersUpdateOne) Where(ps ...predicate.Indexers) *IndexersUpdateOne {
|
||||
iuo.mutation.Where(ps...)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (iuo *IndexersUpdateOne) Select(field string, fields ...string) *IndexersUpdateOne {
|
||||
iuo.fields = append([]string{field}, fields...)
|
||||
return iuo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Indexers entity.
|
||||
func (iuo *IndexersUpdateOne) Save(ctx context.Context) (*Indexers, error) {
|
||||
return withHooks(ctx, iuo.sqlSave, iuo.mutation, iuo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (iuo *IndexersUpdateOne) SaveX(ctx context.Context) *Indexers {
|
||||
node, err := iuo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (iuo *IndexersUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := iuo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (iuo *IndexersUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := iuo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (iuo *IndexersUpdateOne) sqlSave(ctx context.Context) (_node *Indexers, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(indexers.Table, indexers.Columns, sqlgraph.NewFieldSpec(indexers.FieldID, field.TypeInt))
|
||||
id, ok := iuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Indexers.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := iuo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, indexers.FieldID)
|
||||
for _, f := range fields {
|
||||
if !indexers.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != indexers.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := iuo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := iuo.mutation.Name(); ok {
|
||||
_spec.SetField(indexers.FieldName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.Implementation(); ok {
|
||||
_spec.SetField(indexers.FieldImplementation, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.Settings(); ok {
|
||||
_spec.SetField(indexers.FieldSettings, field.TypeString, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.EnableRss(); ok {
|
||||
_spec.SetField(indexers.FieldEnableRss, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.Priority(); ok {
|
||||
_spec.SetField(indexers.FieldPriority, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := iuo.mutation.AddedPriority(); ok {
|
||||
_spec.AddField(indexers.FieldPriority, field.TypeInt, value)
|
||||
}
|
||||
_node = &Indexers{config: iuo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, iuo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{indexers.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
iuo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
64
ent/migrate/migrate.go
Normal file
64
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...)
|
||||
}
|
||||
99
ent/migrate/schema.go
Normal file
99
ent/migrate/schema.go
Normal file
@@ -0,0 +1,99 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package migrate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
var (
|
||||
// DownloadClientsColumns holds the columns for the "download_clients" table.
|
||||
DownloadClientsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "enable", Type: field.TypeBool},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "implementation", Type: field.TypeString},
|
||||
{Name: "settings", Type: field.TypeString},
|
||||
{Name: "priority", Type: field.TypeString},
|
||||
{Name: "remove_completed_downloads", Type: field.TypeBool},
|
||||
{Name: "remove_failed_downloads", Type: field.TypeBool},
|
||||
{Name: "tags", Type: field.TypeString},
|
||||
}
|
||||
// DownloadClientsTable holds the schema information for the "download_clients" table.
|
||||
DownloadClientsTable = &schema.Table{
|
||||
Name: "download_clients",
|
||||
Columns: DownloadClientsColumns,
|
||||
PrimaryKey: []*schema.Column{DownloadClientsColumns[0]},
|
||||
}
|
||||
// EpidodesColumns holds the columns for the "epidodes" table.
|
||||
EpidodesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "series_id", Type: field.TypeInt},
|
||||
{Name: "season_number", Type: field.TypeInt},
|
||||
{Name: "episode_number", Type: field.TypeInt},
|
||||
{Name: "title", Type: field.TypeString},
|
||||
{Name: "overview", Type: field.TypeString},
|
||||
{Name: "air_date", Type: field.TypeTime},
|
||||
}
|
||||
// EpidodesTable holds the schema information for the "epidodes" table.
|
||||
EpidodesTable = &schema.Table{
|
||||
Name: "epidodes",
|
||||
Columns: EpidodesColumns,
|
||||
PrimaryKey: []*schema.Column{EpidodesColumns[0]},
|
||||
}
|
||||
// IndexersColumns holds the columns for the "indexers" table.
|
||||
IndexersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "implementation", Type: field.TypeString},
|
||||
{Name: "settings", Type: field.TypeString},
|
||||
{Name: "enable_rss", Type: field.TypeBool},
|
||||
{Name: "priority", Type: field.TypeInt},
|
||||
}
|
||||
// IndexersTable holds the schema information for the "indexers" table.
|
||||
IndexersTable = &schema.Table{
|
||||
Name: "indexers",
|
||||
Columns: IndexersColumns,
|
||||
PrimaryKey: []*schema.Column{IndexersColumns[0]},
|
||||
}
|
||||
// SeriesColumns holds the columns for the "series" table.
|
||||
SeriesColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "tmdb_id", Type: field.TypeInt},
|
||||
{Name: "imdb_id", Type: field.TypeString},
|
||||
{Name: "title", Type: field.TypeString},
|
||||
{Name: "original_name", Type: field.TypeString},
|
||||
{Name: "overview", Type: field.TypeString},
|
||||
{Name: "path", Type: field.TypeString},
|
||||
}
|
||||
// SeriesTable holds the schema information for the "series" table.
|
||||
SeriesTable = &schema.Table{
|
||||
Name: "series",
|
||||
Columns: SeriesColumns,
|
||||
PrimaryKey: []*schema.Column{SeriesColumns[0]},
|
||||
}
|
||||
// SettingsColumns holds the columns for the "settings" table.
|
||||
SettingsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||
{Name: "key", Type: field.TypeString},
|
||||
{Name: "value", Type: field.TypeString},
|
||||
}
|
||||
// SettingsTable holds the schema information for the "settings" table.
|
||||
SettingsTable = &schema.Table{
|
||||
Name: "settings",
|
||||
Columns: SettingsColumns,
|
||||
PrimaryKey: []*schema.Column{SettingsColumns[0]},
|
||||
}
|
||||
// Tables holds all the tables in the schema.
|
||||
Tables = []*schema.Table{
|
||||
DownloadClientsTable,
|
||||
EpidodesTable,
|
||||
IndexersTable,
|
||||
SeriesTable,
|
||||
SettingsTable,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
}
|
||||
3028
ent/mutation.go
Normal file
3028
ent/mutation.go
Normal file
File diff suppressed because it is too large
Load Diff
22
ent/predicate/predicate.go
Normal file
22
ent/predicate/predicate.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package predicate
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// DownloadClients is the predicate function for downloadclients builders.
|
||||
type DownloadClients func(*sql.Selector)
|
||||
|
||||
// Epidodes is the predicate function for epidodes builders.
|
||||
type Epidodes func(*sql.Selector)
|
||||
|
||||
// Indexers is the predicate function for indexers builders.
|
||||
type Indexers func(*sql.Selector)
|
||||
|
||||
// Series is the predicate function for series builders.
|
||||
type Series func(*sql.Selector)
|
||||
|
||||
// Settings is the predicate function for settings builders.
|
||||
type Settings func(*sql.Selector)
|
||||
9
ent/runtime.go
Normal file
9
ent/runtime.go
Normal file
@@ -0,0 +1,9 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
// 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() {
|
||||
}
|
||||
10
ent/runtime/runtime.go
Normal file
10
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 polaris/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.13.1" // Version of ent codegen.
|
||||
Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen.
|
||||
)
|
||||
30
ent/schema/downloadclients.go
Normal file
30
ent/schema/downloadclients.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// DownloadClients holds the schema definition for the DownloadClients entity.
|
||||
type DownloadClients struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the DownloadClients.
|
||||
func (DownloadClients) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Bool("enable"),
|
||||
field.String("name"),
|
||||
field.String("implementation"),
|
||||
field.String("settings"),
|
||||
field.String("priority"),
|
||||
field.Bool("remove_completed_downloads"),
|
||||
field.Bool("remove_failed_downloads"),
|
||||
field.String("tags"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the DownloadClients.
|
||||
func (DownloadClients) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
28
ent/schema/epidodes.go
Normal file
28
ent/schema/epidodes.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Epidodes holds the schema definition for the Epidodes entity.
|
||||
type Epidodes struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Epidodes.
|
||||
func (Epidodes) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("series_id"),
|
||||
field.Int("season_number"),
|
||||
field.Int("episode_number"),
|
||||
field.String("title"),
|
||||
field.String("overview"),
|
||||
field.Time("air_date"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Epidodes.
|
||||
func (Epidodes) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
27
ent/schema/indexers.go
Normal file
27
ent/schema/indexers.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Indexers holds the schema definition for the Indexers entity.
|
||||
type Indexers struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Indexers.
|
||||
func (Indexers) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("name"),
|
||||
field.String("implementation"),
|
||||
field.String("settings"),
|
||||
field.Bool("enable_rss"),
|
||||
field.Int("priority"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Indexers.
|
||||
func (Indexers) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
28
ent/schema/series.go
Normal file
28
ent/schema/series.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Series holds the schema definition for the Series entity.
|
||||
type Series struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Series.
|
||||
func (Series) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("tmdb_id"),
|
||||
field.String("imdb_id"),
|
||||
field.String("title"),
|
||||
field.String("original_name"),
|
||||
field.String("overview"),
|
||||
field.String("path"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Series.
|
||||
func (Series) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
24
ent/schema/settings.go
Normal file
24
ent/schema/settings.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// Settings holds the schema definition for the Settings entity.
|
||||
type Settings struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the Settings.
|
||||
func (Settings) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("key"),
|
||||
field.String("value"),
|
||||
}
|
||||
}
|
||||
|
||||
// Edges of the Settings.
|
||||
func (Settings) Edges() []ent.Edge {
|
||||
return nil
|
||||
}
|
||||
158
ent/series.go
Normal file
158
ent/series.go
Normal file
@@ -0,0 +1,158 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/ent/series"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Series is the model entity for the Series schema.
|
||||
type Series struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// TmdbID holds the value of the "tmdb_id" field.
|
||||
TmdbID int `json:"tmdb_id,omitempty"`
|
||||
// ImdbID holds the value of the "imdb_id" field.
|
||||
ImdbID string `json:"imdb_id,omitempty"`
|
||||
// Title holds the value of the "title" field.
|
||||
Title string `json:"title,omitempty"`
|
||||
// OriginalName holds the value of the "original_name" field.
|
||||
OriginalName string `json:"original_name,omitempty"`
|
||||
// Overview holds the value of the "overview" field.
|
||||
Overview string `json:"overview,omitempty"`
|
||||
// Path holds the value of the "path" field.
|
||||
Path string `json:"path,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Series) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case series.FieldID, series.FieldTmdbID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case series.FieldImdbID, series.FieldTitle, series.FieldOriginalName, series.FieldOverview, series.FieldPath:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Series fields.
|
||||
func (s *Series) 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 series.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
s.ID = int(value.Int64)
|
||||
case series.FieldTmdbID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field tmdb_id", values[i])
|
||||
} else if value.Valid {
|
||||
s.TmdbID = int(value.Int64)
|
||||
}
|
||||
case series.FieldImdbID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field imdb_id", values[i])
|
||||
} else if value.Valid {
|
||||
s.ImdbID = value.String
|
||||
}
|
||||
case series.FieldTitle:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field title", values[i])
|
||||
} else if value.Valid {
|
||||
s.Title = value.String
|
||||
}
|
||||
case series.FieldOriginalName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field original_name", values[i])
|
||||
} else if value.Valid {
|
||||
s.OriginalName = value.String
|
||||
}
|
||||
case series.FieldOverview:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field overview", values[i])
|
||||
} else if value.Valid {
|
||||
s.Overview = value.String
|
||||
}
|
||||
case series.FieldPath:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field path", values[i])
|
||||
} else if value.Valid {
|
||||
s.Path = value.String
|
||||
}
|
||||
default:
|
||||
s.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Series.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (s *Series) Value(name string) (ent.Value, error) {
|
||||
return s.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Series.
|
||||
// Note that you need to call Series.Unwrap() before calling this method if this Series
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (s *Series) Update() *SeriesUpdateOne {
|
||||
return NewSeriesClient(s.config).UpdateOne(s)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Series 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 (s *Series) Unwrap() *Series {
|
||||
_tx, ok := s.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Series is not a transactional entity")
|
||||
}
|
||||
s.config.driver = _tx.drv
|
||||
return s
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (s *Series) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Series(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
|
||||
builder.WriteString("tmdb_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.TmdbID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("imdb_id=")
|
||||
builder.WriteString(s.ImdbID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("title=")
|
||||
builder.WriteString(s.Title)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("original_name=")
|
||||
builder.WriteString(s.OriginalName)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("overview=")
|
||||
builder.WriteString(s.Overview)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("path=")
|
||||
builder.WriteString(s.Path)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// SeriesSlice is a parsable slice of Series.
|
||||
type SeriesSlice []*Series
|
||||
87
ent/series/series.go
Normal file
87
ent/series/series.go
Normal file
@@ -0,0 +1,87 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package series
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the series type in the database.
|
||||
Label = "series"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldTmdbID holds the string denoting the tmdb_id field in the database.
|
||||
FieldTmdbID = "tmdb_id"
|
||||
// FieldImdbID holds the string denoting the imdb_id field in the database.
|
||||
FieldImdbID = "imdb_id"
|
||||
// FieldTitle holds the string denoting the title field in the database.
|
||||
FieldTitle = "title"
|
||||
// FieldOriginalName holds the string denoting the original_name field in the database.
|
||||
FieldOriginalName = "original_name"
|
||||
// FieldOverview holds the string denoting the overview field in the database.
|
||||
FieldOverview = "overview"
|
||||
// FieldPath holds the string denoting the path field in the database.
|
||||
FieldPath = "path"
|
||||
// Table holds the table name of the series in the database.
|
||||
Table = "series"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for series fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldTmdbID,
|
||||
FieldImdbID,
|
||||
FieldTitle,
|
||||
FieldOriginalName,
|
||||
FieldOverview,
|
||||
FieldPath,
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the Series 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()
|
||||
}
|
||||
|
||||
// ByTmdbID orders the results by the tmdb_id field.
|
||||
func ByTmdbID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTmdbID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByImdbID orders the results by the imdb_id field.
|
||||
func ByImdbID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldImdbID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTitle orders the results by the title field.
|
||||
func ByTitle(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTitle, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOriginalName orders the results by the original_name field.
|
||||
func ByOriginalName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldOriginalName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOverview orders the results by the overview field.
|
||||
func ByOverview(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldOverview, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPath orders the results by the path field.
|
||||
func ByPath(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPath, opts...).ToFunc()
|
||||
}
|
||||
464
ent/series/where.go
Normal file
464
ent/series/where.go
Normal file
@@ -0,0 +1,464 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package series
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Series {
|
||||
return predicate.Series(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Series {
|
||||
return predicate.Series(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Series {
|
||||
return predicate.Series(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Series {
|
||||
return predicate.Series(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Series {
|
||||
return predicate.Series(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Series {
|
||||
return predicate.Series(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Series {
|
||||
return predicate.Series(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// TmdbID applies equality check predicate on the "tmdb_id" field. It's identical to TmdbIDEQ.
|
||||
func TmdbID(v int) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldTmdbID, v))
|
||||
}
|
||||
|
||||
// ImdbID applies equality check predicate on the "imdb_id" field. It's identical to ImdbIDEQ.
|
||||
func ImdbID(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// Title applies equality check predicate on the "title" field. It's identical to TitleEQ.
|
||||
func Title(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldTitle, v))
|
||||
}
|
||||
|
||||
// OriginalName applies equality check predicate on the "original_name" field. It's identical to OriginalNameEQ.
|
||||
func OriginalName(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// Overview applies equality check predicate on the "overview" field. It's identical to OverviewEQ.
|
||||
func Overview(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldOverview, v))
|
||||
}
|
||||
|
||||
// Path applies equality check predicate on the "path" field. It's identical to PathEQ.
|
||||
func Path(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldPath, v))
|
||||
}
|
||||
|
||||
// TmdbIDEQ applies the EQ predicate on the "tmdb_id" field.
|
||||
func TmdbIDEQ(v int) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldTmdbID, v))
|
||||
}
|
||||
|
||||
// TmdbIDNEQ applies the NEQ predicate on the "tmdb_id" field.
|
||||
func TmdbIDNEQ(v int) predicate.Series {
|
||||
return predicate.Series(sql.FieldNEQ(FieldTmdbID, v))
|
||||
}
|
||||
|
||||
// TmdbIDIn applies the In predicate on the "tmdb_id" field.
|
||||
func TmdbIDIn(vs ...int) predicate.Series {
|
||||
return predicate.Series(sql.FieldIn(FieldTmdbID, vs...))
|
||||
}
|
||||
|
||||
// TmdbIDNotIn applies the NotIn predicate on the "tmdb_id" field.
|
||||
func TmdbIDNotIn(vs ...int) predicate.Series {
|
||||
return predicate.Series(sql.FieldNotIn(FieldTmdbID, vs...))
|
||||
}
|
||||
|
||||
// TmdbIDGT applies the GT predicate on the "tmdb_id" field.
|
||||
func TmdbIDGT(v int) predicate.Series {
|
||||
return predicate.Series(sql.FieldGT(FieldTmdbID, v))
|
||||
}
|
||||
|
||||
// TmdbIDGTE applies the GTE predicate on the "tmdb_id" field.
|
||||
func TmdbIDGTE(v int) predicate.Series {
|
||||
return predicate.Series(sql.FieldGTE(FieldTmdbID, v))
|
||||
}
|
||||
|
||||
// TmdbIDLT applies the LT predicate on the "tmdb_id" field.
|
||||
func TmdbIDLT(v int) predicate.Series {
|
||||
return predicate.Series(sql.FieldLT(FieldTmdbID, v))
|
||||
}
|
||||
|
||||
// TmdbIDLTE applies the LTE predicate on the "tmdb_id" field.
|
||||
func TmdbIDLTE(v int) predicate.Series {
|
||||
return predicate.Series(sql.FieldLTE(FieldTmdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDEQ applies the EQ predicate on the "imdb_id" field.
|
||||
func ImdbIDEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDNEQ applies the NEQ predicate on the "imdb_id" field.
|
||||
func ImdbIDNEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNEQ(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDIn applies the In predicate on the "imdb_id" field.
|
||||
func ImdbIDIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldIn(FieldImdbID, vs...))
|
||||
}
|
||||
|
||||
// ImdbIDNotIn applies the NotIn predicate on the "imdb_id" field.
|
||||
func ImdbIDNotIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNotIn(FieldImdbID, vs...))
|
||||
}
|
||||
|
||||
// ImdbIDGT applies the GT predicate on the "imdb_id" field.
|
||||
func ImdbIDGT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGT(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDGTE applies the GTE predicate on the "imdb_id" field.
|
||||
func ImdbIDGTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGTE(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDLT applies the LT predicate on the "imdb_id" field.
|
||||
func ImdbIDLT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLT(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDLTE applies the LTE predicate on the "imdb_id" field.
|
||||
func ImdbIDLTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLTE(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDContains applies the Contains predicate on the "imdb_id" field.
|
||||
func ImdbIDContains(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContains(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDHasPrefix applies the HasPrefix predicate on the "imdb_id" field.
|
||||
func ImdbIDHasPrefix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasPrefix(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDHasSuffix applies the HasSuffix predicate on the "imdb_id" field.
|
||||
func ImdbIDHasSuffix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasSuffix(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDEqualFold applies the EqualFold predicate on the "imdb_id" field.
|
||||
func ImdbIDEqualFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEqualFold(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// ImdbIDContainsFold applies the ContainsFold predicate on the "imdb_id" field.
|
||||
func ImdbIDContainsFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContainsFold(FieldImdbID, v))
|
||||
}
|
||||
|
||||
// TitleEQ applies the EQ predicate on the "title" field.
|
||||
func TitleEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleNEQ applies the NEQ predicate on the "title" field.
|
||||
func TitleNEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNEQ(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleIn applies the In predicate on the "title" field.
|
||||
func TitleIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldIn(FieldTitle, vs...))
|
||||
}
|
||||
|
||||
// TitleNotIn applies the NotIn predicate on the "title" field.
|
||||
func TitleNotIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNotIn(FieldTitle, vs...))
|
||||
}
|
||||
|
||||
// TitleGT applies the GT predicate on the "title" field.
|
||||
func TitleGT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGT(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleGTE applies the GTE predicate on the "title" field.
|
||||
func TitleGTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGTE(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleLT applies the LT predicate on the "title" field.
|
||||
func TitleLT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLT(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleLTE applies the LTE predicate on the "title" field.
|
||||
func TitleLTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLTE(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleContains applies the Contains predicate on the "title" field.
|
||||
func TitleContains(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContains(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleHasPrefix applies the HasPrefix predicate on the "title" field.
|
||||
func TitleHasPrefix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasPrefix(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleHasSuffix applies the HasSuffix predicate on the "title" field.
|
||||
func TitleHasSuffix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasSuffix(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleEqualFold applies the EqualFold predicate on the "title" field.
|
||||
func TitleEqualFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEqualFold(FieldTitle, v))
|
||||
}
|
||||
|
||||
// TitleContainsFold applies the ContainsFold predicate on the "title" field.
|
||||
func TitleContainsFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContainsFold(FieldTitle, v))
|
||||
}
|
||||
|
||||
// OriginalNameEQ applies the EQ predicate on the "original_name" field.
|
||||
func OriginalNameEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameNEQ applies the NEQ predicate on the "original_name" field.
|
||||
func OriginalNameNEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNEQ(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameIn applies the In predicate on the "original_name" field.
|
||||
func OriginalNameIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldIn(FieldOriginalName, vs...))
|
||||
}
|
||||
|
||||
// OriginalNameNotIn applies the NotIn predicate on the "original_name" field.
|
||||
func OriginalNameNotIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNotIn(FieldOriginalName, vs...))
|
||||
}
|
||||
|
||||
// OriginalNameGT applies the GT predicate on the "original_name" field.
|
||||
func OriginalNameGT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGT(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameGTE applies the GTE predicate on the "original_name" field.
|
||||
func OriginalNameGTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGTE(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameLT applies the LT predicate on the "original_name" field.
|
||||
func OriginalNameLT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLT(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameLTE applies the LTE predicate on the "original_name" field.
|
||||
func OriginalNameLTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLTE(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameContains applies the Contains predicate on the "original_name" field.
|
||||
func OriginalNameContains(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContains(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameHasPrefix applies the HasPrefix predicate on the "original_name" field.
|
||||
func OriginalNameHasPrefix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasPrefix(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameHasSuffix applies the HasSuffix predicate on the "original_name" field.
|
||||
func OriginalNameHasSuffix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasSuffix(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameEqualFold applies the EqualFold predicate on the "original_name" field.
|
||||
func OriginalNameEqualFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEqualFold(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OriginalNameContainsFold applies the ContainsFold predicate on the "original_name" field.
|
||||
func OriginalNameContainsFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContainsFold(FieldOriginalName, v))
|
||||
}
|
||||
|
||||
// OverviewEQ applies the EQ predicate on the "overview" field.
|
||||
func OverviewEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewNEQ applies the NEQ predicate on the "overview" field.
|
||||
func OverviewNEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNEQ(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewIn applies the In predicate on the "overview" field.
|
||||
func OverviewIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldIn(FieldOverview, vs...))
|
||||
}
|
||||
|
||||
// OverviewNotIn applies the NotIn predicate on the "overview" field.
|
||||
func OverviewNotIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNotIn(FieldOverview, vs...))
|
||||
}
|
||||
|
||||
// OverviewGT applies the GT predicate on the "overview" field.
|
||||
func OverviewGT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGT(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewGTE applies the GTE predicate on the "overview" field.
|
||||
func OverviewGTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGTE(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewLT applies the LT predicate on the "overview" field.
|
||||
func OverviewLT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLT(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewLTE applies the LTE predicate on the "overview" field.
|
||||
func OverviewLTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLTE(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewContains applies the Contains predicate on the "overview" field.
|
||||
func OverviewContains(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContains(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewHasPrefix applies the HasPrefix predicate on the "overview" field.
|
||||
func OverviewHasPrefix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasPrefix(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewHasSuffix applies the HasSuffix predicate on the "overview" field.
|
||||
func OverviewHasSuffix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasSuffix(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewEqualFold applies the EqualFold predicate on the "overview" field.
|
||||
func OverviewEqualFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEqualFold(FieldOverview, v))
|
||||
}
|
||||
|
||||
// OverviewContainsFold applies the ContainsFold predicate on the "overview" field.
|
||||
func OverviewContainsFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContainsFold(FieldOverview, v))
|
||||
}
|
||||
|
||||
// PathEQ applies the EQ predicate on the "path" field.
|
||||
func PathEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEQ(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathNEQ applies the NEQ predicate on the "path" field.
|
||||
func PathNEQ(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNEQ(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathIn applies the In predicate on the "path" field.
|
||||
func PathIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldIn(FieldPath, vs...))
|
||||
}
|
||||
|
||||
// PathNotIn applies the NotIn predicate on the "path" field.
|
||||
func PathNotIn(vs ...string) predicate.Series {
|
||||
return predicate.Series(sql.FieldNotIn(FieldPath, vs...))
|
||||
}
|
||||
|
||||
// PathGT applies the GT predicate on the "path" field.
|
||||
func PathGT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGT(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathGTE applies the GTE predicate on the "path" field.
|
||||
func PathGTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldGTE(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathLT applies the LT predicate on the "path" field.
|
||||
func PathLT(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLT(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathLTE applies the LTE predicate on the "path" field.
|
||||
func PathLTE(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldLTE(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathContains applies the Contains predicate on the "path" field.
|
||||
func PathContains(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContains(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathHasPrefix applies the HasPrefix predicate on the "path" field.
|
||||
func PathHasPrefix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasPrefix(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathHasSuffix applies the HasSuffix predicate on the "path" field.
|
||||
func PathHasSuffix(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldHasSuffix(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathEqualFold applies the EqualFold predicate on the "path" field.
|
||||
func PathEqualFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldEqualFold(FieldPath, v))
|
||||
}
|
||||
|
||||
// PathContainsFold applies the ContainsFold predicate on the "path" field.
|
||||
func PathContainsFold(v string) predicate.Series {
|
||||
return predicate.Series(sql.FieldContainsFold(FieldPath, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Series) predicate.Series {
|
||||
return predicate.Series(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Series) predicate.Series {
|
||||
return predicate.Series(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Series) predicate.Series {
|
||||
return predicate.Series(sql.NotPredicates(p))
|
||||
}
|
||||
248
ent/series_create.go
Normal file
248
ent/series_create.go
Normal file
@@ -0,0 +1,248 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/series"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SeriesCreate is the builder for creating a Series entity.
|
||||
type SeriesCreate struct {
|
||||
config
|
||||
mutation *SeriesMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetTmdbID sets the "tmdb_id" field.
|
||||
func (sc *SeriesCreate) SetTmdbID(i int) *SeriesCreate {
|
||||
sc.mutation.SetTmdbID(i)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetImdbID sets the "imdb_id" field.
|
||||
func (sc *SeriesCreate) SetImdbID(s string) *SeriesCreate {
|
||||
sc.mutation.SetImdbID(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (sc *SeriesCreate) SetTitle(s string) *SeriesCreate {
|
||||
sc.mutation.SetTitle(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetOriginalName sets the "original_name" field.
|
||||
func (sc *SeriesCreate) SetOriginalName(s string) *SeriesCreate {
|
||||
sc.mutation.SetOriginalName(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetOverview sets the "overview" field.
|
||||
func (sc *SeriesCreate) SetOverview(s string) *SeriesCreate {
|
||||
sc.mutation.SetOverview(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (sc *SeriesCreate) SetPath(s string) *SeriesCreate {
|
||||
sc.mutation.SetPath(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// Mutation returns the SeriesMutation object of the builder.
|
||||
func (sc *SeriesCreate) Mutation() *SeriesMutation {
|
||||
return sc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Series in the database.
|
||||
func (sc *SeriesCreate) Save(ctx context.Context) (*Series, error) {
|
||||
return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (sc *SeriesCreate) SaveX(ctx context.Context) *Series {
|
||||
v, err := sc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (sc *SeriesCreate) Exec(ctx context.Context) error {
|
||||
_, err := sc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sc *SeriesCreate) ExecX(ctx context.Context) {
|
||||
if err := sc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (sc *SeriesCreate) check() error {
|
||||
if _, ok := sc.mutation.TmdbID(); !ok {
|
||||
return &ValidationError{Name: "tmdb_id", err: errors.New(`ent: missing required field "Series.tmdb_id"`)}
|
||||
}
|
||||
if _, ok := sc.mutation.ImdbID(); !ok {
|
||||
return &ValidationError{Name: "imdb_id", err: errors.New(`ent: missing required field "Series.imdb_id"`)}
|
||||
}
|
||||
if _, ok := sc.mutation.Title(); !ok {
|
||||
return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Series.title"`)}
|
||||
}
|
||||
if _, ok := sc.mutation.OriginalName(); !ok {
|
||||
return &ValidationError{Name: "original_name", err: errors.New(`ent: missing required field "Series.original_name"`)}
|
||||
}
|
||||
if _, ok := sc.mutation.Overview(); !ok {
|
||||
return &ValidationError{Name: "overview", err: errors.New(`ent: missing required field "Series.overview"`)}
|
||||
}
|
||||
if _, ok := sc.mutation.Path(); !ok {
|
||||
return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Series.path"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sc *SeriesCreate) sqlSave(ctx context.Context) (*Series, error) {
|
||||
if err := sc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := sc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, sc.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)
|
||||
sc.mutation.id = &_node.ID
|
||||
sc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (sc *SeriesCreate) createSpec() (*Series, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Series{config: sc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(series.Table, sqlgraph.NewFieldSpec(series.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := sc.mutation.TmdbID(); ok {
|
||||
_spec.SetField(series.FieldTmdbID, field.TypeInt, value)
|
||||
_node.TmdbID = value
|
||||
}
|
||||
if value, ok := sc.mutation.ImdbID(); ok {
|
||||
_spec.SetField(series.FieldImdbID, field.TypeString, value)
|
||||
_node.ImdbID = value
|
||||
}
|
||||
if value, ok := sc.mutation.Title(); ok {
|
||||
_spec.SetField(series.FieldTitle, field.TypeString, value)
|
||||
_node.Title = value
|
||||
}
|
||||
if value, ok := sc.mutation.OriginalName(); ok {
|
||||
_spec.SetField(series.FieldOriginalName, field.TypeString, value)
|
||||
_node.OriginalName = value
|
||||
}
|
||||
if value, ok := sc.mutation.Overview(); ok {
|
||||
_spec.SetField(series.FieldOverview, field.TypeString, value)
|
||||
_node.Overview = value
|
||||
}
|
||||
if value, ok := sc.mutation.Path(); ok {
|
||||
_spec.SetField(series.FieldPath, field.TypeString, value)
|
||||
_node.Path = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// SeriesCreateBulk is the builder for creating many Series entities in bulk.
|
||||
type SeriesCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*SeriesCreate
|
||||
}
|
||||
|
||||
// Save creates the Series entities in the database.
|
||||
func (scb *SeriesCreateBulk) Save(ctx context.Context) ([]*Series, error) {
|
||||
if scb.err != nil {
|
||||
return nil, scb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(scb.builders))
|
||||
nodes := make([]*Series, len(scb.builders))
|
||||
mutators := make([]Mutator, len(scb.builders))
|
||||
for i := range scb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := scb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SeriesMutation)
|
||||
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, scb.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, scb.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, scb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (scb *SeriesCreateBulk) SaveX(ctx context.Context) []*Series {
|
||||
v, err := scb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (scb *SeriesCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := scb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (scb *SeriesCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := scb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/series_delete.go
Normal file
88
ent/series_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/series"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SeriesDelete is the builder for deleting a Series entity.
|
||||
type SeriesDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SeriesMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SeriesDelete builder.
|
||||
func (sd *SeriesDelete) Where(ps ...predicate.Series) *SeriesDelete {
|
||||
sd.mutation.Where(ps...)
|
||||
return sd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (sd *SeriesDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sd *SeriesDelete) ExecX(ctx context.Context) int {
|
||||
n, err := sd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (sd *SeriesDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(series.Table, sqlgraph.NewFieldSpec(series.FieldID, field.TypeInt))
|
||||
if ps := sd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
sd.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SeriesDeleteOne is the builder for deleting a single Series entity.
|
||||
type SeriesDeleteOne struct {
|
||||
sd *SeriesDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SeriesDelete builder.
|
||||
func (sdo *SeriesDeleteOne) Where(ps ...predicate.Series) *SeriesDeleteOne {
|
||||
sdo.sd.mutation.Where(ps...)
|
||||
return sdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (sdo *SeriesDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := sdo.sd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{series.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sdo *SeriesDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := sdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
526
ent/series_query.go
Normal file
526
ent/series_query.go
Normal file
@@ -0,0 +1,526 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/series"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SeriesQuery is the builder for querying Series entities.
|
||||
type SeriesQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []series.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Series
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the SeriesQuery builder.
|
||||
func (sq *SeriesQuery) Where(ps ...predicate.Series) *SeriesQuery {
|
||||
sq.predicates = append(sq.predicates, ps...)
|
||||
return sq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (sq *SeriesQuery) Limit(limit int) *SeriesQuery {
|
||||
sq.ctx.Limit = &limit
|
||||
return sq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (sq *SeriesQuery) Offset(offset int) *SeriesQuery {
|
||||
sq.ctx.Offset = &offset
|
||||
return sq
|
||||
}
|
||||
|
||||
// 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 (sq *SeriesQuery) Unique(unique bool) *SeriesQuery {
|
||||
sq.ctx.Unique = &unique
|
||||
return sq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (sq *SeriesQuery) Order(o ...series.OrderOption) *SeriesQuery {
|
||||
sq.order = append(sq.order, o...)
|
||||
return sq
|
||||
}
|
||||
|
||||
// First returns the first Series entity from the query.
|
||||
// Returns a *NotFoundError when no Series was found.
|
||||
func (sq *SeriesQuery) First(ctx context.Context) (*Series, error) {
|
||||
nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{series.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (sq *SeriesQuery) FirstX(ctx context.Context) *Series {
|
||||
node, err := sq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Series ID from the query.
|
||||
// Returns a *NotFoundError when no Series ID was found.
|
||||
func (sq *SeriesQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{series.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (sq *SeriesQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := sq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Series entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Series entity is found.
|
||||
// Returns a *NotFoundError when no Series entities are found.
|
||||
func (sq *SeriesQuery) Only(ctx context.Context) (*Series, error) {
|
||||
nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{series.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{series.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (sq *SeriesQuery) OnlyX(ctx context.Context) *Series {
|
||||
node, err := sq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Series ID in the query.
|
||||
// Returns a *NotSingularError when more than one Series ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (sq *SeriesQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{series.Label}
|
||||
default:
|
||||
err = &NotSingularError{series.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (sq *SeriesQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := sq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of SeriesSlice.
|
||||
func (sq *SeriesQuery) All(ctx context.Context) ([]*Series, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "All")
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Series, *SeriesQuery]()
|
||||
return withInterceptors[[]*Series](ctx, sq, qr, sq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (sq *SeriesQuery) AllX(ctx context.Context) []*Series {
|
||||
nodes, err := sq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Series IDs.
|
||||
func (sq *SeriesQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if sq.ctx.Unique == nil && sq.path != nil {
|
||||
sq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, sq.ctx, "IDs")
|
||||
if err = sq.Select(series.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (sq *SeriesQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := sq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (sq *SeriesQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "Count")
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, sq, querierCount[*SeriesQuery](), sq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (sq *SeriesQuery) CountX(ctx context.Context) int {
|
||||
count, err := sq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (sq *SeriesQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "Exist")
|
||||
switch _, err := sq.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 (sq *SeriesQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := sq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the SeriesQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (sq *SeriesQuery) Clone() *SeriesQuery {
|
||||
if sq == nil {
|
||||
return nil
|
||||
}
|
||||
return &SeriesQuery{
|
||||
config: sq.config,
|
||||
ctx: sq.ctx.Clone(),
|
||||
order: append([]series.OrderOption{}, sq.order...),
|
||||
inters: append([]Interceptor{}, sq.inters...),
|
||||
predicates: append([]predicate.Series{}, sq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: sq.sql.Clone(),
|
||||
path: sq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// TmdbID int `json:"tmdb_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Series.Query().
|
||||
// GroupBy(series.FieldTmdbID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (sq *SeriesQuery) GroupBy(field string, fields ...string) *SeriesGroupBy {
|
||||
sq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &SeriesGroupBy{build: sq}
|
||||
grbuild.flds = &sq.ctx.Fields
|
||||
grbuild.label = series.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 {
|
||||
// TmdbID int `json:"tmdb_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Series.Query().
|
||||
// Select(series.FieldTmdbID).
|
||||
// Scan(ctx, &v)
|
||||
func (sq *SeriesQuery) Select(fields ...string) *SeriesSelect {
|
||||
sq.ctx.Fields = append(sq.ctx.Fields, fields...)
|
||||
sbuild := &SeriesSelect{SeriesQuery: sq}
|
||||
sbuild.label = series.Label
|
||||
sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a SeriesSelect configured with the given aggregations.
|
||||
func (sq *SeriesQuery) Aggregate(fns ...AggregateFunc) *SeriesSelect {
|
||||
return sq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (sq *SeriesQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range sq.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, sq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range sq.ctx.Fields {
|
||||
if !series.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if sq.path != nil {
|
||||
prev, err := sq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sq *SeriesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Series, error) {
|
||||
var (
|
||||
nodes = []*Series{}
|
||||
_spec = sq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Series).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Series{config: sq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (sq *SeriesQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sq.querySpec()
|
||||
_spec.Node.Columns = sq.ctx.Fields
|
||||
if len(sq.ctx.Fields) > 0 {
|
||||
_spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, sq.driver, _spec)
|
||||
}
|
||||
|
||||
func (sq *SeriesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(series.Table, series.Columns, sqlgraph.NewFieldSpec(series.FieldID, field.TypeInt))
|
||||
_spec.From = sq.sql
|
||||
if unique := sq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if sq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := sq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, series.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != series.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := sq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := sq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := sq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := sq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (sq *SeriesQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(sq.driver.Dialect())
|
||||
t1 := builder.Table(series.Table)
|
||||
columns := sq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = series.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if sq.sql != nil {
|
||||
selector = sq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if sq.ctx.Unique != nil && *sq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range sq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range sq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := sq.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 := sq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// SeriesGroupBy is the group-by builder for Series entities.
|
||||
type SeriesGroupBy struct {
|
||||
selector
|
||||
build *SeriesQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (sgb *SeriesGroupBy) Aggregate(fns ...AggregateFunc) *SeriesGroupBy {
|
||||
sgb.fns = append(sgb.fns, fns...)
|
||||
return sgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (sgb *SeriesGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy")
|
||||
if err := sgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*SeriesQuery, *SeriesGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (sgb *SeriesGroupBy) sqlScan(ctx context.Context, root *SeriesQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(sgb.fns))
|
||||
for _, fn := range sgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns))
|
||||
for _, f := range *sgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*sgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// SeriesSelect is the builder for selecting fields of Series entities.
|
||||
type SeriesSelect struct {
|
||||
*SeriesQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ss *SeriesSelect) Aggregate(fns ...AggregateFunc) *SeriesSelect {
|
||||
ss.fns = append(ss.fns, fns...)
|
||||
return ss
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ss *SeriesSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ss.ctx, "Select")
|
||||
if err := ss.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*SeriesQuery, *SeriesSelect](ctx, ss.SeriesQuery, ss, ss.inters, v)
|
||||
}
|
||||
|
||||
func (ss *SeriesSelect) sqlScan(ctx context.Context, root *SeriesQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ss.fns))
|
||||
for _, fn := range ss.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ss.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 := ss.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
399
ent/series_update.go
Normal file
399
ent/series_update.go
Normal file
@@ -0,0 +1,399 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/series"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SeriesUpdate is the builder for updating Series entities.
|
||||
type SeriesUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SeriesMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SeriesUpdate builder.
|
||||
func (su *SeriesUpdate) Where(ps ...predicate.Series) *SeriesUpdate {
|
||||
su.mutation.Where(ps...)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetTmdbID sets the "tmdb_id" field.
|
||||
func (su *SeriesUpdate) SetTmdbID(i int) *SeriesUpdate {
|
||||
su.mutation.ResetTmdbID()
|
||||
su.mutation.SetTmdbID(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableTmdbID sets the "tmdb_id" field if the given value is not nil.
|
||||
func (su *SeriesUpdate) SetNillableTmdbID(i *int) *SeriesUpdate {
|
||||
if i != nil {
|
||||
su.SetTmdbID(*i)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// AddTmdbID adds i to the "tmdb_id" field.
|
||||
func (su *SeriesUpdate) AddTmdbID(i int) *SeriesUpdate {
|
||||
su.mutation.AddTmdbID(i)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetImdbID sets the "imdb_id" field.
|
||||
func (su *SeriesUpdate) SetImdbID(s string) *SeriesUpdate {
|
||||
su.mutation.SetImdbID(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableImdbID sets the "imdb_id" field if the given value is not nil.
|
||||
func (su *SeriesUpdate) SetNillableImdbID(s *string) *SeriesUpdate {
|
||||
if s != nil {
|
||||
su.SetImdbID(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (su *SeriesUpdate) SetTitle(s string) *SeriesUpdate {
|
||||
su.mutation.SetTitle(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableTitle sets the "title" field if the given value is not nil.
|
||||
func (su *SeriesUpdate) SetNillableTitle(s *string) *SeriesUpdate {
|
||||
if s != nil {
|
||||
su.SetTitle(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// SetOriginalName sets the "original_name" field.
|
||||
func (su *SeriesUpdate) SetOriginalName(s string) *SeriesUpdate {
|
||||
su.mutation.SetOriginalName(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableOriginalName sets the "original_name" field if the given value is not nil.
|
||||
func (su *SeriesUpdate) SetNillableOriginalName(s *string) *SeriesUpdate {
|
||||
if s != nil {
|
||||
su.SetOriginalName(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// SetOverview sets the "overview" field.
|
||||
func (su *SeriesUpdate) SetOverview(s string) *SeriesUpdate {
|
||||
su.mutation.SetOverview(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableOverview sets the "overview" field if the given value is not nil.
|
||||
func (su *SeriesUpdate) SetNillableOverview(s *string) *SeriesUpdate {
|
||||
if s != nil {
|
||||
su.SetOverview(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (su *SeriesUpdate) SetPath(s string) *SeriesUpdate {
|
||||
su.mutation.SetPath(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillablePath sets the "path" field if the given value is not nil.
|
||||
func (su *SeriesUpdate) SetNillablePath(s *string) *SeriesUpdate {
|
||||
if s != nil {
|
||||
su.SetPath(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// Mutation returns the SeriesMutation object of the builder.
|
||||
func (su *SeriesUpdate) Mutation() *SeriesMutation {
|
||||
return su.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (su *SeriesUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, su.sqlSave, su.mutation, su.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (su *SeriesUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := su.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (su *SeriesUpdate) Exec(ctx context.Context) error {
|
||||
_, err := su.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (su *SeriesUpdate) ExecX(ctx context.Context) {
|
||||
if err := su.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (su *SeriesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(series.Table, series.Columns, sqlgraph.NewFieldSpec(series.FieldID, field.TypeInt))
|
||||
if ps := su.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := su.mutation.TmdbID(); ok {
|
||||
_spec.SetField(series.FieldTmdbID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.AddedTmdbID(); ok {
|
||||
_spec.AddField(series.FieldTmdbID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.ImdbID(); ok {
|
||||
_spec.SetField(series.FieldImdbID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := su.mutation.Title(); ok {
|
||||
_spec.SetField(series.FieldTitle, field.TypeString, value)
|
||||
}
|
||||
if value, ok := su.mutation.OriginalName(); ok {
|
||||
_spec.SetField(series.FieldOriginalName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := su.mutation.Overview(); ok {
|
||||
_spec.SetField(series.FieldOverview, field.TypeString, value)
|
||||
}
|
||||
if value, ok := su.mutation.Path(); ok {
|
||||
_spec.SetField(series.FieldPath, field.TypeString, value)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{series.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
su.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// SeriesUpdateOne is the builder for updating a single Series entity.
|
||||
type SeriesUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *SeriesMutation
|
||||
}
|
||||
|
||||
// SetTmdbID sets the "tmdb_id" field.
|
||||
func (suo *SeriesUpdateOne) SetTmdbID(i int) *SeriesUpdateOne {
|
||||
suo.mutation.ResetTmdbID()
|
||||
suo.mutation.SetTmdbID(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableTmdbID sets the "tmdb_id" field if the given value is not nil.
|
||||
func (suo *SeriesUpdateOne) SetNillableTmdbID(i *int) *SeriesUpdateOne {
|
||||
if i != nil {
|
||||
suo.SetTmdbID(*i)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// AddTmdbID adds i to the "tmdb_id" field.
|
||||
func (suo *SeriesUpdateOne) AddTmdbID(i int) *SeriesUpdateOne {
|
||||
suo.mutation.AddTmdbID(i)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetImdbID sets the "imdb_id" field.
|
||||
func (suo *SeriesUpdateOne) SetImdbID(s string) *SeriesUpdateOne {
|
||||
suo.mutation.SetImdbID(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableImdbID sets the "imdb_id" field if the given value is not nil.
|
||||
func (suo *SeriesUpdateOne) SetNillableImdbID(s *string) *SeriesUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetImdbID(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetTitle sets the "title" field.
|
||||
func (suo *SeriesUpdateOne) SetTitle(s string) *SeriesUpdateOne {
|
||||
suo.mutation.SetTitle(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableTitle sets the "title" field if the given value is not nil.
|
||||
func (suo *SeriesUpdateOne) SetNillableTitle(s *string) *SeriesUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetTitle(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetOriginalName sets the "original_name" field.
|
||||
func (suo *SeriesUpdateOne) SetOriginalName(s string) *SeriesUpdateOne {
|
||||
suo.mutation.SetOriginalName(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableOriginalName sets the "original_name" field if the given value is not nil.
|
||||
func (suo *SeriesUpdateOne) SetNillableOriginalName(s *string) *SeriesUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetOriginalName(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetOverview sets the "overview" field.
|
||||
func (suo *SeriesUpdateOne) SetOverview(s string) *SeriesUpdateOne {
|
||||
suo.mutation.SetOverview(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableOverview sets the "overview" field if the given value is not nil.
|
||||
func (suo *SeriesUpdateOne) SetNillableOverview(s *string) *SeriesUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetOverview(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetPath sets the "path" field.
|
||||
func (suo *SeriesUpdateOne) SetPath(s string) *SeriesUpdateOne {
|
||||
suo.mutation.SetPath(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillablePath sets the "path" field if the given value is not nil.
|
||||
func (suo *SeriesUpdateOne) SetNillablePath(s *string) *SeriesUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetPath(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// Mutation returns the SeriesMutation object of the builder.
|
||||
func (suo *SeriesUpdateOne) Mutation() *SeriesMutation {
|
||||
return suo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SeriesUpdate builder.
|
||||
func (suo *SeriesUpdateOne) Where(ps ...predicate.Series) *SeriesUpdateOne {
|
||||
suo.mutation.Where(ps...)
|
||||
return suo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (suo *SeriesUpdateOne) Select(field string, fields ...string) *SeriesUpdateOne {
|
||||
suo.fields = append([]string{field}, fields...)
|
||||
return suo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Series entity.
|
||||
func (suo *SeriesUpdateOne) Save(ctx context.Context) (*Series, error) {
|
||||
return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (suo *SeriesUpdateOne) SaveX(ctx context.Context) *Series {
|
||||
node, err := suo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (suo *SeriesUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := suo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (suo *SeriesUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := suo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (suo *SeriesUpdateOne) sqlSave(ctx context.Context) (_node *Series, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(series.Table, series.Columns, sqlgraph.NewFieldSpec(series.FieldID, field.TypeInt))
|
||||
id, ok := suo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Series.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := suo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, series.FieldID)
|
||||
for _, f := range fields {
|
||||
if !series.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != series.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := suo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := suo.mutation.TmdbID(); ok {
|
||||
_spec.SetField(series.FieldTmdbID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.AddedTmdbID(); ok {
|
||||
_spec.AddField(series.FieldTmdbID, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.ImdbID(); ok {
|
||||
_spec.SetField(series.FieldImdbID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := suo.mutation.Title(); ok {
|
||||
_spec.SetField(series.FieldTitle, field.TypeString, value)
|
||||
}
|
||||
if value, ok := suo.mutation.OriginalName(); ok {
|
||||
_spec.SetField(series.FieldOriginalName, field.TypeString, value)
|
||||
}
|
||||
if value, ok := suo.mutation.Overview(); ok {
|
||||
_spec.SetField(series.FieldOverview, field.TypeString, value)
|
||||
}
|
||||
if value, ok := suo.mutation.Path(); ok {
|
||||
_spec.SetField(series.FieldPath, field.TypeString, value)
|
||||
}
|
||||
_node = &Series{config: suo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{series.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
suo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
114
ent/settings.go
Normal file
114
ent/settings.go
Normal file
@@ -0,0 +1,114 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"polaris/ent/settings"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// Settings is the model entity for the Settings schema.
|
||||
type Settings struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Key holds the value of the "key" field.
|
||||
Key string `json:"key,omitempty"`
|
||||
// Value holds the value of the "value" field.
|
||||
Value string `json:"value,omitempty"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Settings) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case settings.FieldID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case settings.FieldKey, settings.FieldValue:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
}
|
||||
}
|
||||
return values, nil
|
||||
}
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Settings fields.
|
||||
func (s *Settings) 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 settings.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
s.ID = int(value.Int64)
|
||||
case settings.FieldKey:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field key", values[i])
|
||||
} else if value.Valid {
|
||||
s.Key = value.String
|
||||
}
|
||||
case settings.FieldValue:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field value", values[i])
|
||||
} else if value.Valid {
|
||||
s.Value = value.String
|
||||
}
|
||||
default:
|
||||
s.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue returns the ent.Value that was dynamically selected and assigned to the Settings.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (s *Settings) GetValue(name string) (ent.Value, error) {
|
||||
return s.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Settings.
|
||||
// Note that you need to call Settings.Unwrap() before calling this method if this Settings
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (s *Settings) Update() *SettingsUpdateOne {
|
||||
return NewSettingsClient(s.config).UpdateOne(s)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Settings 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 (s *Settings) Unwrap() *Settings {
|
||||
_tx, ok := s.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Settings is not a transactional entity")
|
||||
}
|
||||
s.config.driver = _tx.drv
|
||||
return s
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (s *Settings) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Settings(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
|
||||
builder.WriteString("key=")
|
||||
builder.WriteString(s.Key)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("value=")
|
||||
builder.WriteString(s.Value)
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// SettingsSlice is a parsable slice of Settings.
|
||||
type SettingsSlice []*Settings
|
||||
55
ent/settings/settings.go
Normal file
55
ent/settings/settings.go
Normal file
@@ -0,0 +1,55 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package settings
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the settings type in the database.
|
||||
Label = "settings"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldKey holds the string denoting the key field in the database.
|
||||
FieldKey = "key"
|
||||
// FieldValue holds the string denoting the value field in the database.
|
||||
FieldValue = "value"
|
||||
// Table holds the table name of the settings in the database.
|
||||
Table = "settings"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for settings fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldKey,
|
||||
FieldValue,
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// OrderOption defines the ordering options for the Settings 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()
|
||||
}
|
||||
|
||||
// ByKey orders the results by the key field.
|
||||
func ByKey(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldKey, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByValue orders the results by the value field.
|
||||
func ByValue(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldValue, opts...).ToFunc()
|
||||
}
|
||||
209
ent/settings/where.go
Normal file
209
ent/settings/where.go
Normal file
@@ -0,0 +1,209 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package settings
|
||||
|
||||
import (
|
||||
"polaris/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id int) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// Key applies equality check predicate on the "key" field. It's identical to KeyEQ.
|
||||
func Key(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldEQ(FieldKey, v))
|
||||
}
|
||||
|
||||
// Value applies equality check predicate on the "value" field. It's identical to ValueEQ.
|
||||
func Value(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldEQ(FieldValue, v))
|
||||
}
|
||||
|
||||
// KeyEQ applies the EQ predicate on the "key" field.
|
||||
func KeyEQ(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldEQ(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyNEQ applies the NEQ predicate on the "key" field.
|
||||
func KeyNEQ(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldNEQ(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyIn applies the In predicate on the "key" field.
|
||||
func KeyIn(vs ...string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldIn(FieldKey, vs...))
|
||||
}
|
||||
|
||||
// KeyNotIn applies the NotIn predicate on the "key" field.
|
||||
func KeyNotIn(vs ...string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldNotIn(FieldKey, vs...))
|
||||
}
|
||||
|
||||
// KeyGT applies the GT predicate on the "key" field.
|
||||
func KeyGT(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldGT(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyGTE applies the GTE predicate on the "key" field.
|
||||
func KeyGTE(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldGTE(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyLT applies the LT predicate on the "key" field.
|
||||
func KeyLT(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldLT(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyLTE applies the LTE predicate on the "key" field.
|
||||
func KeyLTE(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldLTE(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyContains applies the Contains predicate on the "key" field.
|
||||
func KeyContains(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldContains(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyHasPrefix applies the HasPrefix predicate on the "key" field.
|
||||
func KeyHasPrefix(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldHasPrefix(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyHasSuffix applies the HasSuffix predicate on the "key" field.
|
||||
func KeyHasSuffix(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldHasSuffix(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyEqualFold applies the EqualFold predicate on the "key" field.
|
||||
func KeyEqualFold(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldEqualFold(FieldKey, v))
|
||||
}
|
||||
|
||||
// KeyContainsFold applies the ContainsFold predicate on the "key" field.
|
||||
func KeyContainsFold(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldContainsFold(FieldKey, v))
|
||||
}
|
||||
|
||||
// ValueEQ applies the EQ predicate on the "value" field.
|
||||
func ValueEQ(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldEQ(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueNEQ applies the NEQ predicate on the "value" field.
|
||||
func ValueNEQ(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldNEQ(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueIn applies the In predicate on the "value" field.
|
||||
func ValueIn(vs ...string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldIn(FieldValue, vs...))
|
||||
}
|
||||
|
||||
// ValueNotIn applies the NotIn predicate on the "value" field.
|
||||
func ValueNotIn(vs ...string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldNotIn(FieldValue, vs...))
|
||||
}
|
||||
|
||||
// ValueGT applies the GT predicate on the "value" field.
|
||||
func ValueGT(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldGT(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueGTE applies the GTE predicate on the "value" field.
|
||||
func ValueGTE(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldGTE(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueLT applies the LT predicate on the "value" field.
|
||||
func ValueLT(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldLT(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueLTE applies the LTE predicate on the "value" field.
|
||||
func ValueLTE(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldLTE(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueContains applies the Contains predicate on the "value" field.
|
||||
func ValueContains(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldContains(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueHasPrefix applies the HasPrefix predicate on the "value" field.
|
||||
func ValueHasPrefix(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldHasPrefix(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueHasSuffix applies the HasSuffix predicate on the "value" field.
|
||||
func ValueHasSuffix(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldHasSuffix(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueEqualFold applies the EqualFold predicate on the "value" field.
|
||||
func ValueEqualFold(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldEqualFold(FieldValue, v))
|
||||
}
|
||||
|
||||
// ValueContainsFold applies the ContainsFold predicate on the "value" field.
|
||||
func ValueContainsFold(v string) predicate.Settings {
|
||||
return predicate.Settings(sql.FieldContainsFold(FieldValue, v))
|
||||
}
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Settings) predicate.Settings {
|
||||
return predicate.Settings(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Settings) predicate.Settings {
|
||||
return predicate.Settings(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Settings) predicate.Settings {
|
||||
return predicate.Settings(sql.NotPredicates(p))
|
||||
}
|
||||
196
ent/settings_create.go
Normal file
196
ent/settings_create.go
Normal file
@@ -0,0 +1,196 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/settings"
|
||||
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SettingsCreate is the builder for creating a Settings entity.
|
||||
type SettingsCreate struct {
|
||||
config
|
||||
mutation *SettingsMutation
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetKey sets the "key" field.
|
||||
func (sc *SettingsCreate) SetKey(s string) *SettingsCreate {
|
||||
sc.mutation.SetKey(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (sc *SettingsCreate) SetValue(s string) *SettingsCreate {
|
||||
sc.mutation.SetValue(s)
|
||||
return sc
|
||||
}
|
||||
|
||||
// Mutation returns the SettingsMutation object of the builder.
|
||||
func (sc *SettingsCreate) Mutation() *SettingsMutation {
|
||||
return sc.mutation
|
||||
}
|
||||
|
||||
// Save creates the Settings in the database.
|
||||
func (sc *SettingsCreate) Save(ctx context.Context) (*Settings, error) {
|
||||
return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (sc *SettingsCreate) SaveX(ctx context.Context) *Settings {
|
||||
v, err := sc.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (sc *SettingsCreate) Exec(ctx context.Context) error {
|
||||
_, err := sc.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sc *SettingsCreate) ExecX(ctx context.Context) {
|
||||
if err := sc.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (sc *SettingsCreate) check() error {
|
||||
if _, ok := sc.mutation.Key(); !ok {
|
||||
return &ValidationError{Name: "key", err: errors.New(`ent: missing required field "Settings.key"`)}
|
||||
}
|
||||
if _, ok := sc.mutation.Value(); !ok {
|
||||
return &ValidationError{Name: "value", err: errors.New(`ent: missing required field "Settings.value"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sc *SettingsCreate) sqlSave(ctx context.Context) (*Settings, error) {
|
||||
if err := sc.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := sc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, sc.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)
|
||||
sc.mutation.id = &_node.ID
|
||||
sc.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (sc *SettingsCreate) createSpec() (*Settings, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Settings{config: sc.config}
|
||||
_spec = sqlgraph.NewCreateSpec(settings.Table, sqlgraph.NewFieldSpec(settings.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := sc.mutation.Key(); ok {
|
||||
_spec.SetField(settings.FieldKey, field.TypeString, value)
|
||||
_node.Key = value
|
||||
}
|
||||
if value, ok := sc.mutation.Value(); ok {
|
||||
_spec.SetField(settings.FieldValue, field.TypeString, value)
|
||||
_node.Value = value
|
||||
}
|
||||
return _node, _spec
|
||||
}
|
||||
|
||||
// SettingsCreateBulk is the builder for creating many Settings entities in bulk.
|
||||
type SettingsCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*SettingsCreate
|
||||
}
|
||||
|
||||
// Save creates the Settings entities in the database.
|
||||
func (scb *SettingsCreateBulk) Save(ctx context.Context) ([]*Settings, error) {
|
||||
if scb.err != nil {
|
||||
return nil, scb.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(scb.builders))
|
||||
nodes := make([]*Settings, len(scb.builders))
|
||||
mutators := make([]Mutator, len(scb.builders))
|
||||
for i := range scb.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := scb.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SettingsMutation)
|
||||
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, scb.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, scb.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, scb.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (scb *SettingsCreateBulk) SaveX(ctx context.Context) []*Settings {
|
||||
v, err := scb.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (scb *SettingsCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := scb.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (scb *SettingsCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := scb.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
88
ent/settings_delete.go
Normal file
88
ent/settings_delete.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/settings"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SettingsDelete is the builder for deleting a Settings entity.
|
||||
type SettingsDelete struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SettingsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SettingsDelete builder.
|
||||
func (sd *SettingsDelete) Where(ps ...predicate.Settings) *SettingsDelete {
|
||||
sd.mutation.Where(ps...)
|
||||
return sd
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (sd *SettingsDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sd *SettingsDelete) ExecX(ctx context.Context) int {
|
||||
n, err := sd.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (sd *SettingsDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(settings.Table, sqlgraph.NewFieldSpec(settings.FieldID, field.TypeInt))
|
||||
if ps := sd.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
sd.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SettingsDeleteOne is the builder for deleting a single Settings entity.
|
||||
type SettingsDeleteOne struct {
|
||||
sd *SettingsDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SettingsDelete builder.
|
||||
func (sdo *SettingsDeleteOne) Where(ps ...predicate.Settings) *SettingsDeleteOne {
|
||||
sdo.sd.mutation.Where(ps...)
|
||||
return sdo
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (sdo *SettingsDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := sdo.sd.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
case n == 0:
|
||||
return &NotFoundError{settings.Label}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sdo *SettingsDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := sdo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
526
ent/settings_query.go
Normal file
526
ent/settings_query.go
Normal file
@@ -0,0 +1,526 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/settings"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SettingsQuery is the builder for querying Settings entities.
|
||||
type SettingsQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []settings.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Settings
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the SettingsQuery builder.
|
||||
func (sq *SettingsQuery) Where(ps ...predicate.Settings) *SettingsQuery {
|
||||
sq.predicates = append(sq.predicates, ps...)
|
||||
return sq
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (sq *SettingsQuery) Limit(limit int) *SettingsQuery {
|
||||
sq.ctx.Limit = &limit
|
||||
return sq
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (sq *SettingsQuery) Offset(offset int) *SettingsQuery {
|
||||
sq.ctx.Offset = &offset
|
||||
return sq
|
||||
}
|
||||
|
||||
// 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 (sq *SettingsQuery) Unique(unique bool) *SettingsQuery {
|
||||
sq.ctx.Unique = &unique
|
||||
return sq
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (sq *SettingsQuery) Order(o ...settings.OrderOption) *SettingsQuery {
|
||||
sq.order = append(sq.order, o...)
|
||||
return sq
|
||||
}
|
||||
|
||||
// First returns the first Settings entity from the query.
|
||||
// Returns a *NotFoundError when no Settings was found.
|
||||
func (sq *SettingsQuery) First(ctx context.Context) (*Settings, error) {
|
||||
nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nil, &NotFoundError{settings.Label}
|
||||
}
|
||||
return nodes[0], nil
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (sq *SettingsQuery) FirstX(ctx context.Context) *Settings {
|
||||
node, err := sq.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// FirstID returns the first Settings ID from the query.
|
||||
// Returns a *NotFoundError when no Settings ID was found.
|
||||
func (sq *SettingsQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
err = &NotFoundError{settings.Label}
|
||||
return
|
||||
}
|
||||
return ids[0], nil
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (sq *SettingsQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := sq.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// Only returns a single Settings entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Settings entity is found.
|
||||
// Returns a *NotFoundError when no Settings entities are found.
|
||||
func (sq *SettingsQuery) Only(ctx context.Context) (*Settings, error) {
|
||||
nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
switch len(nodes) {
|
||||
case 1:
|
||||
return nodes[0], nil
|
||||
case 0:
|
||||
return nil, &NotFoundError{settings.Label}
|
||||
default:
|
||||
return nil, &NotSingularError{settings.Label}
|
||||
}
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (sq *SettingsQuery) OnlyX(ctx context.Context) *Settings {
|
||||
node, err := sq.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// OnlyID is like Only, but returns the only Settings ID in the query.
|
||||
// Returns a *NotSingularError when more than one Settings ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (sq *SettingsQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
case 1:
|
||||
id = ids[0]
|
||||
case 0:
|
||||
err = &NotFoundError{settings.Label}
|
||||
default:
|
||||
err = &NotSingularError{settings.Label}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (sq *SettingsQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := sq.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of SettingsSlice.
|
||||
func (sq *SettingsQuery) All(ctx context.Context) ([]*Settings, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "All")
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Settings, *SettingsQuery]()
|
||||
return withInterceptors[[]*Settings](ctx, sq, qr, sq.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (sq *SettingsQuery) AllX(ctx context.Context) []*Settings {
|
||||
nodes, err := sq.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nodes
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Settings IDs.
|
||||
func (sq *SettingsQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if sq.ctx.Unique == nil && sq.path != nil {
|
||||
sq.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, sq.ctx, "IDs")
|
||||
if err = sq.Select(settings.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (sq *SettingsQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := sq.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (sq *SettingsQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "Count")
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, sq, querierCount[*SettingsQuery](), sq.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (sq *SettingsQuery) CountX(ctx context.Context) int {
|
||||
count, err := sq.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (sq *SettingsQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "Exist")
|
||||
switch _, err := sq.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 (sq *SettingsQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := sq.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return exist
|
||||
}
|
||||
|
||||
// Clone returns a duplicate of the SettingsQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (sq *SettingsQuery) Clone() *SettingsQuery {
|
||||
if sq == nil {
|
||||
return nil
|
||||
}
|
||||
return &SettingsQuery{
|
||||
config: sq.config,
|
||||
ctx: sq.ctx.Clone(),
|
||||
order: append([]settings.OrderOption{}, sq.order...),
|
||||
inters: append([]Interceptor{}, sq.inters...),
|
||||
predicates: append([]predicate.Settings{}, sq.predicates...),
|
||||
// clone intermediate query.
|
||||
sql: sq.sql.Clone(),
|
||||
path: sq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
// Key string `json:"key,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Settings.Query().
|
||||
// GroupBy(settings.FieldKey).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (sq *SettingsQuery) GroupBy(field string, fields ...string) *SettingsGroupBy {
|
||||
sq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &SettingsGroupBy{build: sq}
|
||||
grbuild.flds = &sq.ctx.Fields
|
||||
grbuild.label = settings.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 {
|
||||
// Key string `json:"key,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.Settings.Query().
|
||||
// Select(settings.FieldKey).
|
||||
// Scan(ctx, &v)
|
||||
func (sq *SettingsQuery) Select(fields ...string) *SettingsSelect {
|
||||
sq.ctx.Fields = append(sq.ctx.Fields, fields...)
|
||||
sbuild := &SettingsSelect{SettingsQuery: sq}
|
||||
sbuild.label = settings.Label
|
||||
sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a SettingsSelect configured with the given aggregations.
|
||||
func (sq *SettingsQuery) Aggregate(fns ...AggregateFunc) *SettingsSelect {
|
||||
return sq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (sq *SettingsQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range sq.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, sq); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range sq.ctx.Fields {
|
||||
if !settings.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if sq.path != nil {
|
||||
prev, err := sq.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sq.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sq *SettingsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Settings, error) {
|
||||
var (
|
||||
nodes = []*Settings{}
|
||||
_spec = sq.querySpec()
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Settings).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Settings{config: sq.config}
|
||||
nodes = append(nodes, node)
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (sq *SettingsQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sq.querySpec()
|
||||
_spec.Node.Columns = sq.ctx.Fields
|
||||
if len(sq.ctx.Fields) > 0 {
|
||||
_spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, sq.driver, _spec)
|
||||
}
|
||||
|
||||
func (sq *SettingsQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(settings.Table, settings.Columns, sqlgraph.NewFieldSpec(settings.FieldID, field.TypeInt))
|
||||
_spec.From = sq.sql
|
||||
if unique := sq.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if sq.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := sq.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, settings.FieldID)
|
||||
for i := range fields {
|
||||
if fields[i] != settings.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := sq.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := sq.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := sq.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := sq.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (sq *SettingsQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(sq.driver.Dialect())
|
||||
t1 := builder.Table(settings.Table)
|
||||
columns := sq.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = settings.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if sq.sql != nil {
|
||||
selector = sq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if sq.ctx.Unique != nil && *sq.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range sq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range sq.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := sq.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 := sq.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// SettingsGroupBy is the group-by builder for Settings entities.
|
||||
type SettingsGroupBy struct {
|
||||
selector
|
||||
build *SettingsQuery
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (sgb *SettingsGroupBy) Aggregate(fns ...AggregateFunc) *SettingsGroupBy {
|
||||
sgb.fns = append(sgb.fns, fns...)
|
||||
return sgb
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (sgb *SettingsGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy")
|
||||
if err := sgb.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*SettingsQuery, *SettingsGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v)
|
||||
}
|
||||
|
||||
func (sgb *SettingsGroupBy) sqlScan(ctx context.Context, root *SettingsQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(sgb.fns))
|
||||
for _, fn := range sgb.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns))
|
||||
for _, f := range *sgb.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*sgb.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
|
||||
// SettingsSelect is the builder for selecting fields of Settings entities.
|
||||
type SettingsSelect struct {
|
||||
*SettingsQuery
|
||||
selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ss *SettingsSelect) Aggregate(fns ...AggregateFunc) *SettingsSelect {
|
||||
ss.fns = append(ss.fns, fns...)
|
||||
return ss
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ss *SettingsSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ss.ctx, "Select")
|
||||
if err := ss.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*SettingsQuery, *SettingsSelect](ctx, ss.SettingsQuery, ss, ss.inters, v)
|
||||
}
|
||||
|
||||
func (ss *SettingsSelect) sqlScan(ctx context.Context, root *SettingsQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ss.fns))
|
||||
for _, fn := range ss.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ss.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 := ss.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
return sql.ScanSlice(rows, v)
|
||||
}
|
||||
243
ent/settings_update.go
Normal file
243
ent/settings_update.go
Normal file
@@ -0,0 +1,243 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"polaris/ent/predicate"
|
||||
"polaris/ent/settings"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// SettingsUpdate is the builder for updating Settings entities.
|
||||
type SettingsUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *SettingsMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SettingsUpdate builder.
|
||||
func (su *SettingsUpdate) Where(ps ...predicate.Settings) *SettingsUpdate {
|
||||
su.mutation.Where(ps...)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetKey sets the "key" field.
|
||||
func (su *SettingsUpdate) SetKey(s string) *SettingsUpdate {
|
||||
su.mutation.SetKey(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||
func (su *SettingsUpdate) SetNillableKey(s *string) *SettingsUpdate {
|
||||
if s != nil {
|
||||
su.SetKey(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (su *SettingsUpdate) SetValue(s string) *SettingsUpdate {
|
||||
su.mutation.SetValue(s)
|
||||
return su
|
||||
}
|
||||
|
||||
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||
func (su *SettingsUpdate) SetNillableValue(s *string) *SettingsUpdate {
|
||||
if s != nil {
|
||||
su.SetValue(*s)
|
||||
}
|
||||
return su
|
||||
}
|
||||
|
||||
// Mutation returns the SettingsMutation object of the builder.
|
||||
func (su *SettingsUpdate) Mutation() *SettingsMutation {
|
||||
return su.mutation
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (su *SettingsUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, su.sqlSave, su.mutation, su.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (su *SettingsUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := su.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (su *SettingsUpdate) Exec(ctx context.Context) error {
|
||||
_, err := su.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (su *SettingsUpdate) ExecX(ctx context.Context) {
|
||||
if err := su.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (su *SettingsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(settings.Table, settings.Columns, sqlgraph.NewFieldSpec(settings.FieldID, field.TypeInt))
|
||||
if ps := su.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := su.mutation.Key(); ok {
|
||||
_spec.SetField(settings.FieldKey, field.TypeString, value)
|
||||
}
|
||||
if value, ok := su.mutation.Value(); ok {
|
||||
_spec.SetField(settings.FieldValue, field.TypeString, value)
|
||||
}
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{settings.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
su.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// SettingsUpdateOne is the builder for updating a single Settings entity.
|
||||
type SettingsUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *SettingsMutation
|
||||
}
|
||||
|
||||
// SetKey sets the "key" field.
|
||||
func (suo *SettingsUpdateOne) SetKey(s string) *SettingsUpdateOne {
|
||||
suo.mutation.SetKey(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableKey sets the "key" field if the given value is not nil.
|
||||
func (suo *SettingsUpdateOne) SetNillableKey(s *string) *SettingsUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetKey(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetValue sets the "value" field.
|
||||
func (suo *SettingsUpdateOne) SetValue(s string) *SettingsUpdateOne {
|
||||
suo.mutation.SetValue(s)
|
||||
return suo
|
||||
}
|
||||
|
||||
// SetNillableValue sets the "value" field if the given value is not nil.
|
||||
func (suo *SettingsUpdateOne) SetNillableValue(s *string) *SettingsUpdateOne {
|
||||
if s != nil {
|
||||
suo.SetValue(*s)
|
||||
}
|
||||
return suo
|
||||
}
|
||||
|
||||
// Mutation returns the SettingsMutation object of the builder.
|
||||
func (suo *SettingsUpdateOne) Mutation() *SettingsMutation {
|
||||
return suo.mutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SettingsUpdate builder.
|
||||
func (suo *SettingsUpdateOne) Where(ps ...predicate.Settings) *SettingsUpdateOne {
|
||||
suo.mutation.Where(ps...)
|
||||
return suo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (suo *SettingsUpdateOne) Select(field string, fields ...string) *SettingsUpdateOne {
|
||||
suo.fields = append([]string{field}, fields...)
|
||||
return suo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Settings entity.
|
||||
func (suo *SettingsUpdateOne) Save(ctx context.Context) (*Settings, error) {
|
||||
return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (suo *SettingsUpdateOne) SaveX(ctx context.Context) *Settings {
|
||||
node, err := suo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (suo *SettingsUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := suo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (suo *SettingsUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := suo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func (suo *SettingsUpdateOne) sqlSave(ctx context.Context) (_node *Settings, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(settings.Table, settings.Columns, sqlgraph.NewFieldSpec(settings.FieldID, field.TypeInt))
|
||||
id, ok := suo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Settings.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := suo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, settings.FieldID)
|
||||
for _, f := range fields {
|
||||
if !settings.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != settings.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := suo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := suo.mutation.Key(); ok {
|
||||
_spec.SetField(settings.FieldKey, field.TypeString, value)
|
||||
}
|
||||
if value, ok := suo.mutation.Value(); ok {
|
||||
_spec.SetField(settings.FieldValue, field.TypeString, value)
|
||||
}
|
||||
_node = &Settings{config: suo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{settings.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
suo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
222
ent/tx.go
Normal file
222
ent/tx.go
Normal file
@@ -0,0 +1,222 @@
|
||||
// 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
|
||||
// DownloadClients is the client for interacting with the DownloadClients builders.
|
||||
DownloadClients *DownloadClientsClient
|
||||
// Epidodes is the client for interacting with the Epidodes builders.
|
||||
Epidodes *EpidodesClient
|
||||
// Indexers is the client for interacting with the Indexers builders.
|
||||
Indexers *IndexersClient
|
||||
// Series is the client for interacting with the Series builders.
|
||||
Series *SeriesClient
|
||||
// Settings is the client for interacting with the Settings builders.
|
||||
Settings *SettingsClient
|
||||
|
||||
// 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.DownloadClients = NewDownloadClientsClient(tx.config)
|
||||
tx.Epidodes = NewEpidodesClient(tx.config)
|
||||
tx.Indexers = NewIndexersClient(tx.config)
|
||||
tx.Series = NewSeriesClient(tx.config)
|
||||
tx.Settings = NewSettingsClient(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: DownloadClients.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)
|
||||
42
go.mod
42
go.mod
@@ -2,12 +2,37 @@ module polaris
|
||||
|
||||
go 1.22.4
|
||||
|
||||
require go.uber.org/zap v1.27.0
|
||||
require (
|
||||
entgo.io/ent v0.13.1
|
||||
github.com/mattn/go-sqlite3 v1.14.16
|
||||
go.uber.org/zap v1.27.0
|
||||
)
|
||||
|
||||
require (
|
||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect
|
||||
github.com/agext/levenshtein v1.2.1 // indirect
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||
github.com/bytedance/sonic v1.11.6 // indirect
|
||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/uuid v1.4.0 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
@@ -17,15 +42,24 @@ require (
|
||||
github.com/spf13/cast v1.6.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/zclconf/go-cty v1.8.0 // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/crypto v0.23.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/mod v0.17.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sys v0.21.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cyruzin/golang-tmdb v1.6.3 // indirect
|
||||
github.com/cyruzin/golang-tmdb v1.6.3
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
|
||||
136
go.sum
136
go.sum
@@ -1,16 +1,90 @@
|
||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14=
|
||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU=
|
||||
entgo.io/ent v0.13.1 h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=
|
||||
entgo.io/ent v0.13.1/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
|
||||
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
|
||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/cyruzin/golang-tmdb v1.6.3 h1:TKK9h+uuwiDOaFlsVispG1KxqhsSM5Y4ZELnUF3GlqU=
|
||||
github.com/cyruzin/golang-tmdb v1.6.3/go.mod h1:ZSryJLCcY+9TiKU+LbouXKns++YBrM8Tizannr05c+I=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
||||
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc=
|
||||
github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@@ -18,21 +92,31 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
|
||||
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
|
||||
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
||||
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
|
||||
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
|
||||
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
|
||||
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
|
||||
@@ -42,25 +126,69 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
|
||||
github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
|
||||
github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA=
|
||||
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
|
||||
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
|
||||
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
||||
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package tmdb
|
||||
|
||||
import (
|
||||
"polaris/log"
|
||||
|
||||
tmdb "github.com/cyruzin/golang-tmdb"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@@ -24,19 +22,30 @@ func NewClient(apiKey string) (*Client, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *Client) GetTvDetails(id int, language string) {
|
||||
func (c *Client) GetTvDetails(id int, language string) (*tmdb.TVDetails, error) {
|
||||
language = wrapLanguage(language)
|
||||
d, err := c.tmdbClient.GetTVDetails(id, map[string]string{
|
||||
"language": language,
|
||||
})
|
||||
log.Infof("error %v", err)
|
||||
log.Infof("detail %+v", d)
|
||||
d, err := c.tmdbClient.GetTVDetails(id, withLangOption(language))
|
||||
return d, err
|
||||
}
|
||||
|
||||
func (c *Client) SearchTvShow(query string, lang string) (*tmdb.SearchTVShows, error) {
|
||||
r, err := c.tmdbClient.GetSearchTVShow(query, withLangOption(lang))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "tmdb search tv")
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
func wrapLanguage(lang string) string {
|
||||
if lang == "" {
|
||||
lang = "zh-CN"
|
||||
}
|
||||
return lang
|
||||
}
|
||||
}
|
||||
|
||||
func withLangOption(language string) map[string]string {
|
||||
language = wrapLanguage(language)
|
||||
return map[string]string{
|
||||
"language": language,
|
||||
}
|
||||
}
|
||||
|
||||
36
server/common.go
Normal file
36
server/common.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"polaris/log"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func HttpHandler(f func(*gin.Context) (interface{}, error)) gin.HandlerFunc {
|
||||
return func(ctx *gin.Context) {
|
||||
|
||||
r, err := f(ctx)
|
||||
if err != nil {
|
||||
ctx.JSON(200, Response{
|
||||
Code: 1,
|
||||
Message: fmt.Sprintf("%v", err),
|
||||
})
|
||||
return
|
||||
}
|
||||
log.Infof("url %v return: %+v", ctx.Request.URL, r)
|
||||
|
||||
ctx.JSON(200, Response{
|
||||
Code: 0,
|
||||
Message: "success",
|
||||
Data: r,
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
62
server/server.go
Normal file
62
server/server.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"polaris/db"
|
||||
"polaris/log"
|
||||
"polaris/pkg/tmdb"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func NewServer(db *db.Client) *Server {
|
||||
r := gin.Default()
|
||||
return &Server{
|
||||
r: r,
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
r *gin.Engine
|
||||
db *db.Client
|
||||
language string
|
||||
}
|
||||
|
||||
func (s *Server) Serve() error {
|
||||
api := s.r.Group("/api/v1")
|
||||
|
||||
setting := api.Group("/setting")
|
||||
{
|
||||
setting.POST("/do", HttpHandler(s.SetSetting))
|
||||
setting.GET("/do", HttpHandler(s.GetSetting))
|
||||
}
|
||||
|
||||
tv := api.Group("/tv")
|
||||
{
|
||||
tv.GET("/search", HttpHandler(s.SearchTvSeries))
|
||||
tv.POST("/watchlist", HttpHandler(s.AddWatchlist))
|
||||
tv.GET("/watchlist", HttpHandler(s.GetWatchlist))
|
||||
}
|
||||
|
||||
s.language = s.db.GetLanguage()
|
||||
return s.r.Run(":8080")
|
||||
}
|
||||
|
||||
|
||||
func (s *Server) TMDB() (*tmdb.Client, error) {
|
||||
api := s.db.GetSetting(db.SettingTmdbApiKey)
|
||||
if api == "" {
|
||||
return nil, errors.New("tmdb api not set")
|
||||
}
|
||||
return tmdb.NewClient(api)
|
||||
}
|
||||
|
||||
func (s *Server) MustTMDB() *tmdb.Client {
|
||||
t, err := s.TMDB()
|
||||
if err != nil {
|
||||
log.Panicf("get tmdb: %v", err)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
33
server/setting.go
Normal file
33
server/setting.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"polaris/log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
||||
type setSettingIn struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
func (s *Server) SetSetting(c *gin.Context) (interface{}, error) {
|
||||
var in setSettingIn
|
||||
if err := c.ShouldBindJSON(&in); err != nil {
|
||||
return nil, errors.Wrap(err, "bind json")
|
||||
}
|
||||
err := s.db.SetSetting(in.Key, in.Value)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (s *Server) GetSetting(c *gin.Context) (interface{}, error) {
|
||||
q := c.Query("key")
|
||||
log.Infof("query key: %v", q)
|
||||
if q == "" {
|
||||
return nil, nil
|
||||
}
|
||||
v := s.db.GetSetting(q)
|
||||
log.Infof("get value for key %v: %v", q, v)
|
||||
return v, nil
|
||||
}
|
||||
52
server/watchlist.go
Normal file
52
server/watchlist.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"polaris/log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type searchTvParam struct {
|
||||
Query string `form:"query"`
|
||||
}
|
||||
|
||||
func (s *Server) SearchTvSeries(c *gin.Context) (interface{}, error) {
|
||||
var q searchTvParam
|
||||
if err := c.ShouldBindQuery(&q); err != nil {
|
||||
return nil, errors.Wrap(err, "bind query")
|
||||
}
|
||||
log.Infof("search tv series with keyword: %v", q.Query)
|
||||
r, err := s.MustTMDB().SearchTvShow(q.Query, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "search tv")
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
type addWatchlistIn struct {
|
||||
ID int `json:"id" binding:"required"`
|
||||
RootFolder string `json:"folder" binding:"required"`
|
||||
}
|
||||
|
||||
func (s *Server) AddWatchlist(c *gin.Context) (interface{}, error) {
|
||||
var in addWatchlistIn
|
||||
if err := c.ShouldBindQuery(&in); err != nil {
|
||||
return nil, errors.Wrap(err, "bind query")
|
||||
}
|
||||
detail, err := s.MustTMDB().GetTvDetails(in.ID, s.language)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "get tv detail")
|
||||
}
|
||||
|
||||
if err := s.db.AddWatchlist(in.RootFolder, detail); err != nil {
|
||||
return nil, errors.Wrap(err, "add to list")
|
||||
}
|
||||
log.Infof("add tv %s to watchlist success", detail.Name)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) GetWatchlist(c *gin.Context) (interface{}, error) {
|
||||
list := s.db.GetWatchlist()
|
||||
return list, nil
|
||||
}
|
||||
Reference in New Issue
Block a user