Updated echo and ent.
This commit is contained in:
parent
6546418052
commit
a82ed9c6d0
@ -93,6 +93,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||
cfg := c.config
|
||||
cfg.driver = &txDriver{tx: tx, drv: c.driver}
|
||||
return &Tx{
|
||||
ctx: ctx,
|
||||
config: cfg,
|
||||
PasswordToken: NewPasswordTokenClient(cfg),
|
||||
User: NewUserClient(cfg),
|
||||
|
@ -143,7 +143,7 @@ func Sum(field string) AggregateFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// ValidationError returns when validating a field fails.
|
||||
// ValidationError returns when validating a field or edge fails.
|
||||
type ValidationError struct {
|
||||
Name string // Field or edge name.
|
||||
err error
|
||||
|
@ -37,8 +37,7 @@ var (
|
||||
|
||||
// Schema is the API for creating, migrating and dropping a schema.
|
||||
type Schema struct {
|
||||
drv dialect.Driver
|
||||
universalID bool
|
||||
drv dialect.Driver
|
||||
}
|
||||
|
||||
// NewSchema creates a new schema client.
|
||||
|
@ -4,6 +4,7 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
@ -74,7 +75,7 @@ func withPasswordTokenID(id int) passwordtokenOption {
|
||||
m.oldValue = func(ctx context.Context) (*PasswordToken, error) {
|
||||
once.Do(func() {
|
||||
if m.done {
|
||||
err = fmt.Errorf("querying old values post mutation is not allowed")
|
||||
err = errors.New("querying old values post mutation is not allowed")
|
||||
} else {
|
||||
value, err = m.Client().PasswordToken.Get(ctx, id)
|
||||
}
|
||||
@ -107,7 +108,7 @@ func (m PasswordTokenMutation) Client() *Client {
|
||||
// it returns an error otherwise.
|
||||
func (m PasswordTokenMutation) Tx() (*Tx, error) {
|
||||
if _, ok := m.driver.(*txDriver); !ok {
|
||||
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
|
||||
return nil, errors.New("ent: mutation is not running in a transaction")
|
||||
}
|
||||
tx := &Tx{config: m.config}
|
||||
tx.init()
|
||||
@ -123,6 +124,25 @@ func (m *PasswordTokenMutation) ID() (id int, exists bool) {
|
||||
return *m.id, true
|
||||
}
|
||||
|
||||
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
||||
// That means, if the mutation is applied within a transaction with an isolation level such
|
||||
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
||||
// or updated by the mutation.
|
||||
func (m *PasswordTokenMutation) IDs(ctx context.Context) ([]int, error) {
|
||||
switch {
|
||||
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
||||
id, exists := m.ID()
|
||||
if exists {
|
||||
return []int{id}, nil
|
||||
}
|
||||
fallthrough
|
||||
case m.op.Is(OpUpdate | OpDelete):
|
||||
return m.Client().PasswordToken.Query().Where(m.predicates...).IDs(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
||||
}
|
||||
}
|
||||
|
||||
// SetHash sets the "hash" field.
|
||||
func (m *PasswordTokenMutation) SetHash(s string) {
|
||||
m.hash = &s
|
||||
@ -142,10 +162,10 @@ func (m *PasswordTokenMutation) Hash() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *PasswordTokenMutation) OldHash(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldHash is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldHash is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldHash requires an ID field in the mutation")
|
||||
return v, errors.New("OldHash requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@ -178,10 +198,10 @@ func (m *PasswordTokenMutation) CreatedAt() (r time.Time, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *PasswordTokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
|
||||
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@ -493,7 +513,7 @@ func withUserID(id int) userOption {
|
||||
m.oldValue = func(ctx context.Context) (*User, error) {
|
||||
once.Do(func() {
|
||||
if m.done {
|
||||
err = fmt.Errorf("querying old values post mutation is not allowed")
|
||||
err = errors.New("querying old values post mutation is not allowed")
|
||||
} else {
|
||||
value, err = m.Client().User.Get(ctx, id)
|
||||
}
|
||||
@ -526,7 +546,7 @@ func (m UserMutation) Client() *Client {
|
||||
// it returns an error otherwise.
|
||||
func (m UserMutation) Tx() (*Tx, error) {
|
||||
if _, ok := m.driver.(*txDriver); !ok {
|
||||
return nil, fmt.Errorf("ent: mutation is not running in a transaction")
|
||||
return nil, errors.New("ent: mutation is not running in a transaction")
|
||||
}
|
||||
tx := &Tx{config: m.config}
|
||||
tx.init()
|
||||
@ -542,6 +562,25 @@ func (m *UserMutation) ID() (id int, exists bool) {
|
||||
return *m.id, true
|
||||
}
|
||||
|
||||
// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
||||
// That means, if the mutation is applied within a transaction with an isolation level such
|
||||
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
||||
// or updated by the mutation.
|
||||
func (m *UserMutation) IDs(ctx context.Context) ([]int, error) {
|
||||
switch {
|
||||
case m.op.Is(OpUpdateOne | OpDeleteOne):
|
||||
id, exists := m.ID()
|
||||
if exists {
|
||||
return []int{id}, nil
|
||||
}
|
||||
fallthrough
|
||||
case m.op.Is(OpUpdate | OpDelete):
|
||||
return m.Client().User.Query().Where(m.predicates...).IDs(ctx)
|
||||
default:
|
||||
return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
||||
}
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (m *UserMutation) SetName(s string) {
|
||||
m.name = &s
|
||||
@ -561,10 +600,10 @@ func (m *UserMutation) Name() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *UserMutation) OldName(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldName is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldName is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldName requires an ID field in the mutation")
|
||||
return v, errors.New("OldName requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@ -597,10 +636,10 @@ func (m *UserMutation) Email() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldEmail is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldEmail is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldEmail requires an ID field in the mutation")
|
||||
return v, errors.New("OldEmail requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@ -633,10 +672,10 @@ func (m *UserMutation) Password() (r string, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldPassword is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldPassword requires an ID field in the mutation")
|
||||
return v, errors.New("OldPassword requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@ -669,10 +708,10 @@ func (m *UserMutation) Verified() (r bool, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *UserMutation) OldVerified(ctx context.Context) (v bool, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldVerified is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldVerified is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldVerified requires an ID field in the mutation")
|
||||
return v, errors.New("OldVerified requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
@ -705,10 +744,10 @@ func (m *UserMutation) CreatedAt() (r time.Time, exists bool) {
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *UserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, fmt.Errorf("OldCreatedAt is only allowed on UpdateOne operations")
|
||||
return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, fmt.Errorf("OldCreatedAt requires an ID field in the mutation")
|
||||
return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
|
@ -132,18 +132,18 @@ func (ptc *PasswordTokenCreate) defaults() {
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (ptc *PasswordTokenCreate) check() error {
|
||||
if _, ok := ptc.mutation.Hash(); !ok {
|
||||
return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "hash"`)}
|
||||
return &ValidationError{Name: "hash", err: errors.New(`ent: missing required field "PasswordToken.hash"`)}
|
||||
}
|
||||
if v, ok := ptc.mutation.Hash(); ok {
|
||||
if err := passwordtoken.HashValidator(v); err != nil {
|
||||
return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "hash": %w`, err)}
|
||||
return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "PasswordToken.hash": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := ptc.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "created_at"`)}
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PasswordToken.created_at"`)}
|
||||
}
|
||||
if _, ok := ptc.mutation.UserID(); !ok {
|
||||
return &ValidationError{Name: "user", err: errors.New("ent: missing required edge \"user\"")}
|
||||
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "PasswordToken.user"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -415,6 +415,10 @@ func (ptq *PasswordTokenQuery) sqlAll(ctx context.Context) ([]*PasswordToken, er
|
||||
|
||||
func (ptq *PasswordTokenQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := ptq.querySpec()
|
||||
_spec.Node.Columns = ptq.fields
|
||||
if len(ptq.fields) > 0 {
|
||||
_spec.Unique = ptq.unique != nil && *ptq.unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, ptq.driver, _spec)
|
||||
}
|
||||
|
||||
@ -486,6 +490,9 @@ func (ptq *PasswordTokenQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
selector = ptq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if ptq.unique != nil && *ptq.unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range ptq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
@ -764,9 +771,7 @@ func (ptgb *PasswordTokenGroupBy) sqlQuery() *sql.Selector {
|
||||
for _, f := range ptgb.fields {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
for _, c := range aggregation {
|
||||
columns = append(columns, c)
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
return selector.GroupBy(selector.Columns(ptgb.fields...)...)
|
||||
|
@ -135,11 +135,11 @@ func (ptu *PasswordTokenUpdate) ExecX(ctx context.Context) {
|
||||
func (ptu *PasswordTokenUpdate) check() error {
|
||||
if v, ok := ptu.mutation.Hash(); ok {
|
||||
if err := passwordtoken.HashValidator(v); err != nil {
|
||||
return &ValidationError{Name: "hash", err: fmt.Errorf("ent: validator failed for field \"hash\": %w", err)}
|
||||
return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "PasswordToken.hash": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := ptu.mutation.UserID(); ptu.mutation.UserCleared() && !ok {
|
||||
return errors.New("ent: clearing a required unique edge \"user\"")
|
||||
return errors.New(`ent: clearing a required unique edge "PasswordToken.user"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -343,11 +343,11 @@ func (ptuo *PasswordTokenUpdateOne) ExecX(ctx context.Context) {
|
||||
func (ptuo *PasswordTokenUpdateOne) check() error {
|
||||
if v, ok := ptuo.mutation.Hash(); ok {
|
||||
if err := passwordtoken.HashValidator(v); err != nil {
|
||||
return &ValidationError{Name: "hash", err: fmt.Errorf("ent: validator failed for field \"hash\": %w", err)}
|
||||
return &ValidationError{Name: "hash", err: fmt.Errorf(`ent: validator failed for field "PasswordToken.hash": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := ptuo.mutation.UserID(); ptuo.mutation.UserCleared() && !ok {
|
||||
return errors.New("ent: clearing a required unique edge \"user\"")
|
||||
return errors.New(`ent: clearing a required unique edge "PasswordToken.user"`)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -365,7 +365,7 @@ func (ptuo *PasswordTokenUpdateOne) sqlSave(ctx context.Context) (_node *Passwor
|
||||
}
|
||||
id, ok := ptuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing PasswordToken.ID for update")}
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PasswordToken.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := ptuo.fields; len(fields) > 0 {
|
||||
|
@ -51,6 +51,6 @@ func init() {
|
||||
}
|
||||
|
||||
const (
|
||||
Version = "v0.9.1" // Version of ent codegen.
|
||||
Sum = "h1:IG8andyeD79GG24U8Q+1Y45hQXj6gY5evSBcva5gtBk=" // Sum of ent codegen.
|
||||
Version = "v0.10.0" // Version of ent codegen.
|
||||
Sum = "h1:9cBomE1fh+WX34DPYQL7tDNAIvhKa3tXvwxuLyhYCMo=" // Sum of ent codegen.
|
||||
)
|
||||
|
@ -32,7 +32,7 @@ type Tx struct {
|
||||
}
|
||||
|
||||
type (
|
||||
// Committer is the interface that wraps the Committer method.
|
||||
// Committer is the interface that wraps the Commit method.
|
||||
Committer interface {
|
||||
Commit(context.Context, *Tx) error
|
||||
}
|
||||
@ -46,7 +46,7 @@ type (
|
||||
// and returns a Committer. For example:
|
||||
//
|
||||
// hook := func(next ent.Committer) ent.Committer {
|
||||
// return ent.CommitFunc(func(context.Context, tx *ent.Tx) error {
|
||||
// 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
|
||||
@ -87,7 +87,7 @@ func (tx *Tx) OnCommit(f CommitHook) {
|
||||
}
|
||||
|
||||
type (
|
||||
// Rollbacker is the interface that wraps the Rollbacker method.
|
||||
// Rollbacker is the interface that wraps the Rollback method.
|
||||
Rollbacker interface {
|
||||
Rollback(context.Context, *Tx) error
|
||||
}
|
||||
@ -101,7 +101,7 @@ type (
|
||||
// and returns a Rollbacker. For example:
|
||||
//
|
||||
// hook := func(next ent.Rollbacker) ent.Rollbacker {
|
||||
// return ent.RollbackFunc(func(context.Context, tx *ent.Tx) error {
|
||||
// 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
|
||||
|
@ -172,34 +172,34 @@ func (uc *UserCreate) defaults() error {
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (uc *UserCreate) check() error {
|
||||
if _, ok := uc.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "name"`)}
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "User.name"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Name(); ok {
|
||||
if err := user.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "name": %w`, err)}
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.Email(); !ok {
|
||||
return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "email"`)}
|
||||
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 "email": %w`, err)}
|
||||
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.Password(); !ok {
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "password"`)}
|
||||
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)}
|
||||
}
|
||||
if v, ok := uc.mutation.Password(); ok {
|
||||
if err := user.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "password": %w`, err)}
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := uc.mutation.Verified(); !ok {
|
||||
return &ValidationError{Name: "verified", err: errors.New(`ent: missing required field "verified"`)}
|
||||
return &ValidationError{Name: "verified", err: errors.New(`ent: missing required field "User.verified"`)}
|
||||
}
|
||||
if _, ok := uc.mutation.CreatedAt(); !ok {
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "created_at"`)}
|
||||
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -408,6 +408,10 @@ func (uq *UserQuery) sqlAll(ctx context.Context) ([]*User, error) {
|
||||
|
||||
func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := uq.querySpec()
|
||||
_spec.Node.Columns = uq.fields
|
||||
if len(uq.fields) > 0 {
|
||||
_spec.Unique = uq.unique != nil && *uq.unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, uq.driver, _spec)
|
||||
}
|
||||
|
||||
@ -479,6 +483,9 @@ func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
selector = uq.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if uq.unique != nil && *uq.unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, p := range uq.predicates {
|
||||
p(selector)
|
||||
}
|
||||
@ -757,9 +764,7 @@ func (ugb *UserGroupBy) sqlQuery() *sql.Selector {
|
||||
for _, f := range ugb.fields {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
for _, c := range aggregation {
|
||||
columns = append(columns, c)
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
return selector.GroupBy(selector.Columns(ugb.fields...)...)
|
||||
|
@ -4,6 +4,7 @@ package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@ -164,17 +165,17 @@ func (uu *UserUpdate) ExecX(ctx context.Context) {
|
||||
func (uu *UserUpdate) check() error {
|
||||
if v, ok := uu.mutation.Name(); ok {
|
||||
if err := user.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf("ent: validator failed for field \"name\": %w", err)}
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := uu.mutation.Email(); ok {
|
||||
if err := user.EmailValidator(v); err != nil {
|
||||
return &ValidationError{Name: "email", err: fmt.Errorf("ent: validator failed for field \"email\": %w", err)}
|
||||
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := uu.mutation.Password(); ok {
|
||||
if err := user.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf("ent: validator failed for field \"password\": %w", err)}
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -443,17 +444,17 @@ func (uuo *UserUpdateOne) ExecX(ctx context.Context) {
|
||||
func (uuo *UserUpdateOne) check() error {
|
||||
if v, ok := uuo.mutation.Name(); ok {
|
||||
if err := user.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf("ent: validator failed for field \"name\": %w", err)}
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := uuo.mutation.Email(); ok {
|
||||
if err := user.EmailValidator(v); err != nil {
|
||||
return &ValidationError{Name: "email", err: fmt.Errorf("ent: validator failed for field \"email\": %w", err)}
|
||||
return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := uuo.mutation.Password(); ok {
|
||||
if err := user.PasswordValidator(v); err != nil {
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf("ent: validator failed for field \"password\": %w", err)}
|
||||
return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -472,7 +473,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
|
||||
}
|
||||
id, ok := uuo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "ID", err: fmt.Errorf("missing User.ID for update")}
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := uuo.fields; len(fields) > 0 {
|
||||
|
40
go.mod
40
go.mod
@ -3,10 +3,10 @@ module github.com/mikestefanello/pagoda
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
entgo.io/ent v0.9.1
|
||||
entgo.io/ent v0.10.0
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible
|
||||
github.com/PuerkitoBio/goquery v1.8.0
|
||||
github.com/eko/gocache/v2 v2.1.0
|
||||
github.com/eko/gocache/v2 v2.2.0
|
||||
github.com/go-playground/validator/v10 v10.9.0
|
||||
github.com/go-redis/redis/v8 v8.11.4
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||
@ -14,31 +14,38 @@ require (
|
||||
github.com/jackc/pgx/v4 v4.14.1
|
||||
github.com/joeshaw/envdecode v0.0.0-20200121155833-099f1fc765bd
|
||||
github.com/labstack/echo-contrib v0.11.0
|
||||
github.com/labstack/echo/v4 v4.6.1
|
||||
github.com/labstack/echo/v4 v4.6.3
|
||||
github.com/labstack/gommon v0.3.1
|
||||
github.com/stretchr/testify v1.7.0
|
||||
github.com/stretchr/testify v1.7.1-0.20210427113832-6241f9ab9942
|
||||
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871
|
||||
)
|
||||
|
||||
require (
|
||||
ariga.io/atlas v0.3.2-0.20220120225051-c3fac7d636dd // indirect
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/XiaoMi/pegasus-go-client v0.0.0-20210427083443-f3b6b08bc4c2 // indirect
|
||||
github.com/agext/levenshtein v1.2.1 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/go-cmp v0.5.6 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/gorilla/context v1.1.1 // indirect
|
||||
github.com/gorilla/securecookie v1.1.1 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.10.0 // indirect
|
||||
github.com/huandu/xstrings v1.3.2 // indirect
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.10.1 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
@ -50,26 +57,37 @@ require (
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.12 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.9 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pegasus-kv/thrift v0.13.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_golang v1.10.0 // indirect
|
||||
github.com/prometheus/client_golang v1.12.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.25.0 // indirect
|
||||
github.com/prometheus/procfs v0.6.0 // indirect
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/sirupsen/logrus v1.6.0 // indirect
|
||||
github.com/spf13/cast v1.3.1 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/spf13/cobra v1.3.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/stretchr/objx v0.2.0 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.1 // indirect
|
||||
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
|
||||
github.com/zclconf/go-cty v1.8.0 // indirect
|
||||
golang.org/x/mod v0.5.1 // indirect
|
||||
golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 // indirect
|
||||
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect
|
||||
google.golang.org/appengine v1.6.1 // indirect
|
||||
google.golang.org/protobuf v1.26.0 // indirect
|
||||
golang.org/x/tools v0.1.9-0.20211216111533-8d383106f7e7 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/protobuf v1.27.1 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
entsql "entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/schema"
|
||||
_ "github.com/jackc/pgx/v4/stdlib"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/gommon/log"
|
||||
@ -158,7 +159,7 @@ func (c *Container) initDatabase() {
|
||||
func (c *Container) initORM() {
|
||||
drv := entsql.OpenDB(dialect.Postgres, c.Database)
|
||||
c.ORM = ent.NewClient(ent.Driver(drv))
|
||||
if err := c.ORM.Schema.Create(context.Background()); err != nil {
|
||||
if err := c.ORM.Schema.Create(context.Background(), schema.WithAtlas(true)); err != nil {
|
||||
panic(fmt.Sprintf("failed to create database schema: %v", err))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user