create account, create email
This commit is contained in:
@ -226,6 +226,16 @@ func NicknameHasSuffix(v string) predicate.Account {
|
||||
return predicate.Account(sql.FieldHasSuffix(FieldNickname, v))
|
||||
}
|
||||
|
||||
// NicknameIsNil applies the IsNil predicate on the "nickname" field.
|
||||
func NicknameIsNil() predicate.Account {
|
||||
return predicate.Account(sql.FieldIsNull(FieldNickname))
|
||||
}
|
||||
|
||||
// NicknameNotNil applies the NotNil predicate on the "nickname" field.
|
||||
func NicknameNotNil() predicate.Account {
|
||||
return predicate.Account(sql.FieldNotNull(FieldNickname))
|
||||
}
|
||||
|
||||
// NicknameEqualFold applies the EqualFold predicate on the "nickname" field.
|
||||
func NicknameEqualFold(v string) predicate.Account {
|
||||
return predicate.Account(sql.FieldEqualFold(FieldNickname, v))
|
||||
@ -291,6 +301,16 @@ func NameHasSuffix(v string) predicate.Account {
|
||||
return predicate.Account(sql.FieldHasSuffix(FieldName, v))
|
||||
}
|
||||
|
||||
// NameIsNil applies the IsNil predicate on the "name" field.
|
||||
func NameIsNil() predicate.Account {
|
||||
return predicate.Account(sql.FieldIsNull(FieldName))
|
||||
}
|
||||
|
||||
// NameNotNil applies the NotNil predicate on the "name" field.
|
||||
func NameNotNil() predicate.Account {
|
||||
return predicate.Account(sql.FieldNotNull(FieldName))
|
||||
}
|
||||
|
||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||
func NameEqualFold(v string) predicate.Account {
|
||||
return predicate.Account(sql.FieldEqualFold(FieldName, v))
|
||||
|
@ -56,12 +56,28 @@ func (ac *AccountCreate) SetNickname(s string) *AccountCreate {
|
||||
return ac
|
||||
}
|
||||
|
||||
// SetNillableNickname sets the "nickname" field if the given value is not nil.
|
||||
func (ac *AccountCreate) SetNillableNickname(s *string) *AccountCreate {
|
||||
if s != nil {
|
||||
ac.SetNickname(*s)
|
||||
}
|
||||
return ac
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (ac *AccountCreate) SetName(s string) *AccountCreate {
|
||||
ac.mutation.SetName(s)
|
||||
return ac
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (ac *AccountCreate) SetNillableName(s *string) *AccountCreate {
|
||||
if s != nil {
|
||||
ac.SetName(*s)
|
||||
}
|
||||
return ac
|
||||
}
|
||||
|
||||
// SetSecret sets the "secret" field.
|
||||
func (ac *AccountCreate) SetSecret(b []byte) *AccountCreate {
|
||||
ac.mutation.SetSecret(b)
|
||||
@ -154,12 +170,6 @@ func (ac *AccountCreate) check() error {
|
||||
if _, ok := ac.mutation.UpdatedAt(); !ok {
|
||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Account.updated_at"`)}
|
||||
}
|
||||
if _, ok := ac.mutation.Nickname(); !ok {
|
||||
return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Account.nickname"`)}
|
||||
}
|
||||
if _, ok := ac.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Account.name"`)}
|
||||
}
|
||||
if _, ok := ac.mutation.Secret(); !ok {
|
||||
return &ValidationError{Name: "secret", err: errors.New(`ent: missing required field "Account.secret"`)}
|
||||
}
|
||||
|
@ -50,6 +50,12 @@ func (au *AccountUpdate) SetNillableNickname(s *string) *AccountUpdate {
|
||||
return au
|
||||
}
|
||||
|
||||
// ClearNickname clears the value of the "nickname" field.
|
||||
func (au *AccountUpdate) ClearNickname() *AccountUpdate {
|
||||
au.mutation.ClearNickname()
|
||||
return au
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (au *AccountUpdate) SetName(s string) *AccountUpdate {
|
||||
au.mutation.SetName(s)
|
||||
@ -64,6 +70,12 @@ func (au *AccountUpdate) SetNillableName(s *string) *AccountUpdate {
|
||||
return au
|
||||
}
|
||||
|
||||
// ClearName clears the value of the "name" field.
|
||||
func (au *AccountUpdate) ClearName() *AccountUpdate {
|
||||
au.mutation.ClearName()
|
||||
return au
|
||||
}
|
||||
|
||||
// SetSecret sets the "secret" field.
|
||||
func (au *AccountUpdate) SetSecret(b []byte) *AccountUpdate {
|
||||
au.mutation.SetSecret(b)
|
||||
@ -187,9 +199,15 @@ func (au *AccountUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if value, ok := au.mutation.Nickname(); ok {
|
||||
_spec.SetField(account.FieldNickname, field.TypeString, value)
|
||||
}
|
||||
if au.mutation.NicknameCleared() {
|
||||
_spec.ClearField(account.FieldNickname, field.TypeString)
|
||||
}
|
||||
if value, ok := au.mutation.Name(); ok {
|
||||
_spec.SetField(account.FieldName, field.TypeString, value)
|
||||
}
|
||||
if au.mutation.NameCleared() {
|
||||
_spec.ClearField(account.FieldName, field.TypeString)
|
||||
}
|
||||
if value, ok := au.mutation.Secret(); ok {
|
||||
_spec.SetField(account.FieldSecret, field.TypeBytes, value)
|
||||
}
|
||||
@ -284,6 +302,12 @@ func (auo *AccountUpdateOne) SetNillableNickname(s *string) *AccountUpdateOne {
|
||||
return auo
|
||||
}
|
||||
|
||||
// ClearNickname clears the value of the "nickname" field.
|
||||
func (auo *AccountUpdateOne) ClearNickname() *AccountUpdateOne {
|
||||
auo.mutation.ClearNickname()
|
||||
return auo
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (auo *AccountUpdateOne) SetName(s string) *AccountUpdateOne {
|
||||
auo.mutation.SetName(s)
|
||||
@ -298,6 +322,12 @@ func (auo *AccountUpdateOne) SetNillableName(s *string) *AccountUpdateOne {
|
||||
return auo
|
||||
}
|
||||
|
||||
// ClearName clears the value of the "name" field.
|
||||
func (auo *AccountUpdateOne) ClearName() *AccountUpdateOne {
|
||||
auo.mutation.ClearName()
|
||||
return auo
|
||||
}
|
||||
|
||||
// SetSecret sets the "secret" field.
|
||||
func (auo *AccountUpdateOne) SetSecret(b []byte) *AccountUpdateOne {
|
||||
auo.mutation.SetSecret(b)
|
||||
@ -451,9 +481,15 @@ func (auo *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err e
|
||||
if value, ok := auo.mutation.Nickname(); ok {
|
||||
_spec.SetField(account.FieldNickname, field.TypeString, value)
|
||||
}
|
||||
if auo.mutation.NicknameCleared() {
|
||||
_spec.ClearField(account.FieldNickname, field.TypeString)
|
||||
}
|
||||
if value, ok := auo.mutation.Name(); ok {
|
||||
_spec.SetField(account.FieldName, field.TypeString, value)
|
||||
}
|
||||
if auo.mutation.NameCleared() {
|
||||
_spec.ClearField(account.FieldName, field.TypeString)
|
||||
}
|
||||
if value, ok := auo.mutation.Secret(); ok {
|
||||
_spec.SetField(account.FieldSecret, field.TypeBytes, value)
|
||||
}
|
||||
|
@ -465,15 +465,15 @@ func (c *EmailClient) GetX(ctx context.Context, id uuid.UUID) *Email {
|
||||
return obj
|
||||
}
|
||||
|
||||
// QueryAccounts queries the accounts edge of a Email.
|
||||
func (c *EmailClient) QueryAccounts(e *Email) *AccountQuery {
|
||||
// QueryAccount queries the account edge of a Email.
|
||||
func (c *EmailClient) QueryAccount(e *Email) *AccountQuery {
|
||||
query := (&AccountClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := e.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(email.Table, email.FieldID, id),
|
||||
sqlgraph.To(account.Table, account.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, email.AccountsTable, email.AccountsColumn),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, email.AccountTable, email.AccountColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
|
20
ent/email.go
20
ent/email.go
@ -37,22 +37,22 @@ type Email struct {
|
||||
|
||||
// EmailEdges holds the relations/edges for other nodes in the graph.
|
||||
type EmailEdges struct {
|
||||
// Accounts holds the value of the accounts edge.
|
||||
Accounts *Account `json:"accounts,omitempty"`
|
||||
// Account holds the value of the account edge.
|
||||
Account *Account `json:"account,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// AccountsOrErr returns the Accounts value or an error if the edge
|
||||
// AccountOrErr returns the Account value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e EmailEdges) AccountsOrErr() (*Account, error) {
|
||||
if e.Accounts != nil {
|
||||
return e.Accounts, nil
|
||||
func (e EmailEdges) AccountOrErr() (*Account, error) {
|
||||
if e.Account != nil {
|
||||
return e.Account, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: account.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "accounts"}
|
||||
return nil, &NotLoadedError{edge: "account"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
@ -139,9 +139,9 @@ func (e *Email) Value(name string) (ent.Value, error) {
|
||||
return e.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryAccounts queries the "accounts" edge of the Email entity.
|
||||
func (e *Email) QueryAccounts() *AccountQuery {
|
||||
return NewEmailClient(e.config).QueryAccounts(e)
|
||||
// QueryAccount queries the "account" edge of the Email entity.
|
||||
func (e *Email) QueryAccount() *AccountQuery {
|
||||
return NewEmailClient(e.config).QueryAccount(e)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Email.
|
||||
|
@ -22,17 +22,17 @@ const (
|
||||
FieldVerificationCode = "verification_code"
|
||||
// FieldResetCode holds the string denoting the reset_code field in the database.
|
||||
FieldResetCode = "reset_code"
|
||||
// EdgeAccounts holds the string denoting the accounts edge name in mutations.
|
||||
EdgeAccounts = "accounts"
|
||||
// EdgeAccount holds the string denoting the account edge name in mutations.
|
||||
EdgeAccount = "account"
|
||||
// Table holds the table name of the email in the database.
|
||||
Table = "emails"
|
||||
// AccountsTable is the table that holds the accounts relation/edge.
|
||||
AccountsTable = "emails"
|
||||
// AccountsInverseTable is the table name for the Account entity.
|
||||
// AccountTable is the table that holds the account relation/edge.
|
||||
AccountTable = "emails"
|
||||
// AccountInverseTable is the table name for the Account entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "account" package.
|
||||
AccountsInverseTable = "accounts"
|
||||
// AccountsColumn is the table column denoting the accounts relation/edge.
|
||||
AccountsColumn = "account_emails"
|
||||
AccountInverseTable = "accounts"
|
||||
// AccountColumn is the table column denoting the account relation/edge.
|
||||
AccountColumn = "account_emails"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for email fields.
|
||||
@ -106,16 +106,16 @@ func ByResetCode(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldResetCode, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAccountsField orders the results by accounts field.
|
||||
func ByAccountsField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
// ByAccountField orders the results by account field.
|
||||
func ByAccountField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newAccountsStep(), sql.OrderByField(field, opts...))
|
||||
sqlgraph.OrderByNeighborTerms(s, newAccountStep(), sql.OrderByField(field, opts...))
|
||||
}
|
||||
}
|
||||
func newAccountsStep() *sqlgraph.Step {
|
||||
func newAccountStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(AccountsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, AccountsTable, AccountsColumn),
|
||||
sqlgraph.To(AccountInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn),
|
||||
)
|
||||
}
|
||||
|
@ -314,21 +314,21 @@ func ResetCodeContainsFold(v string) predicate.Email {
|
||||
return predicate.Email(sql.FieldContainsFold(FieldResetCode, v))
|
||||
}
|
||||
|
||||
// HasAccounts applies the HasEdge predicate on the "accounts" edge.
|
||||
func HasAccounts() predicate.Email {
|
||||
// HasAccount applies the HasEdge predicate on the "account" edge.
|
||||
func HasAccount() predicate.Email {
|
||||
return predicate.Email(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, AccountsTable, AccountsColumn),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasAccountsWith applies the HasEdge predicate on the "accounts" edge with a given conditions (other predicates).
|
||||
func HasAccountsWith(preds ...predicate.Account) predicate.Email {
|
||||
// HasAccountWith applies the HasEdge predicate on the "account" edge with a given conditions (other predicates).
|
||||
func HasAccountWith(preds ...predicate.Account) predicate.Email {
|
||||
return predicate.Email(func(s *sql.Selector) {
|
||||
step := newAccountsStep()
|
||||
step := newAccountStep()
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
for _, p := range preds {
|
||||
p(s)
|
||||
|
@ -89,23 +89,23 @@ func (ec *EmailCreate) SetID(u uuid.UUID) *EmailCreate {
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetAccountsID sets the "accounts" edge to the Account entity by ID.
|
||||
func (ec *EmailCreate) SetAccountsID(id uuid.UUID) *EmailCreate {
|
||||
ec.mutation.SetAccountsID(id)
|
||||
// SetAccountID sets the "account" edge to the Account entity by ID.
|
||||
func (ec *EmailCreate) SetAccountID(id uuid.UUID) *EmailCreate {
|
||||
ec.mutation.SetAccountID(id)
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetNillableAccountsID sets the "accounts" edge to the Account entity by ID if the given value is not nil.
|
||||
func (ec *EmailCreate) SetNillableAccountsID(id *uuid.UUID) *EmailCreate {
|
||||
// SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
|
||||
func (ec *EmailCreate) SetNillableAccountID(id *uuid.UUID) *EmailCreate {
|
||||
if id != nil {
|
||||
ec = ec.SetAccountsID(*id)
|
||||
ec = ec.SetAccountID(*id)
|
||||
}
|
||||
return ec
|
||||
}
|
||||
|
||||
// SetAccounts sets the "accounts" edge to the Account entity.
|
||||
func (ec *EmailCreate) SetAccounts(a *Account) *EmailCreate {
|
||||
return ec.SetAccountsID(a.ID)
|
||||
// SetAccount sets the "account" edge to the Account entity.
|
||||
func (ec *EmailCreate) SetAccount(a *Account) *EmailCreate {
|
||||
return ec.SetAccountID(a.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the EmailMutation object of the builder.
|
||||
@ -219,12 +219,12 @@ func (ec *EmailCreate) createSpec() (*Email, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(email.FieldResetCode, field.TypeString, value)
|
||||
_node.ResetCode = value
|
||||
}
|
||||
if nodes := ec.mutation.AccountsIDs(); len(nodes) > 0 {
|
||||
if nodes := ec.mutation.AccountIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: email.AccountsTable,
|
||||
Columns: []string{email.AccountsColumn},
|
||||
Table: email.AccountTable,
|
||||
Columns: []string{email.AccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||
|
@ -20,12 +20,12 @@ import (
|
||||
// EmailQuery is the builder for querying Email entities.
|
||||
type EmailQuery struct {
|
||||
config
|
||||
ctx *QueryContext
|
||||
order []email.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Email
|
||||
withAccounts *AccountQuery
|
||||
withFKs bool
|
||||
ctx *QueryContext
|
||||
order []email.OrderOption
|
||||
inters []Interceptor
|
||||
predicates []predicate.Email
|
||||
withAccount *AccountQuery
|
||||
withFKs bool
|
||||
// intermediate query (i.e. traversal path).
|
||||
sql *sql.Selector
|
||||
path func(context.Context) (*sql.Selector, error)
|
||||
@ -62,8 +62,8 @@ func (eq *EmailQuery) Order(o ...email.OrderOption) *EmailQuery {
|
||||
return eq
|
||||
}
|
||||
|
||||
// QueryAccounts chains the current query on the "accounts" edge.
|
||||
func (eq *EmailQuery) QueryAccounts() *AccountQuery {
|
||||
// QueryAccount chains the current query on the "account" edge.
|
||||
func (eq *EmailQuery) QueryAccount() *AccountQuery {
|
||||
query := (&AccountClient{config: eq.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := eq.prepareQuery(ctx); err != nil {
|
||||
@ -76,7 +76,7 @@ func (eq *EmailQuery) QueryAccounts() *AccountQuery {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(email.Table, email.FieldID, selector),
|
||||
sqlgraph.To(account.Table, account.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, email.AccountsTable, email.AccountsColumn),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, email.AccountTable, email.AccountColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(eq.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
@ -271,26 +271,26 @@ func (eq *EmailQuery) Clone() *EmailQuery {
|
||||
return nil
|
||||
}
|
||||
return &EmailQuery{
|
||||
config: eq.config,
|
||||
ctx: eq.ctx.Clone(),
|
||||
order: append([]email.OrderOption{}, eq.order...),
|
||||
inters: append([]Interceptor{}, eq.inters...),
|
||||
predicates: append([]predicate.Email{}, eq.predicates...),
|
||||
withAccounts: eq.withAccounts.Clone(),
|
||||
config: eq.config,
|
||||
ctx: eq.ctx.Clone(),
|
||||
order: append([]email.OrderOption{}, eq.order...),
|
||||
inters: append([]Interceptor{}, eq.inters...),
|
||||
predicates: append([]predicate.Email{}, eq.predicates...),
|
||||
withAccount: eq.withAccount.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: eq.sql.Clone(),
|
||||
path: eq.path,
|
||||
}
|
||||
}
|
||||
|
||||
// WithAccounts tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "accounts" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (eq *EmailQuery) WithAccounts(opts ...func(*AccountQuery)) *EmailQuery {
|
||||
// WithAccount tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "account" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (eq *EmailQuery) WithAccount(opts ...func(*AccountQuery)) *EmailQuery {
|
||||
query := (&AccountClient{config: eq.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
eq.withAccounts = query
|
||||
eq.withAccount = query
|
||||
return eq
|
||||
}
|
||||
|
||||
@ -374,10 +374,10 @@ func (eq *EmailQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Email,
|
||||
withFKs = eq.withFKs
|
||||
_spec = eq.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
eq.withAccounts != nil,
|
||||
eq.withAccount != nil,
|
||||
}
|
||||
)
|
||||
if eq.withAccounts != nil {
|
||||
if eq.withAccount != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@ -401,16 +401,16 @@ func (eq *EmailQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Email,
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := eq.withAccounts; query != nil {
|
||||
if err := eq.loadAccounts(ctx, query, nodes, nil,
|
||||
func(n *Email, e *Account) { n.Edges.Accounts = e }); err != nil {
|
||||
if query := eq.withAccount; query != nil {
|
||||
if err := eq.loadAccount(ctx, query, nodes, nil,
|
||||
func(n *Email, e *Account) { n.Edges.Account = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (eq *EmailQuery) loadAccounts(ctx context.Context, query *AccountQuery, nodes []*Email, init func(*Email), assign func(*Email, *Account)) error {
|
||||
func (eq *EmailQuery) loadAccount(ctx context.Context, query *AccountQuery, nodes []*Email, init func(*Email), assign func(*Email, *Account)) error {
|
||||
ids := make([]uuid.UUID, 0, len(nodes))
|
||||
nodeids := make(map[uuid.UUID][]*Email)
|
||||
for i := range nodes {
|
||||
|
@ -111,23 +111,23 @@ func (eu *EmailUpdate) ClearResetCode() *EmailUpdate {
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetAccountsID sets the "accounts" edge to the Account entity by ID.
|
||||
func (eu *EmailUpdate) SetAccountsID(id uuid.UUID) *EmailUpdate {
|
||||
eu.mutation.SetAccountsID(id)
|
||||
// SetAccountID sets the "account" edge to the Account entity by ID.
|
||||
func (eu *EmailUpdate) SetAccountID(id uuid.UUID) *EmailUpdate {
|
||||
eu.mutation.SetAccountID(id)
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetNillableAccountsID sets the "accounts" edge to the Account entity by ID if the given value is not nil.
|
||||
func (eu *EmailUpdate) SetNillableAccountsID(id *uuid.UUID) *EmailUpdate {
|
||||
// SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
|
||||
func (eu *EmailUpdate) SetNillableAccountID(id *uuid.UUID) *EmailUpdate {
|
||||
if id != nil {
|
||||
eu = eu.SetAccountsID(*id)
|
||||
eu = eu.SetAccountID(*id)
|
||||
}
|
||||
return eu
|
||||
}
|
||||
|
||||
// SetAccounts sets the "accounts" edge to the Account entity.
|
||||
func (eu *EmailUpdate) SetAccounts(a *Account) *EmailUpdate {
|
||||
return eu.SetAccountsID(a.ID)
|
||||
// SetAccount sets the "account" edge to the Account entity.
|
||||
func (eu *EmailUpdate) SetAccount(a *Account) *EmailUpdate {
|
||||
return eu.SetAccountID(a.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the EmailMutation object of the builder.
|
||||
@ -135,9 +135,9 @@ func (eu *EmailUpdate) Mutation() *EmailMutation {
|
||||
return eu.mutation
|
||||
}
|
||||
|
||||
// ClearAccounts clears the "accounts" edge to the Account entity.
|
||||
func (eu *EmailUpdate) ClearAccounts() *EmailUpdate {
|
||||
eu.mutation.ClearAccounts()
|
||||
// ClearAccount clears the "account" edge to the Account entity.
|
||||
func (eu *EmailUpdate) ClearAccount() *EmailUpdate {
|
||||
eu.mutation.ClearAccount()
|
||||
return eu
|
||||
}
|
||||
|
||||
@ -198,12 +198,12 @@ func (eu *EmailUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if eu.mutation.ResetCodeCleared() {
|
||||
_spec.ClearField(email.FieldResetCode, field.TypeString)
|
||||
}
|
||||
if eu.mutation.AccountsCleared() {
|
||||
if eu.mutation.AccountCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: email.AccountsTable,
|
||||
Columns: []string{email.AccountsColumn},
|
||||
Table: email.AccountTable,
|
||||
Columns: []string{email.AccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||
@ -211,12 +211,12 @@ func (eu *EmailUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := eu.mutation.AccountsIDs(); len(nodes) > 0 {
|
||||
if nodes := eu.mutation.AccountIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: email.AccountsTable,
|
||||
Columns: []string{email.AccountsColumn},
|
||||
Table: email.AccountTable,
|
||||
Columns: []string{email.AccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||
@ -329,23 +329,23 @@ func (euo *EmailUpdateOne) ClearResetCode() *EmailUpdateOne {
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetAccountsID sets the "accounts" edge to the Account entity by ID.
|
||||
func (euo *EmailUpdateOne) SetAccountsID(id uuid.UUID) *EmailUpdateOne {
|
||||
euo.mutation.SetAccountsID(id)
|
||||
// SetAccountID sets the "account" edge to the Account entity by ID.
|
||||
func (euo *EmailUpdateOne) SetAccountID(id uuid.UUID) *EmailUpdateOne {
|
||||
euo.mutation.SetAccountID(id)
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetNillableAccountsID sets the "accounts" edge to the Account entity by ID if the given value is not nil.
|
||||
func (euo *EmailUpdateOne) SetNillableAccountsID(id *uuid.UUID) *EmailUpdateOne {
|
||||
// SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
|
||||
func (euo *EmailUpdateOne) SetNillableAccountID(id *uuid.UUID) *EmailUpdateOne {
|
||||
if id != nil {
|
||||
euo = euo.SetAccountsID(*id)
|
||||
euo = euo.SetAccountID(*id)
|
||||
}
|
||||
return euo
|
||||
}
|
||||
|
||||
// SetAccounts sets the "accounts" edge to the Account entity.
|
||||
func (euo *EmailUpdateOne) SetAccounts(a *Account) *EmailUpdateOne {
|
||||
return euo.SetAccountsID(a.ID)
|
||||
// SetAccount sets the "account" edge to the Account entity.
|
||||
func (euo *EmailUpdateOne) SetAccount(a *Account) *EmailUpdateOne {
|
||||
return euo.SetAccountID(a.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the EmailMutation object of the builder.
|
||||
@ -353,9 +353,9 @@ func (euo *EmailUpdateOne) Mutation() *EmailMutation {
|
||||
return euo.mutation
|
||||
}
|
||||
|
||||
// ClearAccounts clears the "accounts" edge to the Account entity.
|
||||
func (euo *EmailUpdateOne) ClearAccounts() *EmailUpdateOne {
|
||||
euo.mutation.ClearAccounts()
|
||||
// ClearAccount clears the "account" edge to the Account entity.
|
||||
func (euo *EmailUpdateOne) ClearAccount() *EmailUpdateOne {
|
||||
euo.mutation.ClearAccount()
|
||||
return euo
|
||||
}
|
||||
|
||||
@ -446,12 +446,12 @@ func (euo *EmailUpdateOne) sqlSave(ctx context.Context) (_node *Email, err error
|
||||
if euo.mutation.ResetCodeCleared() {
|
||||
_spec.ClearField(email.FieldResetCode, field.TypeString)
|
||||
}
|
||||
if euo.mutation.AccountsCleared() {
|
||||
if euo.mutation.AccountCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: email.AccountsTable,
|
||||
Columns: []string{email.AccountsColumn},
|
||||
Table: email.AccountTable,
|
||||
Columns: []string{email.AccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||
@ -459,12 +459,12 @@ func (euo *EmailUpdateOne) sqlSave(ctx context.Context) (_node *Email, err error
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := euo.mutation.AccountsIDs(); len(nodes) > 0 {
|
||||
if nodes := euo.mutation.AccountIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
Table: email.AccountsTable,
|
||||
Columns: []string{email.AccountsColumn},
|
||||
Table: email.AccountTable,
|
||||
Columns: []string{email.AccountColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||
|
@ -13,8 +13,8 @@ var (
|
||||
{Name: "id", Type: field.TypeUUID, Unique: true, Default: "gen_random_uuid()"},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
{Name: "nickname", Type: field.TypeString},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "nickname", Type: field.TypeString, Nullable: true},
|
||||
{Name: "name", Type: field.TypeString, Nullable: true},
|
||||
{Name: "secret", Type: field.TypeBytes},
|
||||
{Name: "aes", Type: field.TypeBytes, Size: 32},
|
||||
{Name: "x509", Type: field.TypeBytes},
|
||||
|
113
ent/mutation.go
113
ent/mutation.go
@ -259,9 +259,22 @@ func (m *AccountMutation) OldNickname(ctx context.Context) (v string, err error)
|
||||
return oldValue.Nickname, nil
|
||||
}
|
||||
|
||||
// ClearNickname clears the value of the "nickname" field.
|
||||
func (m *AccountMutation) ClearNickname() {
|
||||
m.nickname = nil
|
||||
m.clearedFields[account.FieldNickname] = struct{}{}
|
||||
}
|
||||
|
||||
// NicknameCleared returns if the "nickname" field was cleared in this mutation.
|
||||
func (m *AccountMutation) NicknameCleared() bool {
|
||||
_, ok := m.clearedFields[account.FieldNickname]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetNickname resets all changes to the "nickname" field.
|
||||
func (m *AccountMutation) ResetNickname() {
|
||||
m.nickname = nil
|
||||
delete(m.clearedFields, account.FieldNickname)
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
@ -295,9 +308,22 @@ func (m *AccountMutation) OldName(ctx context.Context) (v string, err error) {
|
||||
return oldValue.Name, nil
|
||||
}
|
||||
|
||||
// ClearName clears the value of the "name" field.
|
||||
func (m *AccountMutation) ClearName() {
|
||||
m.name = nil
|
||||
m.clearedFields[account.FieldName] = struct{}{}
|
||||
}
|
||||
|
||||
// NameCleared returns if the "name" field was cleared in this mutation.
|
||||
func (m *AccountMutation) NameCleared() bool {
|
||||
_, ok := m.clearedFields[account.FieldName]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetName resets all changes to the "name" field.
|
||||
func (m *AccountMutation) ResetName() {
|
||||
m.name = nil
|
||||
delete(m.clearedFields, account.FieldName)
|
||||
}
|
||||
|
||||
// SetSecret sets the "secret" field.
|
||||
@ -650,7 +676,14 @@ func (m *AccountMutation) AddField(name string, value ent.Value) error {
|
||||
// ClearedFields returns all nullable fields that were cleared during this
|
||||
// mutation.
|
||||
func (m *AccountMutation) ClearedFields() []string {
|
||||
return nil
|
||||
var fields []string
|
||||
if m.FieldCleared(account.FieldNickname) {
|
||||
fields = append(fields, account.FieldNickname)
|
||||
}
|
||||
if m.FieldCleared(account.FieldName) {
|
||||
fields = append(fields, account.FieldName)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// FieldCleared returns a boolean indicating if a field with the given name was
|
||||
@ -663,6 +696,14 @@ func (m *AccountMutation) FieldCleared(name string) bool {
|
||||
// ClearField clears the value of the field with the given name. It returns an
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *AccountMutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case account.FieldNickname:
|
||||
m.ClearNickname()
|
||||
return nil
|
||||
case account.FieldName:
|
||||
m.ClearName()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Account nullable field %s", name)
|
||||
}
|
||||
|
||||
@ -791,8 +832,8 @@ type EmailMutation struct {
|
||||
verification_code *string
|
||||
reset_code *string
|
||||
clearedFields map[string]struct{}
|
||||
accounts *uuid.UUID
|
||||
clearedaccounts bool
|
||||
account *uuid.UUID
|
||||
clearedaccount bool
|
||||
done bool
|
||||
oldValue func(context.Context) (*Email, error)
|
||||
predicates []predicate.Email
|
||||
@ -1108,43 +1149,43 @@ func (m *EmailMutation) ResetResetCode() {
|
||||
delete(m.clearedFields, email.FieldResetCode)
|
||||
}
|
||||
|
||||
// SetAccountsID sets the "accounts" edge to the Account entity by id.
|
||||
func (m *EmailMutation) SetAccountsID(id uuid.UUID) {
|
||||
m.accounts = &id
|
||||
// SetAccountID sets the "account" edge to the Account entity by id.
|
||||
func (m *EmailMutation) SetAccountID(id uuid.UUID) {
|
||||
m.account = &id
|
||||
}
|
||||
|
||||
// ClearAccounts clears the "accounts" edge to the Account entity.
|
||||
func (m *EmailMutation) ClearAccounts() {
|
||||
m.clearedaccounts = true
|
||||
// ClearAccount clears the "account" edge to the Account entity.
|
||||
func (m *EmailMutation) ClearAccount() {
|
||||
m.clearedaccount = true
|
||||
}
|
||||
|
||||
// AccountsCleared reports if the "accounts" edge to the Account entity was cleared.
|
||||
func (m *EmailMutation) AccountsCleared() bool {
|
||||
return m.clearedaccounts
|
||||
// AccountCleared reports if the "account" edge to the Account entity was cleared.
|
||||
func (m *EmailMutation) AccountCleared() bool {
|
||||
return m.clearedaccount
|
||||
}
|
||||
|
||||
// AccountsID returns the "accounts" edge ID in the mutation.
|
||||
func (m *EmailMutation) AccountsID() (id uuid.UUID, exists bool) {
|
||||
if m.accounts != nil {
|
||||
return *m.accounts, true
|
||||
// AccountID returns the "account" edge ID in the mutation.
|
||||
func (m *EmailMutation) AccountID() (id uuid.UUID, exists bool) {
|
||||
if m.account != nil {
|
||||
return *m.account, true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// AccountsIDs returns the "accounts" edge IDs in the mutation.
|
||||
// AccountIDs returns the "account" edge IDs in the mutation.
|
||||
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||
// AccountsID instead. It exists only for internal usage by the builders.
|
||||
func (m *EmailMutation) AccountsIDs() (ids []uuid.UUID) {
|
||||
if id := m.accounts; id != nil {
|
||||
// AccountID instead. It exists only for internal usage by the builders.
|
||||
func (m *EmailMutation) AccountIDs() (ids []uuid.UUID) {
|
||||
if id := m.account; id != nil {
|
||||
ids = append(ids, *id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetAccounts resets all changes to the "accounts" edge.
|
||||
func (m *EmailMutation) ResetAccounts() {
|
||||
m.accounts = nil
|
||||
m.clearedaccounts = false
|
||||
// ResetAccount resets all changes to the "account" edge.
|
||||
func (m *EmailMutation) ResetAccount() {
|
||||
m.account = nil
|
||||
m.clearedaccount = false
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the EmailMutation builder.
|
||||
@ -1364,8 +1405,8 @@ func (m *EmailMutation) ResetField(name string) error {
|
||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||
func (m *EmailMutation) AddedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
if m.accounts != nil {
|
||||
edges = append(edges, email.EdgeAccounts)
|
||||
if m.account != nil {
|
||||
edges = append(edges, email.EdgeAccount)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
@ -1374,8 +1415,8 @@ func (m *EmailMutation) AddedEdges() []string {
|
||||
// name in this mutation.
|
||||
func (m *EmailMutation) AddedIDs(name string) []ent.Value {
|
||||
switch name {
|
||||
case email.EdgeAccounts:
|
||||
if id := m.accounts; id != nil {
|
||||
case email.EdgeAccount:
|
||||
if id := m.account; id != nil {
|
||||
return []ent.Value{*id}
|
||||
}
|
||||
}
|
||||
@ -1397,8 +1438,8 @@ func (m *EmailMutation) RemovedIDs(name string) []ent.Value {
|
||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||
func (m *EmailMutation) ClearedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
if m.clearedaccounts {
|
||||
edges = append(edges, email.EdgeAccounts)
|
||||
if m.clearedaccount {
|
||||
edges = append(edges, email.EdgeAccount)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
@ -1407,8 +1448,8 @@ func (m *EmailMutation) ClearedEdges() []string {
|
||||
// was cleared in this mutation.
|
||||
func (m *EmailMutation) EdgeCleared(name string) bool {
|
||||
switch name {
|
||||
case email.EdgeAccounts:
|
||||
return m.clearedaccounts
|
||||
case email.EdgeAccount:
|
||||
return m.clearedaccount
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -1417,8 +1458,8 @@ func (m *EmailMutation) EdgeCleared(name string) bool {
|
||||
// if that edge is not defined in the schema.
|
||||
func (m *EmailMutation) ClearEdge(name string) error {
|
||||
switch name {
|
||||
case email.EdgeAccounts:
|
||||
m.ClearAccounts()
|
||||
case email.EdgeAccount:
|
||||
m.ClearAccount()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Email unique edge %s", name)
|
||||
@ -1428,8 +1469,8 @@ func (m *EmailMutation) ClearEdge(name string) error {
|
||||
// It returns an error if the edge is not defined in the schema.
|
||||
func (m *EmailMutation) ResetEdge(name string) error {
|
||||
switch name {
|
||||
case email.EdgeAccounts:
|
||||
m.ResetAccounts()
|
||||
case email.EdgeAccount:
|
||||
m.ResetAccount()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown Email edge %s", name)
|
||||
|
@ -5,6 +5,6 @@ package runtime
|
||||
// The schema-stitching logic is generated in code.icod.de/auth/accountserver/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.14.0" // Version of ent codegen.
|
||||
Sum = "h1:EO3Z9aZ5bXJatJeGqu/EVdnNr6K4mRq3rWe5owt0MC4=" // Sum of ent codegen.
|
||||
Version = "v0.14.1" // Version of ent codegen.
|
||||
Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen.
|
||||
)
|
||||
|
@ -20,8 +20,8 @@ func (Account) Fields() []ent.Field {
|
||||
field.UUID("id", uuid.UUID{}).Unique().Immutable().Annotations(&entsql.Annotation{Default: "gen_random_uuid()"}),
|
||||
field.Time("created_at").Default(time.Now).Immutable(),
|
||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||
field.String("nickname"),
|
||||
field.String("name"),
|
||||
field.String("nickname").Optional(),
|
||||
field.String("name").Optional(),
|
||||
field.Bytes("secret"),
|
||||
field.Bytes("aes").MinLen(16).MaxLen(32),
|
||||
field.Bytes("x509"),
|
||||
|
@ -28,6 +28,6 @@ func (Email) Fields() []ent.Field {
|
||||
// Edges of the Email.
|
||||
func (Email) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("accounts", Account.Type).Ref("emails").Unique(),
|
||||
edge.From("account", Account.Type).Ref("emails").Unique(),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user