forked from mirrors/homebox
gen: ent code
This commit is contained in:
parent
b491ff9ec1
commit
791d6979b6
23 changed files with 3621 additions and 144 deletions
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/label"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/label"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/location"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/location"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
|
|
||||||
"entgo.io/ent/dialect"
|
"entgo.io/ent/dialect"
|
||||||
|
@ -56,6 +57,8 @@ type Client struct {
|
||||||
Location *LocationClient
|
Location *LocationClient
|
||||||
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
|
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
|
||||||
MaintenanceEntry *MaintenanceEntryClient
|
MaintenanceEntry *MaintenanceEntryClient
|
||||||
|
// Notifier is the client for interacting with the Notifier builders.
|
||||||
|
Notifier *NotifierClient
|
||||||
// User is the client for interacting with the User builders.
|
// User is the client for interacting with the User builders.
|
||||||
User *UserClient
|
User *UserClient
|
||||||
}
|
}
|
||||||
|
@ -82,6 +85,7 @@ func (c *Client) init() {
|
||||||
c.Label = NewLabelClient(c.config)
|
c.Label = NewLabelClient(c.config)
|
||||||
c.Location = NewLocationClient(c.config)
|
c.Location = NewLocationClient(c.config)
|
||||||
c.MaintenanceEntry = NewMaintenanceEntryClient(c.config)
|
c.MaintenanceEntry = NewMaintenanceEntryClient(c.config)
|
||||||
|
c.Notifier = NewNotifierClient(c.config)
|
||||||
c.User = NewUserClient(c.config)
|
c.User = NewUserClient(c.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +131,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||||
Label: NewLabelClient(cfg),
|
Label: NewLabelClient(cfg),
|
||||||
Location: NewLocationClient(cfg),
|
Location: NewLocationClient(cfg),
|
||||||
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
||||||
|
Notifier: NewNotifierClient(cfg),
|
||||||
User: NewUserClient(cfg),
|
User: NewUserClient(cfg),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -158,6 +163,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||||
Label: NewLabelClient(cfg),
|
Label: NewLabelClient(cfg),
|
||||||
Location: NewLocationClient(cfg),
|
Location: NewLocationClient(cfg),
|
||||||
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
MaintenanceEntry: NewMaintenanceEntryClient(cfg),
|
||||||
|
Notifier: NewNotifierClient(cfg),
|
||||||
User: NewUserClient(cfg),
|
User: NewUserClient(cfg),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -198,6 +204,7 @@ func (c *Client) Use(hooks ...Hook) {
|
||||||
c.Label.Use(hooks...)
|
c.Label.Use(hooks...)
|
||||||
c.Location.Use(hooks...)
|
c.Location.Use(hooks...)
|
||||||
c.MaintenanceEntry.Use(hooks...)
|
c.MaintenanceEntry.Use(hooks...)
|
||||||
|
c.Notifier.Use(hooks...)
|
||||||
c.User.Use(hooks...)
|
c.User.Use(hooks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +222,7 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
|
||||||
c.Label.Intercept(interceptors...)
|
c.Label.Intercept(interceptors...)
|
||||||
c.Location.Intercept(interceptors...)
|
c.Location.Intercept(interceptors...)
|
||||||
c.MaintenanceEntry.Intercept(interceptors...)
|
c.MaintenanceEntry.Intercept(interceptors...)
|
||||||
|
c.Notifier.Intercept(interceptors...)
|
||||||
c.User.Intercept(interceptors...)
|
c.User.Intercept(interceptors...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +251,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
|
||||||
return c.Location.mutate(ctx, m)
|
return c.Location.mutate(ctx, m)
|
||||||
case *MaintenanceEntryMutation:
|
case *MaintenanceEntryMutation:
|
||||||
return c.MaintenanceEntry.mutate(ctx, m)
|
return c.MaintenanceEntry.mutate(ctx, m)
|
||||||
|
case *NotifierMutation:
|
||||||
|
return c.Notifier.mutate(ctx, m)
|
||||||
case *UserMutation:
|
case *UserMutation:
|
||||||
return c.User.mutate(ctx, m)
|
return c.User.mutate(ctx, m)
|
||||||
default:
|
default:
|
||||||
|
@ -2028,6 +2038,140 @@ func (c *MaintenanceEntryClient) mutate(ctx context.Context, m *MaintenanceEntry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotifierClient is a client for the Notifier schema.
|
||||||
|
type NotifierClient struct {
|
||||||
|
config
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewNotifierClient returns a client for the Notifier from the given config.
|
||||||
|
func NewNotifierClient(c config) *NotifierClient {
|
||||||
|
return &NotifierClient{config: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use adds a list of mutation hooks to the hooks stack.
|
||||||
|
// A call to `Use(f, g, h)` equals to `notifier.Hooks(f(g(h())))`.
|
||||||
|
func (c *NotifierClient) Use(hooks ...Hook) {
|
||||||
|
c.hooks.Notifier = append(c.hooks.Notifier, hooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intercept adds a list of query interceptors to the interceptors stack.
|
||||||
|
// A call to `Intercept(f, g, h)` equals to `notifier.Intercept(f(g(h())))`.
|
||||||
|
func (c *NotifierClient) Intercept(interceptors ...Interceptor) {
|
||||||
|
c.inters.Notifier = append(c.inters.Notifier, interceptors...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create returns a builder for creating a Notifier entity.
|
||||||
|
func (c *NotifierClient) Create() *NotifierCreate {
|
||||||
|
mutation := newNotifierMutation(c.config, OpCreate)
|
||||||
|
return &NotifierCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateBulk returns a builder for creating a bulk of Notifier entities.
|
||||||
|
func (c *NotifierClient) CreateBulk(builders ...*NotifierCreate) *NotifierCreateBulk {
|
||||||
|
return &NotifierCreateBulk{config: c.config, builders: builders}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns an update builder for Notifier.
|
||||||
|
func (c *NotifierClient) Update() *NotifierUpdate {
|
||||||
|
mutation := newNotifierMutation(c.config, OpUpdate)
|
||||||
|
return &NotifierUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOne returns an update builder for the given entity.
|
||||||
|
func (c *NotifierClient) UpdateOne(n *Notifier) *NotifierUpdateOne {
|
||||||
|
mutation := newNotifierMutation(c.config, OpUpdateOne, withNotifier(n))
|
||||||
|
return &NotifierUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateOneID returns an update builder for the given id.
|
||||||
|
func (c *NotifierClient) UpdateOneID(id uuid.UUID) *NotifierUpdateOne {
|
||||||
|
mutation := newNotifierMutation(c.config, OpUpdateOne, withNotifierID(id))
|
||||||
|
return &NotifierUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete returns a delete builder for Notifier.
|
||||||
|
func (c *NotifierClient) Delete() *NotifierDelete {
|
||||||
|
mutation := newNotifierMutation(c.config, OpDelete)
|
||||||
|
return &NotifierDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
|
func (c *NotifierClient) DeleteOne(n *Notifier) *NotifierDeleteOne {
|
||||||
|
return c.DeleteOneID(n.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||||
|
func (c *NotifierClient) DeleteOneID(id uuid.UUID) *NotifierDeleteOne {
|
||||||
|
builder := c.Delete().Where(notifier.ID(id))
|
||||||
|
builder.mutation.id = &id
|
||||||
|
builder.mutation.op = OpDeleteOne
|
||||||
|
return &NotifierDeleteOne{builder}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query returns a query builder for Notifier.
|
||||||
|
func (c *NotifierClient) Query() *NotifierQuery {
|
||||||
|
return &NotifierQuery{
|
||||||
|
config: c.config,
|
||||||
|
ctx: &QueryContext{Type: TypeNotifier},
|
||||||
|
inters: c.Interceptors(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a Notifier entity by its id.
|
||||||
|
func (c *NotifierClient) Get(ctx context.Context, id uuid.UUID) (*Notifier, error) {
|
||||||
|
return c.Query().Where(notifier.ID(id)).Only(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetX is like Get, but panics if an error occurs.
|
||||||
|
func (c *NotifierClient) GetX(ctx context.Context, id uuid.UUID) *Notifier {
|
||||||
|
obj, err := c.Get(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUser queries the user edge of a Notifier.
|
||||||
|
func (c *NotifierClient) QueryUser(n *Notifier) *UserQuery {
|
||||||
|
query := (&UserClient{config: c.config}).Query()
|
||||||
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||||
|
id := n.ID
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(notifier.Table, notifier.FieldID, id),
|
||||||
|
sqlgraph.To(user.Table, user.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, notifier.UserTable, notifier.UserColumn),
|
||||||
|
)
|
||||||
|
fromV = sqlgraph.Neighbors(n.driver.Dialect(), step)
|
||||||
|
return fromV, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hooks returns the client hooks.
|
||||||
|
func (c *NotifierClient) Hooks() []Hook {
|
||||||
|
return c.hooks.Notifier
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interceptors returns the client interceptors.
|
||||||
|
func (c *NotifierClient) Interceptors() []Interceptor {
|
||||||
|
return c.inters.Notifier
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *NotifierClient) mutate(ctx context.Context, m *NotifierMutation) (Value, error) {
|
||||||
|
switch m.Op() {
|
||||||
|
case OpCreate:
|
||||||
|
return (&NotifierCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdate:
|
||||||
|
return (&NotifierUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpUpdateOne:
|
||||||
|
return (&NotifierUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
|
||||||
|
case OpDelete, OpDeleteOne:
|
||||||
|
return (&NotifierDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("ent: unknown Notifier mutation op: %q", m.Op())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// UserClient is a client for the User schema.
|
// UserClient is a client for the User schema.
|
||||||
type UserClient struct {
|
type UserClient struct {
|
||||||
config
|
config
|
||||||
|
@ -2153,6 +2297,22 @@ func (c *UserClient) QueryAuthTokens(u *User) *AuthTokensQuery {
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryNotifiers queries the notifiers edge of a User.
|
||||||
|
func (c *UserClient) QueryNotifiers(u *User) *NotifierQuery {
|
||||||
|
query := (&NotifierClient{config: c.config}).Query()
|
||||||
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||||
|
id := u.ID
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(user.Table, user.FieldID, id),
|
||||||
|
sqlgraph.To(notifier.Table, notifier.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, user.NotifiersTable, user.NotifiersColumn),
|
||||||
|
)
|
||||||
|
fromV = sqlgraph.Neighbors(u.driver.Dialect(), step)
|
||||||
|
return fromV, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
// Hooks returns the client hooks.
|
// Hooks returns the client hooks.
|
||||||
func (c *UserClient) Hooks() []Hook {
|
func (c *UserClient) Hooks() []Hook {
|
||||||
return c.hooks.User
|
return c.hooks.User
|
||||||
|
|
|
@ -38,6 +38,7 @@ type (
|
||||||
Label []ent.Hook
|
Label []ent.Hook
|
||||||
Location []ent.Hook
|
Location []ent.Hook
|
||||||
MaintenanceEntry []ent.Hook
|
MaintenanceEntry []ent.Hook
|
||||||
|
Notifier []ent.Hook
|
||||||
User []ent.Hook
|
User []ent.Hook
|
||||||
}
|
}
|
||||||
inters struct {
|
inters struct {
|
||||||
|
@ -52,6 +53,7 @@ type (
|
||||||
Label []ent.Interceptor
|
Label []ent.Interceptor
|
||||||
Location []ent.Interceptor
|
Location []ent.Interceptor
|
||||||
MaintenanceEntry []ent.Interceptor
|
MaintenanceEntry []ent.Interceptor
|
||||||
|
Notifier []ent.Interceptor
|
||||||
User []ent.Interceptor
|
User []ent.Interceptor
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/label"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/label"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/location"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/location"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,6 +62,7 @@ func columnChecker(table string) func(string) error {
|
||||||
label.Table: label.ValidColumn,
|
label.Table: label.ValidColumn,
|
||||||
location.Table: location.ValidColumn,
|
location.Table: location.ValidColumn,
|
||||||
maintenanceentry.Table: maintenanceentry.ValidColumn,
|
maintenanceentry.Table: maintenanceentry.ValidColumn,
|
||||||
|
notifier.Table: notifier.ValidColumn,
|
||||||
user.Table: user.ValidColumn,
|
user.Table: user.ValidColumn,
|
||||||
}
|
}
|
||||||
check, ok := checks[table]
|
check, ok := checks[table]
|
||||||
|
|
|
@ -48,6 +48,10 @@ func (me *MaintenanceEntry) GetID() uuid.UUID {
|
||||||
return me.ID
|
return me.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *Notifier) GetID() uuid.UUID {
|
||||||
|
return n.ID
|
||||||
|
}
|
||||||
|
|
||||||
func (u *User) GetID() uuid.UUID {
|
func (u *User) GetID() uuid.UUID {
|
||||||
return u.ID
|
return u.ID
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,18 @@ func (f MaintenanceEntryFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.V
|
||||||
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MaintenanceEntryMutation", m)
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MaintenanceEntryMutation", m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The NotifierFunc type is an adapter to allow the use of ordinary
|
||||||
|
// function as Notifier mutator.
|
||||||
|
type NotifierFunc func(context.Context, *ent.NotifierMutation) (ent.Value, error)
|
||||||
|
|
||||||
|
// Mutate calls f(ctx, m).
|
||||||
|
func (f NotifierFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
if mv, ok := m.(*ent.NotifierMutation); ok {
|
||||||
|
return f(ctx, mv)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NotifierMutation", m)
|
||||||
|
}
|
||||||
|
|
||||||
// The UserFunc type is an adapter to allow the use of ordinary
|
// The UserFunc type is an adapter to allow the use of ordinary
|
||||||
// function as User mutator.
|
// function as User mutator.
|
||||||
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
|
type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error)
|
||||||
|
|
|
@ -344,6 +344,42 @@ var (
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
// NotifiersColumns holds the columns for the "notifiers" table.
|
||||||
|
NotifiersColumns = []*schema.Column{
|
||||||
|
{Name: "id", Type: field.TypeUUID},
|
||||||
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
|
{Name: "updated_at", Type: field.TypeTime},
|
||||||
|
{Name: "name", Type: field.TypeString, Size: 255},
|
||||||
|
{Name: "url", Type: field.TypeString, Size: 2083},
|
||||||
|
{Name: "is_active", Type: field.TypeBool, Default: true},
|
||||||
|
{Name: "user_id", Type: field.TypeUUID},
|
||||||
|
}
|
||||||
|
// NotifiersTable holds the schema information for the "notifiers" table.
|
||||||
|
NotifiersTable = &schema.Table{
|
||||||
|
Name: "notifiers",
|
||||||
|
Columns: NotifiersColumns,
|
||||||
|
PrimaryKey: []*schema.Column{NotifiersColumns[0]},
|
||||||
|
ForeignKeys: []*schema.ForeignKey{
|
||||||
|
{
|
||||||
|
Symbol: "notifiers_users_notifiers",
|
||||||
|
Columns: []*schema.Column{NotifiersColumns[6]},
|
||||||
|
RefColumns: []*schema.Column{UsersColumns[0]},
|
||||||
|
OnDelete: schema.Cascade,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Indexes: []*schema.Index{
|
||||||
|
{
|
||||||
|
Name: "notifier_user_id",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{NotifiersColumns[6]},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "notifier_user_id_is_active",
|
||||||
|
Unique: false,
|
||||||
|
Columns: []*schema.Column{NotifiersColumns[6], NotifiersColumns[5]},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
// UsersColumns holds the columns for the "users" table.
|
// UsersColumns holds the columns for the "users" table.
|
||||||
UsersColumns = []*schema.Column{
|
UsersColumns = []*schema.Column{
|
||||||
{Name: "id", Type: field.TypeUUID},
|
{Name: "id", Type: field.TypeUUID},
|
||||||
|
@ -353,8 +389,8 @@ var (
|
||||||
{Name: "email", Type: field.TypeString, Unique: true, Size: 255},
|
{Name: "email", Type: field.TypeString, Unique: true, Size: 255},
|
||||||
{Name: "password", Type: field.TypeString, Size: 255},
|
{Name: "password", Type: field.TypeString, Size: 255},
|
||||||
{Name: "is_superuser", Type: field.TypeBool, Default: false},
|
{Name: "is_superuser", Type: field.TypeBool, Default: false},
|
||||||
{Name: "role", Type: field.TypeEnum, Enums: []string{"user", "owner"}, Default: "user"},
|
|
||||||
{Name: "superuser", Type: field.TypeBool, Default: false},
|
{Name: "superuser", Type: field.TypeBool, Default: false},
|
||||||
|
{Name: "role", Type: field.TypeEnum, Enums: []string{"user", "owner"}, Default: "user"},
|
||||||
{Name: "activated_on", Type: field.TypeTime, Nullable: true},
|
{Name: "activated_on", Type: field.TypeTime, Nullable: true},
|
||||||
{Name: "group_users", Type: field.TypeUUID},
|
{Name: "group_users", Type: field.TypeUUID},
|
||||||
}
|
}
|
||||||
|
@ -410,6 +446,7 @@ var (
|
||||||
LabelsTable,
|
LabelsTable,
|
||||||
LocationsTable,
|
LocationsTable,
|
||||||
MaintenanceEntriesTable,
|
MaintenanceEntriesTable,
|
||||||
|
NotifiersTable,
|
||||||
UsersTable,
|
UsersTable,
|
||||||
LabelItemsTable,
|
LabelItemsTable,
|
||||||
}
|
}
|
||||||
|
@ -430,6 +467,7 @@ func init() {
|
||||||
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
|
LocationsTable.ForeignKeys[0].RefTable = GroupsTable
|
||||||
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
|
LocationsTable.ForeignKeys[1].RefTable = LocationsTable
|
||||||
MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable
|
MaintenanceEntriesTable.ForeignKeys[0].RefTable = ItemsTable
|
||||||
|
NotifiersTable.ForeignKeys[0].RefTable = UsersTable
|
||||||
UsersTable.ForeignKeys[0].RefTable = GroupsTable
|
UsersTable.ForeignKeys[0].RefTable = GroupsTable
|
||||||
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
|
LabelItemsTable.ForeignKeys[0].RefTable = LabelsTable
|
||||||
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
|
LabelItemsTable.ForeignKeys[1].RefTable = ItemsTable
|
||||||
|
|
File diff suppressed because it is too large
Load diff
184
backend/internal/data/ent/notifier.go
Normal file
184
backend/internal/data/ent/notifier.go
Normal file
|
@ -0,0 +1,184 @@
|
||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Notifier is the model entity for the Notifier schema.
|
||||||
|
type Notifier struct {
|
||||||
|
config `json:"-"`
|
||||||
|
// ID of the ent.
|
||||||
|
ID uuid.UUID `json:"id,omitempty"`
|
||||||
|
// CreatedAt holds the value of the "created_at" field.
|
||||||
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||||
|
// UpdatedAt holds the value of the "updated_at" field.
|
||||||
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||||
|
// UserID holds the value of the "user_id" field.
|
||||||
|
UserID uuid.UUID `json:"user_id,omitempty"`
|
||||||
|
// Name holds the value of the "name" field.
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
// URL holds the value of the "url" field.
|
||||||
|
URL string `json:"-"`
|
||||||
|
// IsActive holds the value of the "is_active" field.
|
||||||
|
IsActive bool `json:"is_active,omitempty"`
|
||||||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
|
// The values are being populated by the NotifierQuery when eager-loading is set.
|
||||||
|
Edges NotifierEdges `json:"edges"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotifierEdges holds the relations/edges for other nodes in the graph.
|
||||||
|
type NotifierEdges 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 NotifierEdges) UserOrErr() (*User, error) {
|
||||||
|
if e.loadedTypes[0] {
|
||||||
|
if e.User == nil {
|
||||||
|
// Edge was loaded but was not found.
|
||||||
|
return nil, &NotFoundError{label: user.Label}
|
||||||
|
}
|
||||||
|
return e.User, nil
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "user"}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
|
func (*Notifier) scanValues(columns []string) ([]any, error) {
|
||||||
|
values := make([]any, len(columns))
|
||||||
|
for i := range columns {
|
||||||
|
switch columns[i] {
|
||||||
|
case notifier.FieldIsActive:
|
||||||
|
values[i] = new(sql.NullBool)
|
||||||
|
case notifier.FieldName, notifier.FieldURL:
|
||||||
|
values[i] = new(sql.NullString)
|
||||||
|
case notifier.FieldCreatedAt, notifier.FieldUpdatedAt:
|
||||||
|
values[i] = new(sql.NullTime)
|
||||||
|
case notifier.FieldID, notifier.FieldUserID:
|
||||||
|
values[i] = new(uuid.UUID)
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unexpected column %q for type Notifier", columns[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
|
// to the Notifier fields.
|
||||||
|
func (n *Notifier) 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 notifier.FieldID:
|
||||||
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
||||||
|
} else if value != nil {
|
||||||
|
n.ID = *value
|
||||||
|
}
|
||||||
|
case notifier.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 {
|
||||||
|
n.CreatedAt = value.Time
|
||||||
|
}
|
||||||
|
case notifier.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 {
|
||||||
|
n.UpdatedAt = value.Time
|
||||||
|
}
|
||||||
|
case notifier.FieldUserID:
|
||||||
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field user_id", values[i])
|
||||||
|
} else if value != nil {
|
||||||
|
n.UserID = *value
|
||||||
|
}
|
||||||
|
case notifier.FieldName:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
n.Name = value.String
|
||||||
|
}
|
||||||
|
case notifier.FieldURL:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field url", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
n.URL = value.String
|
||||||
|
}
|
||||||
|
case notifier.FieldIsActive:
|
||||||
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field is_active", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
n.IsActive = value.Bool
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUser queries the "user" edge of the Notifier entity.
|
||||||
|
func (n *Notifier) QueryUser() *UserQuery {
|
||||||
|
return NewNotifierClient(n.config).QueryUser(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update returns a builder for updating this Notifier.
|
||||||
|
// Note that you need to call Notifier.Unwrap() before calling this method if this Notifier
|
||||||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
func (n *Notifier) Update() *NotifierUpdateOne {
|
||||||
|
return NewNotifierClient(n.config).UpdateOne(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unwrap unwraps the Notifier 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 (n *Notifier) Unwrap() *Notifier {
|
||||||
|
_tx, ok := n.config.driver.(*txDriver)
|
||||||
|
if !ok {
|
||||||
|
panic("ent: Notifier is not a transactional entity")
|
||||||
|
}
|
||||||
|
n.config.driver = _tx.drv
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements the fmt.Stringer.
|
||||||
|
func (n *Notifier) String() string {
|
||||||
|
var builder strings.Builder
|
||||||
|
builder.WriteString("Notifier(")
|
||||||
|
builder.WriteString(fmt.Sprintf("id=%v, ", n.ID))
|
||||||
|
builder.WriteString("created_at=")
|
||||||
|
builder.WriteString(n.CreatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("updated_at=")
|
||||||
|
builder.WriteString(n.UpdatedAt.Format(time.ANSIC))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("user_id=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", n.UserID))
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("name=")
|
||||||
|
builder.WriteString(n.Name)
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("url=<sensitive>")
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("is_active=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", n.IsActive))
|
||||||
|
builder.WriteByte(')')
|
||||||
|
return builder.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notifiers is a parsable slice of Notifier.
|
||||||
|
type Notifiers []*Notifier
|
77
backend/internal/data/ent/notifier/notifier.go
Normal file
77
backend/internal/data/ent/notifier/notifier.go
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package notifier
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// Label holds the string label denoting the notifier type in the database.
|
||||||
|
Label = "notifier"
|
||||||
|
// 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"
|
||||||
|
// FieldUserID holds the string denoting the user_id field in the database.
|
||||||
|
FieldUserID = "user_id"
|
||||||
|
// FieldName holds the string denoting the name field in the database.
|
||||||
|
FieldName = "name"
|
||||||
|
// FieldURL holds the string denoting the url field in the database.
|
||||||
|
FieldURL = "url"
|
||||||
|
// FieldIsActive holds the string denoting the is_active field in the database.
|
||||||
|
FieldIsActive = "is_active"
|
||||||
|
// EdgeUser holds the string denoting the user edge name in mutations.
|
||||||
|
EdgeUser = "user"
|
||||||
|
// Table holds the table name of the notifier in the database.
|
||||||
|
Table = "notifiers"
|
||||||
|
// UserTable is the table that holds the user relation/edge.
|
||||||
|
UserTable = "notifiers"
|
||||||
|
// 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 notifier fields.
|
||||||
|
var Columns = []string{
|
||||||
|
FieldID,
|
||||||
|
FieldCreatedAt,
|
||||||
|
FieldUpdatedAt,
|
||||||
|
FieldUserID,
|
||||||
|
FieldName,
|
||||||
|
FieldURL,
|
||||||
|
FieldIsActive,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
// NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||||
|
NameValidator func(string) error
|
||||||
|
// URLValidator is a validator for the "url" field. It is called by the builders before save.
|
||||||
|
URLValidator func(string) error
|
||||||
|
// DefaultIsActive holds the default value on creation for the "is_active" field.
|
||||||
|
DefaultIsActive bool
|
||||||
|
// DefaultID holds the default value on creation for the "id" field.
|
||||||
|
DefaultID func() uuid.UUID
|
||||||
|
)
|
386
backend/internal/data/ent/notifier/where.go
Normal file
386
backend/internal/data/ent/notifier/where.go
Normal file
|
@ -0,0 +1,386 @@
|
||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package notifier
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ID filters vertices based on their ID field.
|
||||||
|
func ID(id uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDEQ applies the EQ predicate on the ID field.
|
||||||
|
func IDEQ(id uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNEQ applies the NEQ predicate on the ID field.
|
||||||
|
func IDNEQ(id uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNEQ(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDIn applies the In predicate on the ID field.
|
||||||
|
func IDIn(ids ...uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
|
func IDNotIn(ids ...uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNotIn(FieldID, ids...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGT applies the GT predicate on the ID field.
|
||||||
|
func IDGT(id uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDGTE applies the GTE predicate on the ID field.
|
||||||
|
func IDGTE(id uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGTE(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLT applies the LT predicate on the ID field.
|
||||||
|
func IDLT(id uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLT(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDLTE applies the LTE predicate on the ID field.
|
||||||
|
func IDLTE(id uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(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.Notifier {
|
||||||
|
return predicate.Notifier(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.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
|
||||||
|
func UserID(v uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldUserID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||||
|
func Name(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URL applies equality check predicate on the "url" field. It's identical to URLEQ.
|
||||||
|
func URL(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsActive applies equality check predicate on the "is_active" field. It's identical to IsActiveEQ.
|
||||||
|
func IsActive(v bool) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldIsActive, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtEQ(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||||
|
func CreatedAtNEQ(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNEQ(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
|
func CreatedAtIn(vs ...time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
|
func CreatedAtNotIn(vs ...time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||||
|
func CreatedAtGT(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtGTE(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||||
|
func CreatedAtLT(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLT(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||||
|
func CreatedAtLTE(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLTE(FieldCreatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtEQ(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNEQ(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtIn(vs ...time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtNotIn(vs ...time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGT(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtGTE(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLT(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLT(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||||
|
func UpdatedAtLTE(v time.Time) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLTE(FieldUpdatedAt, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserIDEQ applies the EQ predicate on the "user_id" field.
|
||||||
|
func UserIDEQ(v uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldUserID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
|
||||||
|
func UserIDNEQ(v uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNEQ(FieldUserID, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserIDIn applies the In predicate on the "user_id" field.
|
||||||
|
func UserIDIn(vs ...uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldIn(FieldUserID, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
|
||||||
|
func UserIDNotIn(vs ...uuid.UUID) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNotIn(FieldUserID, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEQ applies the EQ predicate on the "name" field.
|
||||||
|
func NameEQ(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNEQ applies the NEQ predicate on the "name" field.
|
||||||
|
func NameNEQ(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNEQ(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameIn applies the In predicate on the "name" field.
|
||||||
|
func NameIn(vs ...string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||||
|
func NameNotIn(vs ...string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNotIn(FieldName, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGT applies the GT predicate on the "name" field.
|
||||||
|
func NameGT(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameGTE applies the GTE predicate on the "name" field.
|
||||||
|
func NameGTE(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLT applies the LT predicate on the "name" field.
|
||||||
|
func NameLT(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLT(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameLTE applies the LTE predicate on the "name" field.
|
||||||
|
func NameLTE(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLTE(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContains applies the Contains predicate on the "name" field.
|
||||||
|
func NameContains(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldContains(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
|
||||||
|
func NameHasPrefix(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldHasPrefix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
|
||||||
|
func NameHasSuffix(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldHasSuffix(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||||
|
func NameEqualFold(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEqualFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameContainsFold applies the ContainsFold predicate on the "name" field.
|
||||||
|
func NameContainsFold(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldContainsFold(FieldName, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLEQ applies the EQ predicate on the "url" field.
|
||||||
|
func URLEQ(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLNEQ applies the NEQ predicate on the "url" field.
|
||||||
|
func URLNEQ(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNEQ(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLIn applies the In predicate on the "url" field.
|
||||||
|
func URLIn(vs ...string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldIn(FieldURL, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLNotIn applies the NotIn predicate on the "url" field.
|
||||||
|
func URLNotIn(vs ...string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNotIn(FieldURL, vs...))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLGT applies the GT predicate on the "url" field.
|
||||||
|
func URLGT(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGT(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLGTE applies the GTE predicate on the "url" field.
|
||||||
|
func URLGTE(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldGTE(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLLT applies the LT predicate on the "url" field.
|
||||||
|
func URLLT(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLT(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLLTE applies the LTE predicate on the "url" field.
|
||||||
|
func URLLTE(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldLTE(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLContains applies the Contains predicate on the "url" field.
|
||||||
|
func URLContains(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldContains(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLHasPrefix applies the HasPrefix predicate on the "url" field.
|
||||||
|
func URLHasPrefix(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldHasPrefix(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLHasSuffix applies the HasSuffix predicate on the "url" field.
|
||||||
|
func URLHasSuffix(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldHasSuffix(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLEqualFold applies the EqualFold predicate on the "url" field.
|
||||||
|
func URLEqualFold(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEqualFold(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// URLContainsFold applies the ContainsFold predicate on the "url" field.
|
||||||
|
func URLContainsFold(v string) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldContainsFold(FieldURL, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsActiveEQ applies the EQ predicate on the "is_active" field.
|
||||||
|
func IsActiveEQ(v bool) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldEQ(FieldIsActive, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsActiveNEQ applies the NEQ predicate on the "is_active" field.
|
||||||
|
func IsActiveNEQ(v bool) predicate.Notifier {
|
||||||
|
return predicate.Notifier(sql.FieldNEQ(FieldIsActive, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasUser applies the HasEdge predicate on the "user" edge.
|
||||||
|
func HasUser() predicate.Notifier {
|
||||||
|
return predicate.Notifier(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.Notifier {
|
||||||
|
return predicate.Notifier(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(UserInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
|
||||||
|
)
|
||||||
|
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.Notifier) predicate.Notifier {
|
||||||
|
return predicate.Notifier(func(s *sql.Selector) {
|
||||||
|
s1 := s.Clone().SetP(nil)
|
||||||
|
for _, p := range predicates {
|
||||||
|
p(s1)
|
||||||
|
}
|
||||||
|
s.Where(s1.P())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Or groups predicates with the OR operator between them.
|
||||||
|
func Or(predicates ...predicate.Notifier) predicate.Notifier {
|
||||||
|
return predicate.Notifier(func(s *sql.Selector) {
|
||||||
|
s1 := s.Clone().SetP(nil)
|
||||||
|
for i, p := range predicates {
|
||||||
|
if i > 0 {
|
||||||
|
s1.Or()
|
||||||
|
}
|
||||||
|
p(s1)
|
||||||
|
}
|
||||||
|
s.Where(s1.P())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not applies the not operator on the given predicate.
|
||||||
|
func Not(p predicate.Notifier) predicate.Notifier {
|
||||||
|
return predicate.Notifier(func(s *sql.Selector) {
|
||||||
|
p(s.Not())
|
||||||
|
})
|
||||||
|
}
|
346
backend/internal/data/ent/notifier_create.go
Normal file
346
backend/internal/data/ent/notifier_create.go
Normal file
|
@ -0,0 +1,346 @@
|
||||||
|
// 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"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NotifierCreate is the builder for creating a Notifier entity.
|
||||||
|
type NotifierCreate struct {
|
||||||
|
config
|
||||||
|
mutation *NotifierMutation
|
||||||
|
hooks []Hook
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCreatedAt sets the "created_at" field.
|
||||||
|
func (nc *NotifierCreate) SetCreatedAt(t time.Time) *NotifierCreate {
|
||||||
|
nc.mutation.SetCreatedAt(t)
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
||||||
|
func (nc *NotifierCreate) SetNillableCreatedAt(t *time.Time) *NotifierCreate {
|
||||||
|
if t != nil {
|
||||||
|
nc.SetCreatedAt(*t)
|
||||||
|
}
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (nc *NotifierCreate) SetUpdatedAt(t time.Time) *NotifierCreate {
|
||||||
|
nc.mutation.SetUpdatedAt(t)
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
||||||
|
func (nc *NotifierCreate) SetNillableUpdatedAt(t *time.Time) *NotifierCreate {
|
||||||
|
if t != nil {
|
||||||
|
nc.SetUpdatedAt(*t)
|
||||||
|
}
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user_id" field.
|
||||||
|
func (nc *NotifierCreate) SetUserID(u uuid.UUID) *NotifierCreate {
|
||||||
|
nc.mutation.SetUserID(u)
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (nc *NotifierCreate) SetName(s string) *NotifierCreate {
|
||||||
|
nc.mutation.SetName(s)
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetURL sets the "url" field.
|
||||||
|
func (nc *NotifierCreate) SetURL(s string) *NotifierCreate {
|
||||||
|
nc.mutation.SetURL(s)
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIsActive sets the "is_active" field.
|
||||||
|
func (nc *NotifierCreate) SetIsActive(b bool) *NotifierCreate {
|
||||||
|
nc.mutation.SetIsActive(b)
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
||||||
|
func (nc *NotifierCreate) SetNillableIsActive(b *bool) *NotifierCreate {
|
||||||
|
if b != nil {
|
||||||
|
nc.SetIsActive(*b)
|
||||||
|
}
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetID sets the "id" field.
|
||||||
|
func (nc *NotifierCreate) SetID(u uuid.UUID) *NotifierCreate {
|
||||||
|
nc.mutation.SetID(u)
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableID sets the "id" field if the given value is not nil.
|
||||||
|
func (nc *NotifierCreate) SetNillableID(u *uuid.UUID) *NotifierCreate {
|
||||||
|
if u != nil {
|
||||||
|
nc.SetID(*u)
|
||||||
|
}
|
||||||
|
return nc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (nc *NotifierCreate) SetUser(u *User) *NotifierCreate {
|
||||||
|
return nc.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the NotifierMutation object of the builder.
|
||||||
|
func (nc *NotifierCreate) Mutation() *NotifierMutation {
|
||||||
|
return nc.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Notifier in the database.
|
||||||
|
func (nc *NotifierCreate) Save(ctx context.Context) (*Notifier, error) {
|
||||||
|
nc.defaults()
|
||||||
|
return withHooks[*Notifier, NotifierMutation](ctx, nc.sqlSave, nc.mutation, nc.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX calls Save and panics if Save returns an error.
|
||||||
|
func (nc *NotifierCreate) SaveX(ctx context.Context) *Notifier {
|
||||||
|
v, err := nc.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (nc *NotifierCreate) Exec(ctx context.Context) error {
|
||||||
|
_, err := nc.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (nc *NotifierCreate) ExecX(ctx context.Context) {
|
||||||
|
if err := nc.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (nc *NotifierCreate) defaults() {
|
||||||
|
if _, ok := nc.mutation.CreatedAt(); !ok {
|
||||||
|
v := notifier.DefaultCreatedAt()
|
||||||
|
nc.mutation.SetCreatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.UpdatedAt(); !ok {
|
||||||
|
v := notifier.DefaultUpdatedAt()
|
||||||
|
nc.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.IsActive(); !ok {
|
||||||
|
v := notifier.DefaultIsActive
|
||||||
|
nc.mutation.SetIsActive(v)
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.ID(); !ok {
|
||||||
|
v := notifier.DefaultID()
|
||||||
|
nc.mutation.SetID(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (nc *NotifierCreate) check() error {
|
||||||
|
if _, ok := nc.mutation.CreatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Notifier.created_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.UpdatedAt(); !ok {
|
||||||
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Notifier.updated_at"`)}
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.UserID(); !ok {
|
||||||
|
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "Notifier.user_id"`)}
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.Name(); !ok {
|
||||||
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Notifier.name"`)}
|
||||||
|
}
|
||||||
|
if v, ok := nc.mutation.Name(); ok {
|
||||||
|
if err := notifier.NameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Notifier.name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.URL(); !ok {
|
||||||
|
return &ValidationError{Name: "url", err: errors.New(`ent: missing required field "Notifier.url"`)}
|
||||||
|
}
|
||||||
|
if v, ok := nc.mutation.URL(); ok {
|
||||||
|
if err := notifier.URLValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.IsActive(); !ok {
|
||||||
|
return &ValidationError{Name: "is_active", err: errors.New(`ent: missing required field "Notifier.is_active"`)}
|
||||||
|
}
|
||||||
|
if _, ok := nc.mutation.UserID(); !ok {
|
||||||
|
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Notifier.user"`)}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nc *NotifierCreate) sqlSave(ctx context.Context) (*Notifier, error) {
|
||||||
|
if err := nc.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_node, _spec := nc.createSpec()
|
||||||
|
if err := sqlgraph.CreateNode(ctx, nc.driver, _spec); err != nil {
|
||||||
|
if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if _spec.ID.Value != nil {
|
||||||
|
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
||||||
|
_node.ID = *id
|
||||||
|
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nc.mutation.id = &_node.ID
|
||||||
|
nc.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nc *NotifierCreate) createSpec() (*Notifier, *sqlgraph.CreateSpec) {
|
||||||
|
var (
|
||||||
|
_node = &Notifier{config: nc.config}
|
||||||
|
_spec = sqlgraph.NewCreateSpec(notifier.Table, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||||
|
)
|
||||||
|
if id, ok := nc.mutation.ID(); ok {
|
||||||
|
_node.ID = id
|
||||||
|
_spec.ID.Value = &id
|
||||||
|
}
|
||||||
|
if value, ok := nc.mutation.CreatedAt(); ok {
|
||||||
|
_spec.SetField(notifier.FieldCreatedAt, field.TypeTime, value)
|
||||||
|
_node.CreatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := nc.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(notifier.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
_node.UpdatedAt = value
|
||||||
|
}
|
||||||
|
if value, ok := nc.mutation.Name(); ok {
|
||||||
|
_spec.SetField(notifier.FieldName, field.TypeString, value)
|
||||||
|
_node.Name = value
|
||||||
|
}
|
||||||
|
if value, ok := nc.mutation.URL(); ok {
|
||||||
|
_spec.SetField(notifier.FieldURL, field.TypeString, value)
|
||||||
|
_node.URL = value
|
||||||
|
}
|
||||||
|
if value, ok := nc.mutation.IsActive(); ok {
|
||||||
|
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
||||||
|
_node.IsActive = value
|
||||||
|
}
|
||||||
|
if nodes := nc.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: notifier.UserTable,
|
||||||
|
Columns: []string{notifier.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: user.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_node.UserID = nodes[0]
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
|
return _node, _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotifierCreateBulk is the builder for creating many Notifier entities in bulk.
|
||||||
|
type NotifierCreateBulk struct {
|
||||||
|
config
|
||||||
|
builders []*NotifierCreate
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save creates the Notifier entities in the database.
|
||||||
|
func (ncb *NotifierCreateBulk) Save(ctx context.Context) ([]*Notifier, error) {
|
||||||
|
specs := make([]*sqlgraph.CreateSpec, len(ncb.builders))
|
||||||
|
nodes := make([]*Notifier, len(ncb.builders))
|
||||||
|
mutators := make([]Mutator, len(ncb.builders))
|
||||||
|
for i := range ncb.builders {
|
||||||
|
func(i int, root context.Context) {
|
||||||
|
builder := ncb.builders[i]
|
||||||
|
builder.defaults()
|
||||||
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||||
|
mutation, ok := m.(*NotifierMutation)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected mutation type %T", m)
|
||||||
|
}
|
||||||
|
if err := builder.check(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
builder.mutation = mutation
|
||||||
|
nodes[i], specs[i] = builder.createSpec()
|
||||||
|
var err error
|
||||||
|
if i < len(mutators)-1 {
|
||||||
|
_, err = mutators[i+1].Mutate(root, ncb.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, ncb.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
|
||||||
|
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, ncb.builders[0].mutation); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (ncb *NotifierCreateBulk) SaveX(ctx context.Context) []*Notifier {
|
||||||
|
v, err := ncb.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (ncb *NotifierCreateBulk) Exec(ctx context.Context) error {
|
||||||
|
_, err := ncb.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ncb *NotifierCreateBulk) ExecX(ctx context.Context) {
|
||||||
|
if err := ncb.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
88
backend/internal/data/ent/notifier_delete.go
Normal file
88
backend/internal/data/ent/notifier_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"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NotifierDelete is the builder for deleting a Notifier entity.
|
||||||
|
type NotifierDelete struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *NotifierMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the NotifierDelete builder.
|
||||||
|
func (nd *NotifierDelete) Where(ps ...predicate.Notifier) *NotifierDelete {
|
||||||
|
nd.mutation.Where(ps...)
|
||||||
|
return nd
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||||
|
func (nd *NotifierDelete) Exec(ctx context.Context) (int, error) {
|
||||||
|
return withHooks[int, NotifierMutation](ctx, nd.sqlExec, nd.mutation, nd.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (nd *NotifierDelete) ExecX(ctx context.Context) int {
|
||||||
|
n, err := nd.Exec(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nd *NotifierDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
|
_spec := sqlgraph.NewDeleteSpec(notifier.Table, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||||
|
if ps := nd.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
affected, err := sqlgraph.DeleteNodes(ctx, nd.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
nd.mutation.done = true
|
||||||
|
return affected, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotifierDeleteOne is the builder for deleting a single Notifier entity.
|
||||||
|
type NotifierDeleteOne struct {
|
||||||
|
nd *NotifierDelete
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the NotifierDelete builder.
|
||||||
|
func (ndo *NotifierDeleteOne) Where(ps ...predicate.Notifier) *NotifierDeleteOne {
|
||||||
|
ndo.nd.mutation.Where(ps...)
|
||||||
|
return ndo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the deletion query.
|
||||||
|
func (ndo *NotifierDeleteOne) Exec(ctx context.Context) error {
|
||||||
|
n, err := ndo.nd.Exec(ctx)
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
case n == 0:
|
||||||
|
return &NotFoundError{notifier.Label}
|
||||||
|
default:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (ndo *NotifierDeleteOne) ExecX(ctx context.Context) {
|
||||||
|
if err := ndo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
603
backend/internal/data/ent/notifier_query.go
Normal file
603
backend/internal/data/ent/notifier_query.go
Normal file
|
@ -0,0 +1,603 @@
|
||||||
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
|
package ent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
|
"entgo.io/ent/schema/field"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NotifierQuery is the builder for querying Notifier entities.
|
||||||
|
type NotifierQuery struct {
|
||||||
|
config
|
||||||
|
ctx *QueryContext
|
||||||
|
order []OrderFunc
|
||||||
|
inters []Interceptor
|
||||||
|
predicates []predicate.Notifier
|
||||||
|
withUser *UserQuery
|
||||||
|
// intermediate query (i.e. traversal path).
|
||||||
|
sql *sql.Selector
|
||||||
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where adds a new predicate for the NotifierQuery builder.
|
||||||
|
func (nq *NotifierQuery) Where(ps ...predicate.Notifier) *NotifierQuery {
|
||||||
|
nq.predicates = append(nq.predicates, ps...)
|
||||||
|
return nq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limit the number of records to be returned by this query.
|
||||||
|
func (nq *NotifierQuery) Limit(limit int) *NotifierQuery {
|
||||||
|
nq.ctx.Limit = &limit
|
||||||
|
return nq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Offset to start from.
|
||||||
|
func (nq *NotifierQuery) Offset(offset int) *NotifierQuery {
|
||||||
|
nq.ctx.Offset = &offset
|
||||||
|
return nq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 (nq *NotifierQuery) Unique(unique bool) *NotifierQuery {
|
||||||
|
nq.ctx.Unique = &unique
|
||||||
|
return nq
|
||||||
|
}
|
||||||
|
|
||||||
|
// Order specifies how the records should be ordered.
|
||||||
|
func (nq *NotifierQuery) Order(o ...OrderFunc) *NotifierQuery {
|
||||||
|
nq.order = append(nq.order, o...)
|
||||||
|
return nq
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryUser chains the current query on the "user" edge.
|
||||||
|
func (nq *NotifierQuery) QueryUser() *UserQuery {
|
||||||
|
query := (&UserClient{config: nq.config}).Query()
|
||||||
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
|
if err := nq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
selector := nq.sqlQuery(ctx)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(notifier.Table, notifier.FieldID, selector),
|
||||||
|
sqlgraph.To(user.Table, user.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.M2O, true, notifier.UserTable, notifier.UserColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(nq.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
|
// First returns the first Notifier entity from the query.
|
||||||
|
// Returns a *NotFoundError when no Notifier was found.
|
||||||
|
func (nq *NotifierQuery) First(ctx context.Context) (*Notifier, error) {
|
||||||
|
nodes, err := nq.Limit(1).All(setContextOp(ctx, nq.ctx, "First"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nil, &NotFoundError{notifier.Label}
|
||||||
|
}
|
||||||
|
return nodes[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstX is like First, but panics if an error occurs.
|
||||||
|
func (nq *NotifierQuery) FirstX(ctx context.Context) *Notifier {
|
||||||
|
node, err := nq.First(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstID returns the first Notifier ID from the query.
|
||||||
|
// Returns a *NotFoundError when no Notifier ID was found.
|
||||||
|
func (nq *NotifierQuery) FirstID(ctx context.Context) (id uuid.UUID, err error) {
|
||||||
|
var ids []uuid.UUID
|
||||||
|
if ids, err = nq.Limit(1).IDs(setContextOp(ctx, nq.ctx, "FirstID")); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len(ids) == 0 {
|
||||||
|
err = &NotFoundError{notifier.Label}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return ids[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||||
|
func (nq *NotifierQuery) FirstIDX(ctx context.Context) uuid.UUID {
|
||||||
|
id, err := nq.FirstID(ctx)
|
||||||
|
if err != nil && !IsNotFound(err) {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only returns a single Notifier entity found by the query, ensuring it only returns one.
|
||||||
|
// Returns a *NotSingularError when more than one Notifier entity is found.
|
||||||
|
// Returns a *NotFoundError when no Notifier entities are found.
|
||||||
|
func (nq *NotifierQuery) Only(ctx context.Context) (*Notifier, error) {
|
||||||
|
nodes, err := nq.Limit(2).All(setContextOp(ctx, nq.ctx, "Only"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(nodes) {
|
||||||
|
case 1:
|
||||||
|
return nodes[0], nil
|
||||||
|
case 0:
|
||||||
|
return nil, &NotFoundError{notifier.Label}
|
||||||
|
default:
|
||||||
|
return nil, &NotSingularError{notifier.Label}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyX is like Only, but panics if an error occurs.
|
||||||
|
func (nq *NotifierQuery) OnlyX(ctx context.Context) *Notifier {
|
||||||
|
node, err := nq.Only(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyID is like Only, but returns the only Notifier ID in the query.
|
||||||
|
// Returns a *NotSingularError when more than one Notifier ID is found.
|
||||||
|
// Returns a *NotFoundError when no entities are found.
|
||||||
|
func (nq *NotifierQuery) OnlyID(ctx context.Context) (id uuid.UUID, err error) {
|
||||||
|
var ids []uuid.UUID
|
||||||
|
if ids, err = nq.Limit(2).IDs(setContextOp(ctx, nq.ctx, "OnlyID")); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(ids) {
|
||||||
|
case 1:
|
||||||
|
id = ids[0]
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{notifier.Label}
|
||||||
|
default:
|
||||||
|
err = &NotSingularError{notifier.Label}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||||
|
func (nq *NotifierQuery) OnlyIDX(ctx context.Context) uuid.UUID {
|
||||||
|
id, err := nq.OnlyID(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
// All executes the query and returns a list of Notifiers.
|
||||||
|
func (nq *NotifierQuery) All(ctx context.Context) ([]*Notifier, error) {
|
||||||
|
ctx = setContextOp(ctx, nq.ctx, "All")
|
||||||
|
if err := nq.prepareQuery(ctx); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qr := querierAll[[]*Notifier, *NotifierQuery]()
|
||||||
|
return withInterceptors[[]*Notifier](ctx, nq, qr, nq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllX is like All, but panics if an error occurs.
|
||||||
|
func (nq *NotifierQuery) AllX(ctx context.Context) []*Notifier {
|
||||||
|
nodes, err := nq.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDs executes the query and returns a list of Notifier IDs.
|
||||||
|
func (nq *NotifierQuery) IDs(ctx context.Context) (ids []uuid.UUID, err error) {
|
||||||
|
if nq.ctx.Unique == nil && nq.path != nil {
|
||||||
|
nq.Unique(true)
|
||||||
|
}
|
||||||
|
ctx = setContextOp(ctx, nq.ctx, "IDs")
|
||||||
|
if err = nq.Select(notifier.FieldID).Scan(ctx, &ids); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDsX is like IDs, but panics if an error occurs.
|
||||||
|
func (nq *NotifierQuery) IDsX(ctx context.Context) []uuid.UUID {
|
||||||
|
ids, err := nq.IDs(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
// Count returns the count of the given query.
|
||||||
|
func (nq *NotifierQuery) Count(ctx context.Context) (int, error) {
|
||||||
|
ctx = setContextOp(ctx, nq.ctx, "Count")
|
||||||
|
if err := nq.prepareQuery(ctx); err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return withInterceptors[int](ctx, nq, querierCount[*NotifierQuery](), nq.inters)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CountX is like Count, but panics if an error occurs.
|
||||||
|
func (nq *NotifierQuery) CountX(ctx context.Context) int {
|
||||||
|
count, err := nq.Count(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exist returns true if the query has elements in the graph.
|
||||||
|
func (nq *NotifierQuery) Exist(ctx context.Context) (bool, error) {
|
||||||
|
ctx = setContextOp(ctx, nq.ctx, "Exist")
|
||||||
|
switch _, err := nq.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 (nq *NotifierQuery) ExistX(ctx context.Context) bool {
|
||||||
|
exist, err := nq.Exist(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return exist
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clone returns a duplicate of the NotifierQuery builder, including all associated steps. It can be
|
||||||
|
// used to prepare common query builders and use them differently after the clone is made.
|
||||||
|
func (nq *NotifierQuery) Clone() *NotifierQuery {
|
||||||
|
if nq == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return &NotifierQuery{
|
||||||
|
config: nq.config,
|
||||||
|
ctx: nq.ctx.Clone(),
|
||||||
|
order: append([]OrderFunc{}, nq.order...),
|
||||||
|
inters: append([]Interceptor{}, nq.inters...),
|
||||||
|
predicates: append([]predicate.Notifier{}, nq.predicates...),
|
||||||
|
withUser: nq.withUser.Clone(),
|
||||||
|
// clone intermediate query.
|
||||||
|
sql: nq.sql.Clone(),
|
||||||
|
path: nq.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 (nq *NotifierQuery) WithUser(opts ...func(*UserQuery)) *NotifierQuery {
|
||||||
|
query := (&UserClient{config: nq.config}).Query()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
nq.withUser = query
|
||||||
|
return nq
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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:"created_at,omitempty"`
|
||||||
|
// Count int `json:"count,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.Notifier.Query().
|
||||||
|
// GroupBy(notifier.FieldCreatedAt).
|
||||||
|
// Aggregate(ent.Count()).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (nq *NotifierQuery) GroupBy(field string, fields ...string) *NotifierGroupBy {
|
||||||
|
nq.ctx.Fields = append([]string{field}, fields...)
|
||||||
|
grbuild := &NotifierGroupBy{build: nq}
|
||||||
|
grbuild.flds = &nq.ctx.Fields
|
||||||
|
grbuild.label = notifier.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:"created_at,omitempty"`
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client.Notifier.Query().
|
||||||
|
// Select(notifier.FieldCreatedAt).
|
||||||
|
// Scan(ctx, &v)
|
||||||
|
func (nq *NotifierQuery) Select(fields ...string) *NotifierSelect {
|
||||||
|
nq.ctx.Fields = append(nq.ctx.Fields, fields...)
|
||||||
|
sbuild := &NotifierSelect{NotifierQuery: nq}
|
||||||
|
sbuild.label = notifier.Label
|
||||||
|
sbuild.flds, sbuild.scan = &nq.ctx.Fields, sbuild.Scan
|
||||||
|
return sbuild
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate returns a NotifierSelect configured with the given aggregations.
|
||||||
|
func (nq *NotifierQuery) Aggregate(fns ...AggregateFunc) *NotifierSelect {
|
||||||
|
return nq.Select().Aggregate(fns...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nq *NotifierQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
for _, inter := range nq.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, nq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, f := range nq.ctx.Fields {
|
||||||
|
if !notifier.ValidColumn(f) {
|
||||||
|
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if nq.path != nil {
|
||||||
|
prev, err := nq.path(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
nq.sql = prev
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nq *NotifierQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Notifier, error) {
|
||||||
|
var (
|
||||||
|
nodes = []*Notifier{}
|
||||||
|
_spec = nq.querySpec()
|
||||||
|
loadedTypes = [1]bool{
|
||||||
|
nq.withUser != nil,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Notifier).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
|
node := &Notifier{config: nq.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, nq.driver, _spec); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if len(nodes) == 0 {
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
if query := nq.withUser; query != nil {
|
||||||
|
if err := nq.loadUser(ctx, query, nodes, nil,
|
||||||
|
func(n *Notifier, e *User) { n.Edges.User = e }); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nq *NotifierQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*Notifier, init func(*Notifier), assign func(*Notifier, *User)) error {
|
||||||
|
ids := make([]uuid.UUID, 0, len(nodes))
|
||||||
|
nodeids := make(map[uuid.UUID][]*Notifier)
|
||||||
|
for i := range nodes {
|
||||||
|
fk := nodes[i].UserID
|
||||||
|
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 (nq *NotifierQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
_spec := nq.querySpec()
|
||||||
|
_spec.Node.Columns = nq.ctx.Fields
|
||||||
|
if len(nq.ctx.Fields) > 0 {
|
||||||
|
_spec.Unique = nq.ctx.Unique != nil && *nq.ctx.Unique
|
||||||
|
}
|
||||||
|
return sqlgraph.CountNodes(ctx, nq.driver, _spec)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nq *NotifierQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
_spec := sqlgraph.NewQuerySpec(notifier.Table, notifier.Columns, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||||
|
_spec.From = nq.sql
|
||||||
|
if unique := nq.ctx.Unique; unique != nil {
|
||||||
|
_spec.Unique = *unique
|
||||||
|
} else if nq.path != nil {
|
||||||
|
_spec.Unique = true
|
||||||
|
}
|
||||||
|
if fields := nq.ctx.Fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, notifier.FieldID)
|
||||||
|
for i := range fields {
|
||||||
|
if fields[i] != notifier.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := nq.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit := nq.ctx.Limit; limit != nil {
|
||||||
|
_spec.Limit = *limit
|
||||||
|
}
|
||||||
|
if offset := nq.ctx.Offset; offset != nil {
|
||||||
|
_spec.Offset = *offset
|
||||||
|
}
|
||||||
|
if ps := nq.order; len(ps) > 0 {
|
||||||
|
_spec.Order = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _spec
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nq *NotifierQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
|
builder := sql.Dialect(nq.driver.Dialect())
|
||||||
|
t1 := builder.Table(notifier.Table)
|
||||||
|
columns := nq.ctx.Fields
|
||||||
|
if len(columns) == 0 {
|
||||||
|
columns = notifier.Columns
|
||||||
|
}
|
||||||
|
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||||
|
if nq.sql != nil {
|
||||||
|
selector = nq.sql
|
||||||
|
selector.Select(selector.Columns(columns...)...)
|
||||||
|
}
|
||||||
|
if nq.ctx.Unique != nil && *nq.ctx.Unique {
|
||||||
|
selector.Distinct()
|
||||||
|
}
|
||||||
|
for _, p := range nq.predicates {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
for _, p := range nq.order {
|
||||||
|
p(selector)
|
||||||
|
}
|
||||||
|
if offset := nq.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 := nq.ctx.Limit; limit != nil {
|
||||||
|
selector.Limit(*limit)
|
||||||
|
}
|
||||||
|
return selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotifierGroupBy is the group-by builder for Notifier entities.
|
||||||
|
type NotifierGroupBy struct {
|
||||||
|
selector
|
||||||
|
build *NotifierQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the group-by query.
|
||||||
|
func (ngb *NotifierGroupBy) Aggregate(fns ...AggregateFunc) *NotifierGroupBy {
|
||||||
|
ngb.fns = append(ngb.fns, fns...)
|
||||||
|
return ngb
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (ngb *NotifierGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, ngb.build.ctx, "GroupBy")
|
||||||
|
if err := ngb.build.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*NotifierQuery, *NotifierGroupBy](ctx, ngb.build, ngb, ngb.build.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ngb *NotifierGroupBy) sqlScan(ctx context.Context, root *NotifierQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx).Select()
|
||||||
|
aggregation := make([]string, 0, len(ngb.fns))
|
||||||
|
for _, fn := range ngb.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
if len(selector.SelectedColumns()) == 0 {
|
||||||
|
columns := make([]string, 0, len(*ngb.flds)+len(ngb.fns))
|
||||||
|
for _, f := range *ngb.flds {
|
||||||
|
columns = append(columns, selector.C(f))
|
||||||
|
}
|
||||||
|
columns = append(columns, aggregation...)
|
||||||
|
selector.Select(columns...)
|
||||||
|
}
|
||||||
|
selector.GroupBy(selector.Columns(*ngb.flds...)...)
|
||||||
|
if err := selector.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rows := &sql.Rows{}
|
||||||
|
query, args := selector.Query()
|
||||||
|
if err := ngb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotifierSelect is the builder for selecting fields of Notifier entities.
|
||||||
|
type NotifierSelect struct {
|
||||||
|
*NotifierQuery
|
||||||
|
selector
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate adds the given aggregation functions to the selector query.
|
||||||
|
func (ns *NotifierSelect) Aggregate(fns ...AggregateFunc) *NotifierSelect {
|
||||||
|
ns.fns = append(ns.fns, fns...)
|
||||||
|
return ns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
|
func (ns *NotifierSelect) Scan(ctx context.Context, v any) error {
|
||||||
|
ctx = setContextOp(ctx, ns.ctx, "Select")
|
||||||
|
if err := ns.prepareQuery(ctx); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return scanWithInterceptors[*NotifierQuery, *NotifierSelect](ctx, ns.NotifierQuery, ns, ns.inters, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ns *NotifierSelect) sqlScan(ctx context.Context, root *NotifierQuery, v any) error {
|
||||||
|
selector := root.sqlQuery(ctx)
|
||||||
|
aggregation := make([]string, 0, len(ns.fns))
|
||||||
|
for _, fn := range ns.fns {
|
||||||
|
aggregation = append(aggregation, fn(selector))
|
||||||
|
}
|
||||||
|
switch n := len(*ns.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 := ns.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
return sql.ScanSlice(rows, v)
|
||||||
|
}
|
430
backend/internal/data/ent/notifier_update.go
Normal file
430
backend/internal/data/ent/notifier_update.go
Normal file
|
@ -0,0 +1,430 @@
|
||||||
|
// 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"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NotifierUpdate is the builder for updating Notifier entities.
|
||||||
|
type NotifierUpdate struct {
|
||||||
|
config
|
||||||
|
hooks []Hook
|
||||||
|
mutation *NotifierMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the NotifierUpdate builder.
|
||||||
|
func (nu *NotifierUpdate) Where(ps ...predicate.Notifier) *NotifierUpdate {
|
||||||
|
nu.mutation.Where(ps...)
|
||||||
|
return nu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (nu *NotifierUpdate) SetUpdatedAt(t time.Time) *NotifierUpdate {
|
||||||
|
nu.mutation.SetUpdatedAt(t)
|
||||||
|
return nu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user_id" field.
|
||||||
|
func (nu *NotifierUpdate) SetUserID(u uuid.UUID) *NotifierUpdate {
|
||||||
|
nu.mutation.SetUserID(u)
|
||||||
|
return nu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (nu *NotifierUpdate) SetName(s string) *NotifierUpdate {
|
||||||
|
nu.mutation.SetName(s)
|
||||||
|
return nu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetURL sets the "url" field.
|
||||||
|
func (nu *NotifierUpdate) SetURL(s string) *NotifierUpdate {
|
||||||
|
nu.mutation.SetURL(s)
|
||||||
|
return nu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIsActive sets the "is_active" field.
|
||||||
|
func (nu *NotifierUpdate) SetIsActive(b bool) *NotifierUpdate {
|
||||||
|
nu.mutation.SetIsActive(b)
|
||||||
|
return nu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
||||||
|
func (nu *NotifierUpdate) SetNillableIsActive(b *bool) *NotifierUpdate {
|
||||||
|
if b != nil {
|
||||||
|
nu.SetIsActive(*b)
|
||||||
|
}
|
||||||
|
return nu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (nu *NotifierUpdate) SetUser(u *User) *NotifierUpdate {
|
||||||
|
return nu.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the NotifierMutation object of the builder.
|
||||||
|
func (nu *NotifierUpdate) Mutation() *NotifierMutation {
|
||||||
|
return nu.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearUser clears the "user" edge to the User entity.
|
||||||
|
func (nu *NotifierUpdate) ClearUser() *NotifierUpdate {
|
||||||
|
nu.mutation.ClearUser()
|
||||||
|
return nu
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
|
func (nu *NotifierUpdate) Save(ctx context.Context) (int, error) {
|
||||||
|
nu.defaults()
|
||||||
|
return withHooks[int, NotifierMutation](ctx, nu.sqlSave, nu.mutation, nu.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (nu *NotifierUpdate) SaveX(ctx context.Context) int {
|
||||||
|
affected, err := nu.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return affected
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query.
|
||||||
|
func (nu *NotifierUpdate) Exec(ctx context.Context) error {
|
||||||
|
_, err := nu.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (nu *NotifierUpdate) ExecX(ctx context.Context) {
|
||||||
|
if err := nu.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (nu *NotifierUpdate) defaults() {
|
||||||
|
if _, ok := nu.mutation.UpdatedAt(); !ok {
|
||||||
|
v := notifier.UpdateDefaultUpdatedAt()
|
||||||
|
nu.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (nu *NotifierUpdate) check() error {
|
||||||
|
if v, ok := nu.mutation.Name(); ok {
|
||||||
|
if err := notifier.NameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Notifier.name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := nu.mutation.URL(); ok {
|
||||||
|
if err := notifier.URLValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := nu.mutation.UserID(); nu.mutation.UserCleared() && !ok {
|
||||||
|
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nu *NotifierUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
|
if err := nu.check(); err != nil {
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(notifier.Table, notifier.Columns, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||||
|
if ps := nu.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := nu.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(notifier.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := nu.mutation.Name(); ok {
|
||||||
|
_spec.SetField(notifier.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := nu.mutation.URL(); ok {
|
||||||
|
_spec.SetField(notifier.FieldURL, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := nu.mutation.IsActive(); ok {
|
||||||
|
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
||||||
|
}
|
||||||
|
if nu.mutation.UserCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: notifier.UserTable,
|
||||||
|
Columns: []string{notifier.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: user.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := nu.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: notifier.UserTable,
|
||||||
|
Columns: []string{notifier.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: user.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
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, nu.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{notifier.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
nu.mutation.done = true
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotifierUpdateOne is the builder for updating a single Notifier entity.
|
||||||
|
type NotifierUpdateOne struct {
|
||||||
|
config
|
||||||
|
fields []string
|
||||||
|
hooks []Hook
|
||||||
|
mutation *NotifierMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUpdatedAt sets the "updated_at" field.
|
||||||
|
func (nuo *NotifierUpdateOne) SetUpdatedAt(t time.Time) *NotifierUpdateOne {
|
||||||
|
nuo.mutation.SetUpdatedAt(t)
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user_id" field.
|
||||||
|
func (nuo *NotifierUpdateOne) SetUserID(u uuid.UUID) *NotifierUpdateOne {
|
||||||
|
nuo.mutation.SetUserID(u)
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetName sets the "name" field.
|
||||||
|
func (nuo *NotifierUpdateOne) SetName(s string) *NotifierUpdateOne {
|
||||||
|
nuo.mutation.SetName(s)
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetURL sets the "url" field.
|
||||||
|
func (nuo *NotifierUpdateOne) SetURL(s string) *NotifierUpdateOne {
|
||||||
|
nuo.mutation.SetURL(s)
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetIsActive sets the "is_active" field.
|
||||||
|
func (nuo *NotifierUpdateOne) SetIsActive(b bool) *NotifierUpdateOne {
|
||||||
|
nuo.mutation.SetIsActive(b)
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
||||||
|
func (nuo *NotifierUpdateOne) SetNillableIsActive(b *bool) *NotifierUpdateOne {
|
||||||
|
if b != nil {
|
||||||
|
nuo.SetIsActive(*b)
|
||||||
|
}
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUser sets the "user" edge to the User entity.
|
||||||
|
func (nuo *NotifierUpdateOne) SetUser(u *User) *NotifierUpdateOne {
|
||||||
|
return nuo.SetUserID(u.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mutation returns the NotifierMutation object of the builder.
|
||||||
|
func (nuo *NotifierUpdateOne) Mutation() *NotifierMutation {
|
||||||
|
return nuo.mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClearUser clears the "user" edge to the User entity.
|
||||||
|
func (nuo *NotifierUpdateOne) ClearUser() *NotifierUpdateOne {
|
||||||
|
nuo.mutation.ClearUser()
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Where appends a list predicates to the NotifierUpdate builder.
|
||||||
|
func (nuo *NotifierUpdateOne) Where(ps ...predicate.Notifier) *NotifierUpdateOne {
|
||||||
|
nuo.mutation.Where(ps...)
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||||
|
// The default is selecting all fields defined in the entity schema.
|
||||||
|
func (nuo *NotifierUpdateOne) Select(field string, fields ...string) *NotifierUpdateOne {
|
||||||
|
nuo.fields = append([]string{field}, fields...)
|
||||||
|
return nuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save executes the query and returns the updated Notifier entity.
|
||||||
|
func (nuo *NotifierUpdateOne) Save(ctx context.Context) (*Notifier, error) {
|
||||||
|
nuo.defaults()
|
||||||
|
return withHooks[*Notifier, NotifierMutation](ctx, nuo.sqlSave, nuo.mutation, nuo.hooks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SaveX is like Save, but panics if an error occurs.
|
||||||
|
func (nuo *NotifierUpdateOne) SaveX(ctx context.Context) *Notifier {
|
||||||
|
node, err := nuo.Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exec executes the query on the entity.
|
||||||
|
func (nuo *NotifierUpdateOne) Exec(ctx context.Context) error {
|
||||||
|
_, err := nuo.Save(ctx)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExecX is like Exec, but panics if an error occurs.
|
||||||
|
func (nuo *NotifierUpdateOne) ExecX(ctx context.Context) {
|
||||||
|
if err := nuo.Exec(ctx); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// defaults sets the default values of the builder before save.
|
||||||
|
func (nuo *NotifierUpdateOne) defaults() {
|
||||||
|
if _, ok := nuo.mutation.UpdatedAt(); !ok {
|
||||||
|
v := notifier.UpdateDefaultUpdatedAt()
|
||||||
|
nuo.mutation.SetUpdatedAt(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check runs all checks and user-defined validators on the builder.
|
||||||
|
func (nuo *NotifierUpdateOne) check() error {
|
||||||
|
if v, ok := nuo.mutation.Name(); ok {
|
||||||
|
if err := notifier.NameValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Notifier.name": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := nuo.mutation.URL(); ok {
|
||||||
|
if err := notifier.URLValidator(v); err != nil {
|
||||||
|
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, ok := nuo.mutation.UserID(); nuo.mutation.UserCleared() && !ok {
|
||||||
|
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err error) {
|
||||||
|
if err := nuo.check(); err != nil {
|
||||||
|
return _node, err
|
||||||
|
}
|
||||||
|
_spec := sqlgraph.NewUpdateSpec(notifier.Table, notifier.Columns, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
||||||
|
id, ok := nuo.mutation.ID()
|
||||||
|
if !ok {
|
||||||
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Notifier.id" for update`)}
|
||||||
|
}
|
||||||
|
_spec.Node.ID.Value = id
|
||||||
|
if fields := nuo.fields; len(fields) > 0 {
|
||||||
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, notifier.FieldID)
|
||||||
|
for _, f := range fields {
|
||||||
|
if !notifier.ValidColumn(f) {
|
||||||
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||||
|
}
|
||||||
|
if f != notifier.FieldID {
|
||||||
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ps := nuo.mutation.predicates; len(ps) > 0 {
|
||||||
|
_spec.Predicate = func(selector *sql.Selector) {
|
||||||
|
for i := range ps {
|
||||||
|
ps[i](selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if value, ok := nuo.mutation.UpdatedAt(); ok {
|
||||||
|
_spec.SetField(notifier.FieldUpdatedAt, field.TypeTime, value)
|
||||||
|
}
|
||||||
|
if value, ok := nuo.mutation.Name(); ok {
|
||||||
|
_spec.SetField(notifier.FieldName, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := nuo.mutation.URL(); ok {
|
||||||
|
_spec.SetField(notifier.FieldURL, field.TypeString, value)
|
||||||
|
}
|
||||||
|
if value, ok := nuo.mutation.IsActive(); ok {
|
||||||
|
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
||||||
|
}
|
||||||
|
if nuo.mutation.UserCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: notifier.UserTable,
|
||||||
|
Columns: []string{notifier.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: user.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := nuo.mutation.UserIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.M2O,
|
||||||
|
Inverse: true,
|
||||||
|
Table: notifier.UserTable,
|
||||||
|
Columns: []string{notifier.UserColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: user.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
|
_node = &Notifier{config: nuo.config}
|
||||||
|
_spec.Assign = _node.assignValues
|
||||||
|
_spec.ScanValues = _node.scanValues
|
||||||
|
if err = sqlgraph.UpdateNode(ctx, nuo.driver, _spec); err != nil {
|
||||||
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
|
err = &NotFoundError{notifier.Label}
|
||||||
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
nuo.mutation.done = true
|
||||||
|
return _node, nil
|
||||||
|
}
|
|
@ -39,5 +39,8 @@ type Location func(*sql.Selector)
|
||||||
// MaintenanceEntry is the predicate function for maintenanceentry builders.
|
// MaintenanceEntry is the predicate function for maintenanceentry builders.
|
||||||
type MaintenanceEntry func(*sql.Selector)
|
type MaintenanceEntry func(*sql.Selector)
|
||||||
|
|
||||||
|
// Notifier is the predicate function for notifier builders.
|
||||||
|
type Notifier func(*sql.Selector)
|
||||||
|
|
||||||
// User is the predicate function for user builders.
|
// User is the predicate function for user builders.
|
||||||
type User func(*sql.Selector)
|
type User func(*sql.Selector)
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/label"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/label"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/location"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/location"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/maintenanceentry"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/schema"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
)
|
)
|
||||||
|
@ -476,6 +477,65 @@ func init() {
|
||||||
maintenanceentryDescID := maintenanceentryMixinFields0[0].Descriptor()
|
maintenanceentryDescID := maintenanceentryMixinFields0[0].Descriptor()
|
||||||
// maintenanceentry.DefaultID holds the default value on creation for the id field.
|
// maintenanceentry.DefaultID holds the default value on creation for the id field.
|
||||||
maintenanceentry.DefaultID = maintenanceentryDescID.Default.(func() uuid.UUID)
|
maintenanceentry.DefaultID = maintenanceentryDescID.Default.(func() uuid.UUID)
|
||||||
|
notifierMixin := schema.Notifier{}.Mixin()
|
||||||
|
notifierMixinFields0 := notifierMixin[0].Fields()
|
||||||
|
_ = notifierMixinFields0
|
||||||
|
notifierFields := schema.Notifier{}.Fields()
|
||||||
|
_ = notifierFields
|
||||||
|
// notifierDescCreatedAt is the schema descriptor for created_at field.
|
||||||
|
notifierDescCreatedAt := notifierMixinFields0[1].Descriptor()
|
||||||
|
// notifier.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||||
|
notifier.DefaultCreatedAt = notifierDescCreatedAt.Default.(func() time.Time)
|
||||||
|
// notifierDescUpdatedAt is the schema descriptor for updated_at field.
|
||||||
|
notifierDescUpdatedAt := notifierMixinFields0[2].Descriptor()
|
||||||
|
// notifier.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||||
|
notifier.DefaultUpdatedAt = notifierDescUpdatedAt.Default.(func() time.Time)
|
||||||
|
// notifier.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||||
|
notifier.UpdateDefaultUpdatedAt = notifierDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||||
|
// notifierDescName is the schema descriptor for name field.
|
||||||
|
notifierDescName := notifierFields[1].Descriptor()
|
||||||
|
// notifier.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||||
|
notifier.NameValidator = func() func(string) error {
|
||||||
|
validators := notifierDescName.Validators
|
||||||
|
fns := [...]func(string) error{
|
||||||
|
validators[0].(func(string) error),
|
||||||
|
validators[1].(func(string) error),
|
||||||
|
}
|
||||||
|
return func(name string) error {
|
||||||
|
for _, fn := range fns {
|
||||||
|
if err := fn(name); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
// notifierDescURL is the schema descriptor for url field.
|
||||||
|
notifierDescURL := notifierFields[2].Descriptor()
|
||||||
|
// notifier.URLValidator is a validator for the "url" field. It is called by the builders before save.
|
||||||
|
notifier.URLValidator = func() func(string) error {
|
||||||
|
validators := notifierDescURL.Validators
|
||||||
|
fns := [...]func(string) error{
|
||||||
|
validators[0].(func(string) error),
|
||||||
|
validators[1].(func(string) error),
|
||||||
|
}
|
||||||
|
return func(url string) error {
|
||||||
|
for _, fn := range fns {
|
||||||
|
if err := fn(url); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
// notifierDescIsActive is the schema descriptor for is_active field.
|
||||||
|
notifierDescIsActive := notifierFields[3].Descriptor()
|
||||||
|
// notifier.DefaultIsActive holds the default value on creation for the is_active field.
|
||||||
|
notifier.DefaultIsActive = notifierDescIsActive.Default.(bool)
|
||||||
|
// notifierDescID is the schema descriptor for id field.
|
||||||
|
notifierDescID := notifierMixinFields0[0].Descriptor()
|
||||||
|
// notifier.DefaultID holds the default value on creation for the id field.
|
||||||
|
notifier.DefaultID = notifierDescID.Default.(func() uuid.UUID)
|
||||||
userMixin := schema.User{}.Mixin()
|
userMixin := schema.User{}.Mixin()
|
||||||
userMixinFields0 := userMixin[0].Fields()
|
userMixinFields0 := userMixin[0].Fields()
|
||||||
_ = userMixinFields0
|
_ = userMixinFields0
|
||||||
|
@ -550,7 +610,7 @@ func init() {
|
||||||
// user.DefaultIsSuperuser holds the default value on creation for the is_superuser field.
|
// user.DefaultIsSuperuser holds the default value on creation for the is_superuser field.
|
||||||
user.DefaultIsSuperuser = userDescIsSuperuser.Default.(bool)
|
user.DefaultIsSuperuser = userDescIsSuperuser.Default.(bool)
|
||||||
// userDescSuperuser is the schema descriptor for superuser field.
|
// userDescSuperuser is the schema descriptor for superuser field.
|
||||||
userDescSuperuser := userFields[5].Descriptor()
|
userDescSuperuser := userFields[4].Descriptor()
|
||||||
// user.DefaultSuperuser holds the default value on creation for the superuser field.
|
// user.DefaultSuperuser holds the default value on creation for the superuser field.
|
||||||
user.DefaultSuperuser = userDescSuperuser.Default.(bool)
|
user.DefaultSuperuser = userDescSuperuser.Default.(bool)
|
||||||
// userDescID is the schema descriptor for id field.
|
// userDescID is the schema descriptor for id field.
|
||||||
|
|
|
@ -34,6 +34,8 @@ type Tx struct {
|
||||||
Location *LocationClient
|
Location *LocationClient
|
||||||
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
|
// MaintenanceEntry is the client for interacting with the MaintenanceEntry builders.
|
||||||
MaintenanceEntry *MaintenanceEntryClient
|
MaintenanceEntry *MaintenanceEntryClient
|
||||||
|
// Notifier is the client for interacting with the Notifier builders.
|
||||||
|
Notifier *NotifierClient
|
||||||
// User is the client for interacting with the User builders.
|
// User is the client for interacting with the User builders.
|
||||||
User *UserClient
|
User *UserClient
|
||||||
|
|
||||||
|
@ -178,6 +180,7 @@ func (tx *Tx) init() {
|
||||||
tx.Label = NewLabelClient(tx.config)
|
tx.Label = NewLabelClient(tx.config)
|
||||||
tx.Location = NewLocationClient(tx.config)
|
tx.Location = NewLocationClient(tx.config)
|
||||||
tx.MaintenanceEntry = NewMaintenanceEntryClient(tx.config)
|
tx.MaintenanceEntry = NewMaintenanceEntryClient(tx.config)
|
||||||
|
tx.Notifier = NewNotifierClient(tx.config)
|
||||||
tx.User = NewUserClient(tx.config)
|
tx.User = NewUserClient(tx.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,10 @@ type User struct {
|
||||||
Password string `json:"-"`
|
Password string `json:"-"`
|
||||||
// IsSuperuser holds the value of the "is_superuser" field.
|
// IsSuperuser holds the value of the "is_superuser" field.
|
||||||
IsSuperuser bool `json:"is_superuser,omitempty"`
|
IsSuperuser bool `json:"is_superuser,omitempty"`
|
||||||
// Role holds the value of the "role" field.
|
|
||||||
Role user.Role `json:"role,omitempty"`
|
|
||||||
// Superuser holds the value of the "superuser" field.
|
// Superuser holds the value of the "superuser" field.
|
||||||
Superuser bool `json:"superuser,omitempty"`
|
Superuser bool `json:"superuser,omitempty"`
|
||||||
|
// Role holds the value of the "role" field.
|
||||||
|
Role user.Role `json:"role,omitempty"`
|
||||||
// ActivatedOn holds the value of the "activated_on" field.
|
// ActivatedOn holds the value of the "activated_on" field.
|
||||||
ActivatedOn time.Time `json:"activated_on,omitempty"`
|
ActivatedOn time.Time `json:"activated_on,omitempty"`
|
||||||
// Edges holds the relations/edges for other nodes in the graph.
|
// Edges holds the relations/edges for other nodes in the graph.
|
||||||
|
@ -48,9 +48,11 @@ type UserEdges struct {
|
||||||
Group *Group `json:"group,omitempty"`
|
Group *Group `json:"group,omitempty"`
|
||||||
// AuthTokens holds the value of the auth_tokens edge.
|
// AuthTokens holds the value of the auth_tokens edge.
|
||||||
AuthTokens []*AuthTokens `json:"auth_tokens,omitempty"`
|
AuthTokens []*AuthTokens `json:"auth_tokens,omitempty"`
|
||||||
|
// Notifiers holds the value of the notifiers edge.
|
||||||
|
Notifiers []*Notifier `json:"notifiers,omitempty"`
|
||||||
// loadedTypes holds the information for reporting if a
|
// loadedTypes holds the information for reporting if a
|
||||||
// type was loaded (or requested) in eager-loading or not.
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
loadedTypes [2]bool
|
loadedTypes [3]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupOrErr returns the Group value or an error if the edge
|
// GroupOrErr returns the Group value or an error if the edge
|
||||||
|
@ -75,6 +77,15 @@ func (e UserEdges) AuthTokensOrErr() ([]*AuthTokens, error) {
|
||||||
return nil, &NotLoadedError{edge: "auth_tokens"}
|
return nil, &NotLoadedError{edge: "auth_tokens"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotifiersOrErr returns the Notifiers value or an error if the edge
|
||||||
|
// was not loaded in eager-loading.
|
||||||
|
func (e UserEdges) NotifiersOrErr() ([]*Notifier, error) {
|
||||||
|
if e.loadedTypes[2] {
|
||||||
|
return e.Notifiers, nil
|
||||||
|
}
|
||||||
|
return nil, &NotLoadedError{edge: "notifiers"}
|
||||||
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*User) scanValues(columns []string) ([]any, error) {
|
func (*User) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]any, len(columns))
|
values := make([]any, len(columns))
|
||||||
|
@ -147,18 +158,18 @@ func (u *User) assignValues(columns []string, values []any) error {
|
||||||
} else if value.Valid {
|
} else if value.Valid {
|
||||||
u.IsSuperuser = value.Bool
|
u.IsSuperuser = value.Bool
|
||||||
}
|
}
|
||||||
case user.FieldRole:
|
|
||||||
if value, ok := values[i].(*sql.NullString); !ok {
|
|
||||||
return fmt.Errorf("unexpected type %T for field role", values[i])
|
|
||||||
} else if value.Valid {
|
|
||||||
u.Role = user.Role(value.String)
|
|
||||||
}
|
|
||||||
case user.FieldSuperuser:
|
case user.FieldSuperuser:
|
||||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field superuser", values[i])
|
return fmt.Errorf("unexpected type %T for field superuser", values[i])
|
||||||
} else if value.Valid {
|
} else if value.Valid {
|
||||||
u.Superuser = value.Bool
|
u.Superuser = value.Bool
|
||||||
}
|
}
|
||||||
|
case user.FieldRole:
|
||||||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field role", values[i])
|
||||||
|
} else if value.Valid {
|
||||||
|
u.Role = user.Role(value.String)
|
||||||
|
}
|
||||||
case user.FieldActivatedOn:
|
case user.FieldActivatedOn:
|
||||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field activated_on", values[i])
|
return fmt.Errorf("unexpected type %T for field activated_on", values[i])
|
||||||
|
@ -187,6 +198,11 @@ func (u *User) QueryAuthTokens() *AuthTokensQuery {
|
||||||
return NewUserClient(u.config).QueryAuthTokens(u)
|
return NewUserClient(u.config).QueryAuthTokens(u)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryNotifiers queries the "notifiers" edge of the User entity.
|
||||||
|
func (u *User) QueryNotifiers() *NotifierQuery {
|
||||||
|
return NewUserClient(u.config).QueryNotifiers(u)
|
||||||
|
}
|
||||||
|
|
||||||
// Update returns a builder for updating this User.
|
// Update returns a builder for updating this User.
|
||||||
// Note that you need to call User.Unwrap() before calling this method if 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.
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
@ -227,12 +243,12 @@ func (u *User) String() string {
|
||||||
builder.WriteString("is_superuser=")
|
builder.WriteString("is_superuser=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", u.IsSuperuser))
|
builder.WriteString(fmt.Sprintf("%v", u.IsSuperuser))
|
||||||
builder.WriteString(", ")
|
builder.WriteString(", ")
|
||||||
builder.WriteString("role=")
|
|
||||||
builder.WriteString(fmt.Sprintf("%v", u.Role))
|
|
||||||
builder.WriteString(", ")
|
|
||||||
builder.WriteString("superuser=")
|
builder.WriteString("superuser=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", u.Superuser))
|
builder.WriteString(fmt.Sprintf("%v", u.Superuser))
|
||||||
builder.WriteString(", ")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("role=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", u.Role))
|
||||||
|
builder.WriteString(", ")
|
||||||
builder.WriteString("activated_on=")
|
builder.WriteString("activated_on=")
|
||||||
builder.WriteString(u.ActivatedOn.Format(time.ANSIC))
|
builder.WriteString(u.ActivatedOn.Format(time.ANSIC))
|
||||||
builder.WriteByte(')')
|
builder.WriteByte(')')
|
||||||
|
|
|
@ -26,16 +26,18 @@ const (
|
||||||
FieldPassword = "password"
|
FieldPassword = "password"
|
||||||
// FieldIsSuperuser holds the string denoting the is_superuser field in the database.
|
// FieldIsSuperuser holds the string denoting the is_superuser field in the database.
|
||||||
FieldIsSuperuser = "is_superuser"
|
FieldIsSuperuser = "is_superuser"
|
||||||
// FieldRole holds the string denoting the role field in the database.
|
|
||||||
FieldRole = "role"
|
|
||||||
// FieldSuperuser holds the string denoting the superuser field in the database.
|
// FieldSuperuser holds the string denoting the superuser field in the database.
|
||||||
FieldSuperuser = "superuser"
|
FieldSuperuser = "superuser"
|
||||||
|
// FieldRole holds the string denoting the role field in the database.
|
||||||
|
FieldRole = "role"
|
||||||
// FieldActivatedOn holds the string denoting the activated_on field in the database.
|
// FieldActivatedOn holds the string denoting the activated_on field in the database.
|
||||||
FieldActivatedOn = "activated_on"
|
FieldActivatedOn = "activated_on"
|
||||||
// EdgeGroup holds the string denoting the group edge name in mutations.
|
// EdgeGroup holds the string denoting the group edge name in mutations.
|
||||||
EdgeGroup = "group"
|
EdgeGroup = "group"
|
||||||
// EdgeAuthTokens holds the string denoting the auth_tokens edge name in mutations.
|
// EdgeAuthTokens holds the string denoting the auth_tokens edge name in mutations.
|
||||||
EdgeAuthTokens = "auth_tokens"
|
EdgeAuthTokens = "auth_tokens"
|
||||||
|
// EdgeNotifiers holds the string denoting the notifiers edge name in mutations.
|
||||||
|
EdgeNotifiers = "notifiers"
|
||||||
// Table holds the table name of the user in the database.
|
// Table holds the table name of the user in the database.
|
||||||
Table = "users"
|
Table = "users"
|
||||||
// GroupTable is the table that holds the group relation/edge.
|
// GroupTable is the table that holds the group relation/edge.
|
||||||
|
@ -52,6 +54,13 @@ const (
|
||||||
AuthTokensInverseTable = "auth_tokens"
|
AuthTokensInverseTable = "auth_tokens"
|
||||||
// AuthTokensColumn is the table column denoting the auth_tokens relation/edge.
|
// AuthTokensColumn is the table column denoting the auth_tokens relation/edge.
|
||||||
AuthTokensColumn = "user_auth_tokens"
|
AuthTokensColumn = "user_auth_tokens"
|
||||||
|
// NotifiersTable is the table that holds the notifiers relation/edge.
|
||||||
|
NotifiersTable = "notifiers"
|
||||||
|
// NotifiersInverseTable is the table name for the Notifier entity.
|
||||||
|
// It exists in this package in order to avoid circular dependency with the "notifier" package.
|
||||||
|
NotifiersInverseTable = "notifiers"
|
||||||
|
// NotifiersColumn is the table column denoting the notifiers relation/edge.
|
||||||
|
NotifiersColumn = "user_id"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for user fields.
|
// Columns holds all SQL columns for user fields.
|
||||||
|
@ -63,8 +72,8 @@ var Columns = []string{
|
||||||
FieldEmail,
|
FieldEmail,
|
||||||
FieldPassword,
|
FieldPassword,
|
||||||
FieldIsSuperuser,
|
FieldIsSuperuser,
|
||||||
FieldRole,
|
|
||||||
FieldSuperuser,
|
FieldSuperuser,
|
||||||
|
FieldRole,
|
||||||
FieldActivatedOn,
|
FieldActivatedOn,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,6 +381,16 @@ func IsSuperuserNEQ(v bool) predicate.User {
|
||||||
return predicate.User(sql.FieldNEQ(FieldIsSuperuser, v))
|
return predicate.User(sql.FieldNEQ(FieldIsSuperuser, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SuperuserEQ applies the EQ predicate on the "superuser" field.
|
||||||
|
func SuperuserEQ(v bool) predicate.User {
|
||||||
|
return predicate.User(sql.FieldEQ(FieldSuperuser, v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SuperuserNEQ applies the NEQ predicate on the "superuser" field.
|
||||||
|
func SuperuserNEQ(v bool) predicate.User {
|
||||||
|
return predicate.User(sql.FieldNEQ(FieldSuperuser, v))
|
||||||
|
}
|
||||||
|
|
||||||
// RoleEQ applies the EQ predicate on the "role" field.
|
// RoleEQ applies the EQ predicate on the "role" field.
|
||||||
func RoleEQ(v Role) predicate.User {
|
func RoleEQ(v Role) predicate.User {
|
||||||
return predicate.User(sql.FieldEQ(FieldRole, v))
|
return predicate.User(sql.FieldEQ(FieldRole, v))
|
||||||
|
@ -401,16 +411,6 @@ func RoleNotIn(vs ...Role) predicate.User {
|
||||||
return predicate.User(sql.FieldNotIn(FieldRole, vs...))
|
return predicate.User(sql.FieldNotIn(FieldRole, vs...))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SuperuserEQ applies the EQ predicate on the "superuser" field.
|
|
||||||
func SuperuserEQ(v bool) predicate.User {
|
|
||||||
return predicate.User(sql.FieldEQ(FieldSuperuser, v))
|
|
||||||
}
|
|
||||||
|
|
||||||
// SuperuserNEQ applies the NEQ predicate on the "superuser" field.
|
|
||||||
func SuperuserNEQ(v bool) predicate.User {
|
|
||||||
return predicate.User(sql.FieldNEQ(FieldSuperuser, v))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ActivatedOnEQ applies the EQ predicate on the "activated_on" field.
|
// ActivatedOnEQ applies the EQ predicate on the "activated_on" field.
|
||||||
func ActivatedOnEQ(v time.Time) predicate.User {
|
func ActivatedOnEQ(v time.Time) predicate.User {
|
||||||
return predicate.User(sql.FieldEQ(FieldActivatedOn, v))
|
return predicate.User(sql.FieldEQ(FieldActivatedOn, v))
|
||||||
|
@ -515,6 +515,33 @@ func HasAuthTokensWith(preds ...predicate.AuthTokens) predicate.User {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HasNotifiers applies the HasEdge predicate on the "notifiers" edge.
|
||||||
|
func HasNotifiers() predicate.User {
|
||||||
|
return predicate.User(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, NotifiersTable, NotifiersColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighbors(s, step)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasNotifiersWith applies the HasEdge predicate on the "notifiers" edge with a given conditions (other predicates).
|
||||||
|
func HasNotifiersWith(preds ...predicate.Notifier) predicate.User {
|
||||||
|
return predicate.User(func(s *sql.Selector) {
|
||||||
|
step := sqlgraph.NewStep(
|
||||||
|
sqlgraph.From(Table, FieldID),
|
||||||
|
sqlgraph.To(NotifiersInverseTable, FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, NotifiersTable, NotifiersColumn),
|
||||||
|
)
|
||||||
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
|
for _, p := range preds {
|
||||||
|
p(s)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// And groups predicates with the AND operator between them.
|
// And groups predicates with the AND operator between them.
|
||||||
func And(predicates ...predicate.User) predicate.User {
|
func And(predicates ...predicate.User) predicate.User {
|
||||||
return predicate.User(func(s *sql.Selector) {
|
return predicate.User(func(s *sql.Selector) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/authtokens"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/authtokens"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,20 +84,6 @@ func (uc *UserCreate) SetNillableIsSuperuser(b *bool) *UserCreate {
|
||||||
return uc
|
return uc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRole sets the "role" field.
|
|
||||||
func (uc *UserCreate) SetRole(u user.Role) *UserCreate {
|
|
||||||
uc.mutation.SetRole(u)
|
|
||||||
return uc
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
||||||
func (uc *UserCreate) SetNillableRole(u *user.Role) *UserCreate {
|
|
||||||
if u != nil {
|
|
||||||
uc.SetRole(*u)
|
|
||||||
}
|
|
||||||
return uc
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetSuperuser sets the "superuser" field.
|
// SetSuperuser sets the "superuser" field.
|
||||||
func (uc *UserCreate) SetSuperuser(b bool) *UserCreate {
|
func (uc *UserCreate) SetSuperuser(b bool) *UserCreate {
|
||||||
uc.mutation.SetSuperuser(b)
|
uc.mutation.SetSuperuser(b)
|
||||||
|
@ -111,6 +98,20 @@ func (uc *UserCreate) SetNillableSuperuser(b *bool) *UserCreate {
|
||||||
return uc
|
return uc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRole sets the "role" field.
|
||||||
|
func (uc *UserCreate) SetRole(u user.Role) *UserCreate {
|
||||||
|
uc.mutation.SetRole(u)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||||
|
func (uc *UserCreate) SetNillableRole(u *user.Role) *UserCreate {
|
||||||
|
if u != nil {
|
||||||
|
uc.SetRole(*u)
|
||||||
|
}
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
// SetActivatedOn sets the "activated_on" field.
|
// SetActivatedOn sets the "activated_on" field.
|
||||||
func (uc *UserCreate) SetActivatedOn(t time.Time) *UserCreate {
|
func (uc *UserCreate) SetActivatedOn(t time.Time) *UserCreate {
|
||||||
uc.mutation.SetActivatedOn(t)
|
uc.mutation.SetActivatedOn(t)
|
||||||
|
@ -165,6 +166,21 @@ func (uc *UserCreate) AddAuthTokens(a ...*AuthTokens) *UserCreate {
|
||||||
return uc.AddAuthTokenIDs(ids...)
|
return uc.AddAuthTokenIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddNotifierIDs adds the "notifiers" edge to the Notifier entity by IDs.
|
||||||
|
func (uc *UserCreate) AddNotifierIDs(ids ...uuid.UUID) *UserCreate {
|
||||||
|
uc.mutation.AddNotifierIDs(ids...)
|
||||||
|
return uc
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddNotifiers adds the "notifiers" edges to the Notifier entity.
|
||||||
|
func (uc *UserCreate) AddNotifiers(n ...*Notifier) *UserCreate {
|
||||||
|
ids := make([]uuid.UUID, len(n))
|
||||||
|
for i := range n {
|
||||||
|
ids[i] = n[i].ID
|
||||||
|
}
|
||||||
|
return uc.AddNotifierIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the UserMutation object of the builder.
|
// Mutation returns the UserMutation object of the builder.
|
||||||
func (uc *UserCreate) Mutation() *UserMutation {
|
func (uc *UserCreate) Mutation() *UserMutation {
|
||||||
return uc.mutation
|
return uc.mutation
|
||||||
|
@ -212,14 +228,14 @@ func (uc *UserCreate) defaults() {
|
||||||
v := user.DefaultIsSuperuser
|
v := user.DefaultIsSuperuser
|
||||||
uc.mutation.SetIsSuperuser(v)
|
uc.mutation.SetIsSuperuser(v)
|
||||||
}
|
}
|
||||||
if _, ok := uc.mutation.Role(); !ok {
|
|
||||||
v := user.DefaultRole
|
|
||||||
uc.mutation.SetRole(v)
|
|
||||||
}
|
|
||||||
if _, ok := uc.mutation.Superuser(); !ok {
|
if _, ok := uc.mutation.Superuser(); !ok {
|
||||||
v := user.DefaultSuperuser
|
v := user.DefaultSuperuser
|
||||||
uc.mutation.SetSuperuser(v)
|
uc.mutation.SetSuperuser(v)
|
||||||
}
|
}
|
||||||
|
if _, ok := uc.mutation.Role(); !ok {
|
||||||
|
v := user.DefaultRole
|
||||||
|
uc.mutation.SetRole(v)
|
||||||
|
}
|
||||||
if _, ok := uc.mutation.ID(); !ok {
|
if _, ok := uc.mutation.ID(); !ok {
|
||||||
v := user.DefaultID()
|
v := user.DefaultID()
|
||||||
uc.mutation.SetID(v)
|
uc.mutation.SetID(v)
|
||||||
|
@ -261,6 +277,9 @@ func (uc *UserCreate) check() error {
|
||||||
if _, ok := uc.mutation.IsSuperuser(); !ok {
|
if _, ok := uc.mutation.IsSuperuser(); !ok {
|
||||||
return &ValidationError{Name: "is_superuser", err: errors.New(`ent: missing required field "User.is_superuser"`)}
|
return &ValidationError{Name: "is_superuser", err: errors.New(`ent: missing required field "User.is_superuser"`)}
|
||||||
}
|
}
|
||||||
|
if _, ok := uc.mutation.Superuser(); !ok {
|
||||||
|
return &ValidationError{Name: "superuser", err: errors.New(`ent: missing required field "User.superuser"`)}
|
||||||
|
}
|
||||||
if _, ok := uc.mutation.Role(); !ok {
|
if _, ok := uc.mutation.Role(); !ok {
|
||||||
return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "User.role"`)}
|
return &ValidationError{Name: "role", err: errors.New(`ent: missing required field "User.role"`)}
|
||||||
}
|
}
|
||||||
|
@ -269,9 +288,6 @@ func (uc *UserCreate) check() error {
|
||||||
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
|
return &ValidationError{Name: "role", err: fmt.Errorf(`ent: validator failed for field "User.role": %w`, err)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := uc.mutation.Superuser(); !ok {
|
|
||||||
return &ValidationError{Name: "superuser", err: errors.New(`ent: missing required field "User.superuser"`)}
|
|
||||||
}
|
|
||||||
if _, ok := uc.mutation.GroupID(); !ok {
|
if _, ok := uc.mutation.GroupID(); !ok {
|
||||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "User.group"`)}
|
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "User.group"`)}
|
||||||
}
|
}
|
||||||
|
@ -334,14 +350,14 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||||
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
||||||
_node.IsSuperuser = value
|
_node.IsSuperuser = value
|
||||||
}
|
}
|
||||||
if value, ok := uc.mutation.Role(); ok {
|
|
||||||
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
|
||||||
_node.Role = value
|
|
||||||
}
|
|
||||||
if value, ok := uc.mutation.Superuser(); ok {
|
if value, ok := uc.mutation.Superuser(); ok {
|
||||||
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
||||||
_node.Superuser = value
|
_node.Superuser = value
|
||||||
}
|
}
|
||||||
|
if value, ok := uc.mutation.Role(); ok {
|
||||||
|
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
||||||
|
_node.Role = value
|
||||||
|
}
|
||||||
if value, ok := uc.mutation.ActivatedOn(); ok {
|
if value, ok := uc.mutation.ActivatedOn(); ok {
|
||||||
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
||||||
_node.ActivatedOn = value
|
_node.ActivatedOn = value
|
||||||
|
@ -385,6 +401,25 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||||
}
|
}
|
||||||
_spec.Edges = append(_spec.Edges, edge)
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
}
|
}
|
||||||
|
if nodes := uc.mutation.NotifiersIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.NotifiersTable,
|
||||||
|
Columns: []string{user.NotifiersColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: notifier.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
|
}
|
||||||
return _node, _spec
|
return _node, _spec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/authtokens"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/authtokens"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
)
|
)
|
||||||
|
@ -27,6 +28,7 @@ type UserQuery struct {
|
||||||
predicates []predicate.User
|
predicates []predicate.User
|
||||||
withGroup *GroupQuery
|
withGroup *GroupQuery
|
||||||
withAuthTokens *AuthTokensQuery
|
withAuthTokens *AuthTokensQuery
|
||||||
|
withNotifiers *NotifierQuery
|
||||||
withFKs bool
|
withFKs bool
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
|
@ -108,6 +110,28 @@ func (uq *UserQuery) QueryAuthTokens() *AuthTokensQuery {
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// QueryNotifiers chains the current query on the "notifiers" edge.
|
||||||
|
func (uq *UserQuery) QueryNotifiers() *NotifierQuery {
|
||||||
|
query := (&NotifierClient{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(notifier.Table, notifier.FieldID),
|
||||||
|
sqlgraph.Edge(sqlgraph.O2M, false, user.NotifiersTable, user.NotifiersColumn),
|
||||||
|
)
|
||||||
|
fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step)
|
||||||
|
return fromU, nil
|
||||||
|
}
|
||||||
|
return query
|
||||||
|
}
|
||||||
|
|
||||||
// First returns the first User entity from the query.
|
// First returns the first User entity from the query.
|
||||||
// Returns a *NotFoundError when no User was found.
|
// Returns a *NotFoundError when no User was found.
|
||||||
func (uq *UserQuery) First(ctx context.Context) (*User, error) {
|
func (uq *UserQuery) First(ctx context.Context) (*User, error) {
|
||||||
|
@ -302,6 +326,7 @@ func (uq *UserQuery) Clone() *UserQuery {
|
||||||
predicates: append([]predicate.User{}, uq.predicates...),
|
predicates: append([]predicate.User{}, uq.predicates...),
|
||||||
withGroup: uq.withGroup.Clone(),
|
withGroup: uq.withGroup.Clone(),
|
||||||
withAuthTokens: uq.withAuthTokens.Clone(),
|
withAuthTokens: uq.withAuthTokens.Clone(),
|
||||||
|
withNotifiers: uq.withNotifiers.Clone(),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: uq.sql.Clone(),
|
sql: uq.sql.Clone(),
|
||||||
path: uq.path,
|
path: uq.path,
|
||||||
|
@ -330,6 +355,17 @@ func (uq *UserQuery) WithAuthTokens(opts ...func(*AuthTokensQuery)) *UserQuery {
|
||||||
return uq
|
return uq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithNotifiers tells the query-builder to eager-load the nodes that are connected to
|
||||||
|
// the "notifiers" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
|
func (uq *UserQuery) WithNotifiers(opts ...func(*NotifierQuery)) *UserQuery {
|
||||||
|
query := (&NotifierClient{config: uq.config}).Query()
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(query)
|
||||||
|
}
|
||||||
|
uq.withNotifiers = query
|
||||||
|
return uq
|
||||||
|
}
|
||||||
|
|
||||||
// GroupBy is used to group vertices by one or more fields/columns.
|
// 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.
|
// It is often used with aggregate functions, like: count, max, mean, min, sum.
|
||||||
//
|
//
|
||||||
|
@ -409,9 +445,10 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||||
nodes = []*User{}
|
nodes = []*User{}
|
||||||
withFKs = uq.withFKs
|
withFKs = uq.withFKs
|
||||||
_spec = uq.querySpec()
|
_spec = uq.querySpec()
|
||||||
loadedTypes = [2]bool{
|
loadedTypes = [3]bool{
|
||||||
uq.withGroup != nil,
|
uq.withGroup != nil,
|
||||||
uq.withAuthTokens != nil,
|
uq.withAuthTokens != nil,
|
||||||
|
uq.withNotifiers != nil,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if uq.withGroup != nil {
|
if uq.withGroup != nil {
|
||||||
|
@ -451,6 +488,13 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if query := uq.withNotifiers; query != nil {
|
||||||
|
if err := uq.loadNotifiers(ctx, query, nodes,
|
||||||
|
func(n *User) { n.Edges.Notifiers = []*Notifier{} },
|
||||||
|
func(n *User, e *Notifier) { n.Edges.Notifiers = append(n.Edges.Notifiers, e) }); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,6 +561,33 @@ func (uq *UserQuery) loadAuthTokens(ctx context.Context, query *AuthTokensQuery,
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (uq *UserQuery) loadNotifiers(ctx context.Context, query *NotifierQuery, nodes []*User, init func(*User), assign func(*User, *Notifier)) error {
|
||||||
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
|
nodeids := make(map[uuid.UUID]*User)
|
||||||
|
for i := range nodes {
|
||||||
|
fks = append(fks, nodes[i].ID)
|
||||||
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
if init != nil {
|
||||||
|
init(nodes[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.Where(predicate.Notifier(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(user.NotifiersColumn, fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.UserID
|
||||||
|
node, ok := nodeids[fk]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected 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) {
|
func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := uq.querySpec()
|
_spec := uq.querySpec()
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/authtokens"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/authtokens"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
|
||||||
|
"github.com/hay-kot/homebox/backend/internal/data/ent/notifier"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/user"
|
||||||
)
|
)
|
||||||
|
@ -69,20 +70,6 @@ func (uu *UserUpdate) SetNillableIsSuperuser(b *bool) *UserUpdate {
|
||||||
return uu
|
return uu
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRole sets the "role" field.
|
|
||||||
func (uu *UserUpdate) SetRole(u user.Role) *UserUpdate {
|
|
||||||
uu.mutation.SetRole(u)
|
|
||||||
return uu
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
||||||
func (uu *UserUpdate) SetNillableRole(u *user.Role) *UserUpdate {
|
|
||||||
if u != nil {
|
|
||||||
uu.SetRole(*u)
|
|
||||||
}
|
|
||||||
return uu
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetSuperuser sets the "superuser" field.
|
// SetSuperuser sets the "superuser" field.
|
||||||
func (uu *UserUpdate) SetSuperuser(b bool) *UserUpdate {
|
func (uu *UserUpdate) SetSuperuser(b bool) *UserUpdate {
|
||||||
uu.mutation.SetSuperuser(b)
|
uu.mutation.SetSuperuser(b)
|
||||||
|
@ -97,6 +84,20 @@ func (uu *UserUpdate) SetNillableSuperuser(b *bool) *UserUpdate {
|
||||||
return uu
|
return uu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRole sets the "role" field.
|
||||||
|
func (uu *UserUpdate) SetRole(u user.Role) *UserUpdate {
|
||||||
|
uu.mutation.SetRole(u)
|
||||||
|
return uu
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||||
|
func (uu *UserUpdate) SetNillableRole(u *user.Role) *UserUpdate {
|
||||||
|
if u != nil {
|
||||||
|
uu.SetRole(*u)
|
||||||
|
}
|
||||||
|
return uu
|
||||||
|
}
|
||||||
|
|
||||||
// SetActivatedOn sets the "activated_on" field.
|
// SetActivatedOn sets the "activated_on" field.
|
||||||
func (uu *UserUpdate) SetActivatedOn(t time.Time) *UserUpdate {
|
func (uu *UserUpdate) SetActivatedOn(t time.Time) *UserUpdate {
|
||||||
uu.mutation.SetActivatedOn(t)
|
uu.mutation.SetActivatedOn(t)
|
||||||
|
@ -143,6 +144,21 @@ func (uu *UserUpdate) AddAuthTokens(a ...*AuthTokens) *UserUpdate {
|
||||||
return uu.AddAuthTokenIDs(ids...)
|
return uu.AddAuthTokenIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddNotifierIDs adds the "notifiers" edge to the Notifier entity by IDs.
|
||||||
|
func (uu *UserUpdate) AddNotifierIDs(ids ...uuid.UUID) *UserUpdate {
|
||||||
|
uu.mutation.AddNotifierIDs(ids...)
|
||||||
|
return uu
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddNotifiers adds the "notifiers" edges to the Notifier entity.
|
||||||
|
func (uu *UserUpdate) AddNotifiers(n ...*Notifier) *UserUpdate {
|
||||||
|
ids := make([]uuid.UUID, len(n))
|
||||||
|
for i := range n {
|
||||||
|
ids[i] = n[i].ID
|
||||||
|
}
|
||||||
|
return uu.AddNotifierIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the UserMutation object of the builder.
|
// Mutation returns the UserMutation object of the builder.
|
||||||
func (uu *UserUpdate) Mutation() *UserMutation {
|
func (uu *UserUpdate) Mutation() *UserMutation {
|
||||||
return uu.mutation
|
return uu.mutation
|
||||||
|
@ -175,6 +191,27 @@ func (uu *UserUpdate) RemoveAuthTokens(a ...*AuthTokens) *UserUpdate {
|
||||||
return uu.RemoveAuthTokenIDs(ids...)
|
return uu.RemoveAuthTokenIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearNotifiers clears all "notifiers" edges to the Notifier entity.
|
||||||
|
func (uu *UserUpdate) ClearNotifiers() *UserUpdate {
|
||||||
|
uu.mutation.ClearNotifiers()
|
||||||
|
return uu
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveNotifierIDs removes the "notifiers" edge to Notifier entities by IDs.
|
||||||
|
func (uu *UserUpdate) RemoveNotifierIDs(ids ...uuid.UUID) *UserUpdate {
|
||||||
|
uu.mutation.RemoveNotifierIDs(ids...)
|
||||||
|
return uu
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveNotifiers removes "notifiers" edges to Notifier entities.
|
||||||
|
func (uu *UserUpdate) RemoveNotifiers(n ...*Notifier) *UserUpdate {
|
||||||
|
ids := make([]uuid.UUID, len(n))
|
||||||
|
for i := range n {
|
||||||
|
ids[i] = n[i].ID
|
||||||
|
}
|
||||||
|
return uu.RemoveNotifierIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
func (uu *UserUpdate) Save(ctx context.Context) (int, error) {
|
func (uu *UserUpdate) Save(ctx context.Context) (int, error) {
|
||||||
uu.defaults()
|
uu.defaults()
|
||||||
|
@ -266,12 +303,12 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
if value, ok := uu.mutation.IsSuperuser(); ok {
|
if value, ok := uu.mutation.IsSuperuser(); ok {
|
||||||
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
||||||
}
|
}
|
||||||
if value, ok := uu.mutation.Role(); ok {
|
|
||||||
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
|
||||||
}
|
|
||||||
if value, ok := uu.mutation.Superuser(); ok {
|
if value, ok := uu.mutation.Superuser(); ok {
|
||||||
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
||||||
}
|
}
|
||||||
|
if value, ok := uu.mutation.Role(); ok {
|
||||||
|
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
||||||
|
}
|
||||||
if value, ok := uu.mutation.ActivatedOn(); ok {
|
if value, ok := uu.mutation.ActivatedOn(); ok {
|
||||||
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
||||||
}
|
}
|
||||||
|
@ -367,6 +404,60 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
}
|
}
|
||||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
}
|
}
|
||||||
|
if uu.mutation.NotifiersCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.NotifiersTable,
|
||||||
|
Columns: []string{user.NotifiersColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: notifier.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := uu.mutation.RemovedNotifiersIDs(); len(nodes) > 0 && !uu.mutation.NotifiersCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.NotifiersTable,
|
||||||
|
Columns: []string{user.NotifiersColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: notifier.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := uu.mutation.NotifiersIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.NotifiersTable,
|
||||||
|
Columns: []string{user.NotifiersColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: notifier.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
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, uu.driver, _spec); err != nil {
|
if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{user.Label}
|
err = &NotFoundError{user.Label}
|
||||||
|
@ -425,20 +516,6 @@ func (uuo *UserUpdateOne) SetNillableIsSuperuser(b *bool) *UserUpdateOne {
|
||||||
return uuo
|
return uuo
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRole sets the "role" field.
|
|
||||||
func (uuo *UserUpdateOne) SetRole(u user.Role) *UserUpdateOne {
|
|
||||||
uuo.mutation.SetRole(u)
|
|
||||||
return uuo
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetNillableRole sets the "role" field if the given value is not nil.
|
|
||||||
func (uuo *UserUpdateOne) SetNillableRole(u *user.Role) *UserUpdateOne {
|
|
||||||
if u != nil {
|
|
||||||
uuo.SetRole(*u)
|
|
||||||
}
|
|
||||||
return uuo
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetSuperuser sets the "superuser" field.
|
// SetSuperuser sets the "superuser" field.
|
||||||
func (uuo *UserUpdateOne) SetSuperuser(b bool) *UserUpdateOne {
|
func (uuo *UserUpdateOne) SetSuperuser(b bool) *UserUpdateOne {
|
||||||
uuo.mutation.SetSuperuser(b)
|
uuo.mutation.SetSuperuser(b)
|
||||||
|
@ -453,6 +530,20 @@ func (uuo *UserUpdateOne) SetNillableSuperuser(b *bool) *UserUpdateOne {
|
||||||
return uuo
|
return uuo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetRole sets the "role" field.
|
||||||
|
func (uuo *UserUpdateOne) SetRole(u user.Role) *UserUpdateOne {
|
||||||
|
uuo.mutation.SetRole(u)
|
||||||
|
return uuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetNillableRole sets the "role" field if the given value is not nil.
|
||||||
|
func (uuo *UserUpdateOne) SetNillableRole(u *user.Role) *UserUpdateOne {
|
||||||
|
if u != nil {
|
||||||
|
uuo.SetRole(*u)
|
||||||
|
}
|
||||||
|
return uuo
|
||||||
|
}
|
||||||
|
|
||||||
// SetActivatedOn sets the "activated_on" field.
|
// SetActivatedOn sets the "activated_on" field.
|
||||||
func (uuo *UserUpdateOne) SetActivatedOn(t time.Time) *UserUpdateOne {
|
func (uuo *UserUpdateOne) SetActivatedOn(t time.Time) *UserUpdateOne {
|
||||||
uuo.mutation.SetActivatedOn(t)
|
uuo.mutation.SetActivatedOn(t)
|
||||||
|
@ -499,6 +590,21 @@ func (uuo *UserUpdateOne) AddAuthTokens(a ...*AuthTokens) *UserUpdateOne {
|
||||||
return uuo.AddAuthTokenIDs(ids...)
|
return uuo.AddAuthTokenIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddNotifierIDs adds the "notifiers" edge to the Notifier entity by IDs.
|
||||||
|
func (uuo *UserUpdateOne) AddNotifierIDs(ids ...uuid.UUID) *UserUpdateOne {
|
||||||
|
uuo.mutation.AddNotifierIDs(ids...)
|
||||||
|
return uuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddNotifiers adds the "notifiers" edges to the Notifier entity.
|
||||||
|
func (uuo *UserUpdateOne) AddNotifiers(n ...*Notifier) *UserUpdateOne {
|
||||||
|
ids := make([]uuid.UUID, len(n))
|
||||||
|
for i := range n {
|
||||||
|
ids[i] = n[i].ID
|
||||||
|
}
|
||||||
|
return uuo.AddNotifierIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Mutation returns the UserMutation object of the builder.
|
// Mutation returns the UserMutation object of the builder.
|
||||||
func (uuo *UserUpdateOne) Mutation() *UserMutation {
|
func (uuo *UserUpdateOne) Mutation() *UserMutation {
|
||||||
return uuo.mutation
|
return uuo.mutation
|
||||||
|
@ -531,6 +637,27 @@ func (uuo *UserUpdateOne) RemoveAuthTokens(a ...*AuthTokens) *UserUpdateOne {
|
||||||
return uuo.RemoveAuthTokenIDs(ids...)
|
return uuo.RemoveAuthTokenIDs(ids...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearNotifiers clears all "notifiers" edges to the Notifier entity.
|
||||||
|
func (uuo *UserUpdateOne) ClearNotifiers() *UserUpdateOne {
|
||||||
|
uuo.mutation.ClearNotifiers()
|
||||||
|
return uuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveNotifierIDs removes the "notifiers" edge to Notifier entities by IDs.
|
||||||
|
func (uuo *UserUpdateOne) RemoveNotifierIDs(ids ...uuid.UUID) *UserUpdateOne {
|
||||||
|
uuo.mutation.RemoveNotifierIDs(ids...)
|
||||||
|
return uuo
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveNotifiers removes "notifiers" edges to Notifier entities.
|
||||||
|
func (uuo *UserUpdateOne) RemoveNotifiers(n ...*Notifier) *UserUpdateOne {
|
||||||
|
ids := make([]uuid.UUID, len(n))
|
||||||
|
for i := range n {
|
||||||
|
ids[i] = n[i].ID
|
||||||
|
}
|
||||||
|
return uuo.RemoveNotifierIDs(ids...)
|
||||||
|
}
|
||||||
|
|
||||||
// Where appends a list predicates to the UserUpdate builder.
|
// Where appends a list predicates to the UserUpdate builder.
|
||||||
func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
|
func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne {
|
||||||
uuo.mutation.Where(ps...)
|
uuo.mutation.Where(ps...)
|
||||||
|
@ -652,12 +779,12 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
|
||||||
if value, ok := uuo.mutation.IsSuperuser(); ok {
|
if value, ok := uuo.mutation.IsSuperuser(); ok {
|
||||||
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
_spec.SetField(user.FieldIsSuperuser, field.TypeBool, value)
|
||||||
}
|
}
|
||||||
if value, ok := uuo.mutation.Role(); ok {
|
|
||||||
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
|
||||||
}
|
|
||||||
if value, ok := uuo.mutation.Superuser(); ok {
|
if value, ok := uuo.mutation.Superuser(); ok {
|
||||||
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
_spec.SetField(user.FieldSuperuser, field.TypeBool, value)
|
||||||
}
|
}
|
||||||
|
if value, ok := uuo.mutation.Role(); ok {
|
||||||
|
_spec.SetField(user.FieldRole, field.TypeEnum, value)
|
||||||
|
}
|
||||||
if value, ok := uuo.mutation.ActivatedOn(); ok {
|
if value, ok := uuo.mutation.ActivatedOn(); ok {
|
||||||
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
_spec.SetField(user.FieldActivatedOn, field.TypeTime, value)
|
||||||
}
|
}
|
||||||
|
@ -753,6 +880,60 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error)
|
||||||
}
|
}
|
||||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
}
|
}
|
||||||
|
if uuo.mutation.NotifiersCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.NotifiersTable,
|
||||||
|
Columns: []string{user.NotifiersColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: notifier.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := uuo.mutation.RemovedNotifiersIDs(); len(nodes) > 0 && !uuo.mutation.NotifiersCleared() {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.NotifiersTable,
|
||||||
|
Columns: []string{user.NotifiersColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: notifier.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
|
}
|
||||||
|
if nodes := uuo.mutation.NotifiersIDs(); len(nodes) > 0 {
|
||||||
|
edge := &sqlgraph.EdgeSpec{
|
||||||
|
Rel: sqlgraph.O2M,
|
||||||
|
Inverse: false,
|
||||||
|
Table: user.NotifiersTable,
|
||||||
|
Columns: []string{user.NotifiersColumn},
|
||||||
|
Bidi: false,
|
||||||
|
Target: &sqlgraph.EdgeTarget{
|
||||||
|
IDSpec: &sqlgraph.FieldSpec{
|
||||||
|
Type: field.TypeUUID,
|
||||||
|
Column: notifier.FieldID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, k := range nodes {
|
||||||
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||||
|
}
|
||||||
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
|
}
|
||||||
_node = &User{config: uuo.config}
|
_node = &User{config: uuo.config}
|
||||||
_spec.Assign = _node.assignValues
|
_spec.Assign = _node.assignValues
|
||||||
_spec.ScanValues = _node.scanValues
|
_spec.ScanValues = _node.scanValues
|
||||||
|
|
Loading…
Reference in a new issue