2022-08-30 18:04:50 +00:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
2022-08-30 02:30:36 +00:00
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
|
|
"entgo.io/ent/schema/field"
|
|
|
|
"github.com/google/uuid"
|
2022-12-03 19:55:00 +00:00
|
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/authroles"
|
2022-10-30 04:05:38 +00:00
|
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/authtokens"
|
|
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
|
|
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
2022-08-30 02:30:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// AuthTokensUpdate is the builder for updating AuthTokens entities.
|
|
|
|
type AuthTokensUpdate struct {
|
|
|
|
config
|
|
|
|
hooks []Hook
|
|
|
|
mutation *AuthTokensMutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// Where appends a list predicates to the AuthTokensUpdate builder.
|
|
|
|
func (atu *AuthTokensUpdate) Where(ps ...predicate.AuthTokens) *AuthTokensUpdate {
|
|
|
|
atu.mutation.Where(ps...)
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
2022-08-30 18:04:50 +00:00
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
|
|
func (atu *AuthTokensUpdate) SetUpdatedAt(t time.Time) *AuthTokensUpdate {
|
|
|
|
atu.mutation.SetUpdatedAt(t)
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
2022-08-30 02:30:36 +00:00
|
|
|
// SetToken sets the "token" field.
|
|
|
|
func (atu *AuthTokensUpdate) SetToken(b []byte) *AuthTokensUpdate {
|
|
|
|
atu.mutation.SetToken(b)
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetExpiresAt sets the "expires_at" field.
|
|
|
|
func (atu *AuthTokensUpdate) SetExpiresAt(t time.Time) *AuthTokensUpdate {
|
|
|
|
atu.mutation.SetExpiresAt(t)
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
|
|
|
func (atu *AuthTokensUpdate) SetNillableExpiresAt(t *time.Time) *AuthTokensUpdate {
|
|
|
|
if t != nil {
|
|
|
|
atu.SetExpiresAt(*t)
|
|
|
|
}
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUserID sets the "user" edge to the User entity by ID.
|
|
|
|
func (atu *AuthTokensUpdate) SetUserID(id uuid.UUID) *AuthTokensUpdate {
|
|
|
|
atu.mutation.SetUserID(id)
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
|
|
|
|
func (atu *AuthTokensUpdate) SetNillableUserID(id *uuid.UUID) *AuthTokensUpdate {
|
|
|
|
if id != nil {
|
|
|
|
atu = atu.SetUserID(*id)
|
|
|
|
}
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
|
|
func (atu *AuthTokensUpdate) SetUser(u *User) *AuthTokensUpdate {
|
|
|
|
return atu.SetUserID(u.ID)
|
|
|
|
}
|
|
|
|
|
2022-12-03 19:55:00 +00:00
|
|
|
// SetRolesID sets the "roles" edge to the AuthRoles entity by ID.
|
|
|
|
func (atu *AuthTokensUpdate) SetRolesID(id int) *AuthTokensUpdate {
|
|
|
|
atu.mutation.SetRolesID(id)
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableRolesID sets the "roles" edge to the AuthRoles entity by ID if the given value is not nil.
|
|
|
|
func (atu *AuthTokensUpdate) SetNillableRolesID(id *int) *AuthTokensUpdate {
|
|
|
|
if id != nil {
|
|
|
|
atu = atu.SetRolesID(*id)
|
|
|
|
}
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetRoles sets the "roles" edge to the AuthRoles entity.
|
|
|
|
func (atu *AuthTokensUpdate) SetRoles(a *AuthRoles) *AuthTokensUpdate {
|
|
|
|
return atu.SetRolesID(a.ID)
|
|
|
|
}
|
|
|
|
|
2022-08-30 02:30:36 +00:00
|
|
|
// Mutation returns the AuthTokensMutation object of the builder.
|
|
|
|
func (atu *AuthTokensUpdate) Mutation() *AuthTokensMutation {
|
|
|
|
return atu.mutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
|
|
func (atu *AuthTokensUpdate) ClearUser() *AuthTokensUpdate {
|
|
|
|
atu.mutation.ClearUser()
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
2022-12-03 19:55:00 +00:00
|
|
|
// ClearRoles clears the "roles" edge to the AuthRoles entity.
|
|
|
|
func (atu *AuthTokensUpdate) ClearRoles() *AuthTokensUpdate {
|
|
|
|
atu.mutation.ClearRoles()
|
|
|
|
return atu
|
|
|
|
}
|
|
|
|
|
2022-08-30 02:30:36 +00:00
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
|
|
func (atu *AuthTokensUpdate) Save(ctx context.Context) (int, error) {
|
2022-08-30 18:04:50 +00:00
|
|
|
atu.defaults()
|
2023-01-19 05:44:06 +00:00
|
|
|
return withHooks[int, AuthTokensMutation](ctx, atu.sqlSave, atu.mutation, atu.hooks)
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
|
|
func (atu *AuthTokensUpdate) SaveX(ctx context.Context) int {
|
|
|
|
affected, err := atu.Save(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return affected
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the query.
|
|
|
|
func (atu *AuthTokensUpdate) Exec(ctx context.Context) error {
|
|
|
|
_, err := atu.Save(ctx)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (atu *AuthTokensUpdate) ExecX(ctx context.Context) {
|
|
|
|
if err := atu.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-30 18:04:50 +00:00
|
|
|
// defaults sets the default values of the builder before save.
|
|
|
|
func (atu *AuthTokensUpdate) defaults() {
|
|
|
|
if _, ok := atu.mutation.UpdatedAt(); !ok {
|
|
|
|
v := authtokens.UpdateDefaultUpdatedAt()
|
|
|
|
atu.mutation.SetUpdatedAt(v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-30 02:30:36 +00:00
|
|
|
func (atu *AuthTokensUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
2023-02-18 06:41:01 +00:00
|
|
|
_spec := sqlgraph.NewUpdateSpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
|
2022-08-30 02:30:36 +00:00
|
|
|
if ps := atu.mutation.predicates; len(ps) > 0 {
|
|
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
|
|
for i := range ps {
|
|
|
|
ps[i](selector)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-30 18:04:50 +00:00
|
|
|
if value, ok := atu.mutation.UpdatedAt(); ok {
|
2022-12-02 01:45:28 +00:00
|
|
|
_spec.SetField(authtokens.FieldUpdatedAt, field.TypeTime, value)
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
2022-08-30 02:30:36 +00:00
|
|
|
if value, ok := atu.mutation.Token(); ok {
|
2022-12-02 01:45:28 +00:00
|
|
|
_spec.SetField(authtokens.FieldToken, field.TypeBytes, value)
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
if value, ok := atu.mutation.ExpiresAt(); ok {
|
2022-12-02 01:45:28 +00:00
|
|
|
_spec.SetField(authtokens.FieldExpiresAt, field.TypeTime, value)
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
if atu.mutation.UserCleared() {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2O,
|
|
|
|
Inverse: true,
|
|
|
|
Table: authtokens.UserTable,
|
|
|
|
Columns: []string{authtokens.UserColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
2023-03-23 04:16:04 +00:00
|
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
2022-08-30 02:30:36 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
|
}
|
|
|
|
if nodes := atu.mutation.UserIDs(); len(nodes) > 0 {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2O,
|
|
|
|
Inverse: true,
|
|
|
|
Table: authtokens.UserTable,
|
|
|
|
Columns: []string{authtokens.UserColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
2023-03-23 04:16:04 +00:00
|
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
2022-08-30 02:30:36 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
|
}
|
2022-12-03 19:55:00 +00:00
|
|
|
if atu.mutation.RolesCleared() {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.O2O,
|
|
|
|
Inverse: false,
|
|
|
|
Table: authtokens.RolesTable,
|
|
|
|
Columns: []string{authtokens.RolesColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
2023-03-23 04:16:04 +00:00
|
|
|
IDSpec: sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt),
|
2022-12-03 19:55:00 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
|
}
|
|
|
|
if nodes := atu.mutation.RolesIDs(); len(nodes) > 0 {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.O2O,
|
|
|
|
Inverse: false,
|
|
|
|
Table: authtokens.RolesTable,
|
|
|
|
Columns: []string{authtokens.RolesColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
2023-03-23 04:16:04 +00:00
|
|
|
IDSpec: sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt),
|
2022-12-03 19:55:00 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
|
}
|
2022-08-30 02:30:36 +00:00
|
|
|
if n, err = sqlgraph.UpdateNodes(ctx, atu.driver, _spec); err != nil {
|
|
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
|
|
err = &NotFoundError{authtokens.Label}
|
|
|
|
} else if sqlgraph.IsConstraintError(err) {
|
2022-08-30 18:04:50 +00:00
|
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
return 0, err
|
|
|
|
}
|
2023-01-19 05:44:06 +00:00
|
|
|
atu.mutation.done = true
|
2022-08-30 02:30:36 +00:00
|
|
|
return n, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// AuthTokensUpdateOne is the builder for updating a single AuthTokens entity.
|
|
|
|
type AuthTokensUpdateOne struct {
|
|
|
|
config
|
|
|
|
fields []string
|
|
|
|
hooks []Hook
|
|
|
|
mutation *AuthTokensMutation
|
|
|
|
}
|
|
|
|
|
2022-08-30 18:04:50 +00:00
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetUpdatedAt(t time.Time) *AuthTokensUpdateOne {
|
|
|
|
atuo.mutation.SetUpdatedAt(t)
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
2022-08-30 02:30:36 +00:00
|
|
|
// SetToken sets the "token" field.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetToken(b []byte) *AuthTokensUpdateOne {
|
|
|
|
atuo.mutation.SetToken(b)
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetExpiresAt sets the "expires_at" field.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetExpiresAt(t time.Time) *AuthTokensUpdateOne {
|
|
|
|
atuo.mutation.SetExpiresAt(t)
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetNillableExpiresAt(t *time.Time) *AuthTokensUpdateOne {
|
|
|
|
if t != nil {
|
|
|
|
atuo.SetExpiresAt(*t)
|
|
|
|
}
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUserID sets the "user" edge to the User entity by ID.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetUserID(id uuid.UUID) *AuthTokensUpdateOne {
|
|
|
|
atuo.mutation.SetUserID(id)
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableUserID sets the "user" edge to the User entity by ID if the given value is not nil.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetNillableUserID(id *uuid.UUID) *AuthTokensUpdateOne {
|
|
|
|
if id != nil {
|
|
|
|
atuo = atuo.SetUserID(*id)
|
|
|
|
}
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetUser(u *User) *AuthTokensUpdateOne {
|
|
|
|
return atuo.SetUserID(u.ID)
|
|
|
|
}
|
|
|
|
|
2022-12-03 19:55:00 +00:00
|
|
|
// SetRolesID sets the "roles" edge to the AuthRoles entity by ID.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetRolesID(id int) *AuthTokensUpdateOne {
|
|
|
|
atuo.mutation.SetRolesID(id)
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNillableRolesID sets the "roles" edge to the AuthRoles entity by ID if the given value is not nil.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetNillableRolesID(id *int) *AuthTokensUpdateOne {
|
|
|
|
if id != nil {
|
|
|
|
atuo = atuo.SetRolesID(*id)
|
|
|
|
}
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetRoles sets the "roles" edge to the AuthRoles entity.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SetRoles(a *AuthRoles) *AuthTokensUpdateOne {
|
|
|
|
return atuo.SetRolesID(a.ID)
|
|
|
|
}
|
|
|
|
|
2022-08-30 02:30:36 +00:00
|
|
|
// Mutation returns the AuthTokensMutation object of the builder.
|
|
|
|
func (atuo *AuthTokensUpdateOne) Mutation() *AuthTokensMutation {
|
|
|
|
return atuo.mutation
|
|
|
|
}
|
|
|
|
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
|
|
func (atuo *AuthTokensUpdateOne) ClearUser() *AuthTokensUpdateOne {
|
|
|
|
atuo.mutation.ClearUser()
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
2022-12-03 19:55:00 +00:00
|
|
|
// ClearRoles clears the "roles" edge to the AuthRoles entity.
|
|
|
|
func (atuo *AuthTokensUpdateOne) ClearRoles() *AuthTokensUpdateOne {
|
|
|
|
atuo.mutation.ClearRoles()
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
2023-02-18 06:41:01 +00:00
|
|
|
// Where appends a list predicates to the AuthTokensUpdate builder.
|
|
|
|
func (atuo *AuthTokensUpdateOne) Where(ps ...predicate.AuthTokens) *AuthTokensUpdateOne {
|
|
|
|
atuo.mutation.Where(ps...)
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
2022-08-30 02:30:36 +00:00
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
|
|
// The default is selecting all fields defined in the entity schema.
|
|
|
|
func (atuo *AuthTokensUpdateOne) Select(field string, fields ...string) *AuthTokensUpdateOne {
|
|
|
|
atuo.fields = append([]string{field}, fields...)
|
|
|
|
return atuo
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save executes the query and returns the updated AuthTokens entity.
|
|
|
|
func (atuo *AuthTokensUpdateOne) Save(ctx context.Context) (*AuthTokens, error) {
|
2022-08-30 18:04:50 +00:00
|
|
|
atuo.defaults()
|
2023-01-19 05:44:06 +00:00
|
|
|
return withHooks[*AuthTokens, AuthTokensMutation](ctx, atuo.sqlSave, atuo.mutation, atuo.hooks)
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
|
|
func (atuo *AuthTokensUpdateOne) SaveX(ctx context.Context) *AuthTokens {
|
|
|
|
node, err := atuo.Save(ctx)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
return node
|
|
|
|
}
|
|
|
|
|
|
|
|
// Exec executes the query on the entity.
|
|
|
|
func (atuo *AuthTokensUpdateOne) Exec(ctx context.Context) error {
|
|
|
|
_, err := atuo.Save(ctx)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
|
|
func (atuo *AuthTokensUpdateOne) ExecX(ctx context.Context) {
|
|
|
|
if err := atuo.Exec(ctx); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-30 18:04:50 +00:00
|
|
|
// defaults sets the default values of the builder before save.
|
|
|
|
func (atuo *AuthTokensUpdateOne) defaults() {
|
|
|
|
if _, ok := atuo.mutation.UpdatedAt(); !ok {
|
|
|
|
v := authtokens.UpdateDefaultUpdatedAt()
|
|
|
|
atuo.mutation.SetUpdatedAt(v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-30 02:30:36 +00:00
|
|
|
func (atuo *AuthTokensUpdateOne) sqlSave(ctx context.Context) (_node *AuthTokens, err error) {
|
2023-02-18 06:41:01 +00:00
|
|
|
_spec := sqlgraph.NewUpdateSpec(authtokens.Table, authtokens.Columns, sqlgraph.NewFieldSpec(authtokens.FieldID, field.TypeUUID))
|
2022-08-30 02:30:36 +00:00
|
|
|
id, ok := atuo.mutation.ID()
|
|
|
|
if !ok {
|
|
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthTokens.id" for update`)}
|
|
|
|
}
|
|
|
|
_spec.Node.ID.Value = id
|
|
|
|
if fields := atuo.fields; len(fields) > 0 {
|
|
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
|
|
_spec.Node.Columns = append(_spec.Node.Columns, authtokens.FieldID)
|
|
|
|
for _, f := range fields {
|
|
|
|
if !authtokens.ValidColumn(f) {
|
|
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
|
|
}
|
|
|
|
if f != authtokens.FieldID {
|
|
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ps := atuo.mutation.predicates; len(ps) > 0 {
|
|
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
|
|
for i := range ps {
|
|
|
|
ps[i](selector)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-30 18:04:50 +00:00
|
|
|
if value, ok := atuo.mutation.UpdatedAt(); ok {
|
2022-12-02 01:45:28 +00:00
|
|
|
_spec.SetField(authtokens.FieldUpdatedAt, field.TypeTime, value)
|
2022-08-30 18:04:50 +00:00
|
|
|
}
|
2022-08-30 02:30:36 +00:00
|
|
|
if value, ok := atuo.mutation.Token(); ok {
|
2022-12-02 01:45:28 +00:00
|
|
|
_spec.SetField(authtokens.FieldToken, field.TypeBytes, value)
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
if value, ok := atuo.mutation.ExpiresAt(); ok {
|
2022-12-02 01:45:28 +00:00
|
|
|
_spec.SetField(authtokens.FieldExpiresAt, field.TypeTime, value)
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
if atuo.mutation.UserCleared() {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2O,
|
|
|
|
Inverse: true,
|
|
|
|
Table: authtokens.UserTable,
|
|
|
|
Columns: []string{authtokens.UserColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
2023-03-23 04:16:04 +00:00
|
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
2022-08-30 02:30:36 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
|
}
|
|
|
|
if nodes := atuo.mutation.UserIDs(); len(nodes) > 0 {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.M2O,
|
|
|
|
Inverse: true,
|
|
|
|
Table: authtokens.UserTable,
|
|
|
|
Columns: []string{authtokens.UserColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
2023-03-23 04:16:04 +00:00
|
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
2022-08-30 02:30:36 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
|
}
|
2022-12-03 19:55:00 +00:00
|
|
|
if atuo.mutation.RolesCleared() {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.O2O,
|
|
|
|
Inverse: false,
|
|
|
|
Table: authtokens.RolesTable,
|
|
|
|
Columns: []string{authtokens.RolesColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
2023-03-23 04:16:04 +00:00
|
|
|
IDSpec: sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt),
|
2022-12-03 19:55:00 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
|
}
|
|
|
|
if nodes := atuo.mutation.RolesIDs(); len(nodes) > 0 {
|
|
|
|
edge := &sqlgraph.EdgeSpec{
|
|
|
|
Rel: sqlgraph.O2O,
|
|
|
|
Inverse: false,
|
|
|
|
Table: authtokens.RolesTable,
|
|
|
|
Columns: []string{authtokens.RolesColumn},
|
|
|
|
Bidi: false,
|
|
|
|
Target: &sqlgraph.EdgeTarget{
|
2023-03-23 04:16:04 +00:00
|
|
|
IDSpec: sqlgraph.NewFieldSpec(authroles.FieldID, field.TypeInt),
|
2022-12-03 19:55:00 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, k := range nodes {
|
|
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
|
}
|
|
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
|
}
|
2022-08-30 02:30:36 +00:00
|
|
|
_node = &AuthTokens{config: atuo.config}
|
|
|
|
_spec.Assign = _node.assignValues
|
|
|
|
_spec.ScanValues = _node.scanValues
|
|
|
|
if err = sqlgraph.UpdateNode(ctx, atuo.driver, _spec); err != nil {
|
|
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
|
|
err = &NotFoundError{authtokens.Label}
|
|
|
|
} else if sqlgraph.IsConstraintError(err) {
|
2022-08-30 18:04:50 +00:00
|
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
2022-08-30 02:30:36 +00:00
|
|
|
}
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-01-19 05:44:06 +00:00
|
|
|
atuo.mutation.done = true
|
2022-08-30 02:30:36 +00:00
|
|
|
return _node, nil
|
|
|
|
}
|