ent seteup
This commit is contained in:
parent
45c318b897
commit
b0db98452a
@ -3,3 +3,4 @@ WEB_URL = http://localhost:3006
|
|||||||
GRAPH_PORT = 3009
|
GRAPH_PORT = 3009
|
||||||
GRAPH_URL = http://localhost:3009
|
GRAPH_URL = http://localhost:3009
|
||||||
VITE_GRAPH_URL = http://localhost:3009
|
VITE_GRAPH_URL = http://localhost:3009
|
||||||
|
DB_URL = postgresql://root:root@127.0.0.1/rano_dev?search_path=public&sslmode=disable
|
||||||
|
@ -9,11 +9,14 @@
|
|||||||
```bash
|
```bash
|
||||||
go install github.com/go-task/task/v3/cmd/task@latest
|
go install github.com/go-task/task/v3/cmd/task@latest
|
||||||
```
|
```
|
||||||
|
- [golang-migrate](https://github.com/golang-migrate/migrate) for manual migrations.
|
||||||
|
To install [follow instructions](https://github.com/golang-migrate/migrate/tree/master/cmd/migrate)
|
||||||
|
|
||||||
## Go packages
|
## Go packages
|
||||||
|
|
||||||
- [gqlgen](https://gqlgen.com/)
|
- [gqlgen](https://gqlgen.com/)
|
||||||
- [mux](https://gitserver.in/patialtech/mux)
|
- [mux](https://gitserver.in/patialtech/mux)
|
||||||
|
- [ent. Go](https://entgo.io/docs/tutorial-setup) ORM
|
||||||
|
|
||||||
## Web modules
|
## Web modules
|
||||||
|
|
||||||
|
76
cmd/migrate-up/main.go
Normal file
76
cmd/migrate-up/main.go
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"io/fs"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/golang-migrate/migrate/v4"
|
||||||
|
"github.com/golang-migrate/migrate/v4/database/postgres"
|
||||||
|
"github.com/golang-migrate/migrate/v4/source/httpfs"
|
||||||
|
"gitserver.in/patialtech/rano/db"
|
||||||
|
entMigrate "gitserver.in/patialtech/rano/db/ent/migrate"
|
||||||
|
"gitserver.in/patialtech/rano/db/migrations"
|
||||||
|
"gitserver.in/patialtech/rano/pkg/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
client := db.Client()
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
|
err := client.Schema.Create(
|
||||||
|
context.Background(),
|
||||||
|
entMigrate.WithDropIndex(true),
|
||||||
|
entMigrate.WithDropColumn(true),
|
||||||
|
entMigrate.WithForeignKeys(true),
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatal("😡 migrate-up failed with error: %v", err)
|
||||||
|
} else {
|
||||||
|
logger.Info("✅ migrate-up")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = sqlUp(); err != nil {
|
||||||
|
logger.Fatal("😡 .sql migrate-up failed with error: %v", err)
|
||||||
|
} else {
|
||||||
|
logger.Info("✅ migrate-up .sql migrations")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func sqlUp() error {
|
||||||
|
m, err := mig()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = m.Up(); err != nil && !errors.Is(err, migrate.ErrNoChange) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func mig() (*migrate.Migrate, error) {
|
||||||
|
// migrations files
|
||||||
|
migrations, err := fs.Sub(migrations.FS, ".")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to read embed files: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a source driver from the migrations file system
|
||||||
|
src, err := httpfs.New(http.FS(migrations), ".")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to create source driver: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
driver, err := postgres.WithInstance(db.New(), &postgres.Config{})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return migrate.NewWithInstance("httpfs", src, "postgres", driver)
|
||||||
|
}
|
@ -2,19 +2,56 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"gitserver.in/patialtech/rano/config/dotenv"
|
"gitserver.in/patialtech/rano/config/dotenv"
|
||||||
"gitserver.in/patialtech/rano/pkg/logger"
|
"gitserver.in/patialtech/rano/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Env = "development"
|
const (
|
||||||
|
// projDir need to be same as project code root dir name
|
||||||
|
projDir = "rano"
|
||||||
|
EnvDev = "development"
|
||||||
|
EnvProd = "production"
|
||||||
|
EnvStage = "staging"
|
||||||
|
|
||||||
var conf *Config
|
AuthUserCtxKey = "AuthUser"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
conf *Config
|
||||||
|
AppEnv Env = EnvDev
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
Env string
|
||||||
|
Config struct {
|
||||||
|
WebPort int `env:"WEB_PORT"`
|
||||||
|
WebURL string `env:"WEB_URL"`
|
||||||
|
GraphPort int `env:"GRAPH_PORT"`
|
||||||
|
GrapURL string `env:"GRAPH_URL"`
|
||||||
|
DbURL string `env:"DB_URL"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
envVar, err := dotenv.Read(fmt.Sprintf(".env.%s", Env))
|
wd, _ := os.Getwd()
|
||||||
|
|
||||||
|
// In dev env we run test and other program for diff dir locations under project root,
|
||||||
|
// this makes reading env file harder.
|
||||||
|
// Let's add a hack to make sure we fallback to root dir in dev env
|
||||||
|
if AppEnv == EnvDev {
|
||||||
|
idx := strings.Index(wd, projDir)
|
||||||
|
if idx > -1 {
|
||||||
|
wd = filepath.Join(wd[:idx], projDir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
envVar, err := dotenv.Read(wd, fmt.Sprintf(".env.%s", AppEnv))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -32,13 +69,6 @@ func Read() *Config {
|
|||||||
return conf
|
return conf
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
|
||||||
WebPort int `env:"WEB_PORT"`
|
|
||||||
WebURL string `env:"WEB_URL"`
|
|
||||||
GraphPort int `env:"GRAPH_PORT"`
|
|
||||||
GrapURL string `env:"GRAPH_URL"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Config) loadEnv(vars map[string]string) {
|
func (c *Config) loadEnv(vars map[string]string) {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
return
|
return
|
||||||
@ -54,7 +84,7 @@ func (c *Config) loadEnv(vars map[string]string) {
|
|||||||
|
|
||||||
v, found := vars[tag]
|
v, found := vars[tag]
|
||||||
if !found {
|
if !found {
|
||||||
logger.Warn("var %q not found in file .env.%s", tag, Env)
|
logger.Warn("var %q not found in file .env.%s", tag, AppEnv)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,9 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"gitserver.in/patialtech/rano/pkg/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -12,12 +15,13 @@ import (
|
|||||||
|
|
||||||
// Read all env (with same file loading semantics as Load) but return values as
|
// Read all env (with same file loading semantics as Load) but return values as
|
||||||
// a map rather than automatically writing values into env
|
// a map rather than automatically writing values into env
|
||||||
func Read(filenames ...string) (envMap map[string]string, err error) {
|
func Read(dir string, filenames ...string) (envMap map[string]string, err error) {
|
||||||
filenames = filenamesOrDefault(filenames)
|
filenames = filenamesOrDefault(filenames)
|
||||||
envMap = make(map[string]string)
|
envMap = make(map[string]string)
|
||||||
|
|
||||||
for _, filename := range filenames {
|
for _, filename := range filenames {
|
||||||
individualEnvMap, individualErr := readFile(filename)
|
logger.Info("read env file %s", filepath.Join(dir, filename))
|
||||||
|
individualEnvMap, individualErr := readFile(filepath.Join(dir, filename))
|
||||||
|
|
||||||
if individualErr != nil {
|
if individualErr != nil {
|
||||||
err = individualErr
|
err = individualErr
|
||||||
|
90
db/client.go
Normal file
90
db/client.go
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"database/sql/driver"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"contrib.go.opencensus.io/integrations/ocsql"
|
||||||
|
"entgo.io/ent/dialect"
|
||||||
|
entsql "entgo.io/ent/dialect/sql"
|
||||||
|
pgx "github.com/jackc/pgx/v5/stdlib"
|
||||||
|
"gitserver.in/patialtech/rano/config"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent"
|
||||||
|
"gitserver.in/patialtech/rano/pkg/logger"
|
||||||
|
)
|
||||||
|
|
||||||
|
type connector struct {
|
||||||
|
dsn string
|
||||||
|
}
|
||||||
|
|
||||||
|
// New *sql.DB instance
|
||||||
|
func New() *sql.DB {
|
||||||
|
databaseUrl := config.Read().DbURL
|
||||||
|
db := sql.OpenDB(connector{dsn: databaseUrl})
|
||||||
|
db.SetMaxIdleConns(5)
|
||||||
|
db.SetMaxOpenConns(50)
|
||||||
|
db.SetConnMaxLifetime(time.Minute)
|
||||||
|
return db
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c connector) Connect(context.Context) (driver.Conn, error) {
|
||||||
|
return c.Driver().Open(c.dsn)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (connector) Driver() driver.Driver {
|
||||||
|
return ocsql.Wrap(
|
||||||
|
pgx.GetDefaultDriver(),
|
||||||
|
ocsql.WithAllTraceOptions(),
|
||||||
|
ocsql.WithRowsClose(false),
|
||||||
|
ocsql.WithRowsNext(false),
|
||||||
|
ocsql.WithDisableErrSkip(true),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Client for pgx
|
||||||
|
//
|
||||||
|
// https://entgo.io/docs/sql-integration
|
||||||
|
func Client() *ent.Client {
|
||||||
|
// Create an ent.Driver from `db`.
|
||||||
|
drv := entsql.OpenDB(dialect.Postgres, New())
|
||||||
|
cl := ent.NewClient(ent.Driver(drv))
|
||||||
|
cl.Use(AuditHook)
|
||||||
|
return cl
|
||||||
|
}
|
||||||
|
|
||||||
|
// A AuditHook is an example for audit-log hook.
|
||||||
|
func AuditHook(next ent.Mutator) ent.Mutator {
|
||||||
|
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
start := time.Now()
|
||||||
|
defer func() {
|
||||||
|
saveAudit(ctx, m.Type(), m.Op().String(), time.Since(start))
|
||||||
|
}()
|
||||||
|
return next.Mutate(ctx, m)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func saveAudit(_ context.Context, entT, op string, d time.Duration) {
|
||||||
|
logger.Info("audit %s %s %s", entT, op, d)
|
||||||
|
// ml.SetCreatedAt(time.Now())
|
||||||
|
// if usr := auth.CtxUser(ctx); usr != nil {
|
||||||
|
// ml.SetByID(usr.ID)
|
||||||
|
// ml.SetBy(usr.DisplayName)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// switch op := m.Op(); {
|
||||||
|
// case op.Is(ent.OpCreate):
|
||||||
|
// ml.SetOperation("Create")
|
||||||
|
|
||||||
|
// case op.Is(ent.OpUpdate):
|
||||||
|
// ml.SetOperation("Update")
|
||||||
|
// case op.Is(ent.OpUpdateOne):
|
||||||
|
// ml.SetOperation("UpdateOne")
|
||||||
|
|
||||||
|
// case op.Is(ent.OpDelete):
|
||||||
|
// ml.SetOperation("Delete")
|
||||||
|
// case op.Is(ent.OpDeleteOne):
|
||||||
|
// ml.SetOperation("DeleteOne")
|
||||||
|
// }
|
||||||
|
}
|
194
db/ent/accesscontrol.go
Normal file
194
db/ent/accesscontrol.go
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/accesscontrol"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessControl is the model entity for the AccessControl schema.
|
||||||
|
type AccessControl struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int64 `json:"id,omitempty"`
|
||||||
|
// CreatedAt holds the value of the "created_at" field.
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// UpdatedAt holds the value of the "updated_at" field.
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
// Ptype holds the value of the "ptype" field.
|
||||||
|
Ptype string `json:"ptype,omitempty"`
|
||||||
|
// V0 holds the value of the "v0" field.
|
||||||
|
V0 string `json:"v0,omitempty"`
|
||||||
|
// V1 holds the value of the "v1" field.
|
||||||
|
V1 string `json:"v1,omitempty"`
|
||||||
|
// V2 holds the value of the "v2" field.
|
||||||
|
V2 string `json:"v2,omitempty"`
|
||||||
|
// V3 holds the value of the "v3" field.
|
||||||
|
V3 string `json:"v3,omitempty"`
|
||||||
|
// V4 holds the value of the "v4" field.
|
||||||
|
V4 string `json:"v4,omitempty"`
|
||||||
|
// V5 holds the value of the "v5" field.
|
||||||
|
V5 string `json:"v5,omitempty"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*AccessControl) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case accesscontrol.FieldID:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case accesscontrol.FieldPtype, accesscontrol.FieldV0, accesscontrol.FieldV1, accesscontrol.FieldV2, accesscontrol.FieldV3, accesscontrol.FieldV4, accesscontrol.FieldV5:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case accesscontrol.FieldCreatedAt, accesscontrol.FieldUpdatedAt:
|
||||||
|
values[i] = new(sql.NullTime)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the AccessControl fields.
|
||||||
|
func (ac *AccessControl) 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 accesscontrol.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
ac.ID = int64(value.Int64)
|
||||||
|
case accesscontrol.FieldCreatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.CreatedAt = value.Time
|
||||||
|
}
|
||||||
|
case accesscontrol.FieldUpdatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.UpdatedAt = value.Time
|
||||||
|
}
|
||||||
|
case accesscontrol.FieldPtype:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field ptype", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.Ptype = value.String
|
||||||
|
}
|
||||||
|
case accesscontrol.FieldV0:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field v0", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.V0 = value.String
|
||||||
|
}
|
||||||
|
case accesscontrol.FieldV1:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field v1", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.V1 = value.String
|
||||||
|
}
|
||||||
|
case accesscontrol.FieldV2:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field v2", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.V2 = value.String
|
||||||
|
}
|
||||||
|
case accesscontrol.FieldV3:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field v3", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.V3 = value.String
|
||||||
|
}
|
||||||
|
case accesscontrol.FieldV4:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field v4", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.V4 = value.String
|
||||||
|
}
|
||||||
|
case accesscontrol.FieldV5:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field v5", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
ac.V5 = value.String
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
ac.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the AccessControl.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (ac *AccessControl) Value(name string) (ent.Value, error) {
|
||||||
|
return ac.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this AccessControl.
|
||||||
|
// Note that you need to call AccessControl.Unwrap() before calling this method if this AccessControl
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (ac *AccessControl) Update() *AccessControlUpdateOne {
|
||||||
|
return NewAccessControlClient(ac.config).UpdateOne(ac)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the AccessControl 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 (ac *AccessControl) Unwrap() *AccessControl {
|
||||||
|
_tx, ok := ac.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: AccessControl is not a transactional entity")
|
||||||
|
}
|
||||||
|
ac.config.driver = _tx.drv
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (ac *AccessControl) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("AccessControl(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", ac.ID))
|
||||||
|
builder.WriteString("created_at=")
|
||||||
|
builder.WriteString(ac.CreatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("updated_at=")
|
||||||
|
builder.WriteString(ac.UpdatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ptype=")
|
||||||
|
builder.WriteString(ac.Ptype)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("v0=")
|
||||||
|
builder.WriteString(ac.V0)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("v1=")
|
||||||
|
builder.WriteString(ac.V1)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("v2=")
|
||||||
|
builder.WriteString(ac.V2)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("v3=")
|
||||||
|
builder.WriteString(ac.V3)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("v4=")
|
||||||
|
builder.WriteString(ac.V4)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("v5=")
|
||||||
|
builder.WriteString(ac.V5)
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessControls is a parsable slice of AccessControl.
|
||||||
|
type AccessControls []*AccessControl
|
136
db/ent/accesscontrol/accesscontrol.go
Normal file
136
db/ent/accesscontrol/accesscontrol.go
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package accesscontrol
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the accesscontrol type in the database.
|
||||||
|
Label = "access_control"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||||
|
FieldCreatedAt = "created_at"
|
||||||
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||||
|
FieldUpdatedAt = "updated_at"
|
||||||
|
// FieldPtype holds the string denoting the ptype field in the database.
|
||||||
|
FieldPtype = "ptype"
|
||||||
|
// FieldV0 holds the string denoting the v0 field in the database.
|
||||||
|
FieldV0 = "v0"
|
||||||
|
// FieldV1 holds the string denoting the v1 field in the database.
|
||||||
|
FieldV1 = "v1"
|
||||||
|
// FieldV2 holds the string denoting the v2 field in the database.
|
||||||
|
FieldV2 = "v2"
|
||||||
|
// FieldV3 holds the string denoting the v3 field in the database.
|
||||||
|
FieldV3 = "v3"
|
||||||
|
// FieldV4 holds the string denoting the v4 field in the database.
|
||||||
|
FieldV4 = "v4"
|
||||||
|
// FieldV5 holds the string denoting the v5 field in the database.
|
||||||
|
FieldV5 = "v5"
|
||||||
|
// Table holds the table name of the accesscontrol in the database.
|
||||||
|
Table = "access_controls"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for accesscontrol fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldCreatedAt,
|
||||||
|
FieldUpdatedAt,
|
||||||
|
FieldPtype,
|
||||||
|
FieldV0,
|
||||||
|
FieldV1,
|
||||||
|
FieldV2,
|
||||||
|
FieldV3,
|
||||||
|
FieldV4,
|
||||||
|
FieldV5,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||||
|
DefaultCreatedAt func() time.Time
|
||||||
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||||
|
DefaultUpdatedAt func() time.Time
|
||||||
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||||
|
UpdateDefaultUpdatedAt func() time.Time
|
||||||
|
// DefaultPtype holds the default value on creation for the "ptype" field.
|
||||||
|
DefaultPtype string
|
||||||
|
// DefaultV0 holds the default value on creation for the "v0" field.
|
||||||
|
DefaultV0 string
|
||||||
|
// DefaultV1 holds the default value on creation for the "v1" field.
|
||||||
|
DefaultV1 string
|
||||||
|
// DefaultV2 holds the default value on creation for the "v2" field.
|
||||||
|
DefaultV2 string
|
||||||
|
// DefaultV3 holds the default value on creation for the "v3" field.
|
||||||
|
DefaultV3 string
|
||||||
|
// DefaultV4 holds the default value on creation for the "v4" field.
|
||||||
|
DefaultV4 string
|
||||||
|
// DefaultV5 holds the default value on creation for the "v5" field.
|
||||||
|
DefaultV5 string
|
||||||
|
)
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the AccessControl 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()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCreatedAt orders the results by the created_at field.
|
||||||
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUpdatedAt orders the results by the updated_at field.
|
||||||
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByPtype orders the results by the ptype field.
|
||||||
|
func ByPtype(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldPtype, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByV0 orders the results by the v0 field.
|
||||||
|
func ByV0(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldV0, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByV1 orders the results by the v1 field.
|
||||||
|
func ByV1(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldV1, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByV2 orders the results by the v2 field.
|
||||||
|
func ByV2(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldV2, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByV3 orders the results by the v3 field.
|
||||||
|
func ByV3(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldV3, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByV4 orders the results by the v4 field.
|
||||||
|
func ByV4(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldV4, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByV5 orders the results by the v5 field.
|
||||||
|
func ByV5(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldV5, opts...).ToFunc()
|
||||||
|
}
|
650
db/ent/accesscontrol/where.go
Normal file
650
db/ent/accesscontrol/where.go
Normal file
@ -0,0 +1,650 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package accesscontrol
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int64) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||||
|
func CreatedAt(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||||
|
func UpdatedAt(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ptype applies equality check predicate on the "ptype" field. It's identical to PtypeEQ.
|
||||||
|
func Ptype(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0 applies equality check predicate on the "v0" field. It's identical to V0EQ.
|
||||||
|
func V0(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1 applies equality check predicate on the "v1" field. It's identical to V1EQ.
|
||||||
|
func V1(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2 applies equality check predicate on the "v2" field. It's identical to V2EQ.
|
||||||
|
func V2(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3 applies equality check predicate on the "v3" field. It's identical to V3EQ.
|
||||||
|
func V3(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4 applies equality check predicate on the "v4" field. It's identical to V4EQ.
|
||||||
|
func V4(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5 applies equality check predicate on the "v5" field. It's identical to V5EQ.
|
||||||
|
func V5(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtEQ(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtNEQ(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
|
func CreatedAtIn(vs ...time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
|
func CreatedAtNotIn(vs ...time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||||
|
func CreatedAtGT(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtGTE(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||||
|
func CreatedAtLT(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtLTE(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtEQ(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNEQ(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtIn(vs ...time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNotIn(vs ...time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGT(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGTE(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLT(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLTE(v time.Time) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeEQ applies the EQ predicate on the "ptype" field.
|
||||||
|
func PtypeEQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeNEQ applies the NEQ predicate on the "ptype" field.
|
||||||
|
func PtypeNEQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeIn applies the In predicate on the "ptype" field.
|
||||||
|
func PtypeIn(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldPtype, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeNotIn applies the NotIn predicate on the "ptype" field.
|
||||||
|
func PtypeNotIn(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldPtype, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeGT applies the GT predicate on the "ptype" field.
|
||||||
|
func PtypeGT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeGTE applies the GTE predicate on the "ptype" field.
|
||||||
|
func PtypeGTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeLT applies the LT predicate on the "ptype" field.
|
||||||
|
func PtypeLT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeLTE applies the LTE predicate on the "ptype" field.
|
||||||
|
func PtypeLTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeContains applies the Contains predicate on the "ptype" field.
|
||||||
|
func PtypeContains(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContains(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeHasPrefix applies the HasPrefix predicate on the "ptype" field.
|
||||||
|
func PtypeHasPrefix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasPrefix(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeHasSuffix applies the HasSuffix predicate on the "ptype" field.
|
||||||
|
func PtypeHasSuffix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasSuffix(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeEqualFold applies the EqualFold predicate on the "ptype" field.
|
||||||
|
func PtypeEqualFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEqualFold(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PtypeContainsFold applies the ContainsFold predicate on the "ptype" field.
|
||||||
|
func PtypeContainsFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContainsFold(FieldPtype, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0EQ applies the EQ predicate on the "v0" field.
|
||||||
|
func V0EQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0NEQ applies the NEQ predicate on the "v0" field.
|
||||||
|
func V0NEQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0In applies the In predicate on the "v0" field.
|
||||||
|
func V0In(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldV0, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0NotIn applies the NotIn predicate on the "v0" field.
|
||||||
|
func V0NotIn(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldV0, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0GT applies the GT predicate on the "v0" field.
|
||||||
|
func V0GT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0GTE applies the GTE predicate on the "v0" field.
|
||||||
|
func V0GTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0LT applies the LT predicate on the "v0" field.
|
||||||
|
func V0LT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0LTE applies the LTE predicate on the "v0" field.
|
||||||
|
func V0LTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0Contains applies the Contains predicate on the "v0" field.
|
||||||
|
func V0Contains(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContains(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0HasPrefix applies the HasPrefix predicate on the "v0" field.
|
||||||
|
func V0HasPrefix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasPrefix(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0HasSuffix applies the HasSuffix predicate on the "v0" field.
|
||||||
|
func V0HasSuffix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasSuffix(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0EqualFold applies the EqualFold predicate on the "v0" field.
|
||||||
|
func V0EqualFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEqualFold(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V0ContainsFold applies the ContainsFold predicate on the "v0" field.
|
||||||
|
func V0ContainsFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContainsFold(FieldV0, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1EQ applies the EQ predicate on the "v1" field.
|
||||||
|
func V1EQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1NEQ applies the NEQ predicate on the "v1" field.
|
||||||
|
func V1NEQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1In applies the In predicate on the "v1" field.
|
||||||
|
func V1In(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldV1, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1NotIn applies the NotIn predicate on the "v1" field.
|
||||||
|
func V1NotIn(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldV1, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1GT applies the GT predicate on the "v1" field.
|
||||||
|
func V1GT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1GTE applies the GTE predicate on the "v1" field.
|
||||||
|
func V1GTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1LT applies the LT predicate on the "v1" field.
|
||||||
|
func V1LT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1LTE applies the LTE predicate on the "v1" field.
|
||||||
|
func V1LTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1Contains applies the Contains predicate on the "v1" field.
|
||||||
|
func V1Contains(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContains(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1HasPrefix applies the HasPrefix predicate on the "v1" field.
|
||||||
|
func V1HasPrefix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasPrefix(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1HasSuffix applies the HasSuffix predicate on the "v1" field.
|
||||||
|
func V1HasSuffix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasSuffix(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1EqualFold applies the EqualFold predicate on the "v1" field.
|
||||||
|
func V1EqualFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEqualFold(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V1ContainsFold applies the ContainsFold predicate on the "v1" field.
|
||||||
|
func V1ContainsFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContainsFold(FieldV1, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2EQ applies the EQ predicate on the "v2" field.
|
||||||
|
func V2EQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2NEQ applies the NEQ predicate on the "v2" field.
|
||||||
|
func V2NEQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2In applies the In predicate on the "v2" field.
|
||||||
|
func V2In(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldV2, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2NotIn applies the NotIn predicate on the "v2" field.
|
||||||
|
func V2NotIn(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldV2, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2GT applies the GT predicate on the "v2" field.
|
||||||
|
func V2GT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2GTE applies the GTE predicate on the "v2" field.
|
||||||
|
func V2GTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2LT applies the LT predicate on the "v2" field.
|
||||||
|
func V2LT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2LTE applies the LTE predicate on the "v2" field.
|
||||||
|
func V2LTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2Contains applies the Contains predicate on the "v2" field.
|
||||||
|
func V2Contains(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContains(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2HasPrefix applies the HasPrefix predicate on the "v2" field.
|
||||||
|
func V2HasPrefix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasPrefix(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2HasSuffix applies the HasSuffix predicate on the "v2" field.
|
||||||
|
func V2HasSuffix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasSuffix(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2EqualFold applies the EqualFold predicate on the "v2" field.
|
||||||
|
func V2EqualFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEqualFold(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V2ContainsFold applies the ContainsFold predicate on the "v2" field.
|
||||||
|
func V2ContainsFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContainsFold(FieldV2, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3EQ applies the EQ predicate on the "v3" field.
|
||||||
|
func V3EQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3NEQ applies the NEQ predicate on the "v3" field.
|
||||||
|
func V3NEQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3In applies the In predicate on the "v3" field.
|
||||||
|
func V3In(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldV3, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3NotIn applies the NotIn predicate on the "v3" field.
|
||||||
|
func V3NotIn(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldV3, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3GT applies the GT predicate on the "v3" field.
|
||||||
|
func V3GT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3GTE applies the GTE predicate on the "v3" field.
|
||||||
|
func V3GTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3LT applies the LT predicate on the "v3" field.
|
||||||
|
func V3LT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3LTE applies the LTE predicate on the "v3" field.
|
||||||
|
func V3LTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3Contains applies the Contains predicate on the "v3" field.
|
||||||
|
func V3Contains(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContains(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3HasPrefix applies the HasPrefix predicate on the "v3" field.
|
||||||
|
func V3HasPrefix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasPrefix(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3HasSuffix applies the HasSuffix predicate on the "v3" field.
|
||||||
|
func V3HasSuffix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasSuffix(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3EqualFold applies the EqualFold predicate on the "v3" field.
|
||||||
|
func V3EqualFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEqualFold(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V3ContainsFold applies the ContainsFold predicate on the "v3" field.
|
||||||
|
func V3ContainsFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContainsFold(FieldV3, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4EQ applies the EQ predicate on the "v4" field.
|
||||||
|
func V4EQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4NEQ applies the NEQ predicate on the "v4" field.
|
||||||
|
func V4NEQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4In applies the In predicate on the "v4" field.
|
||||||
|
func V4In(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldV4, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4NotIn applies the NotIn predicate on the "v4" field.
|
||||||
|
func V4NotIn(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldV4, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4GT applies the GT predicate on the "v4" field.
|
||||||
|
func V4GT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4GTE applies the GTE predicate on the "v4" field.
|
||||||
|
func V4GTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4LT applies the LT predicate on the "v4" field.
|
||||||
|
func V4LT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4LTE applies the LTE predicate on the "v4" field.
|
||||||
|
func V4LTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4Contains applies the Contains predicate on the "v4" field.
|
||||||
|
func V4Contains(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContains(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4HasPrefix applies the HasPrefix predicate on the "v4" field.
|
||||||
|
func V4HasPrefix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasPrefix(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4HasSuffix applies the HasSuffix predicate on the "v4" field.
|
||||||
|
func V4HasSuffix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasSuffix(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4EqualFold applies the EqualFold predicate on the "v4" field.
|
||||||
|
func V4EqualFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEqualFold(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V4ContainsFold applies the ContainsFold predicate on the "v4" field.
|
||||||
|
func V4ContainsFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContainsFold(FieldV4, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5EQ applies the EQ predicate on the "v5" field.
|
||||||
|
func V5EQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEQ(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5NEQ applies the NEQ predicate on the "v5" field.
|
||||||
|
func V5NEQ(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNEQ(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5In applies the In predicate on the "v5" field.
|
||||||
|
func V5In(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldIn(FieldV5, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5NotIn applies the NotIn predicate on the "v5" field.
|
||||||
|
func V5NotIn(vs ...string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldNotIn(FieldV5, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5GT applies the GT predicate on the "v5" field.
|
||||||
|
func V5GT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGT(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5GTE applies the GTE predicate on the "v5" field.
|
||||||
|
func V5GTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldGTE(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5LT applies the LT predicate on the "v5" field.
|
||||||
|
func V5LT(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLT(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5LTE applies the LTE predicate on the "v5" field.
|
||||||
|
func V5LTE(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldLTE(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5Contains applies the Contains predicate on the "v5" field.
|
||||||
|
func V5Contains(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContains(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5HasPrefix applies the HasPrefix predicate on the "v5" field.
|
||||||
|
func V5HasPrefix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasPrefix(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5HasSuffix applies the HasSuffix predicate on the "v5" field.
|
||||||
|
func V5HasSuffix(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldHasSuffix(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5EqualFold applies the EqualFold predicate on the "v5" field.
|
||||||
|
func V5EqualFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldEqualFold(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// V5ContainsFold applies the ContainsFold predicate on the "v5" field.
|
||||||
|
func V5ContainsFold(v string) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.FieldContainsFold(FieldV5, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.AccessControl) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.AccessControl) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.AccessControl) predicate.AccessControl {
|
||||||
|
return predicate.AccessControl(sql.NotPredicates(p))
|
||||||
|
}
|
414
db/ent/accesscontrol_create.go
Normal file
414
db/ent/accesscontrol_create.go
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/accesscontrol"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessControlCreate is the builder for creating a AccessControl entity.
|
||||||
|
type AccessControlCreate struct {
|
||||||
|
config
|
||||||
|
mutation *AccessControlMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (acc *AccessControlCreate) SetCreatedAt(t time.Time) *AccessControlCreate {
|
||||||
|
acc.mutation.SetCreatedAt(t)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillableCreatedAt(t *time.Time) *AccessControlCreate {
|
||||||
|
if t != nil {
|
||||||
|
acc.SetCreatedAt(*t)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (acc *AccessControlCreate) SetUpdatedAt(t time.Time) *AccessControlCreate {
|
||||||
|
acc.mutation.SetUpdatedAt(t)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillableUpdatedAt(t *time.Time) *AccessControlCreate {
|
||||||
|
if t != nil {
|
||||||
|
acc.SetUpdatedAt(*t)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPtype sets the "ptype" field.
|
||||||
|
func (acc *AccessControlCreate) SetPtype(s string) *AccessControlCreate {
|
||||||
|
acc.mutation.SetPtype(s)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePtype sets the "ptype" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillablePtype(s *string) *AccessControlCreate {
|
||||||
|
if s != nil {
|
||||||
|
acc.SetPtype(*s)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV0 sets the "v0" field.
|
||||||
|
func (acc *AccessControlCreate) SetV0(s string) *AccessControlCreate {
|
||||||
|
acc.mutation.SetV0(s)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV0 sets the "v0" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillableV0(s *string) *AccessControlCreate {
|
||||||
|
if s != nil {
|
||||||
|
acc.SetV0(*s)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV1 sets the "v1" field.
|
||||||
|
func (acc *AccessControlCreate) SetV1(s string) *AccessControlCreate {
|
||||||
|
acc.mutation.SetV1(s)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV1 sets the "v1" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillableV1(s *string) *AccessControlCreate {
|
||||||
|
if s != nil {
|
||||||
|
acc.SetV1(*s)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV2 sets the "v2" field.
|
||||||
|
func (acc *AccessControlCreate) SetV2(s string) *AccessControlCreate {
|
||||||
|
acc.mutation.SetV2(s)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV2 sets the "v2" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillableV2(s *string) *AccessControlCreate {
|
||||||
|
if s != nil {
|
||||||
|
acc.SetV2(*s)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV3 sets the "v3" field.
|
||||||
|
func (acc *AccessControlCreate) SetV3(s string) *AccessControlCreate {
|
||||||
|
acc.mutation.SetV3(s)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV3 sets the "v3" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillableV3(s *string) *AccessControlCreate {
|
||||||
|
if s != nil {
|
||||||
|
acc.SetV3(*s)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV4 sets the "v4" field.
|
||||||
|
func (acc *AccessControlCreate) SetV4(s string) *AccessControlCreate {
|
||||||
|
acc.mutation.SetV4(s)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV4 sets the "v4" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillableV4(s *string) *AccessControlCreate {
|
||||||
|
if s != nil {
|
||||||
|
acc.SetV4(*s)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV5 sets the "v5" field.
|
||||||
|
func (acc *AccessControlCreate) SetV5(s string) *AccessControlCreate {
|
||||||
|
acc.mutation.SetV5(s)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV5 sets the "v5" field if the given value is not nil.
|
||||||
|
func (acc *AccessControlCreate) SetNillableV5(s *string) *AccessControlCreate {
|
||||||
|
if s != nil {
|
||||||
|
acc.SetV5(*s)
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets the "id" field.
|
||||||
|
func (acc *AccessControlCreate) SetID(i int64) *AccessControlCreate {
|
||||||
|
acc.mutation.SetID(i)
|
||||||
|
return acc
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the AccessControlMutation object of the builder.
|
||||||
|
func (acc *AccessControlCreate) Mutation() *AccessControlMutation {
|
||||||
|
return acc.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the AccessControl in the database.
|
||||||
|
func (acc *AccessControlCreate) Save(ctx context.Context) (*AccessControl, error) {
|
||||||
|
acc.defaults()
|
||||||
|
return withHooks(ctx, acc.sqlSave, acc.mutation, acc.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (acc *AccessControlCreate) SaveX(ctx context.Context) *AccessControl {
|
||||||
|
v, err := acc.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (acc *AccessControlCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := acc.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (acc *AccessControlCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := acc.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (acc *AccessControlCreate) defaults() {
|
||||||
|
if _, ok := acc.mutation.CreatedAt(); !ok {
|
||||||
|
v := accesscontrol.DefaultCreatedAt()
|
||||||
|
acc.mutation.SetCreatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.UpdatedAt(); !ok {
|
||||||
|
v := accesscontrol.DefaultUpdatedAt()
|
||||||
|
acc.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.Ptype(); !ok {
|
||||||
|
v := accesscontrol.DefaultPtype
|
||||||
|
acc.mutation.SetPtype(v)
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V0(); !ok {
|
||||||
|
v := accesscontrol.DefaultV0
|
||||||
|
acc.mutation.SetV0(v)
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V1(); !ok {
|
||||||
|
v := accesscontrol.DefaultV1
|
||||||
|
acc.mutation.SetV1(v)
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V2(); !ok {
|
||||||
|
v := accesscontrol.DefaultV2
|
||||||
|
acc.mutation.SetV2(v)
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V3(); !ok {
|
||||||
|
v := accesscontrol.DefaultV3
|
||||||
|
acc.mutation.SetV3(v)
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V4(); !ok {
|
||||||
|
v := accesscontrol.DefaultV4
|
||||||
|
acc.mutation.SetV4(v)
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V5(); !ok {
|
||||||
|
v := accesscontrol.DefaultV5
|
||||||
|
acc.mutation.SetV5(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (acc *AccessControlCreate) check() error {
|
||||||
|
if _, ok := acc.mutation.CreatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AccessControl.created_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.UpdatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "AccessControl.updated_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.Ptype(); !ok {
|
||||||
|
return &ValidationError{Name: "ptype", err: errors.New(`ent: missing required field "AccessControl.ptype"`)}
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V0(); !ok {
|
||||||
|
return &ValidationError{Name: "v0", err: errors.New(`ent: missing required field "AccessControl.v0"`)}
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V1(); !ok {
|
||||||
|
return &ValidationError{Name: "v1", err: errors.New(`ent: missing required field "AccessControl.v1"`)}
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V2(); !ok {
|
||||||
|
return &ValidationError{Name: "v2", err: errors.New(`ent: missing required field "AccessControl.v2"`)}
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V3(); !ok {
|
||||||
|
return &ValidationError{Name: "v3", err: errors.New(`ent: missing required field "AccessControl.v3"`)}
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V4(); !ok {
|
||||||
|
return &ValidationError{Name: "v4", err: errors.New(`ent: missing required field "AccessControl.v4"`)}
|
||||||
|
}
|
||||||
|
if _, ok := acc.mutation.V5(); !ok {
|
||||||
|
return &ValidationError{Name: "v5", err: errors.New(`ent: missing required field "AccessControl.v5"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acc *AccessControlCreate) sqlSave(ctx context.Context) (*AccessControl, error) {
|
||||||
|
if err := acc.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := acc.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, acc.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if _spec.ID.Value != _node.ID {
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int64(id)
|
||||||
|
}
|
||||||
|
acc.mutation.id = &_node.ID
|
||||||
|
acc.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acc *AccessControlCreate) createSpec() (*AccessControl, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &AccessControl{config: acc.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(accesscontrol.Table, sqlgraph.NewFieldSpec(accesscontrol.FieldID, field.TypeInt64))
|
||||||
|
)
|
||||||
|
if id, ok := acc.mutation.ID(); ok {
|
||||||
|
_node.ID = id
|
||||||
|
_spec.ID.Value = id
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
_node.CreatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
_node.UpdatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.Ptype(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldPtype, field.TypeString, value)
|
||||||
|
_node.Ptype = value
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.V0(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV0, field.TypeString, value)
|
||||||
|
_node.V0 = value
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.V1(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV1, field.TypeString, value)
|
||||||
|
_node.V1 = value
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.V2(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV2, field.TypeString, value)
|
||||||
|
_node.V2 = value
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.V3(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV3, field.TypeString, value)
|
||||||
|
_node.V3 = value
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.V4(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV4, field.TypeString, value)
|
||||||
|
_node.V4 = value
|
||||||
|
}
|
||||||
|
if value, ok := acc.mutation.V5(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV5, field.TypeString, value)
|
||||||
|
_node.V5 = value
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessControlCreateBulk is the builder for creating many AccessControl entities in bulk.
|
||||||
|
type AccessControlCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*AccessControlCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the AccessControl entities in the database.
|
||||||
|
func (accb *AccessControlCreateBulk) Save(ctx context.Context) ([]*AccessControl, error) {
|
||||||
|
if accb.err != nil {
|
||||||
|
return nil, accb.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(accb.builders))
|
||||||
|
nodes := make([]*AccessControl, len(accb.builders))
|
||||||
|
mutators := make([]Mutator, len(accb.builders))
|
||||||
|
for i := range accb.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := accb.builders[i]
|
||||||
|
builder.defaults()
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*AccessControlMutation)
|
||||||
|
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, accb.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, accb.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 && nodes[i].ID == 0 {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int64(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, accb.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (accb *AccessControlCreateBulk) SaveX(ctx context.Context) []*AccessControl {
|
||||||
|
v, err := accb.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (accb *AccessControlCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := accb.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (accb *AccessControlCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := accb.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
88
db/ent/accesscontrol_delete.go
Normal file
88
db/ent/accesscontrol_delete.go
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/accesscontrol"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessControlDelete is the builder for deleting a AccessControl entity.
|
||||||
|
type AccessControlDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *AccessControlMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the AccessControlDelete builder.
|
||||||
|
func (acd *AccessControlDelete) Where(ps ...predicate.AccessControl) *AccessControlDelete {
|
||||||
|
acd.mutation.Where(ps...)
|
||||||
|
return acd
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (acd *AccessControlDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, acd.sqlExec, acd.mutation, acd.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (acd *AccessControlDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := acd.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acd *AccessControlDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(accesscontrol.Table, sqlgraph.NewFieldSpec(accesscontrol.FieldID, field.TypeInt64))
|
||||||
|
if ps := acd.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, acd.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
acd.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessControlDeleteOne is the builder for deleting a single AccessControl entity.
|
||||||
|
type AccessControlDeleteOne struct {
|
||||||
|
acd *AccessControlDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the AccessControlDelete builder.
|
||||||
|
func (acdo *AccessControlDeleteOne) Where(ps ...predicate.AccessControl) *AccessControlDeleteOne {
|
||||||
|
acdo.acd.mutation.Where(ps...)
|
||||||
|
return acdo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (acdo *AccessControlDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := acdo.acd.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{accesscontrol.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (acdo *AccessControlDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := acdo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
527
db/ent/accesscontrol_query.go
Normal file
527
db/ent/accesscontrol_query.go
Normal file
@ -0,0 +1,527 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/accesscontrol"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessControlQuery is the builder for querying AccessControl entities.
|
||||||
|
type AccessControlQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []accesscontrol.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.AccessControl
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the AccessControlQuery builder.
|
||||||
|
func (acq *AccessControlQuery) Where(ps ...predicate.AccessControl) *AccessControlQuery {
|
||||||
|
acq.predicates = append(acq.predicates, ps...)
|
||||||
|
return acq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (acq *AccessControlQuery) Limit(limit int) *AccessControlQuery {
|
||||||
|
acq.ctx.Limit = &limit
|
||||||
|
return acq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (acq *AccessControlQuery) Offset(offset int) *AccessControlQuery {
|
||||||
|
acq.ctx.Offset = &offset
|
||||||
|
return acq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (acq *AccessControlQuery) Unique(unique bool) *AccessControlQuery {
|
||||||
|
acq.ctx.Unique = &unique
|
||||||
|
return acq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (acq *AccessControlQuery) Order(o ...accesscontrol.OrderOption) *AccessControlQuery {
|
||||||
|
acq.order = append(acq.order, o...)
|
||||||
|
return acq
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first AccessControl entity from the query.
|
||||||
|
// Returns a *NotFoundError when no AccessControl was found.
|
||||||
|
func (acq *AccessControlQuery) First(ctx context.Context) (*AccessControl, error) {
|
||||||
|
nodes, err := acq.Limit(1).All(setContextOp(ctx, acq.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{accesscontrol.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (acq *AccessControlQuery) FirstX(ctx context.Context) *AccessControl {
|
||||||
|
node, err := acq.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first AccessControl ID from the query.
|
||||||
|
// Returns a *NotFoundError when no AccessControl ID was found.
|
||||||
|
func (acq *AccessControlQuery) FirstID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = acq.Limit(1).IDs(setContextOp(ctx, acq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{accesscontrol.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (acq *AccessControlQuery) FirstIDX(ctx context.Context) int64 {
|
||||||
|
id, err := acq.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single AccessControl entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one AccessControl entity is found.
|
||||||
|
// Returns a *NotFoundError when no AccessControl entities are found.
|
||||||
|
func (acq *AccessControlQuery) Only(ctx context.Context) (*AccessControl, error) {
|
||||||
|
nodes, err := acq.Limit(2).All(setContextOp(ctx, acq.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{accesscontrol.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{accesscontrol.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (acq *AccessControlQuery) OnlyX(ctx context.Context) *AccessControl {
|
||||||
|
node, err := acq.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only AccessControl ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one AccessControl ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (acq *AccessControlQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = acq.Limit(2).IDs(setContextOp(ctx, acq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{accesscontrol.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{accesscontrol.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (acq *AccessControlQuery) OnlyIDX(ctx context.Context) int64 {
|
||||||
|
id, err := acq.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of AccessControls.
|
||||||
|
func (acq *AccessControlQuery) All(ctx context.Context) ([]*AccessControl, error) {
|
||||||
|
ctx = setContextOp(ctx, acq.ctx, ent.OpQueryAll)
|
||||||
|
if err := acq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*AccessControl, *AccessControlQuery]()
|
||||||
|
return withInterceptors[[]*AccessControl](ctx, acq, qr, acq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (acq *AccessControlQuery) AllX(ctx context.Context) []*AccessControl {
|
||||||
|
nodes, err := acq.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of AccessControl IDs.
|
||||||
|
func (acq *AccessControlQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
||||||
|
if acq.ctx.Unique == nil && acq.path != nil {
|
||||||
|
acq.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, acq.ctx, ent.OpQueryIDs)
|
||||||
|
if err = acq.Select(accesscontrol.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (acq *AccessControlQuery) IDsX(ctx context.Context) []int64 {
|
||||||
|
ids, err := acq.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (acq *AccessControlQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, acq.ctx, ent.OpQueryCount)
|
||||||
|
if err := acq.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, acq, querierCount[*AccessControlQuery](), acq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (acq *AccessControlQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := acq.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (acq *AccessControlQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, acq.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := acq.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 (acq *AccessControlQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := acq.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the AccessControlQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (acq *AccessControlQuery) Clone() *AccessControlQuery {
|
||||||
|
if acq == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &AccessControlQuery{
|
||||||
|
config: acq.config,
|
||||||
|
ctx: acq.ctx.Clone(),
|
||||||
|
order: append([]accesscontrol.OrderOption{}, acq.order...),
|
||||||
|
inters: append([]Interceptor{}, acq.inters...),
|
||||||
|
predicates: append([]predicate.AccessControl{}, acq.predicates...),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: acq.sql.Clone(),
|
||||||
|
path: acq.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 {
|
||||||
|
// CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.AccessControl.Query().
|
||||||
|
// GroupBy(accesscontrol.FieldCreatedAt).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (acq *AccessControlQuery) GroupBy(field string, fields ...string) *AccessControlGroupBy {
|
||||||
|
acq.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &AccessControlGroupBy{build: acq}
|
||||||
|
grbuild.flds = &acq.ctx.Fields
|
||||||
|
grbuild.label = accesscontrol.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 {
|
||||||
|
// CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.AccessControl.Query().
|
||||||
|
// Select(accesscontrol.FieldCreatedAt).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (acq *AccessControlQuery) Select(fields ...string) *AccessControlSelect {
|
||||||
|
acq.ctx.Fields = append(acq.ctx.Fields, fields...)
|
||||||
|
sbuild := &AccessControlSelect{AccessControlQuery: acq}
|
||||||
|
sbuild.label = accesscontrol.Label
|
||||||
|
sbuild.flds, sbuild.scan = &acq.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a AccessControlSelect configured with the given aggregations.
|
||||||
|
func (acq *AccessControlQuery) Aggregate(fns ...AggregateFunc) *AccessControlSelect {
|
||||||
|
return acq.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acq *AccessControlQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range acq.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, acq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range acq.ctx.Fields {
|
||||||
|
if !accesscontrol.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if acq.path != nil {
|
||||||
|
prev, err := acq.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
acq.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acq *AccessControlQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AccessControl, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*AccessControl{}
|
||||||
|
_spec = acq.querySpec()
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*AccessControl).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &AccessControl{config: acq.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, acq.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acq *AccessControlQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := acq.querySpec()
|
||||||
|
_spec.Node.Columns = acq.ctx.Fields
|
||||||
|
if len(acq.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = acq.ctx.Unique != nil && *acq.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, acq.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acq *AccessControlQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(accesscontrol.Table, accesscontrol.Columns, sqlgraph.NewFieldSpec(accesscontrol.FieldID, field.TypeInt64))
|
||||||
|
_spec.From = acq.sql
|
||||||
|
if unique := acq.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if acq.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := acq.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, accesscontrol.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != accesscontrol.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := acq.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := acq.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := acq.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := acq.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acq *AccessControlQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(acq.driver.Dialect())
|
||||||
|
t1 := builder.Table(accesscontrol.Table)
|
||||||
|
columns := acq.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = accesscontrol.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if acq.sql != nil {
|
||||||
|
selector = acq.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if acq.ctx.Unique != nil && *acq.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range acq.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range acq.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := acq.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 := acq.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessControlGroupBy is the group-by builder for AccessControl entities.
|
||||||
|
type AccessControlGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *AccessControlQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (acgb *AccessControlGroupBy) Aggregate(fns ...AggregateFunc) *AccessControlGroupBy {
|
||||||
|
acgb.fns = append(acgb.fns, fns...)
|
||||||
|
return acgb
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (acgb *AccessControlGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, acgb.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := acgb.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*AccessControlQuery, *AccessControlGroupBy](ctx, acgb.build, acgb, acgb.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acgb *AccessControlGroupBy) sqlScan(ctx context.Context, root *AccessControlQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(acgb.fns))
|
||||||
|
for _, fn := range acgb.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*acgb.flds)+len(acgb.fns))
|
||||||
|
for _, f := range *acgb.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*acgb.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := acgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessControlSelect is the builder for selecting fields of AccessControl entities.
|
||||||
|
type AccessControlSelect struct {
|
||||||
|
*AccessControlQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (acs *AccessControlSelect) Aggregate(fns ...AggregateFunc) *AccessControlSelect {
|
||||||
|
acs.fns = append(acs.fns, fns...)
|
||||||
|
return acs
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (acs *AccessControlSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, acs.ctx, ent.OpQuerySelect)
|
||||||
|
if err := acs.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*AccessControlQuery, *AccessControlSelect](ctx, acs.AccessControlQuery, acs, acs.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acs *AccessControlSelect) sqlScan(ctx context.Context, root *AccessControlQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(acs.fns))
|
||||||
|
for _, fn := range acs.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*acs.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 := acs.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
450
db/ent/accesscontrol_update.go
Normal file
450
db/ent/accesscontrol_update.go
Normal file
@ -0,0 +1,450 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/accesscontrol"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessControlUpdate is the builder for updating AccessControl entities.
|
||||||
|
type AccessControlUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *AccessControlMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the AccessControlUpdate builder.
|
||||||
|
func (acu *AccessControlUpdate) Where(ps ...predicate.AccessControl) *AccessControlUpdate {
|
||||||
|
acu.mutation.Where(ps...)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (acu *AccessControlUpdate) SetUpdatedAt(t time.Time) *AccessControlUpdate {
|
||||||
|
acu.mutation.SetUpdatedAt(t)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPtype sets the "ptype" field.
|
||||||
|
func (acu *AccessControlUpdate) SetPtype(s string) *AccessControlUpdate {
|
||||||
|
acu.mutation.SetPtype(s)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePtype sets the "ptype" field if the given value is not nil.
|
||||||
|
func (acu *AccessControlUpdate) SetNillablePtype(s *string) *AccessControlUpdate {
|
||||||
|
if s != nil {
|
||||||
|
acu.SetPtype(*s)
|
||||||
|
}
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV0 sets the "v0" field.
|
||||||
|
func (acu *AccessControlUpdate) SetV0(s string) *AccessControlUpdate {
|
||||||
|
acu.mutation.SetV0(s)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV0 sets the "v0" field if the given value is not nil.
|
||||||
|
func (acu *AccessControlUpdate) SetNillableV0(s *string) *AccessControlUpdate {
|
||||||
|
if s != nil {
|
||||||
|
acu.SetV0(*s)
|
||||||
|
}
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV1 sets the "v1" field.
|
||||||
|
func (acu *AccessControlUpdate) SetV1(s string) *AccessControlUpdate {
|
||||||
|
acu.mutation.SetV1(s)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV1 sets the "v1" field if the given value is not nil.
|
||||||
|
func (acu *AccessControlUpdate) SetNillableV1(s *string) *AccessControlUpdate {
|
||||||
|
if s != nil {
|
||||||
|
acu.SetV1(*s)
|
||||||
|
}
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV2 sets the "v2" field.
|
||||||
|
func (acu *AccessControlUpdate) SetV2(s string) *AccessControlUpdate {
|
||||||
|
acu.mutation.SetV2(s)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV2 sets the "v2" field if the given value is not nil.
|
||||||
|
func (acu *AccessControlUpdate) SetNillableV2(s *string) *AccessControlUpdate {
|
||||||
|
if s != nil {
|
||||||
|
acu.SetV2(*s)
|
||||||
|
}
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV3 sets the "v3" field.
|
||||||
|
func (acu *AccessControlUpdate) SetV3(s string) *AccessControlUpdate {
|
||||||
|
acu.mutation.SetV3(s)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV3 sets the "v3" field if the given value is not nil.
|
||||||
|
func (acu *AccessControlUpdate) SetNillableV3(s *string) *AccessControlUpdate {
|
||||||
|
if s != nil {
|
||||||
|
acu.SetV3(*s)
|
||||||
|
}
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV4 sets the "v4" field.
|
||||||
|
func (acu *AccessControlUpdate) SetV4(s string) *AccessControlUpdate {
|
||||||
|
acu.mutation.SetV4(s)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV4 sets the "v4" field if the given value is not nil.
|
||||||
|
func (acu *AccessControlUpdate) SetNillableV4(s *string) *AccessControlUpdate {
|
||||||
|
if s != nil {
|
||||||
|
acu.SetV4(*s)
|
||||||
|
}
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV5 sets the "v5" field.
|
||||||
|
func (acu *AccessControlUpdate) SetV5(s string) *AccessControlUpdate {
|
||||||
|
acu.mutation.SetV5(s)
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV5 sets the "v5" field if the given value is not nil.
|
||||||
|
func (acu *AccessControlUpdate) SetNillableV5(s *string) *AccessControlUpdate {
|
||||||
|
if s != nil {
|
||||||
|
acu.SetV5(*s)
|
||||||
|
}
|
||||||
|
return acu
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the AccessControlMutation object of the builder.
|
||||||
|
func (acu *AccessControlUpdate) Mutation() *AccessControlMutation {
|
||||||
|
return acu.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (acu *AccessControlUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
acu.defaults()
|
||||||
|
return withHooks(ctx, acu.sqlSave, acu.mutation, acu.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (acu *AccessControlUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := acu.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (acu *AccessControlUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := acu.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (acu *AccessControlUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := acu.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (acu *AccessControlUpdate) defaults() {
|
||||||
|
if _, ok := acu.mutation.UpdatedAt(); !ok {
|
||||||
|
v := accesscontrol.UpdateDefaultUpdatedAt()
|
||||||
|
acu.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acu *AccessControlUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(accesscontrol.Table, accesscontrol.Columns, sqlgraph.NewFieldSpec(accesscontrol.FieldID, field.TypeInt64))
|
||||||
|
if ps := acu.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := acu.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := acu.mutation.Ptype(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldPtype, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acu.mutation.V0(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV0, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acu.mutation.V1(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV1, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acu.mutation.V2(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV2, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acu.mutation.V3(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV3, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acu.mutation.V4(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV4, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acu.mutation.V5(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV5, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if n, err = sqlgraph.UpdateNodes(ctx, acu.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{accesscontrol.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
acu.mutation.done = true
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessControlUpdateOne is the builder for updating a single AccessControl entity.
|
||||||
|
type AccessControlUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *AccessControlMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetUpdatedAt(t time.Time) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.SetUpdatedAt(t)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPtype sets the "ptype" field.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetPtype(s string) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.SetPtype(s)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePtype sets the "ptype" field if the given value is not nil.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetNillablePtype(s *string) *AccessControlUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
acuo.SetPtype(*s)
|
||||||
|
}
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV0 sets the "v0" field.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetV0(s string) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.SetV0(s)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV0 sets the "v0" field if the given value is not nil.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetNillableV0(s *string) *AccessControlUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
acuo.SetV0(*s)
|
||||||
|
}
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV1 sets the "v1" field.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetV1(s string) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.SetV1(s)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV1 sets the "v1" field if the given value is not nil.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetNillableV1(s *string) *AccessControlUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
acuo.SetV1(*s)
|
||||||
|
}
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV2 sets the "v2" field.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetV2(s string) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.SetV2(s)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV2 sets the "v2" field if the given value is not nil.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetNillableV2(s *string) *AccessControlUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
acuo.SetV2(*s)
|
||||||
|
}
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV3 sets the "v3" field.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetV3(s string) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.SetV3(s)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV3 sets the "v3" field if the given value is not nil.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetNillableV3(s *string) *AccessControlUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
acuo.SetV3(*s)
|
||||||
|
}
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV4 sets the "v4" field.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetV4(s string) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.SetV4(s)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV4 sets the "v4" field if the given value is not nil.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetNillableV4(s *string) *AccessControlUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
acuo.SetV4(*s)
|
||||||
|
}
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetV5 sets the "v5" field.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetV5(s string) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.SetV5(s)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableV5 sets the "v5" field if the given value is not nil.
|
||||||
|
func (acuo *AccessControlUpdateOne) SetNillableV5(s *string) *AccessControlUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
acuo.SetV5(*s)
|
||||||
|
}
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the AccessControlMutation object of the builder.
|
||||||
|
func (acuo *AccessControlUpdateOne) Mutation() *AccessControlMutation {
|
||||||
|
return acuo.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the AccessControlUpdate builder.
|
||||||
|
func (acuo *AccessControlUpdateOne) Where(ps ...predicate.AccessControl) *AccessControlUpdateOne {
|
||||||
|
acuo.mutation.Where(ps...)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (acuo *AccessControlUpdateOne) Select(field string, fields ...string) *AccessControlUpdateOne {
|
||||||
|
acuo.fields = append([]string{field}, fields...)
|
||||||
|
return acuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated AccessControl entity.
|
||||||
|
func (acuo *AccessControlUpdateOne) Save(ctx context.Context) (*AccessControl, error) {
|
||||||
|
acuo.defaults()
|
||||||
|
return withHooks(ctx, acuo.sqlSave, acuo.mutation, acuo.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (acuo *AccessControlUpdateOne) SaveX(ctx context.Context) *AccessControl {
|
||||||
|
node, err := acuo.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (acuo *AccessControlUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := acuo.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (acuo *AccessControlUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := acuo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (acuo *AccessControlUpdateOne) defaults() {
|
||||||
|
if _, ok := acuo.mutation.UpdatedAt(); !ok {
|
||||||
|
v := accesscontrol.UpdateDefaultUpdatedAt()
|
||||||
|
acuo.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (acuo *AccessControlUpdateOne) sqlSave(ctx context.Context) (_node *AccessControl, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(accesscontrol.Table, accesscontrol.Columns, sqlgraph.NewFieldSpec(accesscontrol.FieldID, field.TypeInt64))
|
||||||
|
id, ok := acuo.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AccessControl.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := acuo.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, accesscontrol.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !accesscontrol.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != accesscontrol.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := acuo.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := acuo.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := acuo.mutation.Ptype(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldPtype, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acuo.mutation.V0(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV0, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acuo.mutation.V1(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV1, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acuo.mutation.V2(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV2, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acuo.mutation.V3(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV3, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acuo.mutation.V4(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV4, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := acuo.mutation.V5(); ok {
|
||||||
|
_spec.SetField(accesscontrol.FieldV5, field.TypeString, value)
|
||||||
|
}
|
||||||
|
_node = &AccessControl{config: acuo.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, acuo.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{accesscontrol.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
acuo.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
211
db/ent/audit.go
Normal file
211
db/ent/audit.go
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Audit is the model entity for the Audit schema.
|
||||||
|
type Audit struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int64 `json:"id,omitempty"`
|
||||||
|
// CreatedAt holds the value of the "created_at" field.
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// EntName holds the value of the "ent_name" field.
|
||||||
|
EntName string `json:"ent_name,omitempty"`
|
||||||
|
// EntID holds the value of the "ent_id" field.
|
||||||
|
EntID int64 `json:"ent_id,omitempty"`
|
||||||
|
// Operation holds the value of the "operation" field.
|
||||||
|
Operation audit.Operation `json:"operation,omitempty"`
|
||||||
|
// Description holds the value of the "description" field.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
// IP holds the value of the "ip" field.
|
||||||
|
IP string `json:"ip,omitempty"`
|
||||||
|
// UserName holds the value of the "user_name" field.
|
||||||
|
UserName string `json:"user_name,omitempty"`
|
||||||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
|
// The values are being populated by the AuditQuery when eager-loading is set.
|
||||||
|
Edges AuditEdges `json:"edges"`
|
||||||
|
user_id *int64
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuditEdges holds the relations/edges for other nodes in the graph.
|
||||||
|
type AuditEdges struct {
|
||||||
|
// User holds the value of the user edge.
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
// loadedTypes holds the information for reporting if a
|
||||||
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
|
loadedTypes [1]bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserOrErr returns the User value or an error if the edge
|
||||||
|
// was not loaded in eager-loading, or loaded but was not found.
|
||||||
|
func (e AuditEdges) UserOrErr() (*User, error) {
|
||||||
|
if e.User != nil {
|
||||||
|
return e.User, nil
|
||||||
|
} else if e.loadedTypes[0] {
|
||||||
|
return nil, &NotFoundError{label: user.Label}
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "user"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*Audit) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case audit.FieldID, audit.FieldEntID:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case audit.FieldEntName, audit.FieldOperation, audit.FieldDescription, audit.FieldIP, audit.FieldUserName:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case audit.FieldCreatedAt:
|
||||||
|
values[i] = new(sql.NullTime)
|
||||||
|
case audit.ForeignKeys[0]: // user_id
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the Audit fields.
|
||||||
|
func (a *Audit) 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 audit.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
a.ID = int64(value.Int64)
|
||||||
|
case audit.FieldCreatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
a.CreatedAt = value.Time
|
||||||
|
}
|
||||||
|
case audit.FieldEntName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field ent_name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
a.EntName = value.String
|
||||||
|
}
|
||||||
|
case audit.FieldEntID:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field ent_id", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
a.EntID = value.Int64
|
||||||
|
}
|
||||||
|
case audit.FieldOperation:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field operation", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
a.Operation = audit.Operation(value.String)
|
||||||
|
}
|
||||||
|
case audit.FieldDescription:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
a.Description = value.String
|
||||||
|
}
|
||||||
|
case audit.FieldIP:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field ip", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
a.IP = value.String
|
||||||
|
}
|
||||||
|
case audit.FieldUserName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field user_name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
a.UserName = value.String
|
||||||
|
}
|
||||||
|
case audit.ForeignKeys[0]:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for edge-field user_id", value)
|
||||||
|
} else if value.Valid {
|
||||||
|
a.user_id = new(int64)
|
||||||
|
*a.user_id = int64(value.Int64)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
a.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the Audit.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (a *Audit) Value(name string) (ent.Value, error) {
|
||||||
|
return a.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUser queries the "user" edge of the Audit entity.
|
||||||
|
func (a *Audit) QueryUser() *UserQuery {
|
||||||
|
return NewAuditClient(a.config).QueryUser(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this Audit.
|
||||||
|
// Note that you need to call Audit.Unwrap() before calling this method if this Audit
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (a *Audit) Update() *AuditUpdateOne {
|
||||||
|
return NewAuditClient(a.config).UpdateOne(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the Audit 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 (a *Audit) Unwrap() *Audit {
|
||||||
|
_tx, ok := a.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: Audit is not a transactional entity")
|
||||||
|
}
|
||||||
|
a.config.driver = _tx.drv
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (a *Audit) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("Audit(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", a.ID))
|
||||||
|
builder.WriteString("created_at=")
|
||||||
|
builder.WriteString(a.CreatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ent_name=")
|
||||||
|
builder.WriteString(a.EntName)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ent_id=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", a.EntID))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("operation=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", a.Operation))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("description=")
|
||||||
|
builder.WriteString(a.Description)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ip=")
|
||||||
|
builder.WriteString(a.IP)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("user_name=")
|
||||||
|
builder.WriteString(a.UserName)
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Audits is a parsable slice of Audit.
|
||||||
|
type Audits []*Audit
|
174
db/ent/audit/audit.go
Normal file
174
db/ent/audit/audit.go
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package audit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the audit type in the database.
|
||||||
|
Label = "audit"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||||
|
FieldCreatedAt = "created_at"
|
||||||
|
// FieldEntName holds the string denoting the ent_name field in the database.
|
||||||
|
FieldEntName = "ent_name"
|
||||||
|
// FieldEntID holds the string denoting the ent_id field in the database.
|
||||||
|
FieldEntID = "ent_id"
|
||||||
|
// FieldOperation holds the string denoting the operation field in the database.
|
||||||
|
FieldOperation = "operation"
|
||||||
|
// FieldDescription holds the string denoting the description field in the database.
|
||||||
|
FieldDescription = "description"
|
||||||
|
// FieldIP holds the string denoting the ip field in the database.
|
||||||
|
FieldIP = "ip"
|
||||||
|
// FieldUserName holds the string denoting the user_name field in the database.
|
||||||
|
FieldUserName = "user_name"
|
||||||
|
// EdgeUser holds the string denoting the user edge name in mutations.
|
||||||
|
EdgeUser = "user"
|
||||||
|
// Table holds the table name of the audit in the database.
|
||||||
|
Table = "audits"
|
||||||
|
// UserTable is the table that holds the user relation/edge.
|
||||||
|
UserTable = "audits"
|
||||||
|
// UserInverseTable is the table name for the User entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "user" package.
|
||||||
|
UserInverseTable = "users"
|
||||||
|
// UserColumn is the table column denoting the user relation/edge.
|
||||||
|
UserColumn = "user_id"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for audit fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldCreatedAt,
|
||||||
|
FieldEntName,
|
||||||
|
FieldEntID,
|
||||||
|
FieldOperation,
|
||||||
|
FieldDescription,
|
||||||
|
FieldIP,
|
||||||
|
FieldUserName,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForeignKeys holds the SQL foreign-keys that are owned by the "audits"
|
||||||
|
// table and are not defined as standalone fields in the schema.
|
||||||
|
var ForeignKeys = []string{
|
||||||
|
"user_id",
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := range ForeignKeys {
|
||||||
|
if column == ForeignKeys[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||||
|
DefaultCreatedAt func() time.Time
|
||||||
|
// EntNameValidator is a validator for the "ent_name" field. It is called by the builders before save.
|
||||||
|
EntNameValidator func(string) error
|
||||||
|
// EntIDValidator is a validator for the "ent_id" field. It is called by the builders before save.
|
||||||
|
EntIDValidator func(int64) error
|
||||||
|
// DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
|
||||||
|
DescriptionValidator func(string) error
|
||||||
|
// IPValidator is a validator for the "ip" field. It is called by the builders before save.
|
||||||
|
IPValidator func(string) error
|
||||||
|
// UserNameValidator is a validator for the "user_name" field. It is called by the builders before save.
|
||||||
|
UserNameValidator func(string) error
|
||||||
|
)
|
||||||
|
|
||||||
|
// Operation defines the type for the "operation" enum field.
|
||||||
|
type Operation string
|
||||||
|
|
||||||
|
// Operation values.
|
||||||
|
const (
|
||||||
|
OperationCreate Operation = "Create"
|
||||||
|
OperationUpdate Operation = "Update"
|
||||||
|
OperationUpdateOne Operation = "UpdateOne"
|
||||||
|
OperationDelete Operation = "Delete"
|
||||||
|
OperationDeleteOne Operation = "DeleteOne"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (o Operation) String() string {
|
||||||
|
return string(o)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationValidator is a validator for the "operation" field enum values. It is called by the builders before save.
|
||||||
|
func OperationValidator(o Operation) error {
|
||||||
|
switch o {
|
||||||
|
case OperationCreate, OperationUpdate, OperationUpdateOne, OperationDelete, OperationDeleteOne:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("audit: invalid enum value for operation field: %q", o)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the Audit 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()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCreatedAt orders the results by the created_at field.
|
||||||
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByEntName orders the results by the ent_name field.
|
||||||
|
func ByEntName(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldEntName, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByEntID orders the results by the ent_id field.
|
||||||
|
func ByEntID(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldEntID, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByOperation orders the results by the operation field.
|
||||||
|
func ByOperation(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldOperation, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByDescription orders the results by the description field.
|
||||||
|
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldDescription, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByIP orders the results by the ip field.
|
||||||
|
func ByIP(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldIP, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUserName orders the results by the user_name field.
|
||||||
|
func ByUserName(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldUserName, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUserField orders the results by user field.
|
||||||
|
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func newUserStep() *sqlgraph.Step {
|
||||||
|
return sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(UserInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
|
||||||
|
)
|
||||||
|
}
|
504
db/ent/audit/where.go
Normal file
504
db/ent/audit/where.go
Normal file
@ -0,0 +1,504 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package audit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||||
|
func CreatedAt(v time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntName applies equality check predicate on the "ent_name" field. It's identical to EntNameEQ.
|
||||||
|
func EntName(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntID applies equality check predicate on the "ent_id" field. It's identical to EntIDEQ.
|
||||||
|
func EntID(v int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldEntID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
|
||||||
|
func Description(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IP applies equality check predicate on the "ip" field. It's identical to IPEQ.
|
||||||
|
func IP(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserName applies equality check predicate on the "user_name" field. It's identical to UserNameEQ.
|
||||||
|
func UserName(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtEQ(v time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtNEQ(v time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
|
func CreatedAtIn(vs ...time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
|
func CreatedAtNotIn(vs ...time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||||
|
func CreatedAtGT(v time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtGTE(v time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||||
|
func CreatedAtLT(v time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtLTE(v time.Time) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameEQ applies the EQ predicate on the "ent_name" field.
|
||||||
|
func EntNameEQ(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameNEQ applies the NEQ predicate on the "ent_name" field.
|
||||||
|
func EntNameNEQ(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNEQ(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameIn applies the In predicate on the "ent_name" field.
|
||||||
|
func EntNameIn(vs ...string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIn(FieldEntName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameNotIn applies the NotIn predicate on the "ent_name" field.
|
||||||
|
func EntNameNotIn(vs ...string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotIn(FieldEntName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameGT applies the GT predicate on the "ent_name" field.
|
||||||
|
func EntNameGT(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGT(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameGTE applies the GTE predicate on the "ent_name" field.
|
||||||
|
func EntNameGTE(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGTE(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameLT applies the LT predicate on the "ent_name" field.
|
||||||
|
func EntNameLT(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLT(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameLTE applies the LTE predicate on the "ent_name" field.
|
||||||
|
func EntNameLTE(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLTE(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameContains applies the Contains predicate on the "ent_name" field.
|
||||||
|
func EntNameContains(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldContains(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameHasPrefix applies the HasPrefix predicate on the "ent_name" field.
|
||||||
|
func EntNameHasPrefix(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldHasPrefix(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameHasSuffix applies the HasSuffix predicate on the "ent_name" field.
|
||||||
|
func EntNameHasSuffix(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldHasSuffix(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameEqualFold applies the EqualFold predicate on the "ent_name" field.
|
||||||
|
func EntNameEqualFold(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEqualFold(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntNameContainsFold applies the ContainsFold predicate on the "ent_name" field.
|
||||||
|
func EntNameContainsFold(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldContainsFold(FieldEntName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntIDEQ applies the EQ predicate on the "ent_id" field.
|
||||||
|
func EntIDEQ(v int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldEntID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntIDNEQ applies the NEQ predicate on the "ent_id" field.
|
||||||
|
func EntIDNEQ(v int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNEQ(FieldEntID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntIDIn applies the In predicate on the "ent_id" field.
|
||||||
|
func EntIDIn(vs ...int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIn(FieldEntID, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntIDNotIn applies the NotIn predicate on the "ent_id" field.
|
||||||
|
func EntIDNotIn(vs ...int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotIn(FieldEntID, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntIDGT applies the GT predicate on the "ent_id" field.
|
||||||
|
func EntIDGT(v int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGT(FieldEntID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntIDGTE applies the GTE predicate on the "ent_id" field.
|
||||||
|
func EntIDGTE(v int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGTE(FieldEntID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntIDLT applies the LT predicate on the "ent_id" field.
|
||||||
|
func EntIDLT(v int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLT(FieldEntID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EntIDLTE applies the LTE predicate on the "ent_id" field.
|
||||||
|
func EntIDLTE(v int64) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLTE(FieldEntID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationEQ applies the EQ predicate on the "operation" field.
|
||||||
|
func OperationEQ(v Operation) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldOperation, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationNEQ applies the NEQ predicate on the "operation" field.
|
||||||
|
func OperationNEQ(v Operation) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNEQ(FieldOperation, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationIn applies the In predicate on the "operation" field.
|
||||||
|
func OperationIn(vs ...Operation) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIn(FieldOperation, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationNotIn applies the NotIn predicate on the "operation" field.
|
||||||
|
func OperationNotIn(vs ...Operation) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotIn(FieldOperation, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionEQ applies the EQ predicate on the "description" field.
|
||||||
|
func DescriptionEQ(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionNEQ applies the NEQ predicate on the "description" field.
|
||||||
|
func DescriptionNEQ(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNEQ(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionIn applies the In predicate on the "description" field.
|
||||||
|
func DescriptionIn(vs ...string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIn(FieldDescription, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionNotIn applies the NotIn predicate on the "description" field.
|
||||||
|
func DescriptionNotIn(vs ...string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotIn(FieldDescription, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionGT applies the GT predicate on the "description" field.
|
||||||
|
func DescriptionGT(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGT(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionGTE applies the GTE predicate on the "description" field.
|
||||||
|
func DescriptionGTE(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGTE(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionLT applies the LT predicate on the "description" field.
|
||||||
|
func DescriptionLT(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLT(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionLTE applies the LTE predicate on the "description" field.
|
||||||
|
func DescriptionLTE(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLTE(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionContains applies the Contains predicate on the "description" field.
|
||||||
|
func DescriptionContains(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldContains(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
|
||||||
|
func DescriptionHasPrefix(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldHasPrefix(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
|
||||||
|
func DescriptionHasSuffix(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldHasSuffix(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
|
||||||
|
func DescriptionEqualFold(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEqualFold(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
|
||||||
|
func DescriptionContainsFold(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldContainsFold(FieldDescription, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPEQ applies the EQ predicate on the "ip" field.
|
||||||
|
func IPEQ(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPNEQ applies the NEQ predicate on the "ip" field.
|
||||||
|
func IPNEQ(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNEQ(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPIn applies the In predicate on the "ip" field.
|
||||||
|
func IPIn(vs ...string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIn(FieldIP, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPNotIn applies the NotIn predicate on the "ip" field.
|
||||||
|
func IPNotIn(vs ...string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotIn(FieldIP, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPGT applies the GT predicate on the "ip" field.
|
||||||
|
func IPGT(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGT(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPGTE applies the GTE predicate on the "ip" field.
|
||||||
|
func IPGTE(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGTE(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPLT applies the LT predicate on the "ip" field.
|
||||||
|
func IPLT(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLT(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPLTE applies the LTE predicate on the "ip" field.
|
||||||
|
func IPLTE(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLTE(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPContains applies the Contains predicate on the "ip" field.
|
||||||
|
func IPContains(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldContains(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPHasPrefix applies the HasPrefix predicate on the "ip" field.
|
||||||
|
func IPHasPrefix(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldHasPrefix(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPHasSuffix applies the HasSuffix predicate on the "ip" field.
|
||||||
|
func IPHasSuffix(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldHasSuffix(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPIsNil applies the IsNil predicate on the "ip" field.
|
||||||
|
func IPIsNil() predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIsNull(FieldIP))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPNotNil applies the NotNil predicate on the "ip" field.
|
||||||
|
func IPNotNil() predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotNull(FieldIP))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPEqualFold applies the EqualFold predicate on the "ip" field.
|
||||||
|
func IPEqualFold(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEqualFold(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPContainsFold applies the ContainsFold predicate on the "ip" field.
|
||||||
|
func IPContainsFold(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldContainsFold(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameEQ applies the EQ predicate on the "user_name" field.
|
||||||
|
func UserNameEQ(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEQ(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameNEQ applies the NEQ predicate on the "user_name" field.
|
||||||
|
func UserNameNEQ(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNEQ(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameIn applies the In predicate on the "user_name" field.
|
||||||
|
func UserNameIn(vs ...string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIn(FieldUserName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameNotIn applies the NotIn predicate on the "user_name" field.
|
||||||
|
func UserNameNotIn(vs ...string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotIn(FieldUserName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameGT applies the GT predicate on the "user_name" field.
|
||||||
|
func UserNameGT(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGT(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameGTE applies the GTE predicate on the "user_name" field.
|
||||||
|
func UserNameGTE(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldGTE(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameLT applies the LT predicate on the "user_name" field.
|
||||||
|
func UserNameLT(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLT(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameLTE applies the LTE predicate on the "user_name" field.
|
||||||
|
func UserNameLTE(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldLTE(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameContains applies the Contains predicate on the "user_name" field.
|
||||||
|
func UserNameContains(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldContains(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameHasPrefix applies the HasPrefix predicate on the "user_name" field.
|
||||||
|
func UserNameHasPrefix(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldHasPrefix(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameHasSuffix applies the HasSuffix predicate on the "user_name" field.
|
||||||
|
func UserNameHasSuffix(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldHasSuffix(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameIsNil applies the IsNil predicate on the "user_name" field.
|
||||||
|
func UserNameIsNil() predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldIsNull(FieldUserName))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameNotNil applies the NotNil predicate on the "user_name" field.
|
||||||
|
func UserNameNotNil() predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldNotNull(FieldUserName))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameEqualFold applies the EqualFold predicate on the "user_name" field.
|
||||||
|
func UserNameEqualFold(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldEqualFold(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserNameContainsFold applies the ContainsFold predicate on the "user_name" field.
|
||||||
|
func UserNameContainsFold(v string) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.FieldContainsFold(FieldUserName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasUser applies the HasEdge predicate on the "user" edge.
|
||||||
|
func HasUser() predicate.Audit {
|
||||||
|
return predicate.Audit(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates).
|
||||||
|
func HasUserWith(preds ...predicate.User) predicate.Audit {
|
||||||
|
return predicate.Audit(func(s *sql.Selector) {
|
||||||
|
step := newUserStep()
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.Audit) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.Audit) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.Audit) predicate.Audit {
|
||||||
|
return predicate.Audit(sql.NotPredicates(p))
|
||||||
|
}
|
369
db/ent/audit_create.go
Normal file
369
db/ent/audit_create.go
Normal file
@ -0,0 +1,369 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuditCreate is the builder for creating a Audit entity.
|
||||||
|
type AuditCreate struct {
|
||||||
|
config
|
||||||
|
mutation *AuditMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (ac *AuditCreate) SetCreatedAt(t time.Time) *AuditCreate {
|
||||||
|
ac.mutation.SetCreatedAt(t)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (ac *AuditCreate) SetNillableCreatedAt(t *time.Time) *AuditCreate {
|
||||||
|
if t != nil {
|
||||||
|
ac.SetCreatedAt(*t)
|
||||||
|
}
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEntName sets the "ent_name" field.
|
||||||
|
func (ac *AuditCreate) SetEntName(s string) *AuditCreate {
|
||||||
|
ac.mutation.SetEntName(s)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEntID sets the "ent_id" field.
|
||||||
|
func (ac *AuditCreate) SetEntID(i int64) *AuditCreate {
|
||||||
|
ac.mutation.SetEntID(i)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOperation sets the "operation" field.
|
||||||
|
func (ac *AuditCreate) SetOperation(a audit.Operation) *AuditCreate {
|
||||||
|
ac.mutation.SetOperation(a)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDescription sets the "description" field.
|
||||||
|
func (ac *AuditCreate) SetDescription(s string) *AuditCreate {
|
||||||
|
ac.mutation.SetDescription(s)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIP sets the "ip" field.
|
||||||
|
func (ac *AuditCreate) SetIP(s string) *AuditCreate {
|
||||||
|
ac.mutation.SetIP(s)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIP sets the "ip" field if the given value is not nil.
|
||||||
|
func (ac *AuditCreate) SetNillableIP(s *string) *AuditCreate {
|
||||||
|
if s != nil {
|
||||||
|
ac.SetIP(*s)
|
||||||
|
}
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserName sets the "user_name" field.
|
||||||
|
func (ac *AuditCreate) SetUserName(s string) *AuditCreate {
|
||||||
|
ac.mutation.SetUserName(s)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUserName sets the "user_name" field if the given value is not nil.
|
||||||
|
func (ac *AuditCreate) SetNillableUserName(s *string) *AuditCreate {
|
||||||
|
if s != nil {
|
||||||
|
ac.SetUserName(*s)
|
||||||
|
}
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets the "id" field.
|
||||||
|
func (ac *AuditCreate) SetID(i int64) *AuditCreate {
|
||||||
|
ac.mutation.SetID(i)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user" edge to the User entity by ID.
|
||||||
|
func (ac *AuditCreate) SetUserID(id int64) *AuditCreate {
|
||||||
|
ac.mutation.SetUserID(id)
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
|
||||||
|
func (ac *AuditCreate) SetNillableUserID(id *int64) *AuditCreate {
|
||||||
|
if id != nil {
|
||||||
|
ac = ac.SetUserID(*id)
|
||||||
|
}
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (ac *AuditCreate) SetUser(u *User) *AuditCreate {
|
||||||
|
return ac.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the AuditMutation object of the builder.
|
||||||
|
func (ac *AuditCreate) Mutation() *AuditMutation {
|
||||||
|
return ac.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Audit in the database.
|
||||||
|
func (ac *AuditCreate) Save(ctx context.Context) (*Audit, error) {
|
||||||
|
ac.defaults()
|
||||||
|
return withHooks(ctx, ac.sqlSave, ac.mutation, ac.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (ac *AuditCreate) SaveX(ctx context.Context) *Audit {
|
||||||
|
v, err := ac.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (ac *AuditCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := ac.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ac *AuditCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := ac.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (ac *AuditCreate) defaults() {
|
||||||
|
if _, ok := ac.mutation.CreatedAt(); !ok {
|
||||||
|
v := audit.DefaultCreatedAt()
|
||||||
|
ac.mutation.SetCreatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (ac *AuditCreate) check() error {
|
||||||
|
if _, ok := ac.mutation.CreatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Audit.created_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := ac.mutation.EntName(); !ok {
|
||||||
|
return &ValidationError{Name: "ent_name", err: errors.New(`ent: missing required field "Audit.ent_name"`)}
|
||||||
|
}
|
||||||
|
if v, ok := ac.mutation.EntName(); ok {
|
||||||
|
if err := audit.EntNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ent_name", err: fmt.Errorf(`ent: validator failed for field "Audit.ent_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := ac.mutation.EntID(); !ok {
|
||||||
|
return &ValidationError{Name: "ent_id", err: errors.New(`ent: missing required field "Audit.ent_id"`)}
|
||||||
|
}
|
||||||
|
if v, ok := ac.mutation.EntID(); ok {
|
||||||
|
if err := audit.EntIDValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ent_id", err: fmt.Errorf(`ent: validator failed for field "Audit.ent_id": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := ac.mutation.Operation(); !ok {
|
||||||
|
return &ValidationError{Name: "operation", err: errors.New(`ent: missing required field "Audit.operation"`)}
|
||||||
|
}
|
||||||
|
if v, ok := ac.mutation.Operation(); ok {
|
||||||
|
if err := audit.OperationValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Audit.operation": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := ac.mutation.Description(); !ok {
|
||||||
|
return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Audit.description"`)}
|
||||||
|
}
|
||||||
|
if v, ok := ac.mutation.Description(); ok {
|
||||||
|
if err := audit.DescriptionValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Audit.description": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := ac.mutation.IP(); ok {
|
||||||
|
if err := audit.IPValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "Audit.ip": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := ac.mutation.UserName(); ok {
|
||||||
|
if err := audit.UserNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "user_name", err: fmt.Errorf(`ent: validator failed for field "Audit.user_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ac *AuditCreate) sqlSave(ctx context.Context) (*Audit, error) {
|
||||||
|
if err := ac.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := ac.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, ac.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if _spec.ID.Value != _node.ID {
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int64(id)
|
||||||
|
}
|
||||||
|
ac.mutation.id = &_node.ID
|
||||||
|
ac.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ac *AuditCreate) createSpec() (*Audit, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &Audit{config: ac.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(audit.Table, sqlgraph.NewFieldSpec(audit.FieldID, field.TypeInt64))
|
||||||
|
)
|
||||||
|
if id, ok := ac.mutation.ID(); ok {
|
||||||
|
_node.ID = id
|
||||||
|
_spec.ID.Value = id
|
||||||
|
}
|
||||||
|
if value, ok := ac.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(audit.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
_node.CreatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := ac.mutation.EntName(); ok {
|
||||||
|
_spec.SetField(audit.FieldEntName, field.TypeString, value)
|
||||||
|
_node.EntName = value
|
||||||
|
}
|
||||||
|
if value, ok := ac.mutation.EntID(); ok {
|
||||||
|
_spec.SetField(audit.FieldEntID, field.TypeInt64, value)
|
||||||
|
_node.EntID = value
|
||||||
|
}
|
||||||
|
if value, ok := ac.mutation.Operation(); ok {
|
||||||
|
_spec.SetField(audit.FieldOperation, field.TypeEnum, value)
|
||||||
|
_node.Operation = value
|
||||||
|
}
|
||||||
|
if value, ok := ac.mutation.Description(); ok {
|
||||||
|
_spec.SetField(audit.FieldDescription, field.TypeString, value)
|
||||||
|
_node.Description = value
|
||||||
|
}
|
||||||
|
if value, ok := ac.mutation.IP(); ok {
|
||||||
|
_spec.SetField(audit.FieldIP, field.TypeString, value)
|
||||||
|
_node.IP = value
|
||||||
|
}
|
||||||
|
if value, ok := ac.mutation.UserName(); ok {
|
||||||
|
_spec.SetField(audit.FieldUserName, field.TypeString, value)
|
||||||
|
_node.UserName = value
|
||||||
|
}
|
||||||
|
if nodes := ac.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: audit.UserTable,
|
||||||
|
Columns: []string{audit.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_node.user_id = &nodes[0]
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuditCreateBulk is the builder for creating many Audit entities in bulk.
|
||||||
|
type AuditCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*AuditCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Audit entities in the database.
|
||||||
|
func (acb *AuditCreateBulk) Save(ctx context.Context) ([]*Audit, error) {
|
||||||
|
if acb.err != nil {
|
||||||
|
return nil, acb.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(acb.builders))
|
||||||
|
nodes := make([]*Audit, len(acb.builders))
|
||||||
|
mutators := make([]Mutator, len(acb.builders))
|
||||||
|
for i := range acb.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := acb.builders[i]
|
||||||
|
builder.defaults()
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*AuditMutation)
|
||||||
|
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, acb.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, acb.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 && nodes[i].ID == 0 {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int64(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, acb.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (acb *AuditCreateBulk) SaveX(ctx context.Context) []*Audit {
|
||||||
|
v, err := acb.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (acb *AuditCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := acb.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (acb *AuditCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := acb.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
88
db/ent/audit_delete.go
Normal file
88
db/ent/audit_delete.go
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuditDelete is the builder for deleting a Audit entity.
|
||||||
|
type AuditDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *AuditMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the AuditDelete builder.
|
||||||
|
func (ad *AuditDelete) Where(ps ...predicate.Audit) *AuditDelete {
|
||||||
|
ad.mutation.Where(ps...)
|
||||||
|
return ad
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (ad *AuditDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, ad.sqlExec, ad.mutation, ad.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ad *AuditDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := ad.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ad *AuditDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(audit.Table, sqlgraph.NewFieldSpec(audit.FieldID, field.TypeInt64))
|
||||||
|
if ps := ad.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, ad.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
ad.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuditDeleteOne is the builder for deleting a single Audit entity.
|
||||||
|
type AuditDeleteOne struct {
|
||||||
|
ad *AuditDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the AuditDelete builder.
|
||||||
|
func (ado *AuditDeleteOne) Where(ps ...predicate.Audit) *AuditDeleteOne {
|
||||||
|
ado.ad.mutation.Where(ps...)
|
||||||
|
return ado
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (ado *AuditDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := ado.ad.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{audit.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ado *AuditDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := ado.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
614
db/ent/audit_query.go
Normal file
614
db/ent/audit_query.go
Normal file
@ -0,0 +1,614 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuditQuery is the builder for querying Audit entities.
|
||||||
|
type AuditQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []audit.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.Audit
|
||||||
|
withUser *UserQuery
|
||||||
|
withFKs bool
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the AuditQuery builder.
|
||||||
|
func (aq *AuditQuery) Where(ps ...predicate.Audit) *AuditQuery {
|
||||||
|
aq.predicates = append(aq.predicates, ps...)
|
||||||
|
return aq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (aq *AuditQuery) Limit(limit int) *AuditQuery {
|
||||||
|
aq.ctx.Limit = &limit
|
||||||
|
return aq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (aq *AuditQuery) Offset(offset int) *AuditQuery {
|
||||||
|
aq.ctx.Offset = &offset
|
||||||
|
return aq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (aq *AuditQuery) Unique(unique bool) *AuditQuery {
|
||||||
|
aq.ctx.Unique = &unique
|
||||||
|
return aq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (aq *AuditQuery) Order(o ...audit.OrderOption) *AuditQuery {
|
||||||
|
aq.order = append(aq.order, o...)
|
||||||
|
return aq
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUser chains the current query on the "user" edge.
|
||||||
|
func (aq *AuditQuery) QueryUser() *UserQuery {
|
||||||
|
query := (&UserClient{config: aq.config}).Query()
|
||||||
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
|
if err := aq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
selector := aq.sqlQuery(ctx)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(audit.Table, audit.FieldID, selector),
|
||||||
|
sqlgraph.To(user.Table, user.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, audit.UserTable, audit.UserColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first Audit entity from the query.
|
||||||
|
// Returns a *NotFoundError when no Audit was found.
|
||||||
|
func (aq *AuditQuery) First(ctx context.Context) (*Audit, error) {
|
||||||
|
nodes, err := aq.Limit(1).All(setContextOp(ctx, aq.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{audit.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (aq *AuditQuery) FirstX(ctx context.Context) *Audit {
|
||||||
|
node, err := aq.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first Audit ID from the query.
|
||||||
|
// Returns a *NotFoundError when no Audit ID was found.
|
||||||
|
func (aq *AuditQuery) FirstID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = aq.Limit(1).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{audit.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (aq *AuditQuery) FirstIDX(ctx context.Context) int64 {
|
||||||
|
id, err := aq.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single Audit entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one Audit entity is found.
|
||||||
|
// Returns a *NotFoundError when no Audit entities are found.
|
||||||
|
func (aq *AuditQuery) Only(ctx context.Context) (*Audit, error) {
|
||||||
|
nodes, err := aq.Limit(2).All(setContextOp(ctx, aq.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{audit.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{audit.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (aq *AuditQuery) OnlyX(ctx context.Context) *Audit {
|
||||||
|
node, err := aq.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only Audit ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one Audit ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (aq *AuditQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = aq.Limit(2).IDs(setContextOp(ctx, aq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{audit.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{audit.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (aq *AuditQuery) OnlyIDX(ctx context.Context) int64 {
|
||||||
|
id, err := aq.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of Audits.
|
||||||
|
func (aq *AuditQuery) All(ctx context.Context) ([]*Audit, error) {
|
||||||
|
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryAll)
|
||||||
|
if err := aq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*Audit, *AuditQuery]()
|
||||||
|
return withInterceptors[[]*Audit](ctx, aq, qr, aq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (aq *AuditQuery) AllX(ctx context.Context) []*Audit {
|
||||||
|
nodes, err := aq.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of Audit IDs.
|
||||||
|
func (aq *AuditQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
||||||
|
if aq.ctx.Unique == nil && aq.path != nil {
|
||||||
|
aq.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryIDs)
|
||||||
|
if err = aq.Select(audit.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (aq *AuditQuery) IDsX(ctx context.Context) []int64 {
|
||||||
|
ids, err := aq.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (aq *AuditQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryCount)
|
||||||
|
if err := aq.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, aq, querierCount[*AuditQuery](), aq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (aq *AuditQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := aq.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (aq *AuditQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, aq.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := aq.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 (aq *AuditQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := aq.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the AuditQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (aq *AuditQuery) Clone() *AuditQuery {
|
||||||
|
if aq == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &AuditQuery{
|
||||||
|
config: aq.config,
|
||||||
|
ctx: aq.ctx.Clone(),
|
||||||
|
order: append([]audit.OrderOption{}, aq.order...),
|
||||||
|
inters: append([]Interceptor{}, aq.inters...),
|
||||||
|
predicates: append([]predicate.Audit{}, aq.predicates...),
|
||||||
|
withUser: aq.withUser.Clone(),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: aq.sql.Clone(),
|
||||||
|
path: aq.path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithUser tells the query-builder to eager-load the nodes that are connected to
|
||||||
|
// the "user" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
|
func (aq *AuditQuery) WithUser(opts ...func(*UserQuery)) *AuditQuery {
|
||||||
|
query := (&UserClient{config: aq.config}).Query()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
aq.withUser = query
|
||||||
|
return aq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
// CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.Audit.Query().
|
||||||
|
// GroupBy(audit.FieldCreatedAt).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (aq *AuditQuery) GroupBy(field string, fields ...string) *AuditGroupBy {
|
||||||
|
aq.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &AuditGroupBy{build: aq}
|
||||||
|
grbuild.flds = &aq.ctx.Fields
|
||||||
|
grbuild.label = audit.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 {
|
||||||
|
// CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.Audit.Query().
|
||||||
|
// Select(audit.FieldCreatedAt).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (aq *AuditQuery) Select(fields ...string) *AuditSelect {
|
||||||
|
aq.ctx.Fields = append(aq.ctx.Fields, fields...)
|
||||||
|
sbuild := &AuditSelect{AuditQuery: aq}
|
||||||
|
sbuild.label = audit.Label
|
||||||
|
sbuild.flds, sbuild.scan = &aq.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a AuditSelect configured with the given aggregations.
|
||||||
|
func (aq *AuditQuery) Aggregate(fns ...AggregateFunc) *AuditSelect {
|
||||||
|
return aq.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (aq *AuditQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range aq.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, aq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range aq.ctx.Fields {
|
||||||
|
if !audit.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if aq.path != nil {
|
||||||
|
prev, err := aq.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
aq.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (aq *AuditQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Audit, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*Audit{}
|
||||||
|
withFKs = aq.withFKs
|
||||||
|
_spec = aq.querySpec()
|
||||||
|
loadedTypes = [1]bool{
|
||||||
|
aq.withUser != nil,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if aq.withUser != nil {
|
||||||
|
withFKs = true
|
||||||
|
}
|
||||||
|
if withFKs {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, audit.ForeignKeys...)
|
||||||
|
}
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Audit).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &Audit{config: aq.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
node.Edges.loadedTypes = loadedTypes
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, aq.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
if query := aq.withUser; query != nil {
|
||||||
|
if err := aq.loadUser(ctx, query, nodes, nil,
|
||||||
|
func(n *Audit, e *User) { n.Edges.User = e }); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (aq *AuditQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Audit, init func(*Audit), assign func(*Audit, *User)) error {
|
||||||
|
ids := make([]int64, 0, len(nodes))
|
||||||
|
nodeids := make(map[int64][]*Audit)
|
||||||
|
for i := range nodes {
|
||||||
|
if nodes[i].user_id == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fk := *nodes[i].user_id
|
||||||
|
if _, ok := nodeids[fk]; !ok {
|
||||||
|
ids = append(ids, fk)
|
||||||
|
}
|
||||||
|
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
query.Where(user.IDIn(ids...))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
nodes, ok := nodeids[n.ID]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "user_id" returned %v`, n.ID)
|
||||||
|
}
|
||||||
|
for i := range nodes {
|
||||||
|
assign(nodes[i], n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (aq *AuditQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := aq.querySpec()
|
||||||
|
_spec.Node.Columns = aq.ctx.Fields
|
||||||
|
if len(aq.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = aq.ctx.Unique != nil && *aq.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, aq.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (aq *AuditQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(audit.Table, audit.Columns, sqlgraph.NewFieldSpec(audit.FieldID, field.TypeInt64))
|
||||||
|
_spec.From = aq.sql
|
||||||
|
if unique := aq.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if aq.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := aq.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, audit.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != audit.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := aq.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := aq.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := aq.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := aq.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (aq *AuditQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(aq.driver.Dialect())
|
||||||
|
t1 := builder.Table(audit.Table)
|
||||||
|
columns := aq.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = audit.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if aq.sql != nil {
|
||||||
|
selector = aq.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if aq.ctx.Unique != nil && *aq.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range aq.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range aq.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := aq.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 := aq.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuditGroupBy is the group-by builder for Audit entities.
|
||||||
|
type AuditGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *AuditQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (agb *AuditGroupBy) Aggregate(fns ...AggregateFunc) *AuditGroupBy {
|
||||||
|
agb.fns = append(agb.fns, fns...)
|
||||||
|
return agb
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (agb *AuditGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, agb.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := agb.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*AuditQuery, *AuditGroupBy](ctx, agb.build, agb, agb.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (agb *AuditGroupBy) sqlScan(ctx context.Context, root *AuditQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(agb.fns))
|
||||||
|
for _, fn := range agb.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*agb.flds)+len(agb.fns))
|
||||||
|
for _, f := range *agb.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*agb.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := agb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuditSelect is the builder for selecting fields of Audit entities.
|
||||||
|
type AuditSelect struct {
|
||||||
|
*AuditQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (as *AuditSelect) Aggregate(fns ...AggregateFunc) *AuditSelect {
|
||||||
|
as.fns = append(as.fns, fns...)
|
||||||
|
return as
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (as *AuditSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, as.ctx, ent.OpQuerySelect)
|
||||||
|
if err := as.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*AuditQuery, *AuditSelect](ctx, as.AuditQuery, as, as.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *AuditSelect) sqlScan(ctx context.Context, root *AuditQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(as.fns))
|
||||||
|
for _, fn := range as.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*as.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 := as.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
620
db/ent/audit_update.go
Normal file
620
db/ent/audit_update.go
Normal file
@ -0,0 +1,620 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuditUpdate is the builder for updating Audit entities.
|
||||||
|
type AuditUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *AuditMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the AuditUpdate builder.
|
||||||
|
func (au *AuditUpdate) Where(ps ...predicate.Audit) *AuditUpdate {
|
||||||
|
au.mutation.Where(ps...)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEntName sets the "ent_name" field.
|
||||||
|
func (au *AuditUpdate) SetEntName(s string) *AuditUpdate {
|
||||||
|
au.mutation.SetEntName(s)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableEntName sets the "ent_name" field if the given value is not nil.
|
||||||
|
func (au *AuditUpdate) SetNillableEntName(s *string) *AuditUpdate {
|
||||||
|
if s != nil {
|
||||||
|
au.SetEntName(*s)
|
||||||
|
}
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEntID sets the "ent_id" field.
|
||||||
|
func (au *AuditUpdate) SetEntID(i int64) *AuditUpdate {
|
||||||
|
au.mutation.ResetEntID()
|
||||||
|
au.mutation.SetEntID(i)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableEntID sets the "ent_id" field if the given value is not nil.
|
||||||
|
func (au *AuditUpdate) SetNillableEntID(i *int64) *AuditUpdate {
|
||||||
|
if i != nil {
|
||||||
|
au.SetEntID(*i)
|
||||||
|
}
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEntID adds i to the "ent_id" field.
|
||||||
|
func (au *AuditUpdate) AddEntID(i int64) *AuditUpdate {
|
||||||
|
au.mutation.AddEntID(i)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOperation sets the "operation" field.
|
||||||
|
func (au *AuditUpdate) SetOperation(a audit.Operation) *AuditUpdate {
|
||||||
|
au.mutation.SetOperation(a)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableOperation sets the "operation" field if the given value is not nil.
|
||||||
|
func (au *AuditUpdate) SetNillableOperation(a *audit.Operation) *AuditUpdate {
|
||||||
|
if a != nil {
|
||||||
|
au.SetOperation(*a)
|
||||||
|
}
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDescription sets the "description" field.
|
||||||
|
func (au *AuditUpdate) SetDescription(s string) *AuditUpdate {
|
||||||
|
au.mutation.SetDescription(s)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||||
|
func (au *AuditUpdate) SetNillableDescription(s *string) *AuditUpdate {
|
||||||
|
if s != nil {
|
||||||
|
au.SetDescription(*s)
|
||||||
|
}
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIP sets the "ip" field.
|
||||||
|
func (au *AuditUpdate) SetIP(s string) *AuditUpdate {
|
||||||
|
au.mutation.SetIP(s)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIP sets the "ip" field if the given value is not nil.
|
||||||
|
func (au *AuditUpdate) SetNillableIP(s *string) *AuditUpdate {
|
||||||
|
if s != nil {
|
||||||
|
au.SetIP(*s)
|
||||||
|
}
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearIP clears the value of the "ip" field.
|
||||||
|
func (au *AuditUpdate) ClearIP() *AuditUpdate {
|
||||||
|
au.mutation.ClearIP()
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserName sets the "user_name" field.
|
||||||
|
func (au *AuditUpdate) SetUserName(s string) *AuditUpdate {
|
||||||
|
au.mutation.SetUserName(s)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUserName sets the "user_name" field if the given value is not nil.
|
||||||
|
func (au *AuditUpdate) SetNillableUserName(s *string) *AuditUpdate {
|
||||||
|
if s != nil {
|
||||||
|
au.SetUserName(*s)
|
||||||
|
}
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearUserName clears the value of the "user_name" field.
|
||||||
|
func (au *AuditUpdate) ClearUserName() *AuditUpdate {
|
||||||
|
au.mutation.ClearUserName()
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user" edge to the User entity by ID.
|
||||||
|
func (au *AuditUpdate) SetUserID(id int64) *AuditUpdate {
|
||||||
|
au.mutation.SetUserID(id)
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
|
||||||
|
func (au *AuditUpdate) SetNillableUserID(id *int64) *AuditUpdate {
|
||||||
|
if id != nil {
|
||||||
|
au = au.SetUserID(*id)
|
||||||
|
}
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (au *AuditUpdate) SetUser(u *User) *AuditUpdate {
|
||||||
|
return au.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the AuditMutation object of the builder.
|
||||||
|
func (au *AuditUpdate) Mutation() *AuditMutation {
|
||||||
|
return au.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearUser clears the "user" edge to the User entity.
|
||||||
|
func (au *AuditUpdate) ClearUser() *AuditUpdate {
|
||||||
|
au.mutation.ClearUser()
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (au *AuditUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, au.sqlSave, au.mutation, au.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (au *AuditUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := au.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (au *AuditUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := au.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (au *AuditUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := au.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (au *AuditUpdate) check() error {
|
||||||
|
if v, ok := au.mutation.EntName(); ok {
|
||||||
|
if err := audit.EntNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ent_name", err: fmt.Errorf(`ent: validator failed for field "Audit.ent_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := au.mutation.EntID(); ok {
|
||||||
|
if err := audit.EntIDValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ent_id", err: fmt.Errorf(`ent: validator failed for field "Audit.ent_id": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := au.mutation.Operation(); ok {
|
||||||
|
if err := audit.OperationValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Audit.operation": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := au.mutation.Description(); ok {
|
||||||
|
if err := audit.DescriptionValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Audit.description": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := au.mutation.IP(); ok {
|
||||||
|
if err := audit.IPValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "Audit.ip": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := au.mutation.UserName(); ok {
|
||||||
|
if err := audit.UserNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "user_name", err: fmt.Errorf(`ent: validator failed for field "Audit.user_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (au *AuditUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
|
if err := au.check(); err != nil {
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(audit.Table, audit.Columns, sqlgraph.NewFieldSpec(audit.FieldID, field.TypeInt64))
|
||||||
|
if ps := au.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := au.mutation.EntName(); ok {
|
||||||
|
_spec.SetField(audit.FieldEntName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := au.mutation.EntID(); ok {
|
||||||
|
_spec.SetField(audit.FieldEntID, field.TypeInt64, value)
|
||||||
|
}
|
||||||
|
if value, ok := au.mutation.AddedEntID(); ok {
|
||||||
|
_spec.AddField(audit.FieldEntID, field.TypeInt64, value)
|
||||||
|
}
|
||||||
|
if value, ok := au.mutation.Operation(); ok {
|
||||||
|
_spec.SetField(audit.FieldOperation, field.TypeEnum, value)
|
||||||
|
}
|
||||||
|
if value, ok := au.mutation.Description(); ok {
|
||||||
|
_spec.SetField(audit.FieldDescription, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := au.mutation.IP(); ok {
|
||||||
|
_spec.SetField(audit.FieldIP, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if au.mutation.IPCleared() {
|
||||||
|
_spec.ClearField(audit.FieldIP, field.TypeString)
|
||||||
|
}
|
||||||
|
if value, ok := au.mutation.UserName(); ok {
|
||||||
|
_spec.SetField(audit.FieldUserName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if au.mutation.UserNameCleared() {
|
||||||
|
_spec.ClearField(audit.FieldUserName, field.TypeString)
|
||||||
|
}
|
||||||
|
if au.mutation.UserCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: audit.UserTable,
|
||||||
|
Columns: []string{audit.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := au.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: audit.UserTable,
|
||||||
|
Columns: []string{audit.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
|
if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{audit.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
au.mutation.done = true
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuditUpdateOne is the builder for updating a single Audit entity.
|
||||||
|
type AuditUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *AuditMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEntName sets the "ent_name" field.
|
||||||
|
func (auo *AuditUpdateOne) SetEntName(s string) *AuditUpdateOne {
|
||||||
|
auo.mutation.SetEntName(s)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableEntName sets the "ent_name" field if the given value is not nil.
|
||||||
|
func (auo *AuditUpdateOne) SetNillableEntName(s *string) *AuditUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
auo.SetEntName(*s)
|
||||||
|
}
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEntID sets the "ent_id" field.
|
||||||
|
func (auo *AuditUpdateOne) SetEntID(i int64) *AuditUpdateOne {
|
||||||
|
auo.mutation.ResetEntID()
|
||||||
|
auo.mutation.SetEntID(i)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableEntID sets the "ent_id" field if the given value is not nil.
|
||||||
|
func (auo *AuditUpdateOne) SetNillableEntID(i *int64) *AuditUpdateOne {
|
||||||
|
if i != nil {
|
||||||
|
auo.SetEntID(*i)
|
||||||
|
}
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEntID adds i to the "ent_id" field.
|
||||||
|
func (auo *AuditUpdateOne) AddEntID(i int64) *AuditUpdateOne {
|
||||||
|
auo.mutation.AddEntID(i)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetOperation sets the "operation" field.
|
||||||
|
func (auo *AuditUpdateOne) SetOperation(a audit.Operation) *AuditUpdateOne {
|
||||||
|
auo.mutation.SetOperation(a)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableOperation sets the "operation" field if the given value is not nil.
|
||||||
|
func (auo *AuditUpdateOne) SetNillableOperation(a *audit.Operation) *AuditUpdateOne {
|
||||||
|
if a != nil {
|
||||||
|
auo.SetOperation(*a)
|
||||||
|
}
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDescription sets the "description" field.
|
||||||
|
func (auo *AuditUpdateOne) SetDescription(s string) *AuditUpdateOne {
|
||||||
|
auo.mutation.SetDescription(s)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableDescription sets the "description" field if the given value is not nil.
|
||||||
|
func (auo *AuditUpdateOne) SetNillableDescription(s *string) *AuditUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
auo.SetDescription(*s)
|
||||||
|
}
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIP sets the "ip" field.
|
||||||
|
func (auo *AuditUpdateOne) SetIP(s string) *AuditUpdateOne {
|
||||||
|
auo.mutation.SetIP(s)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIP sets the "ip" field if the given value is not nil.
|
||||||
|
func (auo *AuditUpdateOne) SetNillableIP(s *string) *AuditUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
auo.SetIP(*s)
|
||||||
|
}
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearIP clears the value of the "ip" field.
|
||||||
|
func (auo *AuditUpdateOne) ClearIP() *AuditUpdateOne {
|
||||||
|
auo.mutation.ClearIP()
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserName sets the "user_name" field.
|
||||||
|
func (auo *AuditUpdateOne) SetUserName(s string) *AuditUpdateOne {
|
||||||
|
auo.mutation.SetUserName(s)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUserName sets the "user_name" field if the given value is not nil.
|
||||||
|
func (auo *AuditUpdateOne) SetNillableUserName(s *string) *AuditUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
auo.SetUserName(*s)
|
||||||
|
}
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearUserName clears the value of the "user_name" field.
|
||||||
|
func (auo *AuditUpdateOne) ClearUserName() *AuditUpdateOne {
|
||||||
|
auo.mutation.ClearUserName()
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user" edge to the User entity by ID.
|
||||||
|
func (auo *AuditUpdateOne) SetUserID(id int64) *AuditUpdateOne {
|
||||||
|
auo.mutation.SetUserID(id)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
|
||||||
|
func (auo *AuditUpdateOne) SetNillableUserID(id *int64) *AuditUpdateOne {
|
||||||
|
if id != nil {
|
||||||
|
auo = auo.SetUserID(*id)
|
||||||
|
}
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (auo *AuditUpdateOne) SetUser(u *User) *AuditUpdateOne {
|
||||||
|
return auo.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the AuditMutation object of the builder.
|
||||||
|
func (auo *AuditUpdateOne) Mutation() *AuditMutation {
|
||||||
|
return auo.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearUser clears the "user" edge to the User entity.
|
||||||
|
func (auo *AuditUpdateOne) ClearUser() *AuditUpdateOne {
|
||||||
|
auo.mutation.ClearUser()
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the AuditUpdate builder.
|
||||||
|
func (auo *AuditUpdateOne) Where(ps ...predicate.Audit) *AuditUpdateOne {
|
||||||
|
auo.mutation.Where(ps...)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (auo *AuditUpdateOne) Select(field string, fields ...string) *AuditUpdateOne {
|
||||||
|
auo.fields = append([]string{field}, fields...)
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated Audit entity.
|
||||||
|
func (auo *AuditUpdateOne) Save(ctx context.Context) (*Audit, error) {
|
||||||
|
return withHooks(ctx, auo.sqlSave, auo.mutation, auo.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (auo *AuditUpdateOne) SaveX(ctx context.Context) *Audit {
|
||||||
|
node, err := auo.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (auo *AuditUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := auo.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (auo *AuditUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := auo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (auo *AuditUpdateOne) check() error {
|
||||||
|
if v, ok := auo.mutation.EntName(); ok {
|
||||||
|
if err := audit.EntNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ent_name", err: fmt.Errorf(`ent: validator failed for field "Audit.ent_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := auo.mutation.EntID(); ok {
|
||||||
|
if err := audit.EntIDValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ent_id", err: fmt.Errorf(`ent: validator failed for field "Audit.ent_id": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := auo.mutation.Operation(); ok {
|
||||||
|
if err := audit.OperationValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Audit.operation": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := auo.mutation.Description(); ok {
|
||||||
|
if err := audit.DescriptionValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Audit.description": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := auo.mutation.IP(); ok {
|
||||||
|
if err := audit.IPValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "Audit.ip": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := auo.mutation.UserName(); ok {
|
||||||
|
if err := audit.UserNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "user_name", err: fmt.Errorf(`ent: validator failed for field "Audit.user_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (auo *AuditUpdateOne) sqlSave(ctx context.Context) (_node *Audit, err error) {
|
||||||
|
if err := auo.check(); err != nil {
|
||||||
|
return _node, err
|
||||||
|
}
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(audit.Table, audit.Columns, sqlgraph.NewFieldSpec(audit.FieldID, field.TypeInt64))
|
||||||
|
id, ok := auo.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Audit.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := auo.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, audit.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !audit.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != audit.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := auo.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := auo.mutation.EntName(); ok {
|
||||||
|
_spec.SetField(audit.FieldEntName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := auo.mutation.EntID(); ok {
|
||||||
|
_spec.SetField(audit.FieldEntID, field.TypeInt64, value)
|
||||||
|
}
|
||||||
|
if value, ok := auo.mutation.AddedEntID(); ok {
|
||||||
|
_spec.AddField(audit.FieldEntID, field.TypeInt64, value)
|
||||||
|
}
|
||||||
|
if value, ok := auo.mutation.Operation(); ok {
|
||||||
|
_spec.SetField(audit.FieldOperation, field.TypeEnum, value)
|
||||||
|
}
|
||||||
|
if value, ok := auo.mutation.Description(); ok {
|
||||||
|
_spec.SetField(audit.FieldDescription, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := auo.mutation.IP(); ok {
|
||||||
|
_spec.SetField(audit.FieldIP, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if auo.mutation.IPCleared() {
|
||||||
|
_spec.ClearField(audit.FieldIP, field.TypeString)
|
||||||
|
}
|
||||||
|
if value, ok := auo.mutation.UserName(); ok {
|
||||||
|
_spec.SetField(audit.FieldUserName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if auo.mutation.UserNameCleared() {
|
||||||
|
_spec.ClearField(audit.FieldUserName, field.TypeString)
|
||||||
|
}
|
||||||
|
if auo.mutation.UserCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: audit.UserTable,
|
||||||
|
Columns: []string{audit.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := auo.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: audit.UserTable,
|
||||||
|
Columns: []string{audit.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
|
_node = &Audit{config: auo.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, auo.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{audit.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
auo.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
1118
db/ent/client.go
Normal file
1118
db/ent/client.go
Normal file
File diff suppressed because it is too large
Load Diff
618
db/ent/ent.go
Normal file
618
db/ent/ent.go
Normal file
@ -0,0 +1,618 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/accesscontrol"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/role"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/todo"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ent aliases to avoid import conflicts in user's code.
|
||||||
|
type (
|
||||||
|
Op = ent.Op
|
||||||
|
Hook = ent.Hook
|
||||||
|
Value = ent.Value
|
||||||
|
Query = ent.Query
|
||||||
|
QueryContext = ent.QueryContext
|
||||||
|
Querier = ent.Querier
|
||||||
|
QuerierFunc = ent.QuerierFunc
|
||||||
|
Interceptor = ent.Interceptor
|
||||||
|
InterceptFunc = ent.InterceptFunc
|
||||||
|
Traverser = ent.Traverser
|
||||||
|
TraverseFunc = ent.TraverseFunc
|
||||||
|
Policy = ent.Policy
|
||||||
|
Mutator = ent.Mutator
|
||||||
|
Mutation = ent.Mutation
|
||||||
|
MutateFunc = ent.MutateFunc
|
||||||
|
)
|
||||||
|
|
||||||
|
type clientCtxKey struct{}
|
||||||
|
|
||||||
|
// FromContext returns a Client stored inside a context, or nil if there isn't one.
|
||||||
|
func FromContext(ctx context.Context) *Client {
|
||||||
|
c, _ := ctx.Value(clientCtxKey{}).(*Client)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewContext returns a new context with the given Client attached.
|
||||||
|
func NewContext(parent context.Context, c *Client) context.Context {
|
||||||
|
return context.WithValue(parent, clientCtxKey{}, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
type txCtxKey struct{}
|
||||||
|
|
||||||
|
// TxFromContext returns a Tx stored inside a context, or nil if there isn't one.
|
||||||
|
func TxFromContext(ctx context.Context) *Tx {
|
||||||
|
tx, _ := ctx.Value(txCtxKey{}).(*Tx)
|
||||||
|
return tx
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTxContext returns a new context with the given Tx attached.
|
||||||
|
func NewTxContext(parent context.Context, tx *Tx) context.Context {
|
||||||
|
return context.WithValue(parent, txCtxKey{}, tx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderFunc applies an ordering on the sql selector.
|
||||||
|
// Deprecated: Use Asc/Desc functions or the package builders instead.
|
||||||
|
type OrderFunc func(*sql.Selector)
|
||||||
|
|
||||||
|
var (
|
||||||
|
initCheck sync.Once
|
||||||
|
columnCheck sql.ColumnCheck
|
||||||
|
)
|
||||||
|
|
||||||
|
// checkColumn checks if the column exists in the given table.
|
||||||
|
func checkColumn(table, column string) error {
|
||||||
|
initCheck.Do(func() {
|
||||||
|
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||||
|
accesscontrol.Table: accesscontrol.ValidColumn,
|
||||||
|
audit.Table: audit.ValidColumn,
|
||||||
|
role.Table: role.ValidColumn,
|
||||||
|
todo.Table: todo.ValidColumn,
|
||||||
|
user.Table: user.ValidColumn,
|
||||||
|
usersession.Table: usersession.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
db/ent/enttest/enttest.go
Normal file
84
db/ent/enttest/enttest.go
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package enttest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"gitserver.in/patialtech/rano/db/ent"
|
||||||
|
// required by schema hooks.
|
||||||
|
_ "gitserver.in/patialtech/rano/db/ent/runtime"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/schema"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/migrate"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// TestingT is the interface that is shared between
|
||||||
|
// testing.T and testing.B and used by enttest.
|
||||||
|
TestingT interface {
|
||||||
|
FailNow()
|
||||||
|
Error(...any)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Option configures client creation.
|
||||||
|
Option func(*options)
|
||||||
|
|
||||||
|
options struct {
|
||||||
|
opts []ent.Option
|
||||||
|
migrateOpts []schema.MigrateOption
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// WithOptions forwards options to client creation.
|
||||||
|
func WithOptions(opts ...ent.Option) Option {
|
||||||
|
return func(o *options) {
|
||||||
|
o.opts = append(o.opts, opts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithMigrateOptions forwards options to auto migration.
|
||||||
|
func WithMigrateOptions(opts ...schema.MigrateOption) Option {
|
||||||
|
return func(o *options) {
|
||||||
|
o.migrateOpts = append(o.migrateOpts, opts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newOptions(opts []Option) *options {
|
||||||
|
o := &options{}
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(o)
|
||||||
|
}
|
||||||
|
return o
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open calls ent.Open and auto-run migration.
|
||||||
|
func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client {
|
||||||
|
o := newOptions(opts)
|
||||||
|
c, err := ent.Open(driverName, dataSourceName, o.opts...)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
migrateSchema(t, c, o)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClient calls ent.NewClient and auto-run migration.
|
||||||
|
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
||||||
|
o := newOptions(opts)
|
||||||
|
c := ent.NewClient(o.opts...)
|
||||||
|
migrateSchema(t, c, o)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
func migrateSchema(t TestingT, c *ent.Client, o *options) {
|
||||||
|
tables, err := schema.CopyTables(migrate.Tables)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
}
|
3
db/ent/generate.go
Normal file
3
db/ent/generate.go
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
package ent
|
||||||
|
|
||||||
|
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema
|
259
db/ent/hook/hook.go
Normal file
259
db/ent/hook/hook.go
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package hook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"gitserver.in/patialtech/rano/db/ent"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The AccessControlFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as AccessControl mutator.
|
||||||
|
type AccessControlFunc func(context.Context, *ent.AccessControlMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f AccessControlFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.AccessControlMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AccessControlMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The AuditFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as Audit mutator.
|
||||||
|
type AuditFunc func(context.Context, *ent.AuditMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f AuditFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.AuditMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuditMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The RoleFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as Role mutator.
|
||||||
|
type RoleFunc func(context.Context, *ent.RoleMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f RoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.RoleMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RoleMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The TodoFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as Todo mutator.
|
||||||
|
type TodoFunc func(context.Context, *ent.TodoMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f TodoFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.TodoMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.TodoMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The UserFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as User mutator.
|
||||||
|
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.UserMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The UserSessionFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as UserSession mutator.
|
||||||
|
type UserSessionFunc func(context.Context, *ent.UserSessionMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f UserSessionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.UserSessionMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserSessionMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Condition is a hook condition function.
|
||||||
|
type Condition func(context.Context, ent.Mutation) bool
|
||||||
|
|
||||||
|
// And groups conditions with the AND operator.
|
||||||
|
func And(first, second Condition, rest ...Condition) Condition {
|
||||||
|
return func(ctx context.Context, m ent.Mutation) bool {
|
||||||
|
if !first(ctx, m) || !second(ctx, m) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, cond := range rest {
|
||||||
|
if !cond(ctx, m) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups conditions with the OR operator.
|
||||||
|
func Or(first, second Condition, rest ...Condition) Condition {
|
||||||
|
return func(ctx context.Context, m ent.Mutation) bool {
|
||||||
|
if first(ctx, m) || second(ctx, m) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
for _, cond := range rest {
|
||||||
|
if cond(ctx, m) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not negates a given condition.
|
||||||
|
func Not(cond Condition) Condition {
|
||||||
|
return func(ctx context.Context, m ent.Mutation) bool {
|
||||||
|
return !cond(ctx, m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasOp is a condition testing mutation operation.
|
||||||
|
func HasOp(op ent.Op) Condition {
|
||||||
|
return func(_ context.Context, m ent.Mutation) bool {
|
||||||
|
return m.Op().Is(op)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasAddedFields is a condition validating `.AddedField` on fields.
|
||||||
|
func HasAddedFields(field string, fields ...string) Condition {
|
||||||
|
return func(_ context.Context, m ent.Mutation) bool {
|
||||||
|
if _, exists := m.AddedField(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, field := range fields {
|
||||||
|
if _, exists := m.AddedField(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasClearedFields is a condition validating `.FieldCleared` on fields.
|
||||||
|
func HasClearedFields(field string, fields ...string) Condition {
|
||||||
|
return func(_ context.Context, m ent.Mutation) bool {
|
||||||
|
if exists := m.FieldCleared(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, field := range fields {
|
||||||
|
if exists := m.FieldCleared(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasFields is a condition validating `.Field` on fields.
|
||||||
|
func HasFields(field string, fields ...string) Condition {
|
||||||
|
return func(_ context.Context, m ent.Mutation) bool {
|
||||||
|
if _, exists := m.Field(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, field := range fields {
|
||||||
|
if _, exists := m.Field(field); !exists {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If executes the given hook under condition.
|
||||||
|
//
|
||||||
|
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||||
|
func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||||
|
return func(next ent.Mutator) ent.Mutator {
|
||||||
|
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if cond(ctx, m) {
|
||||||
|
return hk(next).Mutate(ctx, m)
|
||||||
|
}
|
||||||
|
return next.Mutate(ctx, m)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// On executes the given hook only for the given operation.
|
||||||
|
//
|
||||||
|
// hook.On(Log, ent.Delete|ent.Create)
|
||||||
|
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||||
|
return If(hk, HasOp(op))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unless skips the given hook only for the given operation.
|
||||||
|
//
|
||||||
|
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
||||||
|
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
||||||
|
return If(hk, Not(HasOp(op)))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FixedError is a hook returning a fixed error.
|
||||||
|
func FixedError(err error) ent.Hook {
|
||||||
|
return func(ent.Mutator) ent.Mutator {
|
||||||
|
return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) {
|
||||||
|
return nil, err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject returns a hook that rejects all operations that match op.
|
||||||
|
//
|
||||||
|
// func (T) Hooks() []ent.Hook {
|
||||||
|
// return []ent.Hook{
|
||||||
|
// Reject(ent.Delete|ent.Update),
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
func Reject(op ent.Op) ent.Hook {
|
||||||
|
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
||||||
|
return On(hk, op)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Chain acts as a list of hooks and is effectively immutable.
|
||||||
|
// Once created, it will always hold the same set of hooks in the same order.
|
||||||
|
type Chain struct {
|
||||||
|
hooks []ent.Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewChain creates a new chain of hooks.
|
||||||
|
func NewChain(hooks ...ent.Hook) Chain {
|
||||||
|
return Chain{append([]ent.Hook(nil), hooks...)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook chains the list of hooks and returns the final hook.
|
||||||
|
func (c Chain) Hook() ent.Hook {
|
||||||
|
return func(mutator ent.Mutator) ent.Mutator {
|
||||||
|
for i := len(c.hooks) - 1; i >= 0; i-- {
|
||||||
|
mutator = c.hooks[i](mutator)
|
||||||
|
}
|
||||||
|
return mutator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append extends a chain, adding the specified hook
|
||||||
|
// as the last ones in the mutation flow.
|
||||||
|
func (c Chain) Append(hooks ...ent.Hook) Chain {
|
||||||
|
newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks))
|
||||||
|
newHooks = append(newHooks, c.hooks...)
|
||||||
|
newHooks = append(newHooks, hooks...)
|
||||||
|
return Chain{newHooks}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extend extends a chain, adding the specified chain
|
||||||
|
// as the last ones in the mutation flow.
|
||||||
|
func (c Chain) Extend(chain Chain) Chain {
|
||||||
|
return c.Append(chain.hooks...)
|
||||||
|
}
|
64
db/ent/migrate/migrate.go
Normal file
64
db/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...)
|
||||||
|
}
|
203
db/ent/migrate/schema.go
Normal file
203
db/ent/migrate/schema.go
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package migrate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/dialect/sql/schema"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AccessControlsColumns holds the columns for the "access_controls" table.
|
||||||
|
AccessControlsColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
|
{Name: "updated_at", Type: field.TypeTime},
|
||||||
|
{Name: "ptype", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "v0", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "v1", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "v2", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "v3", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "v4", Type: field.TypeString, Default: ""},
|
||||||
|
{Name: "v5", Type: field.TypeString, Default: ""},
|
||||||
|
}
|
||||||
|
// AccessControlsTable holds the schema information for the "access_controls" table.
|
||||||
|
AccessControlsTable = &schema.Table{
|
||||||
|
Name: "access_controls",
|
||||||
|
Columns: AccessControlsColumns,
|
||||||
|
PrimaryKey: []*schema.Column{AccessControlsColumns[0]},
|
||||||
|
}
|
||||||
|
// AuditsColumns holds the columns for the "audits" table.
|
||||||
|
AuditsColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
|
{Name: "ent_name", Type: field.TypeString, Size: 50},
|
||||||
|
{Name: "ent_id", Type: field.TypeInt64},
|
||||||
|
{Name: "operation", Type: field.TypeEnum, Enums: []string{"Create", "Update", "UpdateOne", "Delete", "DeleteOne"}},
|
||||||
|
{Name: "description", Type: field.TypeString, Size: 1000},
|
||||||
|
{Name: "ip", Type: field.TypeString, Nullable: true, Size: 40},
|
||||||
|
{Name: "user_name", Type: field.TypeString, Nullable: true, Size: 150},
|
||||||
|
{Name: "user_id", Type: field.TypeInt64, Nullable: true},
|
||||||
|
}
|
||||||
|
// AuditsTable holds the schema information for the "audits" table.
|
||||||
|
AuditsTable = &schema.Table{
|
||||||
|
Name: "audits",
|
||||||
|
Columns: AuditsColumns,
|
||||||
|
PrimaryKey: []*schema.Column{AuditsColumns[0]},
|
||||||
|
ForeignKeys: []*schema.ForeignKey{
|
||||||
|
{
|
||||||
|
Symbol: "audits_users_audit_logs",
|
||||||
|
Columns: []*schema.Column{AuditsColumns[8]},
|
||||||
|
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||||
|
OnDelete: schema.SetNull,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Indexes: []*schema.Index{
|
||||||
|
{
|
||||||
|
Name: "audit_ent_name_ent_id",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{AuditsColumns[2], AuditsColumns[3]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "audit_operation",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{AuditsColumns[4]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "audit_ip",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{AuditsColumns[6]},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// RolesColumns holds the columns for the "roles" table.
|
||||||
|
RolesColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
|
{Name: "name", Type: field.TypeString},
|
||||||
|
}
|
||||||
|
// RolesTable holds the schema information for the "roles" table.
|
||||||
|
RolesTable = &schema.Table{
|
||||||
|
Name: "roles",
|
||||||
|
Columns: RolesColumns,
|
||||||
|
PrimaryKey: []*schema.Column{RolesColumns[0]},
|
||||||
|
}
|
||||||
|
// TodosColumns holds the columns for the "todos" table.
|
||||||
|
TodosColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt, Increment: true},
|
||||||
|
}
|
||||||
|
// TodosTable holds the schema information for the "todos" table.
|
||||||
|
TodosTable = &schema.Table{
|
||||||
|
Name: "todos",
|
||||||
|
Columns: TodosColumns,
|
||||||
|
PrimaryKey: []*schema.Column{TodosColumns[0]},
|
||||||
|
}
|
||||||
|
// UsersColumns holds the columns for the "users" table.
|
||||||
|
UsersColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
|
{Name: "updated_at", Type: field.TypeTime},
|
||||||
|
{Name: "email", Type: field.TypeString, Unique: true},
|
||||||
|
{Name: "email_verified", Type: field.TypeBool, Default: false},
|
||||||
|
{Name: "phone", Type: field.TypeString, Size: 20},
|
||||||
|
{Name: "phone_verified", Type: field.TypeBool, Default: false},
|
||||||
|
{Name: "pwd_salt", Type: field.TypeString},
|
||||||
|
{Name: "pwd_hash", Type: field.TypeString},
|
||||||
|
{Name: "login_failed_count", Type: field.TypeUint8, Nullable: true, Default: 0},
|
||||||
|
{Name: "login_attempt_on", Type: field.TypeTime, Nullable: true},
|
||||||
|
{Name: "login_locked_until", Type: field.TypeTime, Nullable: true},
|
||||||
|
{Name: "first_name", Type: field.TypeString, Size: 30},
|
||||||
|
{Name: "middle_name", Type: field.TypeString, Size: 30},
|
||||||
|
{Name: "last_name", Type: field.TypeString, Size: 30},
|
||||||
|
{Name: "status", Type: field.TypeEnum, Enums: []string{"Pending", "Active", "InActive"}, Default: "Pending"},
|
||||||
|
}
|
||||||
|
// UsersTable holds the schema information for the "users" table.
|
||||||
|
UsersTable = &schema.Table{
|
||||||
|
Name: "users",
|
||||||
|
Columns: UsersColumns,
|
||||||
|
PrimaryKey: []*schema.Column{UsersColumns[0]},
|
||||||
|
Indexes: []*schema.Index{
|
||||||
|
{
|
||||||
|
Name: "user_created_at",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{UsersColumns[1]},
|
||||||
|
Annotation: &entsql.IndexAnnotation{
|
||||||
|
Desc: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "user_updated_at",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{UsersColumns[2]},
|
||||||
|
Annotation: &entsql.IndexAnnotation{
|
||||||
|
Desc: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "user_phone",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{UsersColumns[5]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "user_status",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{UsersColumns[15]},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// UserSessionsColumns holds the columns for the "user_sessions" table.
|
||||||
|
UserSessionsColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||||
|
{Name: "issued_at", Type: field.TypeTime},
|
||||||
|
{Name: "expires_at", Type: field.TypeTime},
|
||||||
|
{Name: "invalidated", Type: field.TypeBool, Nullable: true, Default: false},
|
||||||
|
{Name: "user_agent", Type: field.TypeString, Size: 50},
|
||||||
|
{Name: "ip", Type: field.TypeString, Size: 40},
|
||||||
|
{Name: "user_id", Type: field.TypeInt64},
|
||||||
|
}
|
||||||
|
// UserSessionsTable holds the schema information for the "user_sessions" table.
|
||||||
|
UserSessionsTable = &schema.Table{
|
||||||
|
Name: "user_sessions",
|
||||||
|
Columns: UserSessionsColumns,
|
||||||
|
PrimaryKey: []*schema.Column{UserSessionsColumns[0]},
|
||||||
|
ForeignKeys: []*schema.ForeignKey{
|
||||||
|
{
|
||||||
|
Symbol: "user_sessions_users_sessions",
|
||||||
|
Columns: []*schema.Column{UserSessionsColumns[6]},
|
||||||
|
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||||
|
OnDelete: schema.NoAction,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Indexes: []*schema.Index{
|
||||||
|
{
|
||||||
|
Name: "usersession_expires_at",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{UserSessionsColumns[2]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "usersession_invalidated",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{UserSessionsColumns[3]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "usersession_ip",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{UserSessionsColumns[5]},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// Tables holds all the tables in the schema.
|
||||||
|
Tables = []*schema.Table{
|
||||||
|
AccessControlsTable,
|
||||||
|
AuditsTable,
|
||||||
|
RolesTable,
|
||||||
|
TodosTable,
|
||||||
|
UsersTable,
|
||||||
|
UserSessionsTable,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
AuditsTable.ForeignKeys[0].RefTable = UsersTable
|
||||||
|
UserSessionsTable.ForeignKeys[0].RefTable = UsersTable
|
||||||
|
}
|
4195
db/ent/mutation.go
Normal file
4195
db/ent/mutation.go
Normal file
File diff suppressed because it is too large
Load Diff
25
db/ent/predicate/predicate.go
Normal file
25
db/ent/predicate/predicate.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package predicate
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessControl is the predicate function for accesscontrol builders.
|
||||||
|
type AccessControl func(*sql.Selector)
|
||||||
|
|
||||||
|
// Audit is the predicate function for audit builders.
|
||||||
|
type Audit func(*sql.Selector)
|
||||||
|
|
||||||
|
// Role is the predicate function for role builders.
|
||||||
|
type Role func(*sql.Selector)
|
||||||
|
|
||||||
|
// Todo is the predicate function for todo builders.
|
||||||
|
type Todo func(*sql.Selector)
|
||||||
|
|
||||||
|
// User is the predicate function for user builders.
|
||||||
|
type User func(*sql.Selector)
|
||||||
|
|
||||||
|
// UserSession is the predicate function for usersession builders.
|
||||||
|
type UserSession func(*sql.Selector)
|
103
db/ent/role.go
Normal file
103
db/ent/role.go
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/role"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Role is the model entity for the Role schema.
|
||||||
|
type Role struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int64 `json:"id,omitempty"`
|
||||||
|
// Name holds the value of the "name" field.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*Role) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case role.FieldID:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case role.FieldName:
|
||||||
|
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 Role fields.
|
||||||
|
func (r *Role) 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 role.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
r.ID = int64(value.Int64)
|
||||||
|
case role.FieldName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
r.Name = value.String
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
r.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the Role.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (r *Role) Value(name string) (ent.Value, error) {
|
||||||
|
return r.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this Role.
|
||||||
|
// Note that you need to call Role.Unwrap() before calling this method if this Role
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (r *Role) Update() *RoleUpdateOne {
|
||||||
|
return NewRoleClient(r.config).UpdateOne(r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the Role 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 (r *Role) Unwrap() *Role {
|
||||||
|
_tx, ok := r.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: Role is not a transactional entity")
|
||||||
|
}
|
||||||
|
r.config.driver = _tx.drv
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (r *Role) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("Role(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", r.ID))
|
||||||
|
builder.WriteString("name=")
|
||||||
|
builder.WriteString(r.Name)
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Roles is a parsable slice of Role.
|
||||||
|
type Roles []*Role
|
47
db/ent/role/role.go
Normal file
47
db/ent/role/role.go
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package role
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the role type in the database.
|
||||||
|
Label = "role"
|
||||||
|
// 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"
|
||||||
|
// Table holds the table name of the role in the database.
|
||||||
|
Table = "roles"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for role fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldName,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 Role 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()
|
||||||
|
}
|
138
db/ent/role/where.go
Normal file
138
db/ent/role/where.go
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package role
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int64) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||||
|
func Name(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEQ applies the EQ predicate on the "name" field.
|
||||||
|
func NameEQ(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||||
|
func NameNEQ(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldNEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameIn applies the In predicate on the "name" field.
|
||||||
|
func NameIn(vs ...string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||||
|
func NameNotIn(vs ...string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldNotIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGT applies the GT predicate on the "name" field.
|
||||||
|
func NameGT(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldGT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGTE applies the GTE predicate on the "name" field.
|
||||||
|
func NameGTE(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldGTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLT applies the LT predicate on the "name" field.
|
||||||
|
func NameLT(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldLT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLTE applies the LTE predicate on the "name" field.
|
||||||
|
func NameLTE(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldLTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContains applies the Contains predicate on the "name" field.
|
||||||
|
func NameContains(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldContains(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||||
|
func NameHasPrefix(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldHasPrefix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||||
|
func NameHasSuffix(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldHasSuffix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||||
|
func NameEqualFold(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldEqualFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||||
|
func NameContainsFold(v string) predicate.Role {
|
||||||
|
return predicate.Role(sql.FieldContainsFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.Role) predicate.Role {
|
||||||
|
return predicate.Role(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.Role) predicate.Role {
|
||||||
|
return predicate.Role(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.Role) predicate.Role {
|
||||||
|
return predicate.Role(sql.NotPredicates(p))
|
||||||
|
}
|
195
db/ent/role_create.go
Normal file
195
db/ent/role_create.go
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/role"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoleCreate is the builder for creating a Role entity.
|
||||||
|
type RoleCreate struct {
|
||||||
|
config
|
||||||
|
mutation *RoleMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (rc *RoleCreate) SetName(s string) *RoleCreate {
|
||||||
|
rc.mutation.SetName(s)
|
||||||
|
return rc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets the "id" field.
|
||||||
|
func (rc *RoleCreate) SetID(i int64) *RoleCreate {
|
||||||
|
rc.mutation.SetID(i)
|
||||||
|
return rc
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the RoleMutation object of the builder.
|
||||||
|
func (rc *RoleCreate) Mutation() *RoleMutation {
|
||||||
|
return rc.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Role in the database.
|
||||||
|
func (rc *RoleCreate) Save(ctx context.Context) (*Role, error) {
|
||||||
|
return withHooks(ctx, rc.sqlSave, rc.mutation, rc.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (rc *RoleCreate) SaveX(ctx context.Context) *Role {
|
||||||
|
v, err := rc.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (rc *RoleCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := rc.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rc *RoleCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := rc.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (rc *RoleCreate) check() error {
|
||||||
|
if _, ok := rc.mutation.Name(); !ok {
|
||||||
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Role.name"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rc *RoleCreate) sqlSave(ctx context.Context) (*Role, error) {
|
||||||
|
if err := rc.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := rc.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, rc.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if _spec.ID.Value != _node.ID {
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int64(id)
|
||||||
|
}
|
||||||
|
rc.mutation.id = &_node.ID
|
||||||
|
rc.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rc *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &Role{config: rc.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(role.Table, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64))
|
||||||
|
)
|
||||||
|
if id, ok := rc.mutation.ID(); ok {
|
||||||
|
_node.ID = id
|
||||||
|
_spec.ID.Value = id
|
||||||
|
}
|
||||||
|
if value, ok := rc.mutation.Name(); ok {
|
||||||
|
_spec.SetField(role.FieldName, field.TypeString, value)
|
||||||
|
_node.Name = value
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleCreateBulk is the builder for creating many Role entities in bulk.
|
||||||
|
type RoleCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*RoleCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Role entities in the database.
|
||||||
|
func (rcb *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error) {
|
||||||
|
if rcb.err != nil {
|
||||||
|
return nil, rcb.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(rcb.builders))
|
||||||
|
nodes := make([]*Role, len(rcb.builders))
|
||||||
|
mutators := make([]Mutator, len(rcb.builders))
|
||||||
|
for i := range rcb.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := rcb.builders[i]
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*RoleMutation)
|
||||||
|
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, rcb.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, rcb.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 && nodes[i].ID == 0 {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int64(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, rcb.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (rcb *RoleCreateBulk) SaveX(ctx context.Context) []*Role {
|
||||||
|
v, err := rcb.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (rcb *RoleCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := rcb.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rcb *RoleCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := rcb.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
88
db/ent/role_delete.go
Normal file
88
db/ent/role_delete.go
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/role"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoleDelete is the builder for deleting a Role entity.
|
||||||
|
type RoleDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *RoleMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the RoleDelete builder.
|
||||||
|
func (rd *RoleDelete) Where(ps ...predicate.Role) *RoleDelete {
|
||||||
|
rd.mutation.Where(ps...)
|
||||||
|
return rd
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (rd *RoleDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, rd.sqlExec, rd.mutation, rd.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rd *RoleDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := rd.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rd *RoleDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(role.Table, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64))
|
||||||
|
if ps := rd.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, rd.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
rd.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleDeleteOne is the builder for deleting a single Role entity.
|
||||||
|
type RoleDeleteOne struct {
|
||||||
|
rd *RoleDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the RoleDelete builder.
|
||||||
|
func (rdo *RoleDeleteOne) Where(ps ...predicate.Role) *RoleDeleteOne {
|
||||||
|
rdo.rd.mutation.Where(ps...)
|
||||||
|
return rdo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (rdo *RoleDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := rdo.rd.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{role.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (rdo *RoleDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := rdo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
527
db/ent/role_query.go
Normal file
527
db/ent/role_query.go
Normal file
@ -0,0 +1,527 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/role"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoleQuery is the builder for querying Role entities.
|
||||||
|
type RoleQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []role.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.Role
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the RoleQuery builder.
|
||||||
|
func (rq *RoleQuery) Where(ps ...predicate.Role) *RoleQuery {
|
||||||
|
rq.predicates = append(rq.predicates, ps...)
|
||||||
|
return rq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (rq *RoleQuery) Limit(limit int) *RoleQuery {
|
||||||
|
rq.ctx.Limit = &limit
|
||||||
|
return rq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (rq *RoleQuery) Offset(offset int) *RoleQuery {
|
||||||
|
rq.ctx.Offset = &offset
|
||||||
|
return rq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (rq *RoleQuery) Unique(unique bool) *RoleQuery {
|
||||||
|
rq.ctx.Unique = &unique
|
||||||
|
return rq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (rq *RoleQuery) Order(o ...role.OrderOption) *RoleQuery {
|
||||||
|
rq.order = append(rq.order, o...)
|
||||||
|
return rq
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first Role entity from the query.
|
||||||
|
// Returns a *NotFoundError when no Role was found.
|
||||||
|
func (rq *RoleQuery) First(ctx context.Context) (*Role, error) {
|
||||||
|
nodes, err := rq.Limit(1).All(setContextOp(ctx, rq.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{role.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (rq *RoleQuery) FirstX(ctx context.Context) *Role {
|
||||||
|
node, err := rq.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first Role ID from the query.
|
||||||
|
// Returns a *NotFoundError when no Role ID was found.
|
||||||
|
func (rq *RoleQuery) FirstID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = rq.Limit(1).IDs(setContextOp(ctx, rq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{role.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (rq *RoleQuery) FirstIDX(ctx context.Context) int64 {
|
||||||
|
id, err := rq.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single Role entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one Role entity is found.
|
||||||
|
// Returns a *NotFoundError when no Role entities are found.
|
||||||
|
func (rq *RoleQuery) Only(ctx context.Context) (*Role, error) {
|
||||||
|
nodes, err := rq.Limit(2).All(setContextOp(ctx, rq.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{role.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{role.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (rq *RoleQuery) OnlyX(ctx context.Context) *Role {
|
||||||
|
node, err := rq.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only Role ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one Role ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (rq *RoleQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = rq.Limit(2).IDs(setContextOp(ctx, rq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{role.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{role.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (rq *RoleQuery) OnlyIDX(ctx context.Context) int64 {
|
||||||
|
id, err := rq.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of Roles.
|
||||||
|
func (rq *RoleQuery) All(ctx context.Context) ([]*Role, error) {
|
||||||
|
ctx = setContextOp(ctx, rq.ctx, ent.OpQueryAll)
|
||||||
|
if err := rq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*Role, *RoleQuery]()
|
||||||
|
return withInterceptors[[]*Role](ctx, rq, qr, rq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (rq *RoleQuery) AllX(ctx context.Context) []*Role {
|
||||||
|
nodes, err := rq.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of Role IDs.
|
||||||
|
func (rq *RoleQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
||||||
|
if rq.ctx.Unique == nil && rq.path != nil {
|
||||||
|
rq.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, rq.ctx, ent.OpQueryIDs)
|
||||||
|
if err = rq.Select(role.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (rq *RoleQuery) IDsX(ctx context.Context) []int64 {
|
||||||
|
ids, err := rq.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (rq *RoleQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, rq.ctx, ent.OpQueryCount)
|
||||||
|
if err := rq.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, rq, querierCount[*RoleQuery](), rq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (rq *RoleQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := rq.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (rq *RoleQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, rq.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := rq.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 (rq *RoleQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := rq.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the RoleQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (rq *RoleQuery) Clone() *RoleQuery {
|
||||||
|
if rq == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &RoleQuery{
|
||||||
|
config: rq.config,
|
||||||
|
ctx: rq.ctx.Clone(),
|
||||||
|
order: append([]role.OrderOption{}, rq.order...),
|
||||||
|
inters: append([]Interceptor{}, rq.inters...),
|
||||||
|
predicates: append([]predicate.Role{}, rq.predicates...),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: rq.sql.Clone(),
|
||||||
|
path: rq.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.Role.Query().
|
||||||
|
// GroupBy(role.FieldName).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (rq *RoleQuery) GroupBy(field string, fields ...string) *RoleGroupBy {
|
||||||
|
rq.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &RoleGroupBy{build: rq}
|
||||||
|
grbuild.flds = &rq.ctx.Fields
|
||||||
|
grbuild.label = role.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.Role.Query().
|
||||||
|
// Select(role.FieldName).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (rq *RoleQuery) Select(fields ...string) *RoleSelect {
|
||||||
|
rq.ctx.Fields = append(rq.ctx.Fields, fields...)
|
||||||
|
sbuild := &RoleSelect{RoleQuery: rq}
|
||||||
|
sbuild.label = role.Label
|
||||||
|
sbuild.flds, sbuild.scan = &rq.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a RoleSelect configured with the given aggregations.
|
||||||
|
func (rq *RoleQuery) Aggregate(fns ...AggregateFunc) *RoleSelect {
|
||||||
|
return rq.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rq *RoleQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range rq.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, rq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range rq.ctx.Fields {
|
||||||
|
if !role.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if rq.path != nil {
|
||||||
|
prev, err := rq.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rq.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rq *RoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Role, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*Role{}
|
||||||
|
_spec = rq.querySpec()
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Role).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &Role{config: rq.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, rq.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rq *RoleQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := rq.querySpec()
|
||||||
|
_spec.Node.Columns = rq.ctx.Fields
|
||||||
|
if len(rq.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = rq.ctx.Unique != nil && *rq.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, rq.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rq *RoleQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64))
|
||||||
|
_spec.From = rq.sql
|
||||||
|
if unique := rq.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if rq.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := rq.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, role.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != role.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := rq.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := rq.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := rq.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := rq.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rq *RoleQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(rq.driver.Dialect())
|
||||||
|
t1 := builder.Table(role.Table)
|
||||||
|
columns := rq.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = role.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if rq.sql != nil {
|
||||||
|
selector = rq.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if rq.ctx.Unique != nil && *rq.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range rq.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range rq.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := rq.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 := rq.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleGroupBy is the group-by builder for Role entities.
|
||||||
|
type RoleGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *RoleQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (rgb *RoleGroupBy) Aggregate(fns ...AggregateFunc) *RoleGroupBy {
|
||||||
|
rgb.fns = append(rgb.fns, fns...)
|
||||||
|
return rgb
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (rgb *RoleGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, rgb.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := rgb.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*RoleQuery, *RoleGroupBy](ctx, rgb.build, rgb, rgb.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rgb *RoleGroupBy) sqlScan(ctx context.Context, root *RoleQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(rgb.fns))
|
||||||
|
for _, fn := range rgb.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*rgb.flds)+len(rgb.fns))
|
||||||
|
for _, f := range *rgb.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*rgb.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := rgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleSelect is the builder for selecting fields of Role entities.
|
||||||
|
type RoleSelect struct {
|
||||||
|
*RoleQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (rs *RoleSelect) Aggregate(fns ...AggregateFunc) *RoleSelect {
|
||||||
|
rs.fns = append(rs.fns, fns...)
|
||||||
|
return rs
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (rs *RoleSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, rs.ctx, ent.OpQuerySelect)
|
||||||
|
if err := rs.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*RoleQuery, *RoleSelect](ctx, rs.RoleQuery, rs, rs.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rs *RoleSelect) sqlScan(ctx context.Context, root *RoleQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(rs.fns))
|
||||||
|
for _, fn := range rs.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*rs.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 := rs.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
209
db/ent/role_update.go
Normal file
209
db/ent/role_update.go
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/role"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoleUpdate is the builder for updating Role entities.
|
||||||
|
type RoleUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *RoleMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the RoleUpdate builder.
|
||||||
|
func (ru *RoleUpdate) Where(ps ...predicate.Role) *RoleUpdate {
|
||||||
|
ru.mutation.Where(ps...)
|
||||||
|
return ru
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (ru *RoleUpdate) SetName(s string) *RoleUpdate {
|
||||||
|
ru.mutation.SetName(s)
|
||||||
|
return ru
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (ru *RoleUpdate) SetNillableName(s *string) *RoleUpdate {
|
||||||
|
if s != nil {
|
||||||
|
ru.SetName(*s)
|
||||||
|
}
|
||||||
|
return ru
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the RoleMutation object of the builder.
|
||||||
|
func (ru *RoleUpdate) Mutation() *RoleMutation {
|
||||||
|
return ru.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (ru *RoleUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, ru.sqlSave, ru.mutation, ru.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (ru *RoleUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := ru.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (ru *RoleUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := ru.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ru *RoleUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := ru.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64))
|
||||||
|
if ps := ru.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := ru.mutation.Name(); ok {
|
||||||
|
_spec.SetField(role.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if n, err = sqlgraph.UpdateNodes(ctx, ru.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{role.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
ru.mutation.done = true
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RoleUpdateOne is the builder for updating a single Role entity.
|
||||||
|
type RoleUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *RoleMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (ruo *RoleUpdateOne) SetName(s string) *RoleUpdateOne {
|
||||||
|
ruo.mutation.SetName(s)
|
||||||
|
return ruo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (ruo *RoleUpdateOne) SetNillableName(s *string) *RoleUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
ruo.SetName(*s)
|
||||||
|
}
|
||||||
|
return ruo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the RoleMutation object of the builder.
|
||||||
|
func (ruo *RoleUpdateOne) Mutation() *RoleMutation {
|
||||||
|
return ruo.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the RoleUpdate builder.
|
||||||
|
func (ruo *RoleUpdateOne) Where(ps ...predicate.Role) *RoleUpdateOne {
|
||||||
|
ruo.mutation.Where(ps...)
|
||||||
|
return ruo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (ruo *RoleUpdateOne) Select(field string, fields ...string) *RoleUpdateOne {
|
||||||
|
ruo.fields = append([]string{field}, fields...)
|
||||||
|
return ruo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated Role entity.
|
||||||
|
func (ruo *RoleUpdateOne) Save(ctx context.Context) (*Role, error) {
|
||||||
|
return withHooks(ctx, ruo.sqlSave, ruo.mutation, ruo.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (ruo *RoleUpdateOne) SaveX(ctx context.Context) *Role {
|
||||||
|
node, err := ruo.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (ruo *RoleUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := ruo.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ruo *RoleUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := ruo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64))
|
||||||
|
id, ok := ruo.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Role.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := ruo.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, role.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !role.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != role.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := ruo.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := ruo.mutation.Name(); ok {
|
||||||
|
_spec.SetField(role.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
_node = &Role{config: ruo.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, ruo.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{role.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ruo.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
151
db/ent/runtime.go
Normal file
151
db/ent/runtime.go
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/accesscontrol"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/schema"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 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() {
|
||||||
|
accesscontrolFields := schema.AccessControl{}.Fields()
|
||||||
|
_ = accesscontrolFields
|
||||||
|
// accesscontrolDescCreatedAt is the schema descriptor for created_at field.
|
||||||
|
accesscontrolDescCreatedAt := accesscontrolFields[1].Descriptor()
|
||||||
|
// accesscontrol.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||||
|
accesscontrol.DefaultCreatedAt = accesscontrolDescCreatedAt.Default.(func() time.Time)
|
||||||
|
// accesscontrolDescUpdatedAt is the schema descriptor for updated_at field.
|
||||||
|
accesscontrolDescUpdatedAt := accesscontrolFields[2].Descriptor()
|
||||||
|
// accesscontrol.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||||
|
accesscontrol.DefaultUpdatedAt = accesscontrolDescUpdatedAt.Default.(func() time.Time)
|
||||||
|
// accesscontrol.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||||
|
accesscontrol.UpdateDefaultUpdatedAt = accesscontrolDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||||
|
// accesscontrolDescPtype is the schema descriptor for ptype field.
|
||||||
|
accesscontrolDescPtype := accesscontrolFields[3].Descriptor()
|
||||||
|
// accesscontrol.DefaultPtype holds the default value on creation for the ptype field.
|
||||||
|
accesscontrol.DefaultPtype = accesscontrolDescPtype.Default.(string)
|
||||||
|
// accesscontrolDescV0 is the schema descriptor for v0 field.
|
||||||
|
accesscontrolDescV0 := accesscontrolFields[4].Descriptor()
|
||||||
|
// accesscontrol.DefaultV0 holds the default value on creation for the v0 field.
|
||||||
|
accesscontrol.DefaultV0 = accesscontrolDescV0.Default.(string)
|
||||||
|
// accesscontrolDescV1 is the schema descriptor for v1 field.
|
||||||
|
accesscontrolDescV1 := accesscontrolFields[5].Descriptor()
|
||||||
|
// accesscontrol.DefaultV1 holds the default value on creation for the v1 field.
|
||||||
|
accesscontrol.DefaultV1 = accesscontrolDescV1.Default.(string)
|
||||||
|
// accesscontrolDescV2 is the schema descriptor for v2 field.
|
||||||
|
accesscontrolDescV2 := accesscontrolFields[6].Descriptor()
|
||||||
|
// accesscontrol.DefaultV2 holds the default value on creation for the v2 field.
|
||||||
|
accesscontrol.DefaultV2 = accesscontrolDescV2.Default.(string)
|
||||||
|
// accesscontrolDescV3 is the schema descriptor for v3 field.
|
||||||
|
accesscontrolDescV3 := accesscontrolFields[7].Descriptor()
|
||||||
|
// accesscontrol.DefaultV3 holds the default value on creation for the v3 field.
|
||||||
|
accesscontrol.DefaultV3 = accesscontrolDescV3.Default.(string)
|
||||||
|
// accesscontrolDescV4 is the schema descriptor for v4 field.
|
||||||
|
accesscontrolDescV4 := accesscontrolFields[8].Descriptor()
|
||||||
|
// accesscontrol.DefaultV4 holds the default value on creation for the v4 field.
|
||||||
|
accesscontrol.DefaultV4 = accesscontrolDescV4.Default.(string)
|
||||||
|
// accesscontrolDescV5 is the schema descriptor for v5 field.
|
||||||
|
accesscontrolDescV5 := accesscontrolFields[9].Descriptor()
|
||||||
|
// accesscontrol.DefaultV5 holds the default value on creation for the v5 field.
|
||||||
|
accesscontrol.DefaultV5 = accesscontrolDescV5.Default.(string)
|
||||||
|
auditFields := schema.Audit{}.Fields()
|
||||||
|
_ = auditFields
|
||||||
|
// auditDescCreatedAt is the schema descriptor for created_at field.
|
||||||
|
auditDescCreatedAt := auditFields[1].Descriptor()
|
||||||
|
// audit.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||||
|
audit.DefaultCreatedAt = auditDescCreatedAt.Default.(func() time.Time)
|
||||||
|
// auditDescEntName is the schema descriptor for ent_name field.
|
||||||
|
auditDescEntName := auditFields[2].Descriptor()
|
||||||
|
// audit.EntNameValidator is a validator for the "ent_name" field. It is called by the builders before save.
|
||||||
|
audit.EntNameValidator = auditDescEntName.Validators[0].(func(string) error)
|
||||||
|
// auditDescEntID is the schema descriptor for ent_id field.
|
||||||
|
auditDescEntID := auditFields[3].Descriptor()
|
||||||
|
// audit.EntIDValidator is a validator for the "ent_id" field. It is called by the builders before save.
|
||||||
|
audit.EntIDValidator = auditDescEntID.Validators[0].(func(int64) error)
|
||||||
|
// auditDescDescription is the schema descriptor for description field.
|
||||||
|
auditDescDescription := auditFields[5].Descriptor()
|
||||||
|
// audit.DescriptionValidator is a validator for the "description" field. It is called by the builders before save.
|
||||||
|
audit.DescriptionValidator = auditDescDescription.Validators[0].(func(string) error)
|
||||||
|
// auditDescIP is the schema descriptor for ip field.
|
||||||
|
auditDescIP := auditFields[6].Descriptor()
|
||||||
|
// audit.IPValidator is a validator for the "ip" field. It is called by the builders before save.
|
||||||
|
audit.IPValidator = auditDescIP.Validators[0].(func(string) error)
|
||||||
|
// auditDescUserName is the schema descriptor for user_name field.
|
||||||
|
auditDescUserName := auditFields[7].Descriptor()
|
||||||
|
// audit.UserNameValidator is a validator for the "user_name" field. It is called by the builders before save.
|
||||||
|
audit.UserNameValidator = auditDescUserName.Validators[0].(func(string) error)
|
||||||
|
userFields := schema.User{}.Fields()
|
||||||
|
_ = userFields
|
||||||
|
// userDescCreatedAt is the schema descriptor for created_at field.
|
||||||
|
userDescCreatedAt := userFields[1].Descriptor()
|
||||||
|
// user.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||||
|
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
|
||||||
|
// userDescUpdatedAt is the schema descriptor for updated_at field.
|
||||||
|
userDescUpdatedAt := userFields[2].Descriptor()
|
||||||
|
// user.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||||
|
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
|
||||||
|
// user.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||||
|
user.UpdateDefaultUpdatedAt = userDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||||
|
// userDescEmail is the schema descriptor for email field.
|
||||||
|
userDescEmail := userFields[3].Descriptor()
|
||||||
|
// user.EmailValidator is a validator for the "email" field. It is called by the builders before save.
|
||||||
|
user.EmailValidator = userDescEmail.Validators[0].(func(string) error)
|
||||||
|
// userDescEmailVerified is the schema descriptor for email_verified field.
|
||||||
|
userDescEmailVerified := userFields[4].Descriptor()
|
||||||
|
// user.DefaultEmailVerified holds the default value on creation for the email_verified field.
|
||||||
|
user.DefaultEmailVerified = userDescEmailVerified.Default.(bool)
|
||||||
|
// userDescPhone is the schema descriptor for phone field.
|
||||||
|
userDescPhone := userFields[5].Descriptor()
|
||||||
|
// user.PhoneValidator is a validator for the "phone" field. It is called by the builders before save.
|
||||||
|
user.PhoneValidator = userDescPhone.Validators[0].(func(string) error)
|
||||||
|
// userDescPhoneVerified is the schema descriptor for phone_verified field.
|
||||||
|
userDescPhoneVerified := userFields[6].Descriptor()
|
||||||
|
// user.DefaultPhoneVerified holds the default value on creation for the phone_verified field.
|
||||||
|
user.DefaultPhoneVerified = userDescPhoneVerified.Default.(bool)
|
||||||
|
// userDescPwdSalt is the schema descriptor for pwd_salt field.
|
||||||
|
userDescPwdSalt := userFields[7].Descriptor()
|
||||||
|
// user.PwdSaltValidator is a validator for the "pwd_salt" field. It is called by the builders before save.
|
||||||
|
user.PwdSaltValidator = userDescPwdSalt.Validators[0].(func(string) error)
|
||||||
|
// userDescPwdHash is the schema descriptor for pwd_hash field.
|
||||||
|
userDescPwdHash := userFields[8].Descriptor()
|
||||||
|
// user.PwdHashValidator is a validator for the "pwd_hash" field. It is called by the builders before save.
|
||||||
|
user.PwdHashValidator = userDescPwdHash.Validators[0].(func(string) error)
|
||||||
|
// userDescLoginFailedCount is the schema descriptor for login_failed_count field.
|
||||||
|
userDescLoginFailedCount := userFields[9].Descriptor()
|
||||||
|
// user.DefaultLoginFailedCount holds the default value on creation for the login_failed_count field.
|
||||||
|
user.DefaultLoginFailedCount = userDescLoginFailedCount.Default.(uint8)
|
||||||
|
// userDescFirstName is the schema descriptor for first_name field.
|
||||||
|
userDescFirstName := userFields[12].Descriptor()
|
||||||
|
// user.FirstNameValidator is a validator for the "first_name" field. It is called by the builders before save.
|
||||||
|
user.FirstNameValidator = userDescFirstName.Validators[0].(func(string) error)
|
||||||
|
// userDescMiddleName is the schema descriptor for middle_name field.
|
||||||
|
userDescMiddleName := userFields[13].Descriptor()
|
||||||
|
// user.MiddleNameValidator is a validator for the "middle_name" field. It is called by the builders before save.
|
||||||
|
user.MiddleNameValidator = userDescMiddleName.Validators[0].(func(string) error)
|
||||||
|
// userDescLastName is the schema descriptor for last_name field.
|
||||||
|
userDescLastName := userFields[14].Descriptor()
|
||||||
|
// user.LastNameValidator is a validator for the "last_name" field. It is called by the builders before save.
|
||||||
|
user.LastNameValidator = userDescLastName.Validators[0].(func(string) error)
|
||||||
|
usersessionFields := schema.UserSession{}.Fields()
|
||||||
|
_ = usersessionFields
|
||||||
|
// usersessionDescInvalidated is the schema descriptor for invalidated field.
|
||||||
|
usersessionDescInvalidated := usersessionFields[3].Descriptor()
|
||||||
|
// usersession.DefaultInvalidated holds the default value on creation for the invalidated field.
|
||||||
|
usersession.DefaultInvalidated = usersessionDescInvalidated.Default.(bool)
|
||||||
|
// usersessionDescUserAgent is the schema descriptor for user_agent field.
|
||||||
|
usersessionDescUserAgent := usersessionFields[4].Descriptor()
|
||||||
|
// usersession.UserAgentValidator is a validator for the "user_agent" field. It is called by the builders before save.
|
||||||
|
usersession.UserAgentValidator = usersessionDescUserAgent.Validators[0].(func(string) error)
|
||||||
|
// usersessionDescIP is the schema descriptor for ip field.
|
||||||
|
usersessionDescIP := usersessionFields[5].Descriptor()
|
||||||
|
// usersession.IPValidator is a validator for the "ip" field. It is called by the builders before save.
|
||||||
|
usersession.IPValidator = usersessionDescIP.Validators[0].(func(string) error)
|
||||||
|
}
|
10
db/ent/runtime/runtime.go
Normal file
10
db/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 gitserver.in/patialtech/rano/db/ent/runtime.go
|
||||||
|
|
||||||
|
const (
|
||||||
|
Version = "v0.14.1" // Version of ent codegen.
|
||||||
|
Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen.
|
||||||
|
)
|
35
db/ent/schema/accesscontrol.go
Normal file
35
db/ent/schema/accesscontrol.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"entgo.io/ent/schema/index"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessControl holds the schema definition for the AccessControl entity.
|
||||||
|
type AccessControl struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields of the AccessControl.
|
||||||
|
func (AccessControl) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
fieldID,
|
||||||
|
fieldCreated,
|
||||||
|
fieldUpdated,
|
||||||
|
field.String("ptype").Default(""),
|
||||||
|
field.String("v0").Default(""),
|
||||||
|
field.String("v1").Default(""),
|
||||||
|
field.String("v2").Default(""),
|
||||||
|
field.String("v3").Default(""),
|
||||||
|
field.String("v4").Default(""),
|
||||||
|
field.String("v5").Default(""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edges of the AccessControl.
|
||||||
|
func (AccessControl) Index() []ent.Index {
|
||||||
|
return []ent.Index{
|
||||||
|
index.Fields("ptype", "v0", "v1", "v2", "v3", "v4", "v5").Unique(),
|
||||||
|
}
|
||||||
|
}
|
41
db/ent/schema/audit.go
Normal file
41
db/ent/schema/audit.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/edge"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"entgo.io/ent/schema/index"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Audit holds the schema definition for the Audit entity.
|
||||||
|
type Audit struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields of the Audit.
|
||||||
|
func (Audit) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
fieldID,
|
||||||
|
fieldCreated,
|
||||||
|
field.String("ent_name").MaxLen(50),
|
||||||
|
field.Int64("ent_id").Positive(),
|
||||||
|
field.Enum("operation").Values("Create", "Update", "UpdateOne", "Delete", "DeleteOne"),
|
||||||
|
field.String("description").MaxLen(1000),
|
||||||
|
field.String("ip").MaxLen(40).Optional(),
|
||||||
|
field.String("user_name").MaxLen(150).Optional(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Audit) Indexes() []ent.Index {
|
||||||
|
return []ent.Index{
|
||||||
|
index.Fields("ent_name", "ent_id"),
|
||||||
|
index.Fields("operation"),
|
||||||
|
index.Fields("ip"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (Audit) Edges() []ent.Edge {
|
||||||
|
return []ent.Edge{
|
||||||
|
edge.From("user", User.Type).Ref("audit_logs").Unique(),
|
||||||
|
}
|
||||||
|
}
|
19
db/ent/schema/role.go
Normal file
19
db/ent/schema/role.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Role holds the schema definition for the Role entity.
|
||||||
|
type Role struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields of the Role.
|
||||||
|
func (Role) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
fieldID,
|
||||||
|
field.String("name"),
|
||||||
|
}
|
||||||
|
}
|
36
db/ent/schema/schema.go
Normal file
36
db/ent/schema/schema.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/contrib/entgql"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
)
|
||||||
|
|
||||||
|
var fieldID = field.Int64("id").
|
||||||
|
Immutable().
|
||||||
|
Unique()
|
||||||
|
|
||||||
|
var fieldCreated = field.Time("created_at").
|
||||||
|
Immutable().
|
||||||
|
Default(time.Now).
|
||||||
|
StructTag(`json:"createdAt"`).
|
||||||
|
Annotations(
|
||||||
|
entgql.OrderField("created"),
|
||||||
|
)
|
||||||
|
|
||||||
|
var fieldUpdated = field.Time("updated_at").
|
||||||
|
Default(time.Now).
|
||||||
|
UpdateDefault(time.Now).
|
||||||
|
StructTag(`json:"updatedAt"`).
|
||||||
|
Annotations(
|
||||||
|
entgql.OrderField("updated"),
|
||||||
|
)
|
||||||
|
|
||||||
|
var fieldDeleted = field.Time("deleted_at").
|
||||||
|
Optional().
|
||||||
|
Nillable().
|
||||||
|
StructTag(`json:"deletedAt"`).
|
||||||
|
Annotations(
|
||||||
|
entgql.OrderField("deleted"),
|
||||||
|
)
|
18
db/ent/schema/todo.go
Normal file
18
db/ent/schema/todo.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import "entgo.io/ent"
|
||||||
|
|
||||||
|
// Todo holds the schema definition for the Todo entity.
|
||||||
|
type Todo struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields of the Todo.
|
||||||
|
func (Todo) Fields() []ent.Field {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edges of the Todo.
|
||||||
|
func (Todo) Edges() []ent.Edge {
|
||||||
|
return nil
|
||||||
|
}
|
53
db/ent/schema/user.go
Normal file
53
db/ent/schema/user.go
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/entsql"
|
||||||
|
"entgo.io/ent/schema/edge"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"entgo.io/ent/schema/index"
|
||||||
|
)
|
||||||
|
|
||||||
|
// User holds the schema definition for the User entity.
|
||||||
|
type User struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields of the User.
|
||||||
|
func (User) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
fieldID,
|
||||||
|
fieldCreated,
|
||||||
|
fieldUpdated,
|
||||||
|
field.String("email").Unique().NotEmpty(),
|
||||||
|
field.Bool("email_verified").Default(false),
|
||||||
|
field.String("phone").MaxLen(20),
|
||||||
|
field.Bool("phone_verified").Default(false),
|
||||||
|
field.String("pwd_salt").NotEmpty(),
|
||||||
|
field.String("pwd_hash").NotEmpty(),
|
||||||
|
field.Uint8("login_failed_count").Optional().Default(0),
|
||||||
|
field.Time("login_attempt_on").Optional().Nillable(),
|
||||||
|
field.Time("login_locked_until").Optional().Nillable(),
|
||||||
|
field.String("first_name").MaxLen(30),
|
||||||
|
field.String("middle_name").MaxLen(30).Nillable(),
|
||||||
|
field.String("last_name").MaxLen(30),
|
||||||
|
field.Enum("status").Values("Pending", "Active", "InActive").Default("Pending"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edges of the User.
|
||||||
|
func (User) Edges() []ent.Edge {
|
||||||
|
return []ent.Edge{
|
||||||
|
edge.To("sessions", UserSession.Type).StorageKey(edge.Column("user_id")),
|
||||||
|
edge.To("audit_logs", Audit.Type).StorageKey(edge.Column("user_id")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (User) Indexes() []ent.Index {
|
||||||
|
return []ent.Index{
|
||||||
|
index.Fields("created_at").Annotations(entsql.Desc()),
|
||||||
|
index.Fields("updated_at").Annotations(entsql.Desc()),
|
||||||
|
index.Fields("phone"),
|
||||||
|
index.Fields("status"),
|
||||||
|
}
|
||||||
|
}
|
40
db/ent/schema/usersession.go
Normal file
40
db/ent/schema/usersession.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package schema
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/schema/edge"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"entgo.io/ent/schema/index"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserSession holds the schema definition for the UserSession entity.
|
||||||
|
type UserSession struct {
|
||||||
|
ent.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields of the UserSession.
|
||||||
|
func (UserSession) Fields() []ent.Field {
|
||||||
|
return []ent.Field{
|
||||||
|
fieldID,
|
||||||
|
field.Time("issued_at"),
|
||||||
|
field.Time("expires_at"),
|
||||||
|
field.Bool("invalidated").Optional().Default(false),
|
||||||
|
field.String("user_agent").MaxLen(50),
|
||||||
|
field.String("ip").MaxLen(40),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edges of the UserSession.
|
||||||
|
func (UserSession) Edges() []ent.Edge {
|
||||||
|
return []ent.Edge{
|
||||||
|
edge.From("user", User.Type).Ref("sessions").Unique().Required(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (UserSession) Indexes() []ent.Index {
|
||||||
|
return []ent.Index{
|
||||||
|
index.Fields("expires_at"),
|
||||||
|
index.Fields("invalidated"),
|
||||||
|
index.Fields("ip"),
|
||||||
|
}
|
||||||
|
}
|
91
db/ent/todo.go
Normal file
91
db/ent/todo.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/todo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Todo is the model entity for the Todo schema.
|
||||||
|
type Todo struct {
|
||||||
|
config
|
||||||
|
// ID of the ent.
|
||||||
|
ID int `json:"id,omitempty"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*Todo) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case todo.FieldID:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the Todo fields.
|
||||||
|
func (t *Todo) 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 todo.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
t.ID = int(value.Int64)
|
||||||
|
default:
|
||||||
|
t.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the Todo.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (t *Todo) Value(name string) (ent.Value, error) {
|
||||||
|
return t.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this Todo.
|
||||||
|
// Note that you need to call Todo.Unwrap() before calling this method if this Todo
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (t *Todo) Update() *TodoUpdateOne {
|
||||||
|
return NewTodoClient(t.config).UpdateOne(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the Todo 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 (t *Todo) Unwrap() *Todo {
|
||||||
|
_tx, ok := t.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: Todo is not a transactional entity")
|
||||||
|
}
|
||||||
|
t.config.driver = _tx.drv
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (t *Todo) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("Todo(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v", t.ID))
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Todos is a parsable slice of Todo.
|
||||||
|
type Todos []*Todo
|
39
db/ent/todo/todo.go
Normal file
39
db/ent/todo/todo.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package todo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the todo type in the database.
|
||||||
|
Label = "todo"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// Table holds the table name of the todo in the database.
|
||||||
|
Table = "todos"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for todo fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 Todo 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()
|
||||||
|
}
|
68
db/ent/todo/where.go
Normal file
68
db/ent/todo/where.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package todo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.Todo) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.Todo) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.Todo) predicate.Todo {
|
||||||
|
return predicate.Todo(sql.NotPredicates(p))
|
||||||
|
}
|
169
db/ent/todo_create.go
Normal file
169
db/ent/todo_create.go
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/todo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TodoCreate is the builder for creating a Todo entity.
|
||||||
|
type TodoCreate struct {
|
||||||
|
config
|
||||||
|
mutation *TodoMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the TodoMutation object of the builder.
|
||||||
|
func (tc *TodoCreate) Mutation() *TodoMutation {
|
||||||
|
return tc.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Todo in the database.
|
||||||
|
func (tc *TodoCreate) Save(ctx context.Context) (*Todo, error) {
|
||||||
|
return withHooks(ctx, tc.sqlSave, tc.mutation, tc.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (tc *TodoCreate) SaveX(ctx context.Context) *Todo {
|
||||||
|
v, err := tc.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (tc *TodoCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := tc.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (tc *TodoCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := tc.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (tc *TodoCreate) check() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tc *TodoCreate) sqlSave(ctx context.Context) (*Todo, error) {
|
||||||
|
if err := tc.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := tc.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, tc.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)
|
||||||
|
tc.mutation.id = &_node.ID
|
||||||
|
tc.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tc *TodoCreate) createSpec() (*Todo, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &Todo{config: tc.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(todo.Table, sqlgraph.NewFieldSpec(todo.FieldID, field.TypeInt))
|
||||||
|
)
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// TodoCreateBulk is the builder for creating many Todo entities in bulk.
|
||||||
|
type TodoCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*TodoCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Todo entities in the database.
|
||||||
|
func (tcb *TodoCreateBulk) Save(ctx context.Context) ([]*Todo, error) {
|
||||||
|
if tcb.err != nil {
|
||||||
|
return nil, tcb.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(tcb.builders))
|
||||||
|
nodes := make([]*Todo, len(tcb.builders))
|
||||||
|
mutators := make([]Mutator, len(tcb.builders))
|
||||||
|
for i := range tcb.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := tcb.builders[i]
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*TodoMutation)
|
||||||
|
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, tcb.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, tcb.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, tcb.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (tcb *TodoCreateBulk) SaveX(ctx context.Context) []*Todo {
|
||||||
|
v, err := tcb.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (tcb *TodoCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := tcb.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (tcb *TodoCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := tcb.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
88
db/ent/todo_delete.go
Normal file
88
db/ent/todo_delete.go
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/todo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TodoDelete is the builder for deleting a Todo entity.
|
||||||
|
type TodoDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *TodoMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the TodoDelete builder.
|
||||||
|
func (td *TodoDelete) Where(ps ...predicate.Todo) *TodoDelete {
|
||||||
|
td.mutation.Where(ps...)
|
||||||
|
return td
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (td *TodoDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, td.sqlExec, td.mutation, td.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (td *TodoDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := td.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (td *TodoDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(todo.Table, sqlgraph.NewFieldSpec(todo.FieldID, field.TypeInt))
|
||||||
|
if ps := td.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, td.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
td.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// TodoDeleteOne is the builder for deleting a single Todo entity.
|
||||||
|
type TodoDeleteOne struct {
|
||||||
|
td *TodoDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the TodoDelete builder.
|
||||||
|
func (tdo *TodoDeleteOne) Where(ps ...predicate.Todo) *TodoDeleteOne {
|
||||||
|
tdo.td.mutation.Where(ps...)
|
||||||
|
return tdo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (tdo *TodoDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := tdo.td.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{todo.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (tdo *TodoDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := tdo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
505
db/ent/todo_query.go
Normal file
505
db/ent/todo_query.go
Normal file
@ -0,0 +1,505 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/todo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TodoQuery is the builder for querying Todo entities.
|
||||||
|
type TodoQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []todo.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.Todo
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the TodoQuery builder.
|
||||||
|
func (tq *TodoQuery) Where(ps ...predicate.Todo) *TodoQuery {
|
||||||
|
tq.predicates = append(tq.predicates, ps...)
|
||||||
|
return tq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (tq *TodoQuery) Limit(limit int) *TodoQuery {
|
||||||
|
tq.ctx.Limit = &limit
|
||||||
|
return tq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (tq *TodoQuery) Offset(offset int) *TodoQuery {
|
||||||
|
tq.ctx.Offset = &offset
|
||||||
|
return tq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (tq *TodoQuery) Unique(unique bool) *TodoQuery {
|
||||||
|
tq.ctx.Unique = &unique
|
||||||
|
return tq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (tq *TodoQuery) Order(o ...todo.OrderOption) *TodoQuery {
|
||||||
|
tq.order = append(tq.order, o...)
|
||||||
|
return tq
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first Todo entity from the query.
|
||||||
|
// Returns a *NotFoundError when no Todo was found.
|
||||||
|
func (tq *TodoQuery) First(ctx context.Context) (*Todo, error) {
|
||||||
|
nodes, err := tq.Limit(1).All(setContextOp(ctx, tq.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{todo.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (tq *TodoQuery) FirstX(ctx context.Context) *Todo {
|
||||||
|
node, err := tq.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first Todo ID from the query.
|
||||||
|
// Returns a *NotFoundError when no Todo ID was found.
|
||||||
|
func (tq *TodoQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = tq.Limit(1).IDs(setContextOp(ctx, tq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{todo.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (tq *TodoQuery) FirstIDX(ctx context.Context) int {
|
||||||
|
id, err := tq.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single Todo entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one Todo entity is found.
|
||||||
|
// Returns a *NotFoundError when no Todo entities are found.
|
||||||
|
func (tq *TodoQuery) Only(ctx context.Context) (*Todo, error) {
|
||||||
|
nodes, err := tq.Limit(2).All(setContextOp(ctx, tq.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{todo.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{todo.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (tq *TodoQuery) OnlyX(ctx context.Context) *Todo {
|
||||||
|
node, err := tq.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only Todo ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one Todo ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (tq *TodoQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||||
|
var ids []int
|
||||||
|
if ids, err = tq.Limit(2).IDs(setContextOp(ctx, tq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{todo.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{todo.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (tq *TodoQuery) OnlyIDX(ctx context.Context) int {
|
||||||
|
id, err := tq.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of Todos.
|
||||||
|
func (tq *TodoQuery) All(ctx context.Context) ([]*Todo, error) {
|
||||||
|
ctx = setContextOp(ctx, tq.ctx, ent.OpQueryAll)
|
||||||
|
if err := tq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*Todo, *TodoQuery]()
|
||||||
|
return withInterceptors[[]*Todo](ctx, tq, qr, tq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (tq *TodoQuery) AllX(ctx context.Context) []*Todo {
|
||||||
|
nodes, err := tq.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of Todo IDs.
|
||||||
|
func (tq *TodoQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||||
|
if tq.ctx.Unique == nil && tq.path != nil {
|
||||||
|
tq.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, tq.ctx, ent.OpQueryIDs)
|
||||||
|
if err = tq.Select(todo.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (tq *TodoQuery) IDsX(ctx context.Context) []int {
|
||||||
|
ids, err := tq.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (tq *TodoQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, tq.ctx, ent.OpQueryCount)
|
||||||
|
if err := tq.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, tq, querierCount[*TodoQuery](), tq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (tq *TodoQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := tq.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (tq *TodoQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, tq.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := tq.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 (tq *TodoQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := tq.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the TodoQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (tq *TodoQuery) Clone() *TodoQuery {
|
||||||
|
if tq == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &TodoQuery{
|
||||||
|
config: tq.config,
|
||||||
|
ctx: tq.ctx.Clone(),
|
||||||
|
order: append([]todo.OrderOption{}, tq.order...),
|
||||||
|
inters: append([]Interceptor{}, tq.inters...),
|
||||||
|
predicates: append([]predicate.Todo{}, tq.predicates...),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: tq.sql.Clone(),
|
||||||
|
path: tq.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.
|
||||||
|
func (tq *TodoQuery) GroupBy(field string, fields ...string) *TodoGroupBy {
|
||||||
|
tq.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &TodoGroupBy{build: tq}
|
||||||
|
grbuild.flds = &tq.ctx.Fields
|
||||||
|
grbuild.label = todo.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.
|
||||||
|
func (tq *TodoQuery) Select(fields ...string) *TodoSelect {
|
||||||
|
tq.ctx.Fields = append(tq.ctx.Fields, fields...)
|
||||||
|
sbuild := &TodoSelect{TodoQuery: tq}
|
||||||
|
sbuild.label = todo.Label
|
||||||
|
sbuild.flds, sbuild.scan = &tq.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a TodoSelect configured with the given aggregations.
|
||||||
|
func (tq *TodoQuery) Aggregate(fns ...AggregateFunc) *TodoSelect {
|
||||||
|
return tq.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tq *TodoQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range tq.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, tq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range tq.ctx.Fields {
|
||||||
|
if !todo.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if tq.path != nil {
|
||||||
|
prev, err := tq.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tq.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tq *TodoQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Todo, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*Todo{}
|
||||||
|
_spec = tq.querySpec()
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Todo).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &Todo{config: tq.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, tq.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tq *TodoQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := tq.querySpec()
|
||||||
|
_spec.Node.Columns = tq.ctx.Fields
|
||||||
|
if len(tq.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = tq.ctx.Unique != nil && *tq.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, tq.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tq *TodoQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(todo.Table, todo.Columns, sqlgraph.NewFieldSpec(todo.FieldID, field.TypeInt))
|
||||||
|
_spec.From = tq.sql
|
||||||
|
if unique := tq.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if tq.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := tq.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, todo.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != todo.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := tq.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := tq.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := tq.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := tq.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tq *TodoQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(tq.driver.Dialect())
|
||||||
|
t1 := builder.Table(todo.Table)
|
||||||
|
columns := tq.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = todo.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if tq.sql != nil {
|
||||||
|
selector = tq.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if tq.ctx.Unique != nil && *tq.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range tq.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range tq.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := tq.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 := tq.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// TodoGroupBy is the group-by builder for Todo entities.
|
||||||
|
type TodoGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *TodoQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (tgb *TodoGroupBy) Aggregate(fns ...AggregateFunc) *TodoGroupBy {
|
||||||
|
tgb.fns = append(tgb.fns, fns...)
|
||||||
|
return tgb
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (tgb *TodoGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, tgb.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := tgb.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*TodoQuery, *TodoGroupBy](ctx, tgb.build, tgb, tgb.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tgb *TodoGroupBy) sqlScan(ctx context.Context, root *TodoQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(tgb.fns))
|
||||||
|
for _, fn := range tgb.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*tgb.flds)+len(tgb.fns))
|
||||||
|
for _, f := range *tgb.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*tgb.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := tgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TodoSelect is the builder for selecting fields of Todo entities.
|
||||||
|
type TodoSelect struct {
|
||||||
|
*TodoQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (ts *TodoSelect) Aggregate(fns ...AggregateFunc) *TodoSelect {
|
||||||
|
ts.fns = append(ts.fns, fns...)
|
||||||
|
return ts
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (ts *TodoSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, ts.ctx, ent.OpQuerySelect)
|
||||||
|
if err := ts.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*TodoQuery, *TodoSelect](ctx, ts.TodoQuery, ts, ts.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ts *TodoSelect) sqlScan(ctx context.Context, root *TodoQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(ts.fns))
|
||||||
|
for _, fn := range ts.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*ts.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 := ts.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
175
db/ent/todo_update.go
Normal file
175
db/ent/todo_update.go
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/todo"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TodoUpdate is the builder for updating Todo entities.
|
||||||
|
type TodoUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *TodoMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the TodoUpdate builder.
|
||||||
|
func (tu *TodoUpdate) Where(ps ...predicate.Todo) *TodoUpdate {
|
||||||
|
tu.mutation.Where(ps...)
|
||||||
|
return tu
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the TodoMutation object of the builder.
|
||||||
|
func (tu *TodoUpdate) Mutation() *TodoMutation {
|
||||||
|
return tu.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (tu *TodoUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, tu.sqlSave, tu.mutation, tu.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (tu *TodoUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := tu.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (tu *TodoUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := tu.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (tu *TodoUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := tu.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tu *TodoUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(todo.Table, todo.Columns, sqlgraph.NewFieldSpec(todo.FieldID, field.TypeInt))
|
||||||
|
if ps := tu.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if n, err = sqlgraph.UpdateNodes(ctx, tu.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{todo.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
tu.mutation.done = true
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// TodoUpdateOne is the builder for updating a single Todo entity.
|
||||||
|
type TodoUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *TodoMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the TodoMutation object of the builder.
|
||||||
|
func (tuo *TodoUpdateOne) Mutation() *TodoMutation {
|
||||||
|
return tuo.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the TodoUpdate builder.
|
||||||
|
func (tuo *TodoUpdateOne) Where(ps ...predicate.Todo) *TodoUpdateOne {
|
||||||
|
tuo.mutation.Where(ps...)
|
||||||
|
return tuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (tuo *TodoUpdateOne) Select(field string, fields ...string) *TodoUpdateOne {
|
||||||
|
tuo.fields = append([]string{field}, fields...)
|
||||||
|
return tuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated Todo entity.
|
||||||
|
func (tuo *TodoUpdateOne) Save(ctx context.Context) (*Todo, error) {
|
||||||
|
return withHooks(ctx, tuo.sqlSave, tuo.mutation, tuo.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (tuo *TodoUpdateOne) SaveX(ctx context.Context) *Todo {
|
||||||
|
node, err := tuo.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (tuo *TodoUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := tuo.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (tuo *TodoUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := tuo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tuo *TodoUpdateOne) sqlSave(ctx context.Context) (_node *Todo, err error) {
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(todo.Table, todo.Columns, sqlgraph.NewFieldSpec(todo.FieldID, field.TypeInt))
|
||||||
|
id, ok := tuo.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Todo.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := tuo.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, todo.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !todo.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != todo.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := tuo.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_node = &Todo{config: tuo.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, tuo.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{todo.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
tuo.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
225
db/ent/tx.go
Normal file
225
db/ent/tx.go
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
// 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
|
||||||
|
// AccessControl is the client for interacting with the AccessControl builders.
|
||||||
|
AccessControl *AccessControlClient
|
||||||
|
// Audit is the client for interacting with the Audit builders.
|
||||||
|
Audit *AuditClient
|
||||||
|
// Role is the client for interacting with the Role builders.
|
||||||
|
Role *RoleClient
|
||||||
|
// Todo is the client for interacting with the Todo builders.
|
||||||
|
Todo *TodoClient
|
||||||
|
// User is the client for interacting with the User builders.
|
||||||
|
User *UserClient
|
||||||
|
// UserSession is the client for interacting with the UserSession builders.
|
||||||
|
UserSession *UserSessionClient
|
||||||
|
|
||||||
|
// 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.AccessControl = NewAccessControlClient(tx.config)
|
||||||
|
tx.Audit = NewAuditClient(tx.config)
|
||||||
|
tx.Role = NewRoleClient(tx.config)
|
||||||
|
tx.Todo = NewTodoClient(tx.config)
|
||||||
|
tx.User = NewUserClient(tx.config)
|
||||||
|
tx.UserSession = NewUserSessionClient(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: AccessControl.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)
|
313
db/ent/user.go
Normal file
313
db/ent/user.go
Normal file
@ -0,0 +1,313 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// User is the model entity for the User schema.
|
||||||
|
type User struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int64 `json:"id,omitempty"`
|
||||||
|
// CreatedAt holds the value of the "created_at" field.
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// UpdatedAt holds the value of the "updated_at" field.
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
// Email holds the value of the "email" field.
|
||||||
|
Email string `json:"email,omitempty"`
|
||||||
|
// EmailVerified holds the value of the "email_verified" field.
|
||||||
|
EmailVerified bool `json:"email_verified,omitempty"`
|
||||||
|
// Phone holds the value of the "phone" field.
|
||||||
|
Phone string `json:"phone,omitempty"`
|
||||||
|
// PhoneVerified holds the value of the "phone_verified" field.
|
||||||
|
PhoneVerified bool `json:"phone_verified,omitempty"`
|
||||||
|
// PwdSalt holds the value of the "pwd_salt" field.
|
||||||
|
PwdSalt string `json:"pwd_salt,omitempty"`
|
||||||
|
// PwdHash holds the value of the "pwd_hash" field.
|
||||||
|
PwdHash string `json:"pwd_hash,omitempty"`
|
||||||
|
// LoginFailedCount holds the value of the "login_failed_count" field.
|
||||||
|
LoginFailedCount uint8 `json:"login_failed_count,omitempty"`
|
||||||
|
// LoginAttemptOn holds the value of the "login_attempt_on" field.
|
||||||
|
LoginAttemptOn *time.Time `json:"login_attempt_on,omitempty"`
|
||||||
|
// LoginLockedUntil holds the value of the "login_locked_until" field.
|
||||||
|
LoginLockedUntil *time.Time `json:"login_locked_until,omitempty"`
|
||||||
|
// FirstName holds the value of the "first_name" field.
|
||||||
|
FirstName string `json:"first_name,omitempty"`
|
||||||
|
// MiddleName holds the value of the "middle_name" field.
|
||||||
|
MiddleName *string `json:"middle_name,omitempty"`
|
||||||
|
// LastName holds the value of the "last_name" field.
|
||||||
|
LastName string `json:"last_name,omitempty"`
|
||||||
|
// Status holds the value of the "status" field.
|
||||||
|
Status user.Status `json:"status,omitempty"`
|
||||||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
|
// The values are being populated by the UserQuery when eager-loading is set.
|
||||||
|
Edges UserEdges `json:"edges"`
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserEdges holds the relations/edges for other nodes in the graph.
|
||||||
|
type UserEdges struct {
|
||||||
|
// Sessions holds the value of the sessions edge.
|
||||||
|
Sessions []*UserSession `json:"sessions,omitempty"`
|
||||||
|
// AuditLogs holds the value of the audit_logs edge.
|
||||||
|
AuditLogs []*Audit `json:"audit_logs,omitempty"`
|
||||||
|
// loadedTypes holds the information for reporting if a
|
||||||
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
|
loadedTypes [2]bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// SessionsOrErr returns the Sessions value or an error if the edge
|
||||||
|
// was not loaded in eager-loading.
|
||||||
|
func (e UserEdges) SessionsOrErr() ([]*UserSession, error) {
|
||||||
|
if e.loadedTypes[0] {
|
||||||
|
return e.Sessions, nil
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "sessions"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuditLogsOrErr returns the AuditLogs value or an error if the edge
|
||||||
|
// was not loaded in eager-loading.
|
||||||
|
func (e UserEdges) AuditLogsOrErr() ([]*Audit, error) {
|
||||||
|
if e.loadedTypes[1] {
|
||||||
|
return e.AuditLogs, nil
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "audit_logs"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*User) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case user.FieldEmailVerified, user.FieldPhoneVerified:
|
||||||
|
values[i] = new(sql.NullBool)
|
||||||
|
case user.FieldID, user.FieldLoginFailedCount:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case user.FieldEmail, user.FieldPhone, user.FieldPwdSalt, user.FieldPwdHash, user.FieldFirstName, user.FieldMiddleName, user.FieldLastName, user.FieldStatus:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case user.FieldCreatedAt, user.FieldUpdatedAt, user.FieldLoginAttemptOn, user.FieldLoginLockedUntil:
|
||||||
|
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 User fields.
|
||||||
|
func (u *User) 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 user.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
u.ID = int64(value.Int64)
|
||||||
|
case user.FieldCreatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.CreatedAt = value.Time
|
||||||
|
}
|
||||||
|
case user.FieldUpdatedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.UpdatedAt = value.Time
|
||||||
|
}
|
||||||
|
case user.FieldEmail:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field email", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.Email = value.String
|
||||||
|
}
|
||||||
|
case user.FieldEmailVerified:
|
||||||
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field email_verified", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.EmailVerified = value.Bool
|
||||||
|
}
|
||||||
|
case user.FieldPhone:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field phone", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.Phone = value.String
|
||||||
|
}
|
||||||
|
case user.FieldPhoneVerified:
|
||||||
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field phone_verified", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.PhoneVerified = value.Bool
|
||||||
|
}
|
||||||
|
case user.FieldPwdSalt:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field pwd_salt", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.PwdSalt = value.String
|
||||||
|
}
|
||||||
|
case user.FieldPwdHash:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field pwd_hash", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.PwdHash = value.String
|
||||||
|
}
|
||||||
|
case user.FieldLoginFailedCount:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field login_failed_count", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.LoginFailedCount = uint8(value.Int64)
|
||||||
|
}
|
||||||
|
case user.FieldLoginAttemptOn:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field login_attempt_on", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.LoginAttemptOn = new(time.Time)
|
||||||
|
*u.LoginAttemptOn = value.Time
|
||||||
|
}
|
||||||
|
case user.FieldLoginLockedUntil:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field login_locked_until", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.LoginLockedUntil = new(time.Time)
|
||||||
|
*u.LoginLockedUntil = value.Time
|
||||||
|
}
|
||||||
|
case user.FieldFirstName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field first_name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.FirstName = value.String
|
||||||
|
}
|
||||||
|
case user.FieldMiddleName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field middle_name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.MiddleName = new(string)
|
||||||
|
*u.MiddleName = value.String
|
||||||
|
}
|
||||||
|
case user.FieldLastName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field last_name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.LastName = value.String
|
||||||
|
}
|
||||||
|
case user.FieldStatus:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field status", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.Status = user.Status(value.String)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
u.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the User.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (u *User) Value(name string) (ent.Value, error) {
|
||||||
|
return u.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// QuerySessions queries the "sessions" edge of the User entity.
|
||||||
|
func (u *User) QuerySessions() *UserSessionQuery {
|
||||||
|
return NewUserClient(u.config).QuerySessions(u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryAuditLogs queries the "audit_logs" edge of the User entity.
|
||||||
|
func (u *User) QueryAuditLogs() *AuditQuery {
|
||||||
|
return NewUserClient(u.config).QueryAuditLogs(u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this User.
|
||||||
|
// Note that you need to call User.Unwrap() before calling this method if this User
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (u *User) Update() *UserUpdateOne {
|
||||||
|
return NewUserClient(u.config).UpdateOne(u)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the User 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 (u *User) Unwrap() *User {
|
||||||
|
_tx, ok := u.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: User is not a transactional entity")
|
||||||
|
}
|
||||||
|
u.config.driver = _tx.drv
|
||||||
|
return u
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (u *User) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("User(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", u.ID))
|
||||||
|
builder.WriteString("created_at=")
|
||||||
|
builder.WriteString(u.CreatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("updated_at=")
|
||||||
|
builder.WriteString(u.UpdatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("email=")
|
||||||
|
builder.WriteString(u.Email)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("email_verified=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", u.EmailVerified))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("phone=")
|
||||||
|
builder.WriteString(u.Phone)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("phone_verified=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", u.PhoneVerified))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("pwd_salt=")
|
||||||
|
builder.WriteString(u.PwdSalt)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("pwd_hash=")
|
||||||
|
builder.WriteString(u.PwdHash)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("login_failed_count=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", u.LoginFailedCount))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
if v := u.LoginAttemptOn; v != nil {
|
||||||
|
builder.WriteString("login_attempt_on=")
|
||||||
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
|
if v := u.LoginLockedUntil; v != nil {
|
||||||
|
builder.WriteString("login_locked_until=")
|
||||||
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("first_name=")
|
||||||
|
builder.WriteString(u.FirstName)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
if v := u.MiddleName; v != nil {
|
||||||
|
builder.WriteString("middle_name=")
|
||||||
|
builder.WriteString(*v)
|
||||||
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("last_name=")
|
||||||
|
builder.WriteString(u.LastName)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("status=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", u.Status))
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Users is a parsable slice of User.
|
||||||
|
type Users []*User
|
279
db/ent/user/user.go
Normal file
279
db/ent/user/user.go
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the user type in the database.
|
||||||
|
Label = "user"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||||
|
FieldCreatedAt = "created_at"
|
||||||
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||||
|
FieldUpdatedAt = "updated_at"
|
||||||
|
// FieldEmail holds the string denoting the email field in the database.
|
||||||
|
FieldEmail = "email"
|
||||||
|
// FieldEmailVerified holds the string denoting the email_verified field in the database.
|
||||||
|
FieldEmailVerified = "email_verified"
|
||||||
|
// FieldPhone holds the string denoting the phone field in the database.
|
||||||
|
FieldPhone = "phone"
|
||||||
|
// FieldPhoneVerified holds the string denoting the phone_verified field in the database.
|
||||||
|
FieldPhoneVerified = "phone_verified"
|
||||||
|
// FieldPwdSalt holds the string denoting the pwd_salt field in the database.
|
||||||
|
FieldPwdSalt = "pwd_salt"
|
||||||
|
// FieldPwdHash holds the string denoting the pwd_hash field in the database.
|
||||||
|
FieldPwdHash = "pwd_hash"
|
||||||
|
// FieldLoginFailedCount holds the string denoting the login_failed_count field in the database.
|
||||||
|
FieldLoginFailedCount = "login_failed_count"
|
||||||
|
// FieldLoginAttemptOn holds the string denoting the login_attempt_on field in the database.
|
||||||
|
FieldLoginAttemptOn = "login_attempt_on"
|
||||||
|
// FieldLoginLockedUntil holds the string denoting the login_locked_until field in the database.
|
||||||
|
FieldLoginLockedUntil = "login_locked_until"
|
||||||
|
// FieldFirstName holds the string denoting the first_name field in the database.
|
||||||
|
FieldFirstName = "first_name"
|
||||||
|
// FieldMiddleName holds the string denoting the middle_name field in the database.
|
||||||
|
FieldMiddleName = "middle_name"
|
||||||
|
// FieldLastName holds the string denoting the last_name field in the database.
|
||||||
|
FieldLastName = "last_name"
|
||||||
|
// FieldStatus holds the string denoting the status field in the database.
|
||||||
|
FieldStatus = "status"
|
||||||
|
// EdgeSessions holds the string denoting the sessions edge name in mutations.
|
||||||
|
EdgeSessions = "sessions"
|
||||||
|
// EdgeAuditLogs holds the string denoting the audit_logs edge name in mutations.
|
||||||
|
EdgeAuditLogs = "audit_logs"
|
||||||
|
// Table holds the table name of the user in the database.
|
||||||
|
Table = "users"
|
||||||
|
// SessionsTable is the table that holds the sessions relation/edge.
|
||||||
|
SessionsTable = "user_sessions"
|
||||||
|
// SessionsInverseTable is the table name for the UserSession entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "usersession" package.
|
||||||
|
SessionsInverseTable = "user_sessions"
|
||||||
|
// SessionsColumn is the table column denoting the sessions relation/edge.
|
||||||
|
SessionsColumn = "user_id"
|
||||||
|
// AuditLogsTable is the table that holds the audit_logs relation/edge.
|
||||||
|
AuditLogsTable = "audits"
|
||||||
|
// AuditLogsInverseTable is the table name for the Audit entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "audit" package.
|
||||||
|
AuditLogsInverseTable = "audits"
|
||||||
|
// AuditLogsColumn is the table column denoting the audit_logs relation/edge.
|
||||||
|
AuditLogsColumn = "user_id"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for user fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldCreatedAt,
|
||||||
|
FieldUpdatedAt,
|
||||||
|
FieldEmail,
|
||||||
|
FieldEmailVerified,
|
||||||
|
FieldPhone,
|
||||||
|
FieldPhoneVerified,
|
||||||
|
FieldPwdSalt,
|
||||||
|
FieldPwdHash,
|
||||||
|
FieldLoginFailedCount,
|
||||||
|
FieldLoginAttemptOn,
|
||||||
|
FieldLoginLockedUntil,
|
||||||
|
FieldFirstName,
|
||||||
|
FieldMiddleName,
|
||||||
|
FieldLastName,
|
||||||
|
FieldStatus,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||||
|
DefaultCreatedAt func() time.Time
|
||||||
|
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
|
||||||
|
DefaultUpdatedAt func() time.Time
|
||||||
|
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
|
||||||
|
UpdateDefaultUpdatedAt func() time.Time
|
||||||
|
// EmailValidator is a validator for the "email" field. It is called by the builders before save.
|
||||||
|
EmailValidator func(string) error
|
||||||
|
// DefaultEmailVerified holds the default value on creation for the "email_verified" field.
|
||||||
|
DefaultEmailVerified bool
|
||||||
|
// PhoneValidator is a validator for the "phone" field. It is called by the builders before save.
|
||||||
|
PhoneValidator func(string) error
|
||||||
|
// DefaultPhoneVerified holds the default value on creation for the "phone_verified" field.
|
||||||
|
DefaultPhoneVerified bool
|
||||||
|
// PwdSaltValidator is a validator for the "pwd_salt" field. It is called by the builders before save.
|
||||||
|
PwdSaltValidator func(string) error
|
||||||
|
// PwdHashValidator is a validator for the "pwd_hash" field. It is called by the builders before save.
|
||||||
|
PwdHashValidator func(string) error
|
||||||
|
// DefaultLoginFailedCount holds the default value on creation for the "login_failed_count" field.
|
||||||
|
DefaultLoginFailedCount uint8
|
||||||
|
// FirstNameValidator is a validator for the "first_name" field. It is called by the builders before save.
|
||||||
|
FirstNameValidator func(string) error
|
||||||
|
// MiddleNameValidator is a validator for the "middle_name" field. It is called by the builders before save.
|
||||||
|
MiddleNameValidator func(string) error
|
||||||
|
// LastNameValidator is a validator for the "last_name" field. It is called by the builders before save.
|
||||||
|
LastNameValidator func(string) error
|
||||||
|
)
|
||||||
|
|
||||||
|
// Status defines the type for the "status" enum field.
|
||||||
|
type Status string
|
||||||
|
|
||||||
|
// StatusPending is the default value of the Status enum.
|
||||||
|
const DefaultStatus = StatusPending
|
||||||
|
|
||||||
|
// Status values.
|
||||||
|
const (
|
||||||
|
StatusPending Status = "Pending"
|
||||||
|
StatusActive Status = "Active"
|
||||||
|
StatusInActive Status = "InActive"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s Status) String() string {
|
||||||
|
return string(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save.
|
||||||
|
func StatusValidator(s Status) error {
|
||||||
|
switch s {
|
||||||
|
case StatusPending, StatusActive, StatusInActive:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("user: invalid enum value for status field: %q", s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the User 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()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByCreatedAt orders the results by the created_at field.
|
||||||
|
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUpdatedAt orders the results by the updated_at field.
|
||||||
|
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByEmail orders the results by the email field.
|
||||||
|
func ByEmail(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldEmail, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByEmailVerified orders the results by the email_verified field.
|
||||||
|
func ByEmailVerified(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldEmailVerified, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByPhone orders the results by the phone field.
|
||||||
|
func ByPhone(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldPhone, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByPhoneVerified orders the results by the phone_verified field.
|
||||||
|
func ByPhoneVerified(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldPhoneVerified, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByPwdSalt orders the results by the pwd_salt field.
|
||||||
|
func ByPwdSalt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldPwdSalt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByPwdHash orders the results by the pwd_hash field.
|
||||||
|
func ByPwdHash(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldPwdHash, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByLoginFailedCount orders the results by the login_failed_count field.
|
||||||
|
func ByLoginFailedCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldLoginFailedCount, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByLoginAttemptOn orders the results by the login_attempt_on field.
|
||||||
|
func ByLoginAttemptOn(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldLoginAttemptOn, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByLoginLockedUntil orders the results by the login_locked_until field.
|
||||||
|
func ByLoginLockedUntil(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldLoginLockedUntil, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByFirstName orders the results by the first_name field.
|
||||||
|
func ByFirstName(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldFirstName, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByMiddleName orders the results by the middle_name field.
|
||||||
|
func ByMiddleName(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldMiddleName, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByLastName orders the results by the last_name field.
|
||||||
|
func ByLastName(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldLastName, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByStatus orders the results by the status field.
|
||||||
|
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldStatus, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// BySessionsCount orders the results by sessions count.
|
||||||
|
func BySessionsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborsCount(s, newSessionsStep(), opts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BySessions orders the results by sessions terms.
|
||||||
|
func BySessions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborTerms(s, newSessionsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByAuditLogsCount orders the results by audit_logs count.
|
||||||
|
func ByAuditLogsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborsCount(s, newAuditLogsStep(), opts...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByAuditLogs orders the results by audit_logs terms.
|
||||||
|
func ByAuditLogs(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborTerms(s, newAuditLogsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func newSessionsStep() *sqlgraph.Step {
|
||||||
|
return sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(SessionsInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, SessionsTable, SessionsColumn),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
func newAuditLogsStep() *sqlgraph.Step {
|
||||||
|
return sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(AuditLogsInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, AuditLogsTable, AuditLogsColumn),
|
||||||
|
)
|
||||||
|
}
|
912
db/ent/user/where.go
Normal file
912
db/ent/user/where.go
Normal file
@ -0,0 +1,912 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int64) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||||
|
func CreatedAt(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||||
|
func UpdatedAt(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Email applies equality check predicate on the "email" field. It's identical to EmailEQ.
|
||||||
|
func Email(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailVerified applies equality check predicate on the "email_verified" field. It's identical to EmailVerifiedEQ.
|
||||||
|
func EmailVerified(v bool) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldEmailVerified, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ.
|
||||||
|
func Phone(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneVerified applies equality check predicate on the "phone_verified" field. It's identical to PhoneVerifiedEQ.
|
||||||
|
func PhoneVerified(v bool) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPhoneVerified, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSalt applies equality check predicate on the "pwd_salt" field. It's identical to PwdSaltEQ.
|
||||||
|
func PwdSalt(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHash applies equality check predicate on the "pwd_hash" field. It's identical to PwdHashEQ.
|
||||||
|
func PwdHash(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCount applies equality check predicate on the "login_failed_count" field. It's identical to LoginFailedCountEQ.
|
||||||
|
func LoginFailedCount(v uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldLoginFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOn applies equality check predicate on the "login_attempt_on" field. It's identical to LoginAttemptOnEQ.
|
||||||
|
func LoginAttemptOn(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldLoginAttemptOn, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntil applies equality check predicate on the "login_locked_until" field. It's identical to LoginLockedUntilEQ.
|
||||||
|
func LoginLockedUntil(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldLoginLockedUntil, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstName applies equality check predicate on the "first_name" field. It's identical to FirstNameEQ.
|
||||||
|
func FirstName(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleName applies equality check predicate on the "middle_name" field. It's identical to MiddleNameEQ.
|
||||||
|
func MiddleName(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastName applies equality check predicate on the "last_name" field. It's identical to LastNameEQ.
|
||||||
|
func LastName(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtNEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
|
func CreatedAtIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
|
func CreatedAtNotIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||||
|
func CreatedAtGT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtGTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||||
|
func CreatedAtLT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtLTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNotIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailEQ applies the EQ predicate on the "email" field.
|
||||||
|
func EmailEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailNEQ applies the NEQ predicate on the "email" field.
|
||||||
|
func EmailNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailIn applies the In predicate on the "email" field.
|
||||||
|
func EmailIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldEmail, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailNotIn applies the NotIn predicate on the "email" field.
|
||||||
|
func EmailNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldEmail, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailGT applies the GT predicate on the "email" field.
|
||||||
|
func EmailGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailGTE applies the GTE predicate on the "email" field.
|
||||||
|
func EmailGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailLT applies the LT predicate on the "email" field.
|
||||||
|
func EmailLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailLTE applies the LTE predicate on the "email" field.
|
||||||
|
func EmailLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailContains applies the Contains predicate on the "email" field.
|
||||||
|
func EmailContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailHasPrefix applies the HasPrefix predicate on the "email" field.
|
||||||
|
func EmailHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailHasSuffix applies the HasSuffix predicate on the "email" field.
|
||||||
|
func EmailHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailEqualFold applies the EqualFold predicate on the "email" field.
|
||||||
|
func EmailEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailContainsFold applies the ContainsFold predicate on the "email" field.
|
||||||
|
func EmailContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldEmail, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailVerifiedEQ applies the EQ predicate on the "email_verified" field.
|
||||||
|
func EmailVerifiedEQ(v bool) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldEmailVerified, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmailVerifiedNEQ applies the NEQ predicate on the "email_verified" field.
|
||||||
|
func EmailVerifiedNEQ(v bool) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldEmailVerified, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneEQ applies the EQ predicate on the "phone" field.
|
||||||
|
func PhoneEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneNEQ applies the NEQ predicate on the "phone" field.
|
||||||
|
func PhoneNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneIn applies the In predicate on the "phone" field.
|
||||||
|
func PhoneIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldPhone, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneNotIn applies the NotIn predicate on the "phone" field.
|
||||||
|
func PhoneNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldPhone, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneGT applies the GT predicate on the "phone" field.
|
||||||
|
func PhoneGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneGTE applies the GTE predicate on the "phone" field.
|
||||||
|
func PhoneGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneLT applies the LT predicate on the "phone" field.
|
||||||
|
func PhoneLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneLTE applies the LTE predicate on the "phone" field.
|
||||||
|
func PhoneLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneContains applies the Contains predicate on the "phone" field.
|
||||||
|
func PhoneContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field.
|
||||||
|
func PhoneHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field.
|
||||||
|
func PhoneHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneEqualFold applies the EqualFold predicate on the "phone" field.
|
||||||
|
func PhoneEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneContainsFold applies the ContainsFold predicate on the "phone" field.
|
||||||
|
func PhoneContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldPhone, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneVerifiedEQ applies the EQ predicate on the "phone_verified" field.
|
||||||
|
func PhoneVerifiedEQ(v bool) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPhoneVerified, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PhoneVerifiedNEQ applies the NEQ predicate on the "phone_verified" field.
|
||||||
|
func PhoneVerifiedNEQ(v bool) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldPhoneVerified, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltEQ applies the EQ predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltNEQ applies the NEQ predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltIn applies the In predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldPwdSalt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltNotIn applies the NotIn predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldPwdSalt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltGT applies the GT predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltGTE applies the GTE predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltLT applies the LT predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltLTE applies the LTE predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltContains applies the Contains predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltHasPrefix applies the HasPrefix predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltHasSuffix applies the HasSuffix predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltEqualFold applies the EqualFold predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdSaltContainsFold applies the ContainsFold predicate on the "pwd_salt" field.
|
||||||
|
func PwdSaltContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldPwdSalt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashEQ applies the EQ predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashNEQ applies the NEQ predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashIn applies the In predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldPwdHash, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashNotIn applies the NotIn predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldPwdHash, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashGT applies the GT predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashGTE applies the GTE predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashLT applies the LT predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashLTE applies the LTE predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashContains applies the Contains predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashHasPrefix applies the HasPrefix predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashHasSuffix applies the HasSuffix predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashEqualFold applies the EqualFold predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// PwdHashContainsFold applies the ContainsFold predicate on the "pwd_hash" field.
|
||||||
|
func PwdHashContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldPwdHash, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountEQ applies the EQ predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountEQ(v uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldLoginFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountNEQ applies the NEQ predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountNEQ(v uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldLoginFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountIn applies the In predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountIn(vs ...uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldLoginFailedCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountNotIn applies the NotIn predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountNotIn(vs ...uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldLoginFailedCount, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountGT applies the GT predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountGT(v uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldLoginFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountGTE applies the GTE predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountGTE(v uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldLoginFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountLT applies the LT predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountLT(v uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldLoginFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountLTE applies the LTE predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountLTE(v uint8) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldLoginFailedCount, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountIsNil applies the IsNil predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountIsNil() predicate.User {
|
||||||
|
return predicate.User(sql.FieldIsNull(FieldLoginFailedCount))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginFailedCountNotNil applies the NotNil predicate on the "login_failed_count" field.
|
||||||
|
func LoginFailedCountNotNil() predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotNull(FieldLoginFailedCount))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnEQ applies the EQ predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldLoginAttemptOn, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnNEQ applies the NEQ predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnNEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldLoginAttemptOn, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnIn applies the In predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldLoginAttemptOn, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnNotIn applies the NotIn predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnNotIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldLoginAttemptOn, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnGT applies the GT predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnGT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldLoginAttemptOn, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnGTE applies the GTE predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnGTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldLoginAttemptOn, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnLT applies the LT predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnLT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldLoginAttemptOn, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnLTE applies the LTE predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnLTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldLoginAttemptOn, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnIsNil applies the IsNil predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnIsNil() predicate.User {
|
||||||
|
return predicate.User(sql.FieldIsNull(FieldLoginAttemptOn))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginAttemptOnNotNil applies the NotNil predicate on the "login_attempt_on" field.
|
||||||
|
func LoginAttemptOnNotNil() predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotNull(FieldLoginAttemptOn))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilEQ applies the EQ predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldLoginLockedUntil, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilNEQ applies the NEQ predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilNEQ(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldLoginLockedUntil, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilIn applies the In predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldLoginLockedUntil, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilNotIn applies the NotIn predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilNotIn(vs ...time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldLoginLockedUntil, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilGT applies the GT predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilGT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldLoginLockedUntil, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilGTE applies the GTE predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilGTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldLoginLockedUntil, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilLT applies the LT predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilLT(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldLoginLockedUntil, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilLTE applies the LTE predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilLTE(v time.Time) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldLoginLockedUntil, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilIsNil applies the IsNil predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilIsNil() predicate.User {
|
||||||
|
return predicate.User(sql.FieldIsNull(FieldLoginLockedUntil))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoginLockedUntilNotNil applies the NotNil predicate on the "login_locked_until" field.
|
||||||
|
func LoginLockedUntilNotNil() predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotNull(FieldLoginLockedUntil))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameEQ applies the EQ predicate on the "first_name" field.
|
||||||
|
func FirstNameEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameNEQ applies the NEQ predicate on the "first_name" field.
|
||||||
|
func FirstNameNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameIn applies the In predicate on the "first_name" field.
|
||||||
|
func FirstNameIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldFirstName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameNotIn applies the NotIn predicate on the "first_name" field.
|
||||||
|
func FirstNameNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldFirstName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameGT applies the GT predicate on the "first_name" field.
|
||||||
|
func FirstNameGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameGTE applies the GTE predicate on the "first_name" field.
|
||||||
|
func FirstNameGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameLT applies the LT predicate on the "first_name" field.
|
||||||
|
func FirstNameLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameLTE applies the LTE predicate on the "first_name" field.
|
||||||
|
func FirstNameLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameContains applies the Contains predicate on the "first_name" field.
|
||||||
|
func FirstNameContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameHasPrefix applies the HasPrefix predicate on the "first_name" field.
|
||||||
|
func FirstNameHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameHasSuffix applies the HasSuffix predicate on the "first_name" field.
|
||||||
|
func FirstNameHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameEqualFold applies the EqualFold predicate on the "first_name" field.
|
||||||
|
func FirstNameEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstNameContainsFold applies the ContainsFold predicate on the "first_name" field.
|
||||||
|
func FirstNameContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldFirstName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameEQ applies the EQ predicate on the "middle_name" field.
|
||||||
|
func MiddleNameEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameNEQ applies the NEQ predicate on the "middle_name" field.
|
||||||
|
func MiddleNameNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameIn applies the In predicate on the "middle_name" field.
|
||||||
|
func MiddleNameIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldMiddleName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameNotIn applies the NotIn predicate on the "middle_name" field.
|
||||||
|
func MiddleNameNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldMiddleName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameGT applies the GT predicate on the "middle_name" field.
|
||||||
|
func MiddleNameGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameGTE applies the GTE predicate on the "middle_name" field.
|
||||||
|
func MiddleNameGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameLT applies the LT predicate on the "middle_name" field.
|
||||||
|
func MiddleNameLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameLTE applies the LTE predicate on the "middle_name" field.
|
||||||
|
func MiddleNameLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameContains applies the Contains predicate on the "middle_name" field.
|
||||||
|
func MiddleNameContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameHasPrefix applies the HasPrefix predicate on the "middle_name" field.
|
||||||
|
func MiddleNameHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameHasSuffix applies the HasSuffix predicate on the "middle_name" field.
|
||||||
|
func MiddleNameHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameEqualFold applies the EqualFold predicate on the "middle_name" field.
|
||||||
|
func MiddleNameEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// MiddleNameContainsFold applies the ContainsFold predicate on the "middle_name" field.
|
||||||
|
func MiddleNameContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldMiddleName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameEQ applies the EQ predicate on the "last_name" field.
|
||||||
|
func LastNameEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameNEQ applies the NEQ predicate on the "last_name" field.
|
||||||
|
func LastNameNEQ(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameIn applies the In predicate on the "last_name" field.
|
||||||
|
func LastNameIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldLastName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameNotIn applies the NotIn predicate on the "last_name" field.
|
||||||
|
func LastNameNotIn(vs ...string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldLastName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameGT applies the GT predicate on the "last_name" field.
|
||||||
|
func LastNameGT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGT(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameGTE applies the GTE predicate on the "last_name" field.
|
||||||
|
func LastNameGTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldGTE(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameLT applies the LT predicate on the "last_name" field.
|
||||||
|
func LastNameLT(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLT(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameLTE applies the LTE predicate on the "last_name" field.
|
||||||
|
func LastNameLTE(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldLTE(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameContains applies the Contains predicate on the "last_name" field.
|
||||||
|
func LastNameContains(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContains(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameHasPrefix applies the HasPrefix predicate on the "last_name" field.
|
||||||
|
func LastNameHasPrefix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasPrefix(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameHasSuffix applies the HasSuffix predicate on the "last_name" field.
|
||||||
|
func LastNameHasSuffix(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldHasSuffix(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameEqualFold applies the EqualFold predicate on the "last_name" field.
|
||||||
|
func LastNameEqualFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEqualFold(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LastNameContainsFold applies the ContainsFold predicate on the "last_name" field.
|
||||||
|
func LastNameContainsFold(v string) predicate.User {
|
||||||
|
return predicate.User(sql.FieldContainsFold(FieldLastName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusEQ applies the EQ predicate on the "status" field.
|
||||||
|
func StatusEQ(v Status) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusNEQ applies the NEQ predicate on the "status" field.
|
||||||
|
func StatusNEQ(v Status) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldStatus, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusIn applies the In predicate on the "status" field.
|
||||||
|
func StatusIn(vs ...Status) predicate.User {
|
||||||
|
return predicate.User(sql.FieldIn(FieldStatus, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StatusNotIn applies the NotIn predicate on the "status" field.
|
||||||
|
func StatusNotIn(vs ...Status) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNotIn(FieldStatus, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasSessions applies the HasEdge predicate on the "sessions" edge.
|
||||||
|
func HasSessions() predicate.User {
|
||||||
|
return predicate.User(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, SessionsTable, SessionsColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasSessionsWith applies the HasEdge predicate on the "sessions" edge with a given conditions (other predicates).
|
||||||
|
func HasSessionsWith(preds ...predicate.UserSession) predicate.User {
|
||||||
|
return predicate.User(func(s *sql.Selector) {
|
||||||
|
step := newSessionsStep()
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasAuditLogs applies the HasEdge predicate on the "audit_logs" edge.
|
||||||
|
func HasAuditLogs() predicate.User {
|
||||||
|
return predicate.User(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, AuditLogsTable, AuditLogsColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasAuditLogsWith applies the HasEdge predicate on the "audit_logs" edge with a given conditions (other predicates).
|
||||||
|
func HasAuditLogsWith(preds ...predicate.Audit) predicate.User {
|
||||||
|
return predicate.User(func(s *sql.Selector) {
|
||||||
|
step := newAuditLogsStep()
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.User) predicate.User {
|
||||||
|
return predicate.User(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.User) predicate.User {
|
||||||
|
return predicate.User(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.User) predicate.User {
|
||||||
|
return predicate.User(sql.NotPredicates(p))
|
||||||
|
}
|
567
db/ent/user_create.go
Normal file
567
db/ent/user_create.go
Normal file
@ -0,0 +1,567 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserCreate is the builder for creating a User entity.
|
||||||
|
type UserCreate struct {
|
||||||
|
config
|
||||||
|
mutation *UserMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (uc *UserCreate) SetCreatedAt(t time.Time) *UserCreate {
|
||||||
|
uc.mutation.SetCreatedAt(t)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillableCreatedAt(t *time.Time) *UserCreate {
|
||||||
|
if t != nil {
|
||||||
|
uc.SetCreatedAt(*t)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (uc *UserCreate) SetUpdatedAt(t time.Time) *UserCreate {
|
||||||
|
uc.mutation.SetUpdatedAt(t)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillableUpdatedAt(t *time.Time) *UserCreate {
|
||||||
|
if t != nil {
|
||||||
|
uc.SetUpdatedAt(*t)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEmail sets the "email" field.
|
||||||
|
func (uc *UserCreate) SetEmail(s string) *UserCreate {
|
||||||
|
uc.mutation.SetEmail(s)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEmailVerified sets the "email_verified" field.
|
||||||
|
func (uc *UserCreate) SetEmailVerified(b bool) *UserCreate {
|
||||||
|
uc.mutation.SetEmailVerified(b)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableEmailVerified sets the "email_verified" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillableEmailVerified(b *bool) *UserCreate {
|
||||||
|
if b != nil {
|
||||||
|
uc.SetEmailVerified(*b)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPhone sets the "phone" field.
|
||||||
|
func (uc *UserCreate) SetPhone(s string) *UserCreate {
|
||||||
|
uc.mutation.SetPhone(s)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPhoneVerified sets the "phone_verified" field.
|
||||||
|
func (uc *UserCreate) SetPhoneVerified(b bool) *UserCreate {
|
||||||
|
uc.mutation.SetPhoneVerified(b)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillablePhoneVerified sets the "phone_verified" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillablePhoneVerified(b *bool) *UserCreate {
|
||||||
|
if b != nil {
|
||||||
|
uc.SetPhoneVerified(*b)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPwdSalt sets the "pwd_salt" field.
|
||||||
|
func (uc *UserCreate) SetPwdSalt(s string) *UserCreate {
|
||||||
|
uc.mutation.SetPwdSalt(s)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetPwdHash sets the "pwd_hash" field.
|
||||||
|
func (uc *UserCreate) SetPwdHash(s string) *UserCreate {
|
||||||
|
uc.mutation.SetPwdHash(s)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLoginFailedCount sets the "login_failed_count" field.
|
||||||
|
func (uc *UserCreate) SetLoginFailedCount(u uint8) *UserCreate {
|
||||||
|
uc.mutation.SetLoginFailedCount(u)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLoginFailedCount sets the "login_failed_count" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillableLoginFailedCount(u *uint8) *UserCreate {
|
||||||
|
if u != nil {
|
||||||
|
uc.SetLoginFailedCount(*u)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLoginAttemptOn sets the "login_attempt_on" field.
|
||||||
|
func (uc *UserCreate) SetLoginAttemptOn(t time.Time) *UserCreate {
|
||||||
|
uc.mutation.SetLoginAttemptOn(t)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLoginAttemptOn sets the "login_attempt_on" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillableLoginAttemptOn(t *time.Time) *UserCreate {
|
||||||
|
if t != nil {
|
||||||
|
uc.SetLoginAttemptOn(*t)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLoginLockedUntil sets the "login_locked_until" field.
|
||||||
|
func (uc *UserCreate) SetLoginLockedUntil(t time.Time) *UserCreate {
|
||||||
|
uc.mutation.SetLoginLockedUntil(t)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableLoginLockedUntil sets the "login_locked_until" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillableLoginLockedUntil(t *time.Time) *UserCreate {
|
||||||
|
if t != nil {
|
||||||
|
uc.SetLoginLockedUntil(*t)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetFirstName sets the "first_name" field.
|
||||||
|
func (uc *UserCreate) SetFirstName(s string) *UserCreate {
|
||||||
|
uc.mutation.SetFirstName(s)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMiddleName sets the "middle_name" field.
|
||||||
|
func (uc *UserCreate) SetMiddleName(s string) *UserCreate {
|
||||||
|
uc.mutation.SetMiddleName(s)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLastName sets the "last_name" field.
|
||||||
|
func (uc *UserCreate) SetLastName(s string) *UserCreate {
|
||||||
|
uc.mutation.SetLastName(s)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetStatus sets the "status" field.
|
||||||
|
func (uc *UserCreate) SetStatus(u user.Status) *UserCreate {
|
||||||
|
uc.mutation.SetStatus(u)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillableStatus(u *user.Status) *UserCreate {
|
||||||
|
if u != nil {
|
||||||
|
uc.SetStatus(*u)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets the "id" field.
|
||||||
|
func (uc *UserCreate) SetID(i int64) *UserCreate {
|
||||||
|
uc.mutation.SetID(i)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSessionIDs adds the "sessions" edge to the UserSession entity by IDs.
|
||||||
|
func (uc *UserCreate) AddSessionIDs(ids ...int64) *UserCreate {
|
||||||
|
uc.mutation.AddSessionIDs(ids...)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddSessions adds the "sessions" edges to the UserSession entity.
|
||||||
|
func (uc *UserCreate) AddSessions(u ...*UserSession) *UserCreate {
|
||||||
|
ids := make([]int64, len(u))
|
||||||
|
for i := range u {
|
||||||
|
ids[i] = u[i].ID
|
||||||
|
}
|
||||||
|
return uc.AddSessionIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddAuditLogIDs adds the "audit_logs" edge to the Audit entity by IDs.
|
||||||
|
func (uc *UserCreate) AddAuditLogIDs(ids ...int64) *UserCreate {
|
||||||
|
uc.mutation.AddAuditLogIDs(ids...)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddAuditLogs adds the "audit_logs" edges to the Audit entity.
|
||||||
|
func (uc *UserCreate) AddAuditLogs(a ...*Audit) *UserCreate {
|
||||||
|
ids := make([]int64, len(a))
|
||||||
|
for i := range a {
|
||||||
|
ids[i] = a[i].ID
|
||||||
|
}
|
||||||
|
return uc.AddAuditLogIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the UserMutation object of the builder.
|
||||||
|
func (uc *UserCreate) Mutation() *UserMutation {
|
||||||
|
return uc.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the User in the database.
|
||||||
|
func (uc *UserCreate) Save(ctx context.Context) (*User, error) {
|
||||||
|
uc.defaults()
|
||||||
|
return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (uc *UserCreate) SaveX(ctx context.Context) *User {
|
||||||
|
v, err := uc.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (uc *UserCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := uc.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (uc *UserCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := uc.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (uc *UserCreate) defaults() {
|
||||||
|
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||||
|
v := user.DefaultCreatedAt()
|
||||||
|
uc.mutation.SetCreatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.UpdatedAt(); !ok {
|
||||||
|
v := user.DefaultUpdatedAt()
|
||||||
|
uc.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.EmailVerified(); !ok {
|
||||||
|
v := user.DefaultEmailVerified
|
||||||
|
uc.mutation.SetEmailVerified(v)
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.PhoneVerified(); !ok {
|
||||||
|
v := user.DefaultPhoneVerified
|
||||||
|
uc.mutation.SetPhoneVerified(v)
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.LoginFailedCount(); !ok {
|
||||||
|
v := user.DefaultLoginFailedCount
|
||||||
|
uc.mutation.SetLoginFailedCount(v)
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.Status(); !ok {
|
||||||
|
v := user.DefaultStatus
|
||||||
|
uc.mutation.SetStatus(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (uc *UserCreate) check() error {
|
||||||
|
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.UpdatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "User.updated_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.Email(); !ok {
|
||||||
|
return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)}
|
||||||
|
}
|
||||||
|
if v, ok := uc.mutation.Email(); ok {
|
||||||
|
if err := user.EmailValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.EmailVerified(); !ok {
|
||||||
|
return &ValidationError{Name: "email_verified", err: errors.New(`ent: missing required field "User.email_verified"`)}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.Phone(); !ok {
|
||||||
|
return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "User.phone"`)}
|
||||||
|
}
|
||||||
|
if v, ok := uc.mutation.Phone(); ok {
|
||||||
|
if err := user.PhoneValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.PhoneVerified(); !ok {
|
||||||
|
return &ValidationError{Name: "phone_verified", err: errors.New(`ent: missing required field "User.phone_verified"`)}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.PwdSalt(); !ok {
|
||||||
|
return &ValidationError{Name: "pwd_salt", err: errors.New(`ent: missing required field "User.pwd_salt"`)}
|
||||||
|
}
|
||||||
|
if v, ok := uc.mutation.PwdSalt(); ok {
|
||||||
|
if err := user.PwdSaltValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "pwd_salt", err: fmt.Errorf(`ent: validator failed for field "User.pwd_salt": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.PwdHash(); !ok {
|
||||||
|
return &ValidationError{Name: "pwd_hash", err: errors.New(`ent: missing required field "User.pwd_hash"`)}
|
||||||
|
}
|
||||||
|
if v, ok := uc.mutation.PwdHash(); ok {
|
||||||
|
if err := user.PwdHashValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "pwd_hash", err: fmt.Errorf(`ent: validator failed for field "User.pwd_hash": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.FirstName(); !ok {
|
||||||
|
return &ValidationError{Name: "first_name", err: errors.New(`ent: missing required field "User.first_name"`)}
|
||||||
|
}
|
||||||
|
if v, ok := uc.mutation.FirstName(); ok {
|
||||||
|
if err := user.FirstNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "first_name", err: fmt.Errorf(`ent: validator failed for field "User.first_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.MiddleName(); !ok {
|
||||||
|
return &ValidationError{Name: "middle_name", err: errors.New(`ent: missing required field "User.middle_name"`)}
|
||||||
|
}
|
||||||
|
if v, ok := uc.mutation.MiddleName(); ok {
|
||||||
|
if err := user.MiddleNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "middle_name", err: fmt.Errorf(`ent: validator failed for field "User.middle_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.LastName(); !ok {
|
||||||
|
return &ValidationError{Name: "last_name", err: errors.New(`ent: missing required field "User.last_name"`)}
|
||||||
|
}
|
||||||
|
if v, ok := uc.mutation.LastName(); ok {
|
||||||
|
if err := user.LastNameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "last_name", err: fmt.Errorf(`ent: validator failed for field "User.last_name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := uc.mutation.Status(); !ok {
|
||||||
|
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "User.status"`)}
|
||||||
|
}
|
||||||
|
if v, ok := uc.mutation.Status(); ok {
|
||||||
|
if err := user.StatusValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "User.status": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) {
|
||||||
|
if err := uc.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := uc.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if _spec.ID.Value != _node.ID {
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int64(id)
|
||||||
|
}
|
||||||
|
uc.mutation.id = &_node.ID
|
||||||
|
uc.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &User{config: uc.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64))
|
||||||
|
)
|
||||||
|
if id, ok := uc.mutation.ID(); ok {
|
||||||
|
_node.ID = id
|
||||||
|
_spec.ID.Value = id
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
_node.CreatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
_node.UpdatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.Email(); ok {
|
||||||
|
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
||||||
|
_node.Email = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.EmailVerified(); ok {
|
||||||
|
_spec.SetField(user.FieldEmailVerified, field.TypeBool, value)
|
||||||
|
_node.EmailVerified = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.Phone(); ok {
|
||||||
|
_spec.SetField(user.FieldPhone, field.TypeString, value)
|
||||||
|
_node.Phone = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.PhoneVerified(); ok {
|
||||||
|
_spec.SetField(user.FieldPhoneVerified, field.TypeBool, value)
|
||||||
|
_node.PhoneVerified = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.PwdSalt(); ok {
|
||||||
|
_spec.SetField(user.FieldPwdSalt, field.TypeString, value)
|
||||||
|
_node.PwdSalt = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.PwdHash(); ok {
|
||||||
|
_spec.SetField(user.FieldPwdHash, field.TypeString, value)
|
||||||
|
_node.PwdHash = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.LoginFailedCount(); ok {
|
||||||
|
_spec.SetField(user.FieldLoginFailedCount, field.TypeUint8, value)
|
||||||
|
_node.LoginFailedCount = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.LoginAttemptOn(); ok {
|
||||||
|
_spec.SetField(user.FieldLoginAttemptOn, field.TypeTime, value)
|
||||||
|
_node.LoginAttemptOn = &value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.LoginLockedUntil(); ok {
|
||||||
|
_spec.SetField(user.FieldLoginLockedUntil, field.TypeTime, value)
|
||||||
|
_node.LoginLockedUntil = &value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.FirstName(); ok {
|
||||||
|
_spec.SetField(user.FieldFirstName, field.TypeString, value)
|
||||||
|
_node.FirstName = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.MiddleName(); ok {
|
||||||
|
_spec.SetField(user.FieldMiddleName, field.TypeString, value)
|
||||||
|
_node.MiddleName = &value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.LastName(); ok {
|
||||||
|
_spec.SetField(user.FieldLastName, field.TypeString, value)
|
||||||
|
_node.LastName = value
|
||||||
|
}
|
||||||
|
if value, ok := uc.mutation.Status(); ok {
|
||||||
|
_spec.SetField(user.FieldStatus, field.TypeEnum, value)
|
||||||
|
_node.Status = value
|
||||||
|
}
|
||||||
|
if nodes := uc.mutation.SessionsIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.SessionsTable,
|
||||||
|
Columns: []string{user.SessionsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
|
if nodes := uc.mutation.AuditLogsIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.AuditLogsTable,
|
||||||
|
Columns: []string{user.AuditLogsColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(audit.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserCreateBulk is the builder for creating many User entities in bulk.
|
||||||
|
type UserCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*UserCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the User entities in the database.
|
||||||
|
func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
||||||
|
if ucb.err != nil {
|
||||||
|
return nil, ucb.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(ucb.builders))
|
||||||
|
nodes := make([]*User, len(ucb.builders))
|
||||||
|
mutators := make([]Mutator, len(ucb.builders))
|
||||||
|
for i := range ucb.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := ucb.builders[i]
|
||||||
|
builder.defaults()
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*UserMutation)
|
||||||
|
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, ucb.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, ucb.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 && nodes[i].ID == 0 {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int64(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, ucb.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User {
|
||||||
|
v, err := ucb.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (ucb *UserCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := ucb.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ucb *UserCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := ucb.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
88
db/ent/user_delete.go
Normal file
88
db/ent/user_delete.go
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserDelete is the builder for deleting a User entity.
|
||||||
|
type UserDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *UserMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserDelete builder.
|
||||||
|
func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete {
|
||||||
|
ud.mutation.Where(ps...)
|
||||||
|
return ud
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (ud *UserDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ud *UserDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := ud.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64))
|
||||||
|
if ps := ud.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
ud.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserDeleteOne is the builder for deleting a single User entity.
|
||||||
|
type UserDeleteOne struct {
|
||||||
|
ud *UserDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserDelete builder.
|
||||||
|
func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne {
|
||||||
|
udo.ud.mutation.Where(ps...)
|
||||||
|
return udo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (udo *UserDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := udo.ud.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{user.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (udo *UserDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := udo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
682
db/ent/user_query.go
Normal file
682
db/ent/user_query.go
Normal file
@ -0,0 +1,682 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql/driver"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/audit"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserQuery is the builder for querying User entities.
|
||||||
|
type UserQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []user.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.User
|
||||||
|
withSessions *UserSessionQuery
|
||||||
|
withAuditLogs *AuditQuery
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the UserQuery builder.
|
||||||
|
func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery {
|
||||||
|
uq.predicates = append(uq.predicates, ps...)
|
||||||
|
return uq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (uq *UserQuery) Limit(limit int) *UserQuery {
|
||||||
|
uq.ctx.Limit = &limit
|
||||||
|
return uq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (uq *UserQuery) Offset(offset int) *UserQuery {
|
||||||
|
uq.ctx.Offset = &offset
|
||||||
|
return uq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (uq *UserQuery) Unique(unique bool) *UserQuery {
|
||||||
|
uq.ctx.Unique = &unique
|
||||||
|
return uq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery {
|
||||||
|
uq.order = append(uq.order, o...)
|
||||||
|
return uq
|
||||||
|
}
|
||||||
|
|
||||||
|
// QuerySessions chains the current query on the "sessions" edge.
|
||||||
|
func (uq *UserQuery) QuerySessions() *UserSessionQuery {
|
||||||
|
query := (&UserSessionClient{config: uq.config}).Query()
|
||||||
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
|
if err := uq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
selector := uq.sqlQuery(ctx)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(user.Table, user.FieldID, selector),
|
||||||
|
sqlgraph.To(usersession.Table, usersession.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, user.SessionsTable, user.SessionsColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryAuditLogs chains the current query on the "audit_logs" edge.
|
||||||
|
func (uq *UserQuery) QueryAuditLogs() *AuditQuery {
|
||||||
|
query := (&AuditClient{config: uq.config}).Query()
|
||||||
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
|
if err := uq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
selector := uq.sqlQuery(ctx)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(user.Table, user.FieldID, selector),
|
||||||
|
sqlgraph.To(audit.Table, audit.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, user.AuditLogsTable, user.AuditLogsColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first User entity from the query.
|
||||||
|
// Returns a *NotFoundError when no User was found.
|
||||||
|
func (uq *UserQuery) First(ctx context.Context) (*User, error) {
|
||||||
|
nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{user.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (uq *UserQuery) FirstX(ctx context.Context) *User {
|
||||||
|
node, err := uq.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first User ID from the query.
|
||||||
|
// Returns a *NotFoundError when no User ID was found.
|
||||||
|
func (uq *UserQuery) FirstID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{user.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (uq *UserQuery) FirstIDX(ctx context.Context) int64 {
|
||||||
|
id, err := uq.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single User entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one User entity is found.
|
||||||
|
// Returns a *NotFoundError when no User entities are found.
|
||||||
|
func (uq *UserQuery) Only(ctx context.Context) (*User, error) {
|
||||||
|
nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{user.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{user.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (uq *UserQuery) OnlyX(ctx context.Context) *User {
|
||||||
|
node, err := uq.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only User ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one User ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (uq *UserQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{user.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{user.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (uq *UserQuery) OnlyIDX(ctx context.Context) int64 {
|
||||||
|
id, err := uq.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of Users.
|
||||||
|
func (uq *UserQuery) All(ctx context.Context) ([]*User, error) {
|
||||||
|
ctx = setContextOp(ctx, uq.ctx, ent.OpQueryAll)
|
||||||
|
if err := uq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*User, *UserQuery]()
|
||||||
|
return withInterceptors[[]*User](ctx, uq, qr, uq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (uq *UserQuery) AllX(ctx context.Context) []*User {
|
||||||
|
nodes, err := uq.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of User IDs.
|
||||||
|
func (uq *UserQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
||||||
|
if uq.ctx.Unique == nil && uq.path != nil {
|
||||||
|
uq.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, uq.ctx, ent.OpQueryIDs)
|
||||||
|
if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (uq *UserQuery) IDsX(ctx context.Context) []int64 {
|
||||||
|
ids, err := uq.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (uq *UserQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, uq.ctx, ent.OpQueryCount)
|
||||||
|
if err := uq.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, uq, querierCount[*UserQuery](), uq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (uq *UserQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := uq.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (uq *UserQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, uq.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := uq.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 (uq *UserQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := uq.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (uq *UserQuery) Clone() *UserQuery {
|
||||||
|
if uq == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &UserQuery{
|
||||||
|
config: uq.config,
|
||||||
|
ctx: uq.ctx.Clone(),
|
||||||
|
order: append([]user.OrderOption{}, uq.order...),
|
||||||
|
inters: append([]Interceptor{}, uq.inters...),
|
||||||
|
predicates: append([]predicate.User{}, uq.predicates...),
|
||||||
|
withSessions: uq.withSessions.Clone(),
|
||||||
|
withAuditLogs: uq.withAuditLogs.Clone(),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: uq.sql.Clone(),
|
||||||
|
path: uq.path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithSessions tells the query-builder to eager-load the nodes that are connected to
|
||||||
|
// the "sessions" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
|
func (uq *UserQuery) WithSessions(opts ...func(*UserSessionQuery)) *UserQuery {
|
||||||
|
query := (&UserSessionClient{config: uq.config}).Query()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
uq.withSessions = query
|
||||||
|
return uq
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithAuditLogs tells the query-builder to eager-load the nodes that are connected to
|
||||||
|
// the "audit_logs" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
|
func (uq *UserQuery) WithAuditLogs(opts ...func(*AuditQuery)) *UserQuery {
|
||||||
|
query := (&AuditClient{config: uq.config}).Query()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
uq.withAuditLogs = query
|
||||||
|
return uq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
// CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.User.Query().
|
||||||
|
// GroupBy(user.FieldCreatedAt).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy {
|
||||||
|
uq.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &UserGroupBy{build: uq}
|
||||||
|
grbuild.flds = &uq.ctx.Fields
|
||||||
|
grbuild.label = user.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 {
|
||||||
|
// CreatedAt time.Time `json:"createdAt"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.User.Query().
|
||||||
|
// Select(user.FieldCreatedAt).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (uq *UserQuery) Select(fields ...string) *UserSelect {
|
||||||
|
uq.ctx.Fields = append(uq.ctx.Fields, fields...)
|
||||||
|
sbuild := &UserSelect{UserQuery: uq}
|
||||||
|
sbuild.label = user.Label
|
||||||
|
sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a UserSelect configured with the given aggregations.
|
||||||
|
func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||||
|
return uq.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uq *UserQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range uq.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, uq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range uq.ctx.Fields {
|
||||||
|
if !user.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if uq.path != nil {
|
||||||
|
prev, err := uq.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
uq.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*User{}
|
||||||
|
_spec = uq.querySpec()
|
||||||
|
loadedTypes = [2]bool{
|
||||||
|
uq.withSessions != nil,
|
||||||
|
uq.withAuditLogs != nil,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*User).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &User{config: uq.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
node.Edges.loadedTypes = loadedTypes
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
if query := uq.withSessions; query != nil {
|
||||||
|
if err := uq.loadSessions(ctx, query, nodes,
|
||||||
|
func(n *User) { n.Edges.Sessions = []*UserSession{} },
|
||||||
|
func(n *User, e *UserSession) { n.Edges.Sessions = append(n.Edges.Sessions, e) }); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if query := uq.withAuditLogs; query != nil {
|
||||||
|
if err := uq.loadAuditLogs(ctx, query, nodes,
|
||||||
|
func(n *User) { n.Edges.AuditLogs = []*Audit{} },
|
||||||
|
func(n *User, e *Audit) { n.Edges.AuditLogs = append(n.Edges.AuditLogs, e) }); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uq *UserQuery) loadSessions(ctx context.Context, query *UserSessionQuery, nodes []*User, init func(*User), assign func(*User, *UserSession)) error {
|
||||||
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
|
nodeids := make(map[int64]*User)
|
||||||
|
for i := range nodes {
|
||||||
|
fks = append(fks, nodes[i].ID)
|
||||||
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
if init != nil {
|
||||||
|
init(nodes[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.withFKs = true
|
||||||
|
query.Where(predicate.UserSession(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(s.C(user.SessionsColumn), fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.user_id
|
||||||
|
if fk == nil {
|
||||||
|
return fmt.Errorf(`foreign-key "user_id" is nil for node %v`, n.ID)
|
||||||
|
}
|
||||||
|
node, ok := nodeids[*fk]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, *fk, n.ID)
|
||||||
|
}
|
||||||
|
assign(node, n)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (uq *UserQuery) loadAuditLogs(ctx context.Context, query *AuditQuery, nodes []*User, init func(*User), assign func(*User, *Audit)) error {
|
||||||
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
|
nodeids := make(map[int64]*User)
|
||||||
|
for i := range nodes {
|
||||||
|
fks = append(fks, nodes[i].ID)
|
||||||
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
if init != nil {
|
||||||
|
init(nodes[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.withFKs = true
|
||||||
|
query.Where(predicate.Audit(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(s.C(user.AuditLogsColumn), fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.user_id
|
||||||
|
if fk == nil {
|
||||||
|
return fmt.Errorf(`foreign-key "user_id" is nil for node %v`, n.ID)
|
||||||
|
}
|
||||||
|
node, ok := nodeids[*fk]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, *fk, n.ID)
|
||||||
|
}
|
||||||
|
assign(node, n)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := uq.querySpec()
|
||||||
|
_spec.Node.Columns = uq.ctx.Fields
|
||||||
|
if len(uq.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = uq.ctx.Unique != nil && *uq.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, uq.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64))
|
||||||
|
_spec.From = uq.sql
|
||||||
|
if unique := uq.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if uq.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := uq.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, user.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != user.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := uq.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := uq.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := uq.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := uq.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(uq.driver.Dialect())
|
||||||
|
t1 := builder.Table(user.Table)
|
||||||
|
columns := uq.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = user.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if uq.sql != nil {
|
||||||
|
selector = uq.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if uq.ctx.Unique != nil && *uq.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range uq.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range uq.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := uq.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 := uq.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserGroupBy is the group-by builder for User entities.
|
||||||
|
type UserGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *UserQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy {
|
||||||
|
ugb.fns = append(ugb.fns, fns...)
|
||||||
|
return ugb
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, ugb.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := ugb.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ugb *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(ugb.fns))
|
||||||
|
for _, fn := range ugb.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns))
|
||||||
|
for _, f := range *ugb.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*ugb.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSelect is the builder for selecting fields of User entities.
|
||||||
|
type UserSelect struct {
|
||||||
|
*UserQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect {
|
||||||
|
us.fns = append(us.fns, fns...)
|
||||||
|
return us
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (us *UserSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, us.ctx, ent.OpQuerySelect)
|
||||||
|
if err := us.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*UserQuery, *UserSelect](ctx, us.UserQuery, us, us.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(us.fns))
|
||||||
|
for _, fn := range us.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*us.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 := us.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
1150
db/ent/user_update.go
Normal file
1150
db/ent/user_update.go
Normal file
File diff suppressed because it is too large
Load Diff
191
db/ent/usersession.go
Normal file
191
db/ent/usersession.go
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserSession is the model entity for the UserSession schema.
|
||||||
|
type UserSession struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID int64 `json:"id,omitempty"`
|
||||||
|
// IssuedAt holds the value of the "issued_at" field.
|
||||||
|
IssuedAt time.Time `json:"issued_at,omitempty"`
|
||||||
|
// ExpiresAt holds the value of the "expires_at" field.
|
||||||
|
ExpiresAt time.Time `json:"expires_at,omitempty"`
|
||||||
|
// Invalidated holds the value of the "invalidated" field.
|
||||||
|
Invalidated bool `json:"invalidated,omitempty"`
|
||||||
|
// UserAgent holds the value of the "user_agent" field.
|
||||||
|
UserAgent string `json:"user_agent,omitempty"`
|
||||||
|
// IP holds the value of the "ip" field.
|
||||||
|
IP string `json:"ip,omitempty"`
|
||||||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
|
// The values are being populated by the UserSessionQuery when eager-loading is set.
|
||||||
|
Edges UserSessionEdges `json:"edges"`
|
||||||
|
user_id *int64
|
||||||
|
selectValues sql.SelectValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSessionEdges holds the relations/edges for other nodes in the graph.
|
||||||
|
type UserSessionEdges struct {
|
||||||
|
// User holds the value of the user edge.
|
||||||
|
User *User `json:"user,omitempty"`
|
||||||
|
// loadedTypes holds the information for reporting if a
|
||||||
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
|
loadedTypes [1]bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserOrErr returns the User value or an error if the edge
|
||||||
|
// was not loaded in eager-loading, or loaded but was not found.
|
||||||
|
func (e UserSessionEdges) UserOrErr() (*User, error) {
|
||||||
|
if e.User != nil {
|
||||||
|
return e.User, nil
|
||||||
|
} else if e.loadedTypes[0] {
|
||||||
|
return nil, &NotFoundError{label: user.Label}
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "user"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*UserSession) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case usersession.FieldInvalidated:
|
||||||
|
values[i] = new(sql.NullBool)
|
||||||
|
case usersession.FieldID:
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
case usersession.FieldUserAgent, usersession.FieldIP:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case usersession.FieldIssuedAt, usersession.FieldExpiresAt:
|
||||||
|
values[i] = new(sql.NullTime)
|
||||||
|
case usersession.ForeignKeys[0]: // user_id
|
||||||
|
values[i] = new(sql.NullInt64)
|
||||||
|
default:
|
||||||
|
values[i] = new(sql.UnknownType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the UserSession fields.
|
||||||
|
func (us *UserSession) 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 usersession.FieldID:
|
||||||
|
value, ok := values[i].(*sql.NullInt64)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||||||
|
}
|
||||||
|
us.ID = int64(value.Int64)
|
||||||
|
case usersession.FieldIssuedAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field issued_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
us.IssuedAt = value.Time
|
||||||
|
}
|
||||||
|
case usersession.FieldExpiresAt:
|
||||||
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field expires_at", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
us.ExpiresAt = value.Time
|
||||||
|
}
|
||||||
|
case usersession.FieldInvalidated:
|
||||||
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field invalidated", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
us.Invalidated = value.Bool
|
||||||
|
}
|
||||||
|
case usersession.FieldUserAgent:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field user_agent", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
us.UserAgent = value.String
|
||||||
|
}
|
||||||
|
case usersession.FieldIP:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field ip", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
us.IP = value.String
|
||||||
|
}
|
||||||
|
case usersession.ForeignKeys[0]:
|
||||||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for edge-field user_id", value)
|
||||||
|
} else if value.Valid {
|
||||||
|
us.user_id = new(int64)
|
||||||
|
*us.user_id = int64(value.Int64)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
us.selectValues.Set(columns[i], values[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Value returns the ent.Value that was dynamically selected and assigned to the UserSession.
|
||||||
|
// This includes values selected through modifiers, order, etc.
|
||||||
|
func (us *UserSession) Value(name string) (ent.Value, error) {
|
||||||
|
return us.selectValues.Get(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUser queries the "user" edge of the UserSession entity.
|
||||||
|
func (us *UserSession) QueryUser() *UserQuery {
|
||||||
|
return NewUserSessionClient(us.config).QueryUser(us)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this UserSession.
|
||||||
|
// Note that you need to call UserSession.Unwrap() before calling this method if this UserSession
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (us *UserSession) Update() *UserSessionUpdateOne {
|
||||||
|
return NewUserSessionClient(us.config).UpdateOne(us)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the UserSession 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 (us *UserSession) Unwrap() *UserSession {
|
||||||
|
_tx, ok := us.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: UserSession is not a transactional entity")
|
||||||
|
}
|
||||||
|
us.config.driver = _tx.drv
|
||||||
|
return us
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (us *UserSession) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("UserSession(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", us.ID))
|
||||||
|
builder.WriteString("issued_at=")
|
||||||
|
builder.WriteString(us.IssuedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("expires_at=")
|
||||||
|
builder.WriteString(us.ExpiresAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("invalidated=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", us.Invalidated))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("user_agent=")
|
||||||
|
builder.WriteString(us.UserAgent)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ip=")
|
||||||
|
builder.WriteString(us.IP)
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSessions is a parsable slice of UserSession.
|
||||||
|
type UserSessions []*UserSession
|
123
db/ent/usersession/usersession.go
Normal file
123
db/ent/usersession/usersession.go
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package usersession
|
||||||
|
|
||||||
|
import (
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the usersession type in the database.
|
||||||
|
Label = "user_session"
|
||||||
|
// FieldID holds the string denoting the id field in the database.
|
||||||
|
FieldID = "id"
|
||||||
|
// FieldIssuedAt holds the string denoting the issued_at field in the database.
|
||||||
|
FieldIssuedAt = "issued_at"
|
||||||
|
// FieldExpiresAt holds the string denoting the expires_at field in the database.
|
||||||
|
FieldExpiresAt = "expires_at"
|
||||||
|
// FieldInvalidated holds the string denoting the invalidated field in the database.
|
||||||
|
FieldInvalidated = "invalidated"
|
||||||
|
// FieldUserAgent holds the string denoting the user_agent field in the database.
|
||||||
|
FieldUserAgent = "user_agent"
|
||||||
|
// FieldIP holds the string denoting the ip field in the database.
|
||||||
|
FieldIP = "ip"
|
||||||
|
// EdgeUser holds the string denoting the user edge name in mutations.
|
||||||
|
EdgeUser = "user"
|
||||||
|
// Table holds the table name of the usersession in the database.
|
||||||
|
Table = "user_sessions"
|
||||||
|
// UserTable is the table that holds the user relation/edge.
|
||||||
|
UserTable = "user_sessions"
|
||||||
|
// UserInverseTable is the table name for the User entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "user" package.
|
||||||
|
UserInverseTable = "users"
|
||||||
|
// UserColumn is the table column denoting the user relation/edge.
|
||||||
|
UserColumn = "user_id"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Columns holds all SQL columns for usersession fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldIssuedAt,
|
||||||
|
FieldExpiresAt,
|
||||||
|
FieldInvalidated,
|
||||||
|
FieldUserAgent,
|
||||||
|
FieldIP,
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForeignKeys holds the SQL foreign-keys that are owned by the "user_sessions"
|
||||||
|
// table and are not defined as standalone fields in the schema.
|
||||||
|
var ForeignKeys = []string{
|
||||||
|
"user_id",
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||||
|
func ValidColumn(column string) bool {
|
||||||
|
for i := range Columns {
|
||||||
|
if column == Columns[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := range ForeignKeys {
|
||||||
|
if column == ForeignKeys[i] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DefaultInvalidated holds the default value on creation for the "invalidated" field.
|
||||||
|
DefaultInvalidated bool
|
||||||
|
// UserAgentValidator is a validator for the "user_agent" field. It is called by the builders before save.
|
||||||
|
UserAgentValidator func(string) error
|
||||||
|
// IPValidator is a validator for the "ip" field. It is called by the builders before save.
|
||||||
|
IPValidator func(string) error
|
||||||
|
)
|
||||||
|
|
||||||
|
// OrderOption defines the ordering options for the UserSession 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()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByIssuedAt orders the results by the issued_at field.
|
||||||
|
func ByIssuedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldIssuedAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByExpiresAt orders the results by the expires_at field.
|
||||||
|
func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldExpiresAt, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByInvalidated orders the results by the invalidated field.
|
||||||
|
func ByInvalidated(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldInvalidated, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUserAgent orders the results by the user_agent field.
|
||||||
|
func ByUserAgent(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldUserAgent, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByIP orders the results by the ip field.
|
||||||
|
func ByIP(opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return sql.OrderByField(FieldIP, opts...).ToFunc()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ByUserField orders the results by user field.
|
||||||
|
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||||
|
return func(s *sql.Selector) {
|
||||||
|
sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func newUserStep() *sqlgraph.Step {
|
||||||
|
return sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(UserInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
|
||||||
|
)
|
||||||
|
}
|
349
db/ent/usersession/where.go
Normal file
349
db/ent/usersession/where.go
Normal file
@ -0,0 +1,349 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package usersession
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id int64) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAt applies equality check predicate on the "issued_at" field. It's identical to IssuedAtEQ.
|
||||||
|
func IssuedAt(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldIssuedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ.
|
||||||
|
func ExpiresAt(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldExpiresAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invalidated applies equality check predicate on the "invalidated" field. It's identical to InvalidatedEQ.
|
||||||
|
func Invalidated(v bool) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldInvalidated, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgent applies equality check predicate on the "user_agent" field. It's identical to UserAgentEQ.
|
||||||
|
func UserAgent(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IP applies equality check predicate on the "ip" field. It's identical to IPEQ.
|
||||||
|
func IP(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAtEQ applies the EQ predicate on the "issued_at" field.
|
||||||
|
func IssuedAtEQ(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldIssuedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAtNEQ applies the NEQ predicate on the "issued_at" field.
|
||||||
|
func IssuedAtNEQ(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNEQ(FieldIssuedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAtIn applies the In predicate on the "issued_at" field.
|
||||||
|
func IssuedAtIn(vs ...time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldIn(FieldIssuedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAtNotIn applies the NotIn predicate on the "issued_at" field.
|
||||||
|
func IssuedAtNotIn(vs ...time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNotIn(FieldIssuedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAtGT applies the GT predicate on the "issued_at" field.
|
||||||
|
func IssuedAtGT(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGT(FieldIssuedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAtGTE applies the GTE predicate on the "issued_at" field.
|
||||||
|
func IssuedAtGTE(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGTE(FieldIssuedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAtLT applies the LT predicate on the "issued_at" field.
|
||||||
|
func IssuedAtLT(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLT(FieldIssuedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IssuedAtLTE applies the LTE predicate on the "issued_at" field.
|
||||||
|
func IssuedAtLTE(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLTE(FieldIssuedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAtEQ applies the EQ predicate on the "expires_at" field.
|
||||||
|
func ExpiresAtEQ(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldExpiresAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field.
|
||||||
|
func ExpiresAtNEQ(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNEQ(FieldExpiresAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAtIn applies the In predicate on the "expires_at" field.
|
||||||
|
func ExpiresAtIn(vs ...time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldIn(FieldExpiresAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field.
|
||||||
|
func ExpiresAtNotIn(vs ...time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNotIn(FieldExpiresAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAtGT applies the GT predicate on the "expires_at" field.
|
||||||
|
func ExpiresAtGT(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGT(FieldExpiresAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAtGTE applies the GTE predicate on the "expires_at" field.
|
||||||
|
func ExpiresAtGTE(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGTE(FieldExpiresAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAtLT applies the LT predicate on the "expires_at" field.
|
||||||
|
func ExpiresAtLT(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLT(FieldExpiresAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExpiresAtLTE applies the LTE predicate on the "expires_at" field.
|
||||||
|
func ExpiresAtLTE(v time.Time) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLTE(FieldExpiresAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidatedEQ applies the EQ predicate on the "invalidated" field.
|
||||||
|
func InvalidatedEQ(v bool) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldInvalidated, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidatedNEQ applies the NEQ predicate on the "invalidated" field.
|
||||||
|
func InvalidatedNEQ(v bool) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNEQ(FieldInvalidated, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidatedIsNil applies the IsNil predicate on the "invalidated" field.
|
||||||
|
func InvalidatedIsNil() predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldIsNull(FieldInvalidated))
|
||||||
|
}
|
||||||
|
|
||||||
|
// InvalidatedNotNil applies the NotNil predicate on the "invalidated" field.
|
||||||
|
func InvalidatedNotNil() predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNotNull(FieldInvalidated))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentEQ applies the EQ predicate on the "user_agent" field.
|
||||||
|
func UserAgentEQ(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentNEQ applies the NEQ predicate on the "user_agent" field.
|
||||||
|
func UserAgentNEQ(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNEQ(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentIn applies the In predicate on the "user_agent" field.
|
||||||
|
func UserAgentIn(vs ...string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldIn(FieldUserAgent, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentNotIn applies the NotIn predicate on the "user_agent" field.
|
||||||
|
func UserAgentNotIn(vs ...string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNotIn(FieldUserAgent, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentGT applies the GT predicate on the "user_agent" field.
|
||||||
|
func UserAgentGT(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGT(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentGTE applies the GTE predicate on the "user_agent" field.
|
||||||
|
func UserAgentGTE(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGTE(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentLT applies the LT predicate on the "user_agent" field.
|
||||||
|
func UserAgentLT(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLT(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentLTE applies the LTE predicate on the "user_agent" field.
|
||||||
|
func UserAgentLTE(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLTE(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentContains applies the Contains predicate on the "user_agent" field.
|
||||||
|
func UserAgentContains(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldContains(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentHasPrefix applies the HasPrefix predicate on the "user_agent" field.
|
||||||
|
func UserAgentHasPrefix(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldHasPrefix(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentHasSuffix applies the HasSuffix predicate on the "user_agent" field.
|
||||||
|
func UserAgentHasSuffix(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldHasSuffix(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentEqualFold applies the EqualFold predicate on the "user_agent" field.
|
||||||
|
func UserAgentEqualFold(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEqualFold(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserAgentContainsFold applies the ContainsFold predicate on the "user_agent" field.
|
||||||
|
func UserAgentContainsFold(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldContainsFold(FieldUserAgent, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPEQ applies the EQ predicate on the "ip" field.
|
||||||
|
func IPEQ(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEQ(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPNEQ applies the NEQ predicate on the "ip" field.
|
||||||
|
func IPNEQ(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNEQ(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPIn applies the In predicate on the "ip" field.
|
||||||
|
func IPIn(vs ...string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldIn(FieldIP, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPNotIn applies the NotIn predicate on the "ip" field.
|
||||||
|
func IPNotIn(vs ...string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldNotIn(FieldIP, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPGT applies the GT predicate on the "ip" field.
|
||||||
|
func IPGT(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGT(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPGTE applies the GTE predicate on the "ip" field.
|
||||||
|
func IPGTE(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldGTE(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPLT applies the LT predicate on the "ip" field.
|
||||||
|
func IPLT(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLT(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPLTE applies the LTE predicate on the "ip" field.
|
||||||
|
func IPLTE(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldLTE(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPContains applies the Contains predicate on the "ip" field.
|
||||||
|
func IPContains(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldContains(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPHasPrefix applies the HasPrefix predicate on the "ip" field.
|
||||||
|
func IPHasPrefix(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldHasPrefix(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPHasSuffix applies the HasSuffix predicate on the "ip" field.
|
||||||
|
func IPHasSuffix(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldHasSuffix(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPEqualFold applies the EqualFold predicate on the "ip" field.
|
||||||
|
func IPEqualFold(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldEqualFold(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPContainsFold applies the ContainsFold predicate on the "ip" field.
|
||||||
|
func IPContainsFold(v string) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.FieldContainsFold(FieldIP, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasUser applies the HasEdge predicate on the "user" edge.
|
||||||
|
func HasUser() predicate.UserSession {
|
||||||
|
return predicate.UserSession(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates).
|
||||||
|
func HasUserWith(preds ...predicate.User) predicate.UserSession {
|
||||||
|
return predicate.UserSession(func(s *sql.Selector) {
|
||||||
|
step := newUserStep()
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// And groups predicates with the AND operator between them.
|
||||||
|
func And(predicates ...predicate.UserSession) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.AndPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.UserSession) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.OrPredicates(predicates...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.UserSession) predicate.UserSession {
|
||||||
|
return predicate.UserSession(sql.NotPredicates(p))
|
||||||
|
}
|
305
db/ent/usersession_create.go
Normal file
305
db/ent/usersession_create.go
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserSessionCreate is the builder for creating a UserSession entity.
|
||||||
|
type UserSessionCreate struct {
|
||||||
|
config
|
||||||
|
mutation *UserSessionMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIssuedAt sets the "issued_at" field.
|
||||||
|
func (usc *UserSessionCreate) SetIssuedAt(t time.Time) *UserSessionCreate {
|
||||||
|
usc.mutation.SetIssuedAt(t)
|
||||||
|
return usc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExpiresAt sets the "expires_at" field.
|
||||||
|
func (usc *UserSessionCreate) SetExpiresAt(t time.Time) *UserSessionCreate {
|
||||||
|
usc.mutation.SetExpiresAt(t)
|
||||||
|
return usc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetInvalidated sets the "invalidated" field.
|
||||||
|
func (usc *UserSessionCreate) SetInvalidated(b bool) *UserSessionCreate {
|
||||||
|
usc.mutation.SetInvalidated(b)
|
||||||
|
return usc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableInvalidated sets the "invalidated" field if the given value is not nil.
|
||||||
|
func (usc *UserSessionCreate) SetNillableInvalidated(b *bool) *UserSessionCreate {
|
||||||
|
if b != nil {
|
||||||
|
usc.SetInvalidated(*b)
|
||||||
|
}
|
||||||
|
return usc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserAgent sets the "user_agent" field.
|
||||||
|
func (usc *UserSessionCreate) SetUserAgent(s string) *UserSessionCreate {
|
||||||
|
usc.mutation.SetUserAgent(s)
|
||||||
|
return usc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIP sets the "ip" field.
|
||||||
|
func (usc *UserSessionCreate) SetIP(s string) *UserSessionCreate {
|
||||||
|
usc.mutation.SetIP(s)
|
||||||
|
return usc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets the "id" field.
|
||||||
|
func (usc *UserSessionCreate) SetID(i int64) *UserSessionCreate {
|
||||||
|
usc.mutation.SetID(i)
|
||||||
|
return usc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user" edge to the User entity by ID.
|
||||||
|
func (usc *UserSessionCreate) SetUserID(id int64) *UserSessionCreate {
|
||||||
|
usc.mutation.SetUserID(id)
|
||||||
|
return usc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (usc *UserSessionCreate) SetUser(u *User) *UserSessionCreate {
|
||||||
|
return usc.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the UserSessionMutation object of the builder.
|
||||||
|
func (usc *UserSessionCreate) Mutation() *UserSessionMutation {
|
||||||
|
return usc.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the UserSession in the database.
|
||||||
|
func (usc *UserSessionCreate) Save(ctx context.Context) (*UserSession, error) {
|
||||||
|
usc.defaults()
|
||||||
|
return withHooks(ctx, usc.sqlSave, usc.mutation, usc.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (usc *UserSessionCreate) SaveX(ctx context.Context) *UserSession {
|
||||||
|
v, err := usc.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (usc *UserSessionCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := usc.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (usc *UserSessionCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := usc.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (usc *UserSessionCreate) defaults() {
|
||||||
|
if _, ok := usc.mutation.Invalidated(); !ok {
|
||||||
|
v := usersession.DefaultInvalidated
|
||||||
|
usc.mutation.SetInvalidated(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (usc *UserSessionCreate) check() error {
|
||||||
|
if _, ok := usc.mutation.IssuedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "issued_at", err: errors.New(`ent: missing required field "UserSession.issued_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := usc.mutation.ExpiresAt(); !ok {
|
||||||
|
return &ValidationError{Name: "expires_at", err: errors.New(`ent: missing required field "UserSession.expires_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := usc.mutation.UserAgent(); !ok {
|
||||||
|
return &ValidationError{Name: "user_agent", err: errors.New(`ent: missing required field "UserSession.user_agent"`)}
|
||||||
|
}
|
||||||
|
if v, ok := usc.mutation.UserAgent(); ok {
|
||||||
|
if err := usersession.UserAgentValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "UserSession.user_agent": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := usc.mutation.IP(); !ok {
|
||||||
|
return &ValidationError{Name: "ip", err: errors.New(`ent: missing required field "UserSession.ip"`)}
|
||||||
|
}
|
||||||
|
if v, ok := usc.mutation.IP(); ok {
|
||||||
|
if err := usersession.IPValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "UserSession.ip": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(usc.mutation.UserIDs()) == 0 {
|
||||||
|
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserSession.user"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usc *UserSessionCreate) sqlSave(ctx context.Context) (*UserSession, error) {
|
||||||
|
if err := usc.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := usc.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, usc.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if _spec.ID.Value != _node.ID {
|
||||||
|
id := _spec.ID.Value.(int64)
|
||||||
|
_node.ID = int64(id)
|
||||||
|
}
|
||||||
|
usc.mutation.id = &_node.ID
|
||||||
|
usc.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usc *UserSessionCreate) createSpec() (*UserSession, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &UserSession{config: usc.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(usersession.Table, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeInt64))
|
||||||
|
)
|
||||||
|
if id, ok := usc.mutation.ID(); ok {
|
||||||
|
_node.ID = id
|
||||||
|
_spec.ID.Value = id
|
||||||
|
}
|
||||||
|
if value, ok := usc.mutation.IssuedAt(); ok {
|
||||||
|
_spec.SetField(usersession.FieldIssuedAt, field.TypeTime, value)
|
||||||
|
_node.IssuedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := usc.mutation.ExpiresAt(); ok {
|
||||||
|
_spec.SetField(usersession.FieldExpiresAt, field.TypeTime, value)
|
||||||
|
_node.ExpiresAt = value
|
||||||
|
}
|
||||||
|
if value, ok := usc.mutation.Invalidated(); ok {
|
||||||
|
_spec.SetField(usersession.FieldInvalidated, field.TypeBool, value)
|
||||||
|
_node.Invalidated = value
|
||||||
|
}
|
||||||
|
if value, ok := usc.mutation.UserAgent(); ok {
|
||||||
|
_spec.SetField(usersession.FieldUserAgent, field.TypeString, value)
|
||||||
|
_node.UserAgent = value
|
||||||
|
}
|
||||||
|
if value, ok := usc.mutation.IP(); ok {
|
||||||
|
_spec.SetField(usersession.FieldIP, field.TypeString, value)
|
||||||
|
_node.IP = value
|
||||||
|
}
|
||||||
|
if nodes := usc.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: usersession.UserTable,
|
||||||
|
Columns: []string{usersession.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_node.user_id = &nodes[0]
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSessionCreateBulk is the builder for creating many UserSession entities in bulk.
|
||||||
|
type UserSessionCreateBulk struct {
|
||||||
|
config
|
||||||
|
err error
|
||||||
|
builders []*UserSessionCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the UserSession entities in the database.
|
||||||
|
func (uscb *UserSessionCreateBulk) Save(ctx context.Context) ([]*UserSession, error) {
|
||||||
|
if uscb.err != nil {
|
||||||
|
return nil, uscb.err
|
||||||
|
}
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(uscb.builders))
|
||||||
|
nodes := make([]*UserSession, len(uscb.builders))
|
||||||
|
mutators := make([]Mutator, len(uscb.builders))
|
||||||
|
for i := range uscb.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := uscb.builders[i]
|
||||||
|
builder.defaults()
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*UserSessionMutation)
|
||||||
|
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, uscb.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, uscb.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 && nodes[i].ID == 0 {
|
||||||
|
id := specs[i].ID.Value.(int64)
|
||||||
|
nodes[i].ID = int64(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, uscb.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (uscb *UserSessionCreateBulk) SaveX(ctx context.Context) []*UserSession {
|
||||||
|
v, err := uscb.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (uscb *UserSessionCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := uscb.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (uscb *UserSessionCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := uscb.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
88
db/ent/usersession_delete.go
Normal file
88
db/ent/usersession_delete.go
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserSessionDelete is the builder for deleting a UserSession entity.
|
||||||
|
type UserSessionDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *UserSessionMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserSessionDelete builder.
|
||||||
|
func (usd *UserSessionDelete) Where(ps ...predicate.UserSession) *UserSessionDelete {
|
||||||
|
usd.mutation.Where(ps...)
|
||||||
|
return usd
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (usd *UserSessionDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, usd.sqlExec, usd.mutation, usd.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (usd *UserSessionDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := usd.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usd *UserSessionDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(usersession.Table, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeInt64))
|
||||||
|
if ps := usd.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, usd.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
usd.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSessionDeleteOne is the builder for deleting a single UserSession entity.
|
||||||
|
type UserSessionDeleteOne struct {
|
||||||
|
usd *UserSessionDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserSessionDelete builder.
|
||||||
|
func (usdo *UserSessionDeleteOne) Where(ps ...predicate.UserSession) *UserSessionDeleteOne {
|
||||||
|
usdo.usd.mutation.Where(ps...)
|
||||||
|
return usdo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (usdo *UserSessionDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := usdo.usd.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{usersession.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (usdo *UserSessionDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := usdo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
614
db/ent/usersession_query.go
Normal file
614
db/ent/usersession_query.go
Normal file
@ -0,0 +1,614 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent"
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserSessionQuery is the builder for querying UserSession entities.
|
||||||
|
type UserSessionQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []usersession.OrderOption
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.UserSession
|
||||||
|
withUser *UserQuery
|
||||||
|
withFKs bool
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the UserSessionQuery builder.
|
||||||
|
func (usq *UserSessionQuery) Where(ps ...predicate.UserSession) *UserSessionQuery {
|
||||||
|
usq.predicates = append(usq.predicates, ps...)
|
||||||
|
return usq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (usq *UserSessionQuery) Limit(limit int) *UserSessionQuery {
|
||||||
|
usq.ctx.Limit = &limit
|
||||||
|
return usq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (usq *UserSessionQuery) Offset(offset int) *UserSessionQuery {
|
||||||
|
usq.ctx.Offset = &offset
|
||||||
|
return usq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (usq *UserSessionQuery) Unique(unique bool) *UserSessionQuery {
|
||||||
|
usq.ctx.Unique = &unique
|
||||||
|
return usq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (usq *UserSessionQuery) Order(o ...usersession.OrderOption) *UserSessionQuery {
|
||||||
|
usq.order = append(usq.order, o...)
|
||||||
|
return usq
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUser chains the current query on the "user" edge.
|
||||||
|
func (usq *UserSessionQuery) QueryUser() *UserQuery {
|
||||||
|
query := (&UserClient{config: usq.config}).Query()
|
||||||
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
|
if err := usq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
selector := usq.sqlQuery(ctx)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(usersession.Table, usersession.FieldID, selector),
|
||||||
|
sqlgraph.To(user.Table, user.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, usersession.UserTable, usersession.UserColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(usq.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first UserSession entity from the query.
|
||||||
|
// Returns a *NotFoundError when no UserSession was found.
|
||||||
|
func (usq *UserSessionQuery) First(ctx context.Context) (*UserSession, error) {
|
||||||
|
nodes, err := usq.Limit(1).All(setContextOp(ctx, usq.ctx, ent.OpQueryFirst))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{usersession.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (usq *UserSessionQuery) FirstX(ctx context.Context) *UserSession {
|
||||||
|
node, err := usq.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first UserSession ID from the query.
|
||||||
|
// Returns a *NotFoundError when no UserSession ID was found.
|
||||||
|
func (usq *UserSessionQuery) FirstID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = usq.Limit(1).IDs(setContextOp(ctx, usq.ctx, ent.OpQueryFirstID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{usersession.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (usq *UserSessionQuery) FirstIDX(ctx context.Context) int64 {
|
||||||
|
id, err := usq.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single UserSession entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one UserSession entity is found.
|
||||||
|
// Returns a *NotFoundError when no UserSession entities are found.
|
||||||
|
func (usq *UserSessionQuery) Only(ctx context.Context) (*UserSession, error) {
|
||||||
|
nodes, err := usq.Limit(2).All(setContextOp(ctx, usq.ctx, ent.OpQueryOnly))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{usersession.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{usersession.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (usq *UserSessionQuery) OnlyX(ctx context.Context) *UserSession {
|
||||||
|
node, err := usq.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only UserSession ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one UserSession ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (usq *UserSessionQuery) OnlyID(ctx context.Context) (id int64, err error) {
|
||||||
|
var ids []int64
|
||||||
|
if ids, err = usq.Limit(2).IDs(setContextOp(ctx, usq.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{usersession.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{usersession.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (usq *UserSessionQuery) OnlyIDX(ctx context.Context) int64 {
|
||||||
|
id, err := usq.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of UserSessions.
|
||||||
|
func (usq *UserSessionQuery) All(ctx context.Context) ([]*UserSession, error) {
|
||||||
|
ctx = setContextOp(ctx, usq.ctx, ent.OpQueryAll)
|
||||||
|
if err := usq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*UserSession, *UserSessionQuery]()
|
||||||
|
return withInterceptors[[]*UserSession](ctx, usq, qr, usq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (usq *UserSessionQuery) AllX(ctx context.Context) []*UserSession {
|
||||||
|
nodes, err := usq.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of UserSession IDs.
|
||||||
|
func (usq *UserSessionQuery) IDs(ctx context.Context) (ids []int64, err error) {
|
||||||
|
if usq.ctx.Unique == nil && usq.path != nil {
|
||||||
|
usq.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, usq.ctx, ent.OpQueryIDs)
|
||||||
|
if err = usq.Select(usersession.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (usq *UserSessionQuery) IDsX(ctx context.Context) []int64 {
|
||||||
|
ids, err := usq.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (usq *UserSessionQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, usq.ctx, ent.OpQueryCount)
|
||||||
|
if err := usq.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, usq, querierCount[*UserSessionQuery](), usq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (usq *UserSessionQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := usq.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (usq *UserSessionQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, usq.ctx, ent.OpQueryExist)
|
||||||
|
switch _, err := usq.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 (usq *UserSessionQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := usq.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the UserSessionQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (usq *UserSessionQuery) Clone() *UserSessionQuery {
|
||||||
|
if usq == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &UserSessionQuery{
|
||||||
|
config: usq.config,
|
||||||
|
ctx: usq.ctx.Clone(),
|
||||||
|
order: append([]usersession.OrderOption{}, usq.order...),
|
||||||
|
inters: append([]Interceptor{}, usq.inters...),
|
||||||
|
predicates: append([]predicate.UserSession{}, usq.predicates...),
|
||||||
|
withUser: usq.withUser.Clone(),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: usq.sql.Clone(),
|
||||||
|
path: usq.path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithUser tells the query-builder to eager-load the nodes that are connected to
|
||||||
|
// the "user" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
|
func (usq *UserSessionQuery) WithUser(opts ...func(*UserQuery)) *UserSessionQuery {
|
||||||
|
query := (&UserClient{config: usq.config}).Query()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
usq.withUser = query
|
||||||
|
return usq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
// IssuedAt time.Time `json:"issued_at,omitempty"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.UserSession.Query().
|
||||||
|
// GroupBy(usersession.FieldIssuedAt).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (usq *UserSessionQuery) GroupBy(field string, fields ...string) *UserSessionGroupBy {
|
||||||
|
usq.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &UserSessionGroupBy{build: usq}
|
||||||
|
grbuild.flds = &usq.ctx.Fields
|
||||||
|
grbuild.label = usersession.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 {
|
||||||
|
// IssuedAt time.Time `json:"issued_at,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.UserSession.Query().
|
||||||
|
// Select(usersession.FieldIssuedAt).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (usq *UserSessionQuery) Select(fields ...string) *UserSessionSelect {
|
||||||
|
usq.ctx.Fields = append(usq.ctx.Fields, fields...)
|
||||||
|
sbuild := &UserSessionSelect{UserSessionQuery: usq}
|
||||||
|
sbuild.label = usersession.Label
|
||||||
|
sbuild.flds, sbuild.scan = &usq.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a UserSessionSelect configured with the given aggregations.
|
||||||
|
func (usq *UserSessionQuery) Aggregate(fns ...AggregateFunc) *UserSessionSelect {
|
||||||
|
return usq.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usq *UserSessionQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range usq.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, usq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range usq.ctx.Fields {
|
||||||
|
if !usersession.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if usq.path != nil {
|
||||||
|
prev, err := usq.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
usq.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usq *UserSessionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserSession, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*UserSession{}
|
||||||
|
withFKs = usq.withFKs
|
||||||
|
_spec = usq.querySpec()
|
||||||
|
loadedTypes = [1]bool{
|
||||||
|
usq.withUser != nil,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if usq.withUser != nil {
|
||||||
|
withFKs = true
|
||||||
|
}
|
||||||
|
if withFKs {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, usersession.ForeignKeys...)
|
||||||
|
}
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*UserSession).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &UserSession{config: usq.config}
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
node.Edges.loadedTypes = loadedTypes
|
||||||
|
return node.assignValues(columns, values)
|
||||||
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
|
if err := sqlgraph.QueryNodes(ctx, usq.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
if query := usq.withUser; query != nil {
|
||||||
|
if err := usq.loadUser(ctx, query, nodes, nil,
|
||||||
|
func(n *UserSession, e *User) { n.Edges.User = e }); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usq *UserSessionQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserSession, init func(*UserSession), assign func(*UserSession, *User)) error {
|
||||||
|
ids := make([]int64, 0, len(nodes))
|
||||||
|
nodeids := make(map[int64][]*UserSession)
|
||||||
|
for i := range nodes {
|
||||||
|
if nodes[i].user_id == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fk := *nodes[i].user_id
|
||||||
|
if _, ok := nodeids[fk]; !ok {
|
||||||
|
ids = append(ids, fk)
|
||||||
|
}
|
||||||
|
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
query.Where(user.IDIn(ids...))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
nodes, ok := nodeids[n.ID]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "user_id" returned %v`, n.ID)
|
||||||
|
}
|
||||||
|
for i := range nodes {
|
||||||
|
assign(nodes[i], n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usq *UserSessionQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := usq.querySpec()
|
||||||
|
_spec.Node.Columns = usq.ctx.Fields
|
||||||
|
if len(usq.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = usq.ctx.Unique != nil && *usq.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, usq.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usq *UserSessionQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(usersession.Table, usersession.Columns, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeInt64))
|
||||||
|
_spec.From = usq.sql
|
||||||
|
if unique := usq.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if usq.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := usq.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, usersession.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != usersession.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := usq.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := usq.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := usq.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := usq.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usq *UserSessionQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(usq.driver.Dialect())
|
||||||
|
t1 := builder.Table(usersession.Table)
|
||||||
|
columns := usq.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = usersession.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if usq.sql != nil {
|
||||||
|
selector = usq.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if usq.ctx.Unique != nil && *usq.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range usq.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range usq.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := usq.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 := usq.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSessionGroupBy is the group-by builder for UserSession entities.
|
||||||
|
type UserSessionGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *UserSessionQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (usgb *UserSessionGroupBy) Aggregate(fns ...AggregateFunc) *UserSessionGroupBy {
|
||||||
|
usgb.fns = append(usgb.fns, fns...)
|
||||||
|
return usgb
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (usgb *UserSessionGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, usgb.build.ctx, ent.OpQueryGroupBy)
|
||||||
|
if err := usgb.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*UserSessionQuery, *UserSessionGroupBy](ctx, usgb.build, usgb, usgb.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usgb *UserSessionGroupBy) sqlScan(ctx context.Context, root *UserSessionQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(usgb.fns))
|
||||||
|
for _, fn := range usgb.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*usgb.flds)+len(usgb.fns))
|
||||||
|
for _, f := range *usgb.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*usgb.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := usgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSessionSelect is the builder for selecting fields of UserSession entities.
|
||||||
|
type UserSessionSelect struct {
|
||||||
|
*UserSessionQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (uss *UserSessionSelect) Aggregate(fns ...AggregateFunc) *UserSessionSelect {
|
||||||
|
uss.fns = append(uss.fns, fns...)
|
||||||
|
return uss
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (uss *UserSessionSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, uss.ctx, ent.OpQuerySelect)
|
||||||
|
if err := uss.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*UserSessionQuery, *UserSessionSelect](ctx, uss.UserSessionQuery, uss, uss.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (uss *UserSessionSelect) sqlScan(ctx context.Context, root *UserSessionQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(uss.fns))
|
||||||
|
for _, fn := range uss.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*uss.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 := uss.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
499
db/ent/usersession_update.go
Normal file
499
db/ent/usersession_update.go
Normal file
@ -0,0 +1,499 @@
|
|||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/predicate"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/user"
|
||||||
|
"gitserver.in/patialtech/rano/db/ent/usersession"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserSessionUpdate is the builder for updating UserSession entities.
|
||||||
|
type UserSessionUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *UserSessionMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserSessionUpdate builder.
|
||||||
|
func (usu *UserSessionUpdate) Where(ps ...predicate.UserSession) *UserSessionUpdate {
|
||||||
|
usu.mutation.Where(ps...)
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIssuedAt sets the "issued_at" field.
|
||||||
|
func (usu *UserSessionUpdate) SetIssuedAt(t time.Time) *UserSessionUpdate {
|
||||||
|
usu.mutation.SetIssuedAt(t)
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIssuedAt sets the "issued_at" field if the given value is not nil.
|
||||||
|
func (usu *UserSessionUpdate) SetNillableIssuedAt(t *time.Time) *UserSessionUpdate {
|
||||||
|
if t != nil {
|
||||||
|
usu.SetIssuedAt(*t)
|
||||||
|
}
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExpiresAt sets the "expires_at" field.
|
||||||
|
func (usu *UserSessionUpdate) SetExpiresAt(t time.Time) *UserSessionUpdate {
|
||||||
|
usu.mutation.SetExpiresAt(t)
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
||||||
|
func (usu *UserSessionUpdate) SetNillableExpiresAt(t *time.Time) *UserSessionUpdate {
|
||||||
|
if t != nil {
|
||||||
|
usu.SetExpiresAt(*t)
|
||||||
|
}
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetInvalidated sets the "invalidated" field.
|
||||||
|
func (usu *UserSessionUpdate) SetInvalidated(b bool) *UserSessionUpdate {
|
||||||
|
usu.mutation.SetInvalidated(b)
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableInvalidated sets the "invalidated" field if the given value is not nil.
|
||||||
|
func (usu *UserSessionUpdate) SetNillableInvalidated(b *bool) *UserSessionUpdate {
|
||||||
|
if b != nil {
|
||||||
|
usu.SetInvalidated(*b)
|
||||||
|
}
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearInvalidated clears the value of the "invalidated" field.
|
||||||
|
func (usu *UserSessionUpdate) ClearInvalidated() *UserSessionUpdate {
|
||||||
|
usu.mutation.ClearInvalidated()
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserAgent sets the "user_agent" field.
|
||||||
|
func (usu *UserSessionUpdate) SetUserAgent(s string) *UserSessionUpdate {
|
||||||
|
usu.mutation.SetUserAgent(s)
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
|
||||||
|
func (usu *UserSessionUpdate) SetNillableUserAgent(s *string) *UserSessionUpdate {
|
||||||
|
if s != nil {
|
||||||
|
usu.SetUserAgent(*s)
|
||||||
|
}
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIP sets the "ip" field.
|
||||||
|
func (usu *UserSessionUpdate) SetIP(s string) *UserSessionUpdate {
|
||||||
|
usu.mutation.SetIP(s)
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIP sets the "ip" field if the given value is not nil.
|
||||||
|
func (usu *UserSessionUpdate) SetNillableIP(s *string) *UserSessionUpdate {
|
||||||
|
if s != nil {
|
||||||
|
usu.SetIP(*s)
|
||||||
|
}
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user" edge to the User entity by ID.
|
||||||
|
func (usu *UserSessionUpdate) SetUserID(id int64) *UserSessionUpdate {
|
||||||
|
usu.mutation.SetUserID(id)
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (usu *UserSessionUpdate) SetUser(u *User) *UserSessionUpdate {
|
||||||
|
return usu.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the UserSessionMutation object of the builder.
|
||||||
|
func (usu *UserSessionUpdate) Mutation() *UserSessionMutation {
|
||||||
|
return usu.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearUser clears the "user" edge to the User entity.
|
||||||
|
func (usu *UserSessionUpdate) ClearUser() *UserSessionUpdate {
|
||||||
|
usu.mutation.ClearUser()
|
||||||
|
return usu
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (usu *UserSessionUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
return withHooks(ctx, usu.sqlSave, usu.mutation, usu.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (usu *UserSessionUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := usu.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (usu *UserSessionUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := usu.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (usu *UserSessionUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := usu.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (usu *UserSessionUpdate) check() error {
|
||||||
|
if v, ok := usu.mutation.UserAgent(); ok {
|
||||||
|
if err := usersession.UserAgentValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "UserSession.user_agent": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := usu.mutation.IP(); ok {
|
||||||
|
if err := usersession.IPValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "UserSession.ip": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if usu.mutation.UserCleared() && len(usu.mutation.UserIDs()) > 0 {
|
||||||
|
return errors.New(`ent: clearing a required unique edge "UserSession.user"`)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usu *UserSessionUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
|
if err := usu.check(); err != nil {
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(usersession.Table, usersession.Columns, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeInt64))
|
||||||
|
if ps := usu.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := usu.mutation.IssuedAt(); ok {
|
||||||
|
_spec.SetField(usersession.FieldIssuedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := usu.mutation.ExpiresAt(); ok {
|
||||||
|
_spec.SetField(usersession.FieldExpiresAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := usu.mutation.Invalidated(); ok {
|
||||||
|
_spec.SetField(usersession.FieldInvalidated, field.TypeBool, value)
|
||||||
|
}
|
||||||
|
if usu.mutation.InvalidatedCleared() {
|
||||||
|
_spec.ClearField(usersession.FieldInvalidated, field.TypeBool)
|
||||||
|
}
|
||||||
|
if value, ok := usu.mutation.UserAgent(); ok {
|
||||||
|
_spec.SetField(usersession.FieldUserAgent, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := usu.mutation.IP(); ok {
|
||||||
|
_spec.SetField(usersession.FieldIP, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if usu.mutation.UserCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: usersession.UserTable,
|
||||||
|
Columns: []string{usersession.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := usu.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: usersession.UserTable,
|
||||||
|
Columns: []string{usersession.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
|
if n, err = sqlgraph.UpdateNodes(ctx, usu.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{usersession.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
usu.mutation.done = true
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserSessionUpdateOne is the builder for updating a single UserSession entity.
|
||||||
|
type UserSessionUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *UserSessionMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIssuedAt sets the "issued_at" field.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetIssuedAt(t time.Time) *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.SetIssuedAt(t)
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIssuedAt sets the "issued_at" field if the given value is not nil.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetNillableIssuedAt(t *time.Time) *UserSessionUpdateOne {
|
||||||
|
if t != nil {
|
||||||
|
usuo.SetIssuedAt(*t)
|
||||||
|
}
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExpiresAt sets the "expires_at" field.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetExpiresAt(t time.Time) *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.SetExpiresAt(t)
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetNillableExpiresAt(t *time.Time) *UserSessionUpdateOne {
|
||||||
|
if t != nil {
|
||||||
|
usuo.SetExpiresAt(*t)
|
||||||
|
}
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetInvalidated sets the "invalidated" field.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetInvalidated(b bool) *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.SetInvalidated(b)
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableInvalidated sets the "invalidated" field if the given value is not nil.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetNillableInvalidated(b *bool) *UserSessionUpdateOne {
|
||||||
|
if b != nil {
|
||||||
|
usuo.SetInvalidated(*b)
|
||||||
|
}
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearInvalidated clears the value of the "invalidated" field.
|
||||||
|
func (usuo *UserSessionUpdateOne) ClearInvalidated() *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.ClearInvalidated()
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserAgent sets the "user_agent" field.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetUserAgent(s string) *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.SetUserAgent(s)
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetNillableUserAgent(s *string) *UserSessionUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
usuo.SetUserAgent(*s)
|
||||||
|
}
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIP sets the "ip" field.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetIP(s string) *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.SetIP(s)
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIP sets the "ip" field if the given value is not nil.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetNillableIP(s *string) *UserSessionUpdateOne {
|
||||||
|
if s != nil {
|
||||||
|
usuo.SetIP(*s)
|
||||||
|
}
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user" edge to the User entity by ID.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetUserID(id int64) *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.SetUserID(id)
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (usuo *UserSessionUpdateOne) SetUser(u *User) *UserSessionUpdateOne {
|
||||||
|
return usuo.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the UserSessionMutation object of the builder.
|
||||||
|
func (usuo *UserSessionUpdateOne) Mutation() *UserSessionMutation {
|
||||||
|
return usuo.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearUser clears the "user" edge to the User entity.
|
||||||
|
func (usuo *UserSessionUpdateOne) ClearUser() *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.ClearUser()
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the UserSessionUpdate builder.
|
||||||
|
func (usuo *UserSessionUpdateOne) Where(ps ...predicate.UserSession) *UserSessionUpdateOne {
|
||||||
|
usuo.mutation.Where(ps...)
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (usuo *UserSessionUpdateOne) Select(field string, fields ...string) *UserSessionUpdateOne {
|
||||||
|
usuo.fields = append([]string{field}, fields...)
|
||||||
|
return usuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated UserSession entity.
|
||||||
|
func (usuo *UserSessionUpdateOne) Save(ctx context.Context) (*UserSession, error) {
|
||||||
|
return withHooks(ctx, usuo.sqlSave, usuo.mutation, usuo.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (usuo *UserSessionUpdateOne) SaveX(ctx context.Context) *UserSession {
|
||||||
|
node, err := usuo.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (usuo *UserSessionUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := usuo.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (usuo *UserSessionUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := usuo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (usuo *UserSessionUpdateOne) check() error {
|
||||||
|
if v, ok := usuo.mutation.UserAgent(); ok {
|
||||||
|
if err := usersession.UserAgentValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "user_agent", err: fmt.Errorf(`ent: validator failed for field "UserSession.user_agent": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := usuo.mutation.IP(); ok {
|
||||||
|
if err := usersession.IPValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "ip", err: fmt.Errorf(`ent: validator failed for field "UserSession.ip": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if usuo.mutation.UserCleared() && len(usuo.mutation.UserIDs()) > 0 {
|
||||||
|
return errors.New(`ent: clearing a required unique edge "UserSession.user"`)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (usuo *UserSessionUpdateOne) sqlSave(ctx context.Context) (_node *UserSession, err error) {
|
||||||
|
if err := usuo.check(); err != nil {
|
||||||
|
return _node, err
|
||||||
|
}
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(usersession.Table, usersession.Columns, sqlgraph.NewFieldSpec(usersession.FieldID, field.TypeInt64))
|
||||||
|
id, ok := usuo.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserSession.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := usuo.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, usersession.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !usersession.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != usersession.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := usuo.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := usuo.mutation.IssuedAt(); ok {
|
||||||
|
_spec.SetField(usersession.FieldIssuedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := usuo.mutation.ExpiresAt(); ok {
|
||||||
|
_spec.SetField(usersession.FieldExpiresAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := usuo.mutation.Invalidated(); ok {
|
||||||
|
_spec.SetField(usersession.FieldInvalidated, field.TypeBool, value)
|
||||||
|
}
|
||||||
|
if usuo.mutation.InvalidatedCleared() {
|
||||||
|
_spec.ClearField(usersession.FieldInvalidated, field.TypeBool)
|
||||||
|
}
|
||||||
|
if value, ok := usuo.mutation.UserAgent(); ok {
|
||||||
|
_spec.SetField(usersession.FieldUserAgent, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := usuo.mutation.IP(); ok {
|
||||||
|
_spec.SetField(usersession.FieldIP, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if usuo.mutation.UserCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: usersession.UserTable,
|
||||||
|
Columns: []string{usersession.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := usuo.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: usersession.UserTable,
|
||||||
|
Columns: []string{usersession.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
|
_node = &UserSession{config: usuo.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, usuo.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{usersession.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
usuo.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
2
db/migrations/000001_roles.up.sql
Normal file
2
db/migrations/000001_roles.up.sql
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
insert into roles(name)
|
||||||
|
values('Super Admin'), ('Admin'), ('User')
|
9
db/migrations/index.go
Normal file
9
db/migrations/index.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
_ "embed"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed *.sql
|
||||||
|
var FS embed.FS
|
45
go.mod
45
go.mod
@ -3,25 +3,58 @@ module gitserver.in/patialtech/rano
|
|||||||
go 1.23.2
|
go 1.23.2
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/99designs/gqlgen v0.17.55
|
github.com/99designs/gqlgen v0.17.56
|
||||||
github.com/vektah/gqlparser/v2 v2.5.18
|
github.com/jackc/pgx/v5 v5.7.1
|
||||||
|
github.com/vektah/gqlparser/v2 v2.5.19
|
||||||
gitserver.in/patialtech/mux v0.3.1
|
gitserver.in/patialtech/mux v0.3.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
ariga.io/atlas v0.28.1 // indirect
|
||||||
|
github.com/agext/levenshtein v1.2.3 // indirect
|
||||||
|
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
||||||
|
github.com/bmatcuk/doublestar v1.3.4 // indirect
|
||||||
|
github.com/go-openapi/inflect v0.21.0 // indirect
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
|
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||||
|
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||||
|
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||||
|
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||||
|
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
|
||||||
|
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||||
|
github.com/zclconf/go-cty v1.15.0 // indirect
|
||||||
|
go.opencensus.io v0.24.0 // indirect
|
||||||
|
go.uber.org/atomic v1.11.0 // indirect
|
||||||
|
golang.org/x/crypto v0.29.0 // indirect
|
||||||
|
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
contrib.go.opencensus.io/integrations/ocsql v0.1.7
|
||||||
|
entgo.io/contrib v0.6.0
|
||||||
|
entgo.io/ent v0.14.1
|
||||||
github.com/agnivade/levenshtein v1.2.0 // indirect
|
github.com/agnivade/levenshtein v1.2.0 // indirect
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
|
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
|
||||||
|
github.com/golang-migrate/migrate/v4 v4.18.1
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/gorilla/websocket v1.5.3 // indirect
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||||
|
github.com/lib/pq v1.10.9 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/sosodev/duration v1.3.1 // indirect
|
github.com/sosodev/duration v1.3.1 // indirect
|
||||||
github.com/urfave/cli/v2 v2.27.5 // indirect
|
github.com/urfave/cli/v2 v2.27.5 // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||||
golang.org/x/mod v0.21.0 // indirect
|
golang.org/x/mod v0.22.0 // indirect
|
||||||
golang.org/x/sync v0.8.0 // indirect
|
golang.org/x/sync v0.9.0 // indirect
|
||||||
golang.org/x/text v0.19.0 // indirect
|
golang.org/x/text v0.20.0 // indirect
|
||||||
golang.org/x/tools v0.26.0 // indirect
|
golang.org/x/tools v0.27.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
253
go.sum
253
go.sum
@ -1,60 +1,311 @@
|
|||||||
|
ariga.io/atlas v0.25.1-0.20240717145915-af51d3945208 h1:ixs1c/fAXGS3mTdalyKQrtvfkFjgChih/unX66YTzYk=
|
||||||
|
ariga.io/atlas v0.25.1-0.20240717145915-af51d3945208/go.mod h1:KPLc7Zj+nzoXfWshrcY1RwlOh94dsATQEy4UPrF2RkM=
|
||||||
|
ariga.io/atlas v0.28.1 h1:cNE0FYmoYs1u4KF+FGnp2on1srhM6FDpjaCgL7Rd8/c=
|
||||||
|
ariga.io/atlas v0.28.1/go.mod h1:LOOp18LCL9r+VifvVlJqgYJwYl271rrXD9/wIyzJ8sw=
|
||||||
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
contrib.go.opencensus.io/integrations/ocsql v0.1.7 h1:G3k7C0/W44zcqkpRSFyjU9f6HZkbwIrL//qqnlqWZ60=
|
||||||
|
contrib.go.opencensus.io/integrations/ocsql v0.1.7/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE=
|
||||||
|
entgo.io/contrib v0.6.0 h1:xfo4TbJE7sJZWx7BV7YrpSz7IPFvS8MzL3fnfzZjKvQ=
|
||||||
|
entgo.io/contrib v0.6.0/go.mod h1:3qWIseJ/9Wx2Hu5zVh15FDzv7d/UvKNcYKdViywWCQg=
|
||||||
|
entgo.io/ent v0.14.1 h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=
|
||||||
|
entgo.io/ent v0.14.1/go.mod h1:MH6XLG0KXpkcDQhKiHfANZSzR55TJyPL5IGNpI8wpco=
|
||||||
github.com/99designs/gqlgen v0.17.55 h1:3vzrNWYyzSZjGDFo68e5j9sSauLxfKvLp+6ioRokVtM=
|
github.com/99designs/gqlgen v0.17.55 h1:3vzrNWYyzSZjGDFo68e5j9sSauLxfKvLp+6ioRokVtM=
|
||||||
github.com/99designs/gqlgen v0.17.55/go.mod h1:3Bq768f8hgVPGZxL8aY9MaYmbxa6llPM/qu1IGH1EJo=
|
github.com/99designs/gqlgen v0.17.55/go.mod h1:3Bq768f8hgVPGZxL8aY9MaYmbxa6llPM/qu1IGH1EJo=
|
||||||
|
github.com/99designs/gqlgen v0.17.56 h1:+J42ARAHvnysH6klO9Wq+tCsGF32cpAgU3SyF0VRJtI=
|
||||||
|
github.com/99designs/gqlgen v0.17.56/go.mod h1:rmB6vLvtL8uf9F9w0/irJ5alBkD8DJvj35ET31BKbtY=
|
||||||
|
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0=
|
||||||
|
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
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/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
||||||
|
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
||||||
github.com/PuerkitoBio/goquery v1.9.3 h1:mpJr/ikUA9/GNJB/DBZcGeFDXUtosHRyRrwh7KGdTG0=
|
github.com/PuerkitoBio/goquery v1.9.3 h1:mpJr/ikUA9/GNJB/DBZcGeFDXUtosHRyRrwh7KGdTG0=
|
||||||
github.com/PuerkitoBio/goquery v1.9.3/go.mod h1:1ndLHPdTz+DyQPICCWYlYQMPl0oXZj0G6D4LCYA6u4U=
|
github.com/PuerkitoBio/goquery v1.9.3/go.mod h1:1ndLHPdTz+DyQPICCWYlYQMPl0oXZj0G6D4LCYA6u4U=
|
||||||
|
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
|
||||||
|
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||||
|
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||||
|
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||||
github.com/agnivade/levenshtein v1.2.0 h1:U9L4IOT0Y3i0TIlUIDJ7rVUziKi/zPbrJGaFrtYH3SY=
|
github.com/agnivade/levenshtein v1.2.0 h1:U9L4IOT0Y3i0TIlUIDJ7rVUziKi/zPbrJGaFrtYH3SY=
|
||||||
github.com/agnivade/levenshtein v1.2.0/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
|
github.com/agnivade/levenshtein v1.2.0/go.mod h1:QVVI16kDrtSuwcpd0p1+xMC6Z/VfhtCyDIjcwga4/DU=
|
||||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
|
||||||
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
|
||||||
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
|
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
|
||||||
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
|
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
|
||||||
|
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/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
|
||||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
|
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
|
||||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
||||||
|
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
|
||||||
|
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
|
||||||
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
|
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo=
|
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54 h1:SG7nF6SRlWhcT7cNTs5R6Hk4V2lcmLz2NsG2VnInyNo=
|
||||||
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
|
github.com/dgryski/trifles v0.0.0-20230903005119-f50d829f2e54/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
|
||||||
|
github.com/dhui/dktest v0.4.3 h1:wquqUxAFdcUgabAVLvSCOKOlag5cIZuaOjYIBOWdsR0=
|
||||||
|
github.com/dhui/dktest v0.4.3/go.mod h1:zNK8IwktWzQRm6I/l2Wjp7MakiyaFWv4G1hjmodmMTs=
|
||||||
|
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
|
||||||
|
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
|
||||||
|
github.com/docker/docker v27.2.0+incompatible h1:Rk9nIVdfH3+Vz4cyI/uhbINhEZ/oLmc+CBXmH6fbNk4=
|
||||||
|
github.com/docker/docker v27.2.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||||
|
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
|
||||||
|
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
|
||||||
|
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||||
|
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||||
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
|
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||||
|
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
|
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||||
|
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
|
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-openapi/inflect v0.21.0 h1:FoBjBTQEcbg2cJUWX6uwL9OyIW8eqc9k4KhN4lfbeYk=
|
||||||
|
github.com/go-openapi/inflect v0.21.0/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw=
|
||||||
|
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/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
||||||
|
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||||
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
|
github.com/golang-migrate/migrate/v4 v4.18.1 h1:JML/k+t4tpHCpQTCAD62Nu43NUFzHY4CV3uAuvHGC+Y=
|
||||||
|
github.com/golang-migrate/migrate/v4 v4.18.1/go.mod h1:HAX6m3sQgcdO81tdjn5exv20+3Kb13cmGli1hrD6hks=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||||
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
|
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
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/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
|
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||||
|
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||||
|
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||||
|
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||||
|
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/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
|
||||||
|
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||||
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
|
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
|
||||||
|
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
|
||||||
|
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||||
|
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||||
|
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||||
|
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||||
|
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/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||||
|
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
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.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||||
|
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/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
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/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
|
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||||
|
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||||
|
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
|
||||||
|
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
|
||||||
|
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
|
||||||
|
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
|
||||||
|
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/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
|
||||||
|
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||||
|
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
|
||||||
|
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
|
||||||
|
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 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||||
|
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||||
github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4=
|
github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4=
|
||||||
github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
|
github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
|
||||||
|
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
|
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||||
|
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.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
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.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
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/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
|
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
|
||||||
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
|
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
|
||||||
github.com/vektah/gqlparser/v2 v2.5.18 h1:zSND3GtutylAQ1JpWnTHcqtaRZjl+y3NROeW8vuNo6Y=
|
github.com/vektah/gqlparser/v2 v2.5.18 h1:zSND3GtutylAQ1JpWnTHcqtaRZjl+y3NROeW8vuNo6Y=
|
||||||
github.com/vektah/gqlparser/v2 v2.5.18/go.mod h1:6HLzf7JKv9Fi3APymudztFQNmLXR5qJeEo6BOFcXVfc=
|
github.com/vektah/gqlparser/v2 v2.5.18/go.mod h1:6HLzf7JKv9Fi3APymudztFQNmLXR5qJeEo6BOFcXVfc=
|
||||||
|
github.com/vektah/gqlparser/v2 v2.5.19 h1:bhCPCX1D4WWzCDvkPl4+TP1N8/kLrWnp43egplt7iSg=
|
||||||
|
github.com/vektah/gqlparser/v2 v2.5.19/go.mod h1:y7kvl5bBlDeuWIvLtA9849ncyvx6/lj06RsMrEjVy3U=
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
|
||||||
|
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
|
||||||
|
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
|
||||||
|
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
|
||||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
|
||||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
|
||||||
|
github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8=
|
||||||
|
github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||||
|
github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
|
||||||
|
github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||||
gitserver.in/patialtech/mux v0.3.1 h1:lbhQVr2vBvTcUp64Qjd2+4/s2lQXiDtsl8c+PpZvnDE=
|
gitserver.in/patialtech/mux v0.3.1 h1:lbhQVr2vBvTcUp64Qjd2+4/s2lQXiDtsl8c+PpZvnDE=
|
||||||
gitserver.in/patialtech/mux v0.3.1/go.mod h1:/pYaLBNkRiMuxMKn9e2X0BIWt1bvHM19yQE/cJsm0q0=
|
gitserver.in/patialtech/mux v0.3.1/go.mod h1:/pYaLBNkRiMuxMKn9e2X0BIWt1bvHM19yQE/cJsm0q0=
|
||||||
|
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||||
|
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||||
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk=
|
||||||
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8=
|
||||||
|
go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw=
|
||||||
|
go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8=
|
||||||
|
go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc=
|
||||||
|
go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8=
|
||||||
|
go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4=
|
||||||
|
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||||
|
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||||
|
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||||
|
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||||
|
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
|
||||||
|
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
|
||||||
|
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
|
||||||
|
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 h1:pVgRXcIictcr+lBQIFeiwuwtDIs4eL21OuM9nyAADmo=
|
||||||
|
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||||
|
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
|
||||||
|
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
|
||||||
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
|
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
|
||||||
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||||
|
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
||||||
|
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||||
|
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
|
||||||
|
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||||
|
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
|
||||||
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
|
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
|
||||||
|
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
|
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||||
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
|
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
|
||||||
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
|
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
|
||||||
|
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
|
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||||
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
|
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
|
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 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
9
pkg/auth/auth.go
Normal file
9
pkg/auth/auth.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package auth
|
||||||
|
|
||||||
|
import "gitserver.in/patialtech/rano/graph/model"
|
||||||
|
|
||||||
|
type AuthUser = model.AuthUser
|
||||||
|
|
||||||
|
func authenticate(email, pwd string) (*AuthUser, error) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
28
pkg/auth/ctx.go
Normal file
28
pkg/auth/ctx.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package auth
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"gitserver.in/patialtech/rano/config"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SessionUser struct {
|
||||||
|
ID int64
|
||||||
|
Email string
|
||||||
|
DisplayName string
|
||||||
|
RoleID int
|
||||||
|
}
|
||||||
|
|
||||||
|
func CtxWithUser(ctx context.Context, u *AuthUser) context.Context {
|
||||||
|
return context.WithValue(ctx, config.AuthUserCtxKey, &SessionUser{
|
||||||
|
ID: u.ID,
|
||||||
|
Email: u.Email,
|
||||||
|
DisplayName: u.DisplayName,
|
||||||
|
RoleID: u.RoleID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func CtxUser(ctx context.Context) *SessionUser {
|
||||||
|
u, _ := ctx.Value(config.AuthUserCtxKey).(*SessionUser)
|
||||||
|
return u
|
||||||
|
}
|
13
pkg/auth/password.go
Normal file
13
pkg/auth/password.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package auth
|
||||||
|
|
||||||
|
// EmailResetPWD link to user to reset password
|
||||||
|
func EmailResetPWD(email string) {
|
||||||
|
// send Password reset instructionss
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePWD in database
|
||||||
|
func UpdatePWD(token, email, pwd, confirmPWD string) error {
|
||||||
|
// update pwd in DB
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
17
pkg/auth/session.go
Normal file
17
pkg/auth/session.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package auth
|
||||||
|
|
||||||
|
// NewSession for user.
|
||||||
|
//
|
||||||
|
// Authenticated
|
||||||
|
func NewSession(email, pwd string) (*AuthUser, error) {
|
||||||
|
// authenticate.
|
||||||
|
|
||||||
|
// create sesion entry in db
|
||||||
|
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveSession entry from DB
|
||||||
|
func RemoveSession(sID uint) {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
@ -3,6 +3,7 @@ package logger
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Info(msg string, args ...any) {
|
func Info(msg string, args ...any) {
|
||||||
@ -21,6 +22,13 @@ func Error(err error, args ...any) {
|
|||||||
// TODO: save error log for later scrutiny
|
// TODO: save error log for later scrutiny
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fatal error will exit with os.Exit(1)
|
||||||
|
func Fatal(msg string, args ...any) {
|
||||||
|
a, b := getArgs(args)
|
||||||
|
slog.Error(fmt.Sprintf(msg, a...), b...)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
func getArgs(args []any) ([]any, []any) {
|
func getArgs(args []any) ([]any, []any) {
|
||||||
var a []any
|
var a []any
|
||||||
var b []any
|
var b []any
|
||||||
|
27
taskfile.yml
27
taskfile.yml
@ -3,13 +3,17 @@ version: '3'
|
|||||||
env:
|
env:
|
||||||
ENV: development
|
ENV: development
|
||||||
|
|
||||||
|
dotenv: ['.env.{{.ENV}}']
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
gen:
|
gen:
|
||||||
desc: use go generate, for graph files
|
desc: use go generate, for graph files
|
||||||
preconditions:
|
preconditions:
|
||||||
- go mod tidy
|
- go mod tidy
|
||||||
cmds:
|
cmds:
|
||||||
|
- go mod tidy
|
||||||
- go generate ./graph
|
- go generate ./graph
|
||||||
|
- task: ent-gen
|
||||||
|
|
||||||
check:
|
check:
|
||||||
desc: perform go vuln check
|
desc: perform go vuln check
|
||||||
@ -28,12 +32,29 @@ tasks:
|
|||||||
|
|
||||||
codegen:
|
codegen:
|
||||||
desc: generate graph types
|
desc: generate graph types
|
||||||
dotenv: ['.env.{{.ENV}}']
|
|
||||||
cmds:
|
cmds:
|
||||||
- cmd: deno task codegen
|
- cmd: deno task codegen
|
||||||
|
|
||||||
web:
|
web:
|
||||||
desc: run web in dev mode
|
desc: run web in dev mode
|
||||||
dotenv: ['.env.{{.ENV}}']
|
cmd: deno task dev
|
||||||
|
|
||||||
|
ent-new:
|
||||||
|
desc: create new db Emtity
|
||||||
|
cmd: cd ./db && go run -mod=mod entgo.io/ent/cmd/ent new {{.name}}
|
||||||
|
|
||||||
|
ent-gen:
|
||||||
|
desc: genertate from ent schema
|
||||||
cmds:
|
cmds:
|
||||||
- cmd: deno task dev
|
- go generate ./db/ent
|
||||||
|
|
||||||
|
migrate-new:
|
||||||
|
desc: create a new sql migration file
|
||||||
|
cmds:
|
||||||
|
- migrate create -ext sql -dir ./db/migrations -seq {{.name}}
|
||||||
|
|
||||||
|
migrate-up:
|
||||||
|
desc: apply automatically migration using Ent schema
|
||||||
|
cmds:
|
||||||
|
- task: ent-gen
|
||||||
|
- go run ./cmd/migrate-up
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
<meta name="mobile-web-app-capable" content="yes" />
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
Loading…
Reference in New Issue
Block a user