forked from mirrors/homebox
refactor schema edges
This commit is contained in:
parent
ccd40ffcac
commit
883468e04c
12 changed files with 499 additions and 460 deletions
|
@ -2147,22 +2147,6 @@ func (c *NotifierClient) GetX(ctx context.Context, id uuid.UUID) *Notifier {
|
||||||
return obj
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryGroup queries the group edge of a Notifier.
|
// QueryGroup queries the group edge of a Notifier.
|
||||||
func (c *NotifierClient) QueryGroup(n *Notifier) *GroupQuery {
|
func (c *NotifierClient) QueryGroup(n *Notifier) *GroupQuery {
|
||||||
query := (&GroupClient{config: c.config}).Query()
|
query := (&GroupClient{config: c.config}).Query()
|
||||||
|
@ -2179,6 +2163,22 @@ func (c *NotifierClient) QueryGroup(n *Notifier) *GroupQuery {
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// Hooks returns the client hooks.
|
||||||
func (c *NotifierClient) Hooks() []Hook {
|
func (c *NotifierClient) Hooks() []Hook {
|
||||||
return c.hooks.Notifier
|
return c.hooks.Notifier
|
||||||
|
|
|
@ -9871,10 +9871,10 @@ type NotifierMutation struct {
|
||||||
url *string
|
url *string
|
||||||
is_active *bool
|
is_active *bool
|
||||||
clearedFields map[string]struct{}
|
clearedFields map[string]struct{}
|
||||||
user *uuid.UUID
|
|
||||||
cleareduser bool
|
|
||||||
group *uuid.UUID
|
group *uuid.UUID
|
||||||
clearedgroup bool
|
clearedgroup bool
|
||||||
|
user *uuid.UUID
|
||||||
|
cleareduser bool
|
||||||
done bool
|
done bool
|
||||||
oldValue func(context.Context) (*Notifier, error)
|
oldValue func(context.Context) (*Notifier, error)
|
||||||
predicates []predicate.Notifier
|
predicates []predicate.Notifier
|
||||||
|
@ -10056,42 +10056,6 @@ func (m *NotifierMutation) ResetUpdatedAt() {
|
||||||
m.updated_at = nil
|
m.updated_at = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUserID sets the "user_id" field.
|
|
||||||
func (m *NotifierMutation) SetUserID(u uuid.UUID) {
|
|
||||||
m.user = &u
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserID returns the value of the "user_id" field in the mutation.
|
|
||||||
func (m *NotifierMutation) UserID() (r uuid.UUID, exists bool) {
|
|
||||||
v := m.user
|
|
||||||
if v == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return *v, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// OldUserID returns the old "user_id" field's value of the Notifier entity.
|
|
||||||
// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
|
|
||||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
||||||
func (m *NotifierMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
|
|
||||||
if !m.op.Is(OpUpdateOne) {
|
|
||||||
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
|
|
||||||
}
|
|
||||||
if m.id == nil || m.oldValue == nil {
|
|
||||||
return v, errors.New("OldUserID requires an ID field in the mutation")
|
|
||||||
}
|
|
||||||
oldValue, err := m.oldValue(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
|
|
||||||
}
|
|
||||||
return oldValue.UserID, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetUserID resets all changes to the "user_id" field.
|
|
||||||
func (m *NotifierMutation) ResetUserID() {
|
|
||||||
m.user = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGroupID sets the "group_id" field.
|
// SetGroupID sets the "group_id" field.
|
||||||
func (m *NotifierMutation) SetGroupID(u uuid.UUID) {
|
func (m *NotifierMutation) SetGroupID(u uuid.UUID) {
|
||||||
m.group = &u
|
m.group = &u
|
||||||
|
@ -10128,6 +10092,42 @@ func (m *NotifierMutation) ResetGroupID() {
|
||||||
m.group = nil
|
m.group = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetUserID sets the "user_id" field.
|
||||||
|
func (m *NotifierMutation) SetUserID(u uuid.UUID) {
|
||||||
|
m.user = &u
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserID returns the value of the "user_id" field in the mutation.
|
||||||
|
func (m *NotifierMutation) UserID() (r uuid.UUID, exists bool) {
|
||||||
|
v := m.user
|
||||||
|
if v == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return *v, true
|
||||||
|
}
|
||||||
|
|
||||||
|
// OldUserID returns the old "user_id" field's value of the Notifier entity.
|
||||||
|
// If the Notifier object wasn't provided to the builder, the object is fetched from the database.
|
||||||
|
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||||
|
func (m *NotifierMutation) OldUserID(ctx context.Context) (v uuid.UUID, err error) {
|
||||||
|
if !m.op.Is(OpUpdateOne) {
|
||||||
|
return v, errors.New("OldUserID is only allowed on UpdateOne operations")
|
||||||
|
}
|
||||||
|
if m.id == nil || m.oldValue == nil {
|
||||||
|
return v, errors.New("OldUserID requires an ID field in the mutation")
|
||||||
|
}
|
||||||
|
oldValue, err := m.oldValue(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return v, fmt.Errorf("querying old value for OldUserID: %w", err)
|
||||||
|
}
|
||||||
|
return oldValue.UserID, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetUserID resets all changes to the "user_id" field.
|
||||||
|
func (m *NotifierMutation) ResetUserID() {
|
||||||
|
m.user = nil
|
||||||
|
}
|
||||||
|
|
||||||
// SetName sets the "name" field.
|
// SetName sets the "name" field.
|
||||||
func (m *NotifierMutation) SetName(s string) {
|
func (m *NotifierMutation) SetName(s string) {
|
||||||
m.name = &s
|
m.name = &s
|
||||||
|
@ -10236,32 +10236,6 @@ func (m *NotifierMutation) ResetIsActive() {
|
||||||
m.is_active = nil
|
m.is_active = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearUser clears the "user" edge to the User entity.
|
|
||||||
func (m *NotifierMutation) ClearUser() {
|
|
||||||
m.cleareduser = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserCleared reports if the "user" edge to the User entity was cleared.
|
|
||||||
func (m *NotifierMutation) UserCleared() bool {
|
|
||||||
return m.cleareduser
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserIDs returns the "user" edge IDs in the mutation.
|
|
||||||
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
||||||
// UserID instead. It exists only for internal usage by the builders.
|
|
||||||
func (m *NotifierMutation) UserIDs() (ids []uuid.UUID) {
|
|
||||||
if id := m.user; id != nil {
|
|
||||||
ids = append(ids, *id)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetUser resets all changes to the "user" edge.
|
|
||||||
func (m *NotifierMutation) ResetUser() {
|
|
||||||
m.user = nil
|
|
||||||
m.cleareduser = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearGroup clears the "group" edge to the Group entity.
|
// ClearGroup clears the "group" edge to the Group entity.
|
||||||
func (m *NotifierMutation) ClearGroup() {
|
func (m *NotifierMutation) ClearGroup() {
|
||||||
m.clearedgroup = true
|
m.clearedgroup = true
|
||||||
|
@ -10288,6 +10262,32 @@ func (m *NotifierMutation) ResetGroup() {
|
||||||
m.clearedgroup = false
|
m.clearedgroup = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearUser clears the "user" edge to the User entity.
|
||||||
|
func (m *NotifierMutation) ClearUser() {
|
||||||
|
m.cleareduser = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserCleared reports if the "user" edge to the User entity was cleared.
|
||||||
|
func (m *NotifierMutation) UserCleared() bool {
|
||||||
|
return m.cleareduser
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserIDs returns the "user" edge IDs in the mutation.
|
||||||
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||||
|
// UserID instead. It exists only for internal usage by the builders.
|
||||||
|
func (m *NotifierMutation) UserIDs() (ids []uuid.UUID) {
|
||||||
|
if id := m.user; id != nil {
|
||||||
|
ids = append(ids, *id)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetUser resets all changes to the "user" edge.
|
||||||
|
func (m *NotifierMutation) ResetUser() {
|
||||||
|
m.user = nil
|
||||||
|
m.cleareduser = false
|
||||||
|
}
|
||||||
|
|
||||||
// Where appends a list predicates to the NotifierMutation builder.
|
// Where appends a list predicates to the NotifierMutation builder.
|
||||||
func (m *NotifierMutation) Where(ps ...predicate.Notifier) {
|
func (m *NotifierMutation) Where(ps ...predicate.Notifier) {
|
||||||
m.predicates = append(m.predicates, ps...)
|
m.predicates = append(m.predicates, ps...)
|
||||||
|
@ -10329,12 +10329,12 @@ func (m *NotifierMutation) Fields() []string {
|
||||||
if m.updated_at != nil {
|
if m.updated_at != nil {
|
||||||
fields = append(fields, notifier.FieldUpdatedAt)
|
fields = append(fields, notifier.FieldUpdatedAt)
|
||||||
}
|
}
|
||||||
if m.user != nil {
|
|
||||||
fields = append(fields, notifier.FieldUserID)
|
|
||||||
}
|
|
||||||
if m.group != nil {
|
if m.group != nil {
|
||||||
fields = append(fields, notifier.FieldGroupID)
|
fields = append(fields, notifier.FieldGroupID)
|
||||||
}
|
}
|
||||||
|
if m.user != nil {
|
||||||
|
fields = append(fields, notifier.FieldUserID)
|
||||||
|
}
|
||||||
if m.name != nil {
|
if m.name != nil {
|
||||||
fields = append(fields, notifier.FieldName)
|
fields = append(fields, notifier.FieldName)
|
||||||
}
|
}
|
||||||
|
@ -10356,10 +10356,10 @@ func (m *NotifierMutation) Field(name string) (ent.Value, bool) {
|
||||||
return m.CreatedAt()
|
return m.CreatedAt()
|
||||||
case notifier.FieldUpdatedAt:
|
case notifier.FieldUpdatedAt:
|
||||||
return m.UpdatedAt()
|
return m.UpdatedAt()
|
||||||
case notifier.FieldUserID:
|
|
||||||
return m.UserID()
|
|
||||||
case notifier.FieldGroupID:
|
case notifier.FieldGroupID:
|
||||||
return m.GroupID()
|
return m.GroupID()
|
||||||
|
case notifier.FieldUserID:
|
||||||
|
return m.UserID()
|
||||||
case notifier.FieldName:
|
case notifier.FieldName:
|
||||||
return m.Name()
|
return m.Name()
|
||||||
case notifier.FieldURL:
|
case notifier.FieldURL:
|
||||||
|
@ -10379,10 +10379,10 @@ func (m *NotifierMutation) OldField(ctx context.Context, name string) (ent.Value
|
||||||
return m.OldCreatedAt(ctx)
|
return m.OldCreatedAt(ctx)
|
||||||
case notifier.FieldUpdatedAt:
|
case notifier.FieldUpdatedAt:
|
||||||
return m.OldUpdatedAt(ctx)
|
return m.OldUpdatedAt(ctx)
|
||||||
case notifier.FieldUserID:
|
|
||||||
return m.OldUserID(ctx)
|
|
||||||
case notifier.FieldGroupID:
|
case notifier.FieldGroupID:
|
||||||
return m.OldGroupID(ctx)
|
return m.OldGroupID(ctx)
|
||||||
|
case notifier.FieldUserID:
|
||||||
|
return m.OldUserID(ctx)
|
||||||
case notifier.FieldName:
|
case notifier.FieldName:
|
||||||
return m.OldName(ctx)
|
return m.OldName(ctx)
|
||||||
case notifier.FieldURL:
|
case notifier.FieldURL:
|
||||||
|
@ -10412,13 +10412,6 @@ func (m *NotifierMutation) SetField(name string, value ent.Value) error {
|
||||||
}
|
}
|
||||||
m.SetUpdatedAt(v)
|
m.SetUpdatedAt(v)
|
||||||
return nil
|
return nil
|
||||||
case notifier.FieldUserID:
|
|
||||||
v, ok := value.(uuid.UUID)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
||||||
}
|
|
||||||
m.SetUserID(v)
|
|
||||||
return nil
|
|
||||||
case notifier.FieldGroupID:
|
case notifier.FieldGroupID:
|
||||||
v, ok := value.(uuid.UUID)
|
v, ok := value.(uuid.UUID)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -10426,6 +10419,13 @@ func (m *NotifierMutation) SetField(name string, value ent.Value) error {
|
||||||
}
|
}
|
||||||
m.SetGroupID(v)
|
m.SetGroupID(v)
|
||||||
return nil
|
return nil
|
||||||
|
case notifier.FieldUserID:
|
||||||
|
v, ok := value.(uuid.UUID)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||||
|
}
|
||||||
|
m.SetUserID(v)
|
||||||
|
return nil
|
||||||
case notifier.FieldName:
|
case notifier.FieldName:
|
||||||
v, ok := value.(string)
|
v, ok := value.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -10502,12 +10502,12 @@ func (m *NotifierMutation) ResetField(name string) error {
|
||||||
case notifier.FieldUpdatedAt:
|
case notifier.FieldUpdatedAt:
|
||||||
m.ResetUpdatedAt()
|
m.ResetUpdatedAt()
|
||||||
return nil
|
return nil
|
||||||
case notifier.FieldUserID:
|
|
||||||
m.ResetUserID()
|
|
||||||
return nil
|
|
||||||
case notifier.FieldGroupID:
|
case notifier.FieldGroupID:
|
||||||
m.ResetGroupID()
|
m.ResetGroupID()
|
||||||
return nil
|
return nil
|
||||||
|
case notifier.FieldUserID:
|
||||||
|
m.ResetUserID()
|
||||||
|
return nil
|
||||||
case notifier.FieldName:
|
case notifier.FieldName:
|
||||||
m.ResetName()
|
m.ResetName()
|
||||||
return nil
|
return nil
|
||||||
|
@ -10524,12 +10524,12 @@ func (m *NotifierMutation) ResetField(name string) error {
|
||||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||||
func (m *NotifierMutation) AddedEdges() []string {
|
func (m *NotifierMutation) AddedEdges() []string {
|
||||||
edges := make([]string, 0, 2)
|
edges := make([]string, 0, 2)
|
||||||
if m.user != nil {
|
|
||||||
edges = append(edges, notifier.EdgeUser)
|
|
||||||
}
|
|
||||||
if m.group != nil {
|
if m.group != nil {
|
||||||
edges = append(edges, notifier.EdgeGroup)
|
edges = append(edges, notifier.EdgeGroup)
|
||||||
}
|
}
|
||||||
|
if m.user != nil {
|
||||||
|
edges = append(edges, notifier.EdgeUser)
|
||||||
|
}
|
||||||
return edges
|
return edges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10537,14 +10537,14 @@ func (m *NotifierMutation) AddedEdges() []string {
|
||||||
// name in this mutation.
|
// name in this mutation.
|
||||||
func (m *NotifierMutation) AddedIDs(name string) []ent.Value {
|
func (m *NotifierMutation) AddedIDs(name string) []ent.Value {
|
||||||
switch name {
|
switch name {
|
||||||
case notifier.EdgeUser:
|
|
||||||
if id := m.user; id != nil {
|
|
||||||
return []ent.Value{*id}
|
|
||||||
}
|
|
||||||
case notifier.EdgeGroup:
|
case notifier.EdgeGroup:
|
||||||
if id := m.group; id != nil {
|
if id := m.group; id != nil {
|
||||||
return []ent.Value{*id}
|
return []ent.Value{*id}
|
||||||
}
|
}
|
||||||
|
case notifier.EdgeUser:
|
||||||
|
if id := m.user; id != nil {
|
||||||
|
return []ent.Value{*id}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -10564,12 +10564,12 @@ func (m *NotifierMutation) RemovedIDs(name string) []ent.Value {
|
||||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||||
func (m *NotifierMutation) ClearedEdges() []string {
|
func (m *NotifierMutation) ClearedEdges() []string {
|
||||||
edges := make([]string, 0, 2)
|
edges := make([]string, 0, 2)
|
||||||
if m.cleareduser {
|
|
||||||
edges = append(edges, notifier.EdgeUser)
|
|
||||||
}
|
|
||||||
if m.clearedgroup {
|
if m.clearedgroup {
|
||||||
edges = append(edges, notifier.EdgeGroup)
|
edges = append(edges, notifier.EdgeGroup)
|
||||||
}
|
}
|
||||||
|
if m.cleareduser {
|
||||||
|
edges = append(edges, notifier.EdgeUser)
|
||||||
|
}
|
||||||
return edges
|
return edges
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10577,10 +10577,10 @@ func (m *NotifierMutation) ClearedEdges() []string {
|
||||||
// was cleared in this mutation.
|
// was cleared in this mutation.
|
||||||
func (m *NotifierMutation) EdgeCleared(name string) bool {
|
func (m *NotifierMutation) EdgeCleared(name string) bool {
|
||||||
switch name {
|
switch name {
|
||||||
case notifier.EdgeUser:
|
|
||||||
return m.cleareduser
|
|
||||||
case notifier.EdgeGroup:
|
case notifier.EdgeGroup:
|
||||||
return m.clearedgroup
|
return m.clearedgroup
|
||||||
|
case notifier.EdgeUser:
|
||||||
|
return m.cleareduser
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -10589,12 +10589,12 @@ func (m *NotifierMutation) EdgeCleared(name string) bool {
|
||||||
// if that edge is not defined in the schema.
|
// if that edge is not defined in the schema.
|
||||||
func (m *NotifierMutation) ClearEdge(name string) error {
|
func (m *NotifierMutation) ClearEdge(name string) error {
|
||||||
switch name {
|
switch name {
|
||||||
case notifier.EdgeUser:
|
|
||||||
m.ClearUser()
|
|
||||||
return nil
|
|
||||||
case notifier.EdgeGroup:
|
case notifier.EdgeGroup:
|
||||||
m.ClearGroup()
|
m.ClearGroup()
|
||||||
return nil
|
return nil
|
||||||
|
case notifier.EdgeUser:
|
||||||
|
m.ClearUser()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown Notifier unique edge %s", name)
|
return fmt.Errorf("unknown Notifier unique edge %s", name)
|
||||||
}
|
}
|
||||||
|
@ -10603,12 +10603,12 @@ func (m *NotifierMutation) ClearEdge(name string) error {
|
||||||
// It returns an error if the edge is not defined in the schema.
|
// It returns an error if the edge is not defined in the schema.
|
||||||
func (m *NotifierMutation) ResetEdge(name string) error {
|
func (m *NotifierMutation) ResetEdge(name string) error {
|
||||||
switch name {
|
switch name {
|
||||||
case notifier.EdgeUser:
|
|
||||||
m.ResetUser()
|
|
||||||
return nil
|
|
||||||
case notifier.EdgeGroup:
|
case notifier.EdgeGroup:
|
||||||
m.ResetGroup()
|
m.ResetGroup()
|
||||||
return nil
|
return nil
|
||||||
|
case notifier.EdgeUser:
|
||||||
|
m.ResetUser()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown Notifier edge %s", name)
|
return fmt.Errorf("unknown Notifier edge %s", name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,10 +23,10 @@ type Notifier struct {
|
||||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||||
// UpdatedAt holds the value of the "updated_at" field.
|
// UpdatedAt holds the value of the "updated_at" field.
|
||||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||||
// UserID holds the value of the "user_id" field.
|
|
||||||
UserID uuid.UUID `json:"user_id,omitempty"`
|
|
||||||
// GroupID holds the value of the "group_id" field.
|
// GroupID holds the value of the "group_id" field.
|
||||||
GroupID uuid.UUID `json:"group_id,omitempty"`
|
GroupID uuid.UUID `json:"group_id,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 holds the value of the "name" field.
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
// URL holds the value of the "url" field.
|
// URL holds the value of the "url" field.
|
||||||
|
@ -40,32 +40,19 @@ type Notifier struct {
|
||||||
|
|
||||||
// NotifierEdges holds the relations/edges for other nodes in the graph.
|
// NotifierEdges holds the relations/edges for other nodes in the graph.
|
||||||
type NotifierEdges struct {
|
type NotifierEdges struct {
|
||||||
// User holds the value of the user edge.
|
|
||||||
User *User `json:"user,omitempty"`
|
|
||||||
// Group holds the value of the group edge.
|
// Group holds the value of the group edge.
|
||||||
Group *Group `json:"group,omitempty"`
|
Group *Group `json:"group,omitempty"`
|
||||||
|
// User holds the value of the user edge.
|
||||||
|
User *User `json:"user,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 [2]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"}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GroupOrErr returns the Group value or an error if the edge
|
// GroupOrErr returns the Group value or an error if the edge
|
||||||
// was not loaded in eager-loading, or loaded but was not found.
|
// was not loaded in eager-loading, or loaded but was not found.
|
||||||
func (e NotifierEdges) GroupOrErr() (*Group, error) {
|
func (e NotifierEdges) GroupOrErr() (*Group, error) {
|
||||||
if e.loadedTypes[1] {
|
if e.loadedTypes[0] {
|
||||||
if e.Group == nil {
|
if e.Group == nil {
|
||||||
// Edge was loaded but was not found.
|
// Edge was loaded but was not found.
|
||||||
return nil, &NotFoundError{label: group.Label}
|
return nil, &NotFoundError{label: group.Label}
|
||||||
|
@ -75,6 +62,19 @@ func (e NotifierEdges) GroupOrErr() (*Group, error) {
|
||||||
return nil, &NotLoadedError{edge: "group"}
|
return nil, &NotLoadedError{edge: "group"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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[1] {
|
||||||
|
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.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*Notifier) scanValues(columns []string) ([]any, error) {
|
func (*Notifier) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]any, len(columns))
|
values := make([]any, len(columns))
|
||||||
|
@ -86,7 +86,7 @@ func (*Notifier) scanValues(columns []string) ([]any, error) {
|
||||||
values[i] = new(sql.NullString)
|
values[i] = new(sql.NullString)
|
||||||
case notifier.FieldCreatedAt, notifier.FieldUpdatedAt:
|
case notifier.FieldCreatedAt, notifier.FieldUpdatedAt:
|
||||||
values[i] = new(sql.NullTime)
|
values[i] = new(sql.NullTime)
|
||||||
case notifier.FieldID, notifier.FieldUserID, notifier.FieldGroupID:
|
case notifier.FieldID, notifier.FieldGroupID, notifier.FieldUserID:
|
||||||
values[i] = new(uuid.UUID)
|
values[i] = new(uuid.UUID)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unexpected column %q for type Notifier", columns[i])
|
return nil, fmt.Errorf("unexpected column %q for type Notifier", columns[i])
|
||||||
|
@ -121,18 +121,18 @@ func (n *Notifier) assignValues(columns []string, values []any) error {
|
||||||
} else if value.Valid {
|
} else if value.Valid {
|
||||||
n.UpdatedAt = value.Time
|
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.FieldGroupID:
|
case notifier.FieldGroupID:
|
||||||
if value, ok := values[i].(*uuid.UUID); !ok {
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field group_id", values[i])
|
return fmt.Errorf("unexpected type %T for field group_id", values[i])
|
||||||
} else if value != nil {
|
} else if value != nil {
|
||||||
n.GroupID = *value
|
n.GroupID = *value
|
||||||
}
|
}
|
||||||
|
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:
|
case notifier.FieldName:
|
||||||
if value, ok := values[i].(*sql.NullString); !ok {
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||||
|
@ -156,16 +156,16 @@ func (n *Notifier) assignValues(columns []string, values []any) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryUser queries the "user" edge of the Notifier entity.
|
|
||||||
func (n *Notifier) QueryUser() *UserQuery {
|
|
||||||
return NewNotifierClient(n.config).QueryUser(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryGroup queries the "group" edge of the Notifier entity.
|
// QueryGroup queries the "group" edge of the Notifier entity.
|
||||||
func (n *Notifier) QueryGroup() *GroupQuery {
|
func (n *Notifier) QueryGroup() *GroupQuery {
|
||||||
return NewNotifierClient(n.config).QueryGroup(n)
|
return NewNotifierClient(n.config).QueryGroup(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// Update returns a builder for updating this Notifier.
|
||||||
// Note that you need to call Notifier.Unwrap() before calling this method if 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.
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||||
|
@ -195,12 +195,12 @@ func (n *Notifier) String() string {
|
||||||
builder.WriteString("updated_at=")
|
builder.WriteString("updated_at=")
|
||||||
builder.WriteString(n.UpdatedAt.Format(time.ANSIC))
|
builder.WriteString(n.UpdatedAt.Format(time.ANSIC))
|
||||||
builder.WriteString(", ")
|
builder.WriteString(", ")
|
||||||
builder.WriteString("user_id=")
|
|
||||||
builder.WriteString(fmt.Sprintf("%v", n.UserID))
|
|
||||||
builder.WriteString(", ")
|
|
||||||
builder.WriteString("group_id=")
|
builder.WriteString("group_id=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", n.GroupID))
|
builder.WriteString(fmt.Sprintf("%v", n.GroupID))
|
||||||
builder.WriteString(", ")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("user_id=")
|
||||||
|
builder.WriteString(fmt.Sprintf("%v", n.UserID))
|
||||||
|
builder.WriteString(", ")
|
||||||
builder.WriteString("name=")
|
builder.WriteString("name=")
|
||||||
builder.WriteString(n.Name)
|
builder.WriteString(n.Name)
|
||||||
builder.WriteString(", ")
|
builder.WriteString(", ")
|
||||||
|
|
|
@ -17,29 +17,22 @@ const (
|
||||||
FieldCreatedAt = "created_at"
|
FieldCreatedAt = "created_at"
|
||||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||||
FieldUpdatedAt = "updated_at"
|
FieldUpdatedAt = "updated_at"
|
||||||
// FieldUserID holds the string denoting the user_id field in the database.
|
|
||||||
FieldUserID = "user_id"
|
|
||||||
// FieldGroupID holds the string denoting the group_id field in the database.
|
// FieldGroupID holds the string denoting the group_id field in the database.
|
||||||
FieldGroupID = "group_id"
|
FieldGroupID = "group_id"
|
||||||
|
// 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 holds the string denoting the name field in the database.
|
||||||
FieldName = "name"
|
FieldName = "name"
|
||||||
// FieldURL holds the string denoting the url field in the database.
|
// FieldURL holds the string denoting the url field in the database.
|
||||||
FieldURL = "url"
|
FieldURL = "url"
|
||||||
// FieldIsActive holds the string denoting the is_active field in the database.
|
// FieldIsActive holds the string denoting the is_active field in the database.
|
||||||
FieldIsActive = "is_active"
|
FieldIsActive = "is_active"
|
||||||
// EdgeUser holds the string denoting the user edge name in mutations.
|
|
||||||
EdgeUser = "user"
|
|
||||||
// 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"
|
||||||
|
// 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 holds the table name of the notifier in the database.
|
||||||
Table = "notifiers"
|
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"
|
|
||||||
// GroupTable is the table that holds the group relation/edge.
|
// GroupTable is the table that holds the group relation/edge.
|
||||||
GroupTable = "notifiers"
|
GroupTable = "notifiers"
|
||||||
// GroupInverseTable is the table name for the Group entity.
|
// GroupInverseTable is the table name for the Group entity.
|
||||||
|
@ -47,6 +40,13 @@ const (
|
||||||
GroupInverseTable = "groups"
|
GroupInverseTable = "groups"
|
||||||
// GroupColumn is the table column denoting the group relation/edge.
|
// GroupColumn is the table column denoting the group relation/edge.
|
||||||
GroupColumn = "group_id"
|
GroupColumn = "group_id"
|
||||||
|
// 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.
|
// Columns holds all SQL columns for notifier fields.
|
||||||
|
@ -54,8 +54,8 @@ var Columns = []string{
|
||||||
FieldID,
|
FieldID,
|
||||||
FieldCreatedAt,
|
FieldCreatedAt,
|
||||||
FieldUpdatedAt,
|
FieldUpdatedAt,
|
||||||
FieldUserID,
|
|
||||||
FieldGroupID,
|
FieldGroupID,
|
||||||
|
FieldUserID,
|
||||||
FieldName,
|
FieldName,
|
||||||
FieldURL,
|
FieldURL,
|
||||||
FieldIsActive,
|
FieldIsActive,
|
||||||
|
|
|
@ -66,16 +66,16 @@ func UpdatedAt(v time.Time) predicate.Notifier {
|
||||||
return predicate.Notifier(sql.FieldEQ(FieldUpdatedAt, v))
|
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))
|
|
||||||
}
|
|
||||||
|
|
||||||
// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ.
|
// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ.
|
||||||
func GroupID(v uuid.UUID) predicate.Notifier {
|
func GroupID(v uuid.UUID) predicate.Notifier {
|
||||||
return predicate.Notifier(sql.FieldEQ(FieldGroupID, v))
|
return predicate.Notifier(sql.FieldEQ(FieldGroupID, 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.
|
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||||
func Name(v string) predicate.Notifier {
|
func Name(v string) predicate.Notifier {
|
||||||
return predicate.Notifier(sql.FieldEQ(FieldName, v))
|
return predicate.Notifier(sql.FieldEQ(FieldName, v))
|
||||||
|
@ -171,26 +171,6 @@ func UpdatedAtLTE(v time.Time) predicate.Notifier {
|
||||||
return predicate.Notifier(sql.FieldLTE(FieldUpdatedAt, v))
|
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...))
|
|
||||||
}
|
|
||||||
|
|
||||||
// GroupIDEQ applies the EQ predicate on the "group_id" field.
|
// GroupIDEQ applies the EQ predicate on the "group_id" field.
|
||||||
func GroupIDEQ(v uuid.UUID) predicate.Notifier {
|
func GroupIDEQ(v uuid.UUID) predicate.Notifier {
|
||||||
return predicate.Notifier(sql.FieldEQ(FieldGroupID, v))
|
return predicate.Notifier(sql.FieldEQ(FieldGroupID, v))
|
||||||
|
@ -211,6 +191,26 @@ func GroupIDNotIn(vs ...uuid.UUID) predicate.Notifier {
|
||||||
return predicate.Notifier(sql.FieldNotIn(FieldGroupID, vs...))
|
return predicate.Notifier(sql.FieldNotIn(FieldGroupID, vs...))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// NameEQ applies the EQ predicate on the "name" field.
|
||||||
func NameEQ(v string) predicate.Notifier {
|
func NameEQ(v string) predicate.Notifier {
|
||||||
return predicate.Notifier(sql.FieldEQ(FieldName, v))
|
return predicate.Notifier(sql.FieldEQ(FieldName, v))
|
||||||
|
@ -351,33 +351,6 @@ func IsActiveNEQ(v bool) predicate.Notifier {
|
||||||
return predicate.Notifier(sql.FieldNEQ(FieldIsActive, v))
|
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)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// HasGroup applies the HasEdge predicate on the "group" edge.
|
// HasGroup applies the HasEdge predicate on the "group" edge.
|
||||||
func HasGroup() predicate.Notifier {
|
func HasGroup() predicate.Notifier {
|
||||||
return predicate.Notifier(func(s *sql.Selector) {
|
return predicate.Notifier(func(s *sql.Selector) {
|
||||||
|
@ -405,6 +378,33 @@ func HasGroupWith(preds ...predicate.Group) predicate.Notifier {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// And groups predicates with the AND operator between them.
|
||||||
func And(predicates ...predicate.Notifier) predicate.Notifier {
|
func And(predicates ...predicate.Notifier) predicate.Notifier {
|
||||||
return predicate.Notifier(func(s *sql.Selector) {
|
return predicate.Notifier(func(s *sql.Selector) {
|
||||||
|
|
|
@ -51,18 +51,18 @@ func (nc *NotifierCreate) SetNillableUpdatedAt(t *time.Time) *NotifierCreate {
|
||||||
return nc
|
return nc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUserID sets the "user_id" field.
|
|
||||||
func (nc *NotifierCreate) SetUserID(u uuid.UUID) *NotifierCreate {
|
|
||||||
nc.mutation.SetUserID(u)
|
|
||||||
return nc
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGroupID sets the "group_id" field.
|
// SetGroupID sets the "group_id" field.
|
||||||
func (nc *NotifierCreate) SetGroupID(u uuid.UUID) *NotifierCreate {
|
func (nc *NotifierCreate) SetGroupID(u uuid.UUID) *NotifierCreate {
|
||||||
nc.mutation.SetGroupID(u)
|
nc.mutation.SetGroupID(u)
|
||||||
return nc
|
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.
|
// SetName sets the "name" field.
|
||||||
func (nc *NotifierCreate) SetName(s string) *NotifierCreate {
|
func (nc *NotifierCreate) SetName(s string) *NotifierCreate {
|
||||||
nc.mutation.SetName(s)
|
nc.mutation.SetName(s)
|
||||||
|
@ -103,16 +103,16 @@ func (nc *NotifierCreate) SetNillableID(u *uuid.UUID) *NotifierCreate {
|
||||||
return nc
|
return nc
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUser sets the "user" edge to the User entity.
|
|
||||||
func (nc *NotifierCreate) SetUser(u *User) *NotifierCreate {
|
|
||||||
return nc.SetUserID(u.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGroup sets the "group" edge to the Group entity.
|
// SetGroup sets the "group" edge to the Group entity.
|
||||||
func (nc *NotifierCreate) SetGroup(g *Group) *NotifierCreate {
|
func (nc *NotifierCreate) SetGroup(g *Group) *NotifierCreate {
|
||||||
return nc.SetGroupID(g.ID)
|
return nc.SetGroupID(g.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// Mutation returns the NotifierMutation object of the builder.
|
||||||
func (nc *NotifierCreate) Mutation() *NotifierMutation {
|
func (nc *NotifierCreate) Mutation() *NotifierMutation {
|
||||||
return nc.mutation
|
return nc.mutation
|
||||||
|
@ -174,12 +174,12 @@ func (nc *NotifierCreate) check() error {
|
||||||
if _, ok := nc.mutation.UpdatedAt(); !ok {
|
if _, ok := nc.mutation.UpdatedAt(); !ok {
|
||||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Notifier.updated_at"`)}
|
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.GroupID(); !ok {
|
if _, ok := nc.mutation.GroupID(); !ok {
|
||||||
return &ValidationError{Name: "group_id", err: errors.New(`ent: missing required field "Notifier.group_id"`)}
|
return &ValidationError{Name: "group_id", err: errors.New(`ent: missing required field "Notifier.group_id"`)}
|
||||||
}
|
}
|
||||||
|
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 {
|
if _, ok := nc.mutation.Name(); !ok {
|
||||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Notifier.name"`)}
|
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Notifier.name"`)}
|
||||||
}
|
}
|
||||||
|
@ -199,12 +199,12 @@ func (nc *NotifierCreate) check() error {
|
||||||
if _, ok := nc.mutation.IsActive(); !ok {
|
if _, ok := nc.mutation.IsActive(); !ok {
|
||||||
return &ValidationError{Name: "is_active", err: errors.New(`ent: missing required field "Notifier.is_active"`)}
|
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"`)}
|
|
||||||
}
|
|
||||||
if _, ok := nc.mutation.GroupID(); !ok {
|
if _, ok := nc.mutation.GroupID(); !ok {
|
||||||
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Notifier.group"`)}
|
return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "Notifier.group"`)}
|
||||||
}
|
}
|
||||||
|
if _, ok := nc.mutation.UserID(); !ok {
|
||||||
|
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "Notifier.user"`)}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,26 +260,6 @@ func (nc *NotifierCreate) createSpec() (*Notifier, *sqlgraph.CreateSpec) {
|
||||||
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
||||||
_node.IsActive = 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)
|
|
||||||
}
|
|
||||||
if nodes := nc.mutation.GroupIDs(); len(nodes) > 0 {
|
if nodes := nc.mutation.GroupIDs(); len(nodes) > 0 {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
|
@ -300,6 +280,26 @@ func (nc *NotifierCreate) createSpec() (*Notifier, *sqlgraph.CreateSpec) {
|
||||||
_node.GroupID = nodes[0]
|
_node.GroupID = nodes[0]
|
||||||
_spec.Edges = append(_spec.Edges, edge)
|
_spec.Edges = append(_spec.Edges, edge)
|
||||||
}
|
}
|
||||||
|
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
|
return _node, _spec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ type NotifierQuery struct {
|
||||||
order []OrderFunc
|
order []OrderFunc
|
||||||
inters []Interceptor
|
inters []Interceptor
|
||||||
predicates []predicate.Notifier
|
predicates []predicate.Notifier
|
||||||
withUser *UserQuery
|
|
||||||
withGroup *GroupQuery
|
withGroup *GroupQuery
|
||||||
|
withUser *UserQuery
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
path func(context.Context) (*sql.Selector, error)
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
@ -62,28 +62,6 @@ func (nq *NotifierQuery) Order(o ...OrderFunc) *NotifierQuery {
|
||||||
return nq
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryGroup chains the current query on the "group" edge.
|
// QueryGroup chains the current query on the "group" edge.
|
||||||
func (nq *NotifierQuery) QueryGroup() *GroupQuery {
|
func (nq *NotifierQuery) QueryGroup() *GroupQuery {
|
||||||
query := (&GroupClient{config: nq.config}).Query()
|
query := (&GroupClient{config: nq.config}).Query()
|
||||||
|
@ -106,6 +84,28 @@ func (nq *NotifierQuery) QueryGroup() *GroupQuery {
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// First returns the first Notifier entity from the query.
|
||||||
// Returns a *NotFoundError when no Notifier was found.
|
// Returns a *NotFoundError when no Notifier was found.
|
||||||
func (nq *NotifierQuery) First(ctx context.Context) (*Notifier, error) {
|
func (nq *NotifierQuery) First(ctx context.Context) (*Notifier, error) {
|
||||||
|
@ -298,25 +298,14 @@ func (nq *NotifierQuery) Clone() *NotifierQuery {
|
||||||
order: append([]OrderFunc{}, nq.order...),
|
order: append([]OrderFunc{}, nq.order...),
|
||||||
inters: append([]Interceptor{}, nq.inters...),
|
inters: append([]Interceptor{}, nq.inters...),
|
||||||
predicates: append([]predicate.Notifier{}, nq.predicates...),
|
predicates: append([]predicate.Notifier{}, nq.predicates...),
|
||||||
withUser: nq.withUser.Clone(),
|
|
||||||
withGroup: nq.withGroup.Clone(),
|
withGroup: nq.withGroup.Clone(),
|
||||||
|
withUser: nq.withUser.Clone(),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: nq.sql.Clone(),
|
sql: nq.sql.Clone(),
|
||||||
path: nq.path,
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
// WithGroup tells the query-builder to eager-load the nodes that are connected to
|
||||||
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
// the "group" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
func (nq *NotifierQuery) WithGroup(opts ...func(*GroupQuery)) *NotifierQuery {
|
func (nq *NotifierQuery) WithGroup(opts ...func(*GroupQuery)) *NotifierQuery {
|
||||||
|
@ -328,6 +317,17 @@ func (nq *NotifierQuery) WithGroup(opts ...func(*GroupQuery)) *NotifierQuery {
|
||||||
return nq
|
return nq
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// 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.
|
||||||
//
|
//
|
||||||
|
@ -407,8 +407,8 @@ func (nq *NotifierQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Not
|
||||||
nodes = []*Notifier{}
|
nodes = []*Notifier{}
|
||||||
_spec = nq.querySpec()
|
_spec = nq.querySpec()
|
||||||
loadedTypes = [2]bool{
|
loadedTypes = [2]bool{
|
||||||
nq.withUser != nil,
|
|
||||||
nq.withGroup != nil,
|
nq.withGroup != nil,
|
||||||
|
nq.withUser != nil,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
@ -429,50 +429,21 @@ func (nq *NotifierQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Not
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
return nodes, nil
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if query := nq.withGroup; query != nil {
|
if query := nq.withGroup; query != nil {
|
||||||
if err := nq.loadGroup(ctx, query, nodes, nil,
|
if err := nq.loadGroup(ctx, query, nodes, nil,
|
||||||
func(n *Notifier, e *Group) { n.Edges.Group = e }); err != nil {
|
func(n *Notifier, e *Group) { n.Edges.Group = e }); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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
|
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) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Notifier, init func(*Notifier), assign func(*Notifier, *Group)) error {
|
func (nq *NotifierQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes []*Notifier, init func(*Notifier), assign func(*Notifier, *Group)) error {
|
||||||
ids := make([]uuid.UUID, 0, len(nodes))
|
ids := make([]uuid.UUID, 0, len(nodes))
|
||||||
nodeids := make(map[uuid.UUID][]*Notifier)
|
nodeids := make(map[uuid.UUID][]*Notifier)
|
||||||
|
@ -502,6 +473,35 @@ func (nq *NotifierQuery) loadGroup(ctx context.Context, query *GroupQuery, nodes
|
||||||
}
|
}
|
||||||
return nil
|
return 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) {
|
func (nq *NotifierQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
_spec := nq.querySpec()
|
_spec := nq.querySpec()
|
||||||
|
|
|
@ -37,18 +37,18 @@ func (nu *NotifierUpdate) SetUpdatedAt(t time.Time) *NotifierUpdate {
|
||||||
return nu
|
return nu
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUserID sets the "user_id" field.
|
|
||||||
func (nu *NotifierUpdate) SetUserID(u uuid.UUID) *NotifierUpdate {
|
|
||||||
nu.mutation.SetUserID(u)
|
|
||||||
return nu
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGroupID sets the "group_id" field.
|
// SetGroupID sets the "group_id" field.
|
||||||
func (nu *NotifierUpdate) SetGroupID(u uuid.UUID) *NotifierUpdate {
|
func (nu *NotifierUpdate) SetGroupID(u uuid.UUID) *NotifierUpdate {
|
||||||
nu.mutation.SetGroupID(u)
|
nu.mutation.SetGroupID(u)
|
||||||
return nu
|
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.
|
// SetName sets the "name" field.
|
||||||
func (nu *NotifierUpdate) SetName(s string) *NotifierUpdate {
|
func (nu *NotifierUpdate) SetName(s string) *NotifierUpdate {
|
||||||
nu.mutation.SetName(s)
|
nu.mutation.SetName(s)
|
||||||
|
@ -75,33 +75,33 @@ func (nu *NotifierUpdate) SetNillableIsActive(b *bool) *NotifierUpdate {
|
||||||
return nu
|
return nu
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUser sets the "user" edge to the User entity.
|
|
||||||
func (nu *NotifierUpdate) SetUser(u *User) *NotifierUpdate {
|
|
||||||
return nu.SetUserID(u.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGroup sets the "group" edge to the Group entity.
|
// SetGroup sets the "group" edge to the Group entity.
|
||||||
func (nu *NotifierUpdate) SetGroup(g *Group) *NotifierUpdate {
|
func (nu *NotifierUpdate) SetGroup(g *Group) *NotifierUpdate {
|
||||||
return nu.SetGroupID(g.ID)
|
return nu.SetGroupID(g.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// Mutation returns the NotifierMutation object of the builder.
|
||||||
func (nu *NotifierUpdate) Mutation() *NotifierMutation {
|
func (nu *NotifierUpdate) Mutation() *NotifierMutation {
|
||||||
return nu.mutation
|
return nu.mutation
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearUser clears the "user" edge to the User entity.
|
|
||||||
func (nu *NotifierUpdate) ClearUser() *NotifierUpdate {
|
|
||||||
nu.mutation.ClearUser()
|
|
||||||
return nu
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearGroup clears the "group" edge to the Group entity.
|
// ClearGroup clears the "group" edge to the Group entity.
|
||||||
func (nu *NotifierUpdate) ClearGroup() *NotifierUpdate {
|
func (nu *NotifierUpdate) ClearGroup() *NotifierUpdate {
|
||||||
nu.mutation.ClearGroup()
|
nu.mutation.ClearGroup()
|
||||||
return nu
|
return nu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||||
func (nu *NotifierUpdate) Save(ctx context.Context) (int, error) {
|
func (nu *NotifierUpdate) Save(ctx context.Context) (int, error) {
|
||||||
nu.defaults()
|
nu.defaults()
|
||||||
|
@ -150,12 +150,12 @@ func (nu *NotifierUpdate) check() error {
|
||||||
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
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"`)
|
|
||||||
}
|
|
||||||
if _, ok := nu.mutation.GroupID(); nu.mutation.GroupCleared() && !ok {
|
if _, ok := nu.mutation.GroupID(); nu.mutation.GroupCleared() && !ok {
|
||||||
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
|
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
|
||||||
}
|
}
|
||||||
|
if _, ok := nu.mutation.UserID(); nu.mutation.UserCleared() && !ok {
|
||||||
|
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,41 +183,6 @@ func (nu *NotifierUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
if value, ok := nu.mutation.IsActive(); ok {
|
if value, ok := nu.mutation.IsActive(); ok {
|
||||||
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
_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 nu.mutation.GroupCleared() {
|
if nu.mutation.GroupCleared() {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
|
@ -253,6 +218,41 @@ func (nu *NotifierUpdate) 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 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 n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{notifier.Label}
|
err = &NotFoundError{notifier.Label}
|
||||||
|
@ -279,18 +279,18 @@ func (nuo *NotifierUpdateOne) SetUpdatedAt(t time.Time) *NotifierUpdateOne {
|
||||||
return nuo
|
return nuo
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUserID sets the "user_id" field.
|
|
||||||
func (nuo *NotifierUpdateOne) SetUserID(u uuid.UUID) *NotifierUpdateOne {
|
|
||||||
nuo.mutation.SetUserID(u)
|
|
||||||
return nuo
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGroupID sets the "group_id" field.
|
// SetGroupID sets the "group_id" field.
|
||||||
func (nuo *NotifierUpdateOne) SetGroupID(u uuid.UUID) *NotifierUpdateOne {
|
func (nuo *NotifierUpdateOne) SetGroupID(u uuid.UUID) *NotifierUpdateOne {
|
||||||
nuo.mutation.SetGroupID(u)
|
nuo.mutation.SetGroupID(u)
|
||||||
return nuo
|
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.
|
// SetName sets the "name" field.
|
||||||
func (nuo *NotifierUpdateOne) SetName(s string) *NotifierUpdateOne {
|
func (nuo *NotifierUpdateOne) SetName(s string) *NotifierUpdateOne {
|
||||||
nuo.mutation.SetName(s)
|
nuo.mutation.SetName(s)
|
||||||
|
@ -317,33 +317,33 @@ func (nuo *NotifierUpdateOne) SetNillableIsActive(b *bool) *NotifierUpdateOne {
|
||||||
return nuo
|
return nuo
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUser sets the "user" edge to the User entity.
|
|
||||||
func (nuo *NotifierUpdateOne) SetUser(u *User) *NotifierUpdateOne {
|
|
||||||
return nuo.SetUserID(u.ID)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetGroup sets the "group" edge to the Group entity.
|
// SetGroup sets the "group" edge to the Group entity.
|
||||||
func (nuo *NotifierUpdateOne) SetGroup(g *Group) *NotifierUpdateOne {
|
func (nuo *NotifierUpdateOne) SetGroup(g *Group) *NotifierUpdateOne {
|
||||||
return nuo.SetGroupID(g.ID)
|
return nuo.SetGroupID(g.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// Mutation returns the NotifierMutation object of the builder.
|
||||||
func (nuo *NotifierUpdateOne) Mutation() *NotifierMutation {
|
func (nuo *NotifierUpdateOne) Mutation() *NotifierMutation {
|
||||||
return nuo.mutation
|
return nuo.mutation
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearUser clears the "user" edge to the User entity.
|
|
||||||
func (nuo *NotifierUpdateOne) ClearUser() *NotifierUpdateOne {
|
|
||||||
nuo.mutation.ClearUser()
|
|
||||||
return nuo
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearGroup clears the "group" edge to the Group entity.
|
// ClearGroup clears the "group" edge to the Group entity.
|
||||||
func (nuo *NotifierUpdateOne) ClearGroup() *NotifierUpdateOne {
|
func (nuo *NotifierUpdateOne) ClearGroup() *NotifierUpdateOne {
|
||||||
nuo.mutation.ClearGroup()
|
nuo.mutation.ClearGroup()
|
||||||
return nuo
|
return nuo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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.
|
// Where appends a list predicates to the NotifierUpdate builder.
|
||||||
func (nuo *NotifierUpdateOne) Where(ps ...predicate.Notifier) *NotifierUpdateOne {
|
func (nuo *NotifierUpdateOne) Where(ps ...predicate.Notifier) *NotifierUpdateOne {
|
||||||
nuo.mutation.Where(ps...)
|
nuo.mutation.Where(ps...)
|
||||||
|
@ -405,12 +405,12 @@ func (nuo *NotifierUpdateOne) check() error {
|
||||||
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
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"`)
|
|
||||||
}
|
|
||||||
if _, ok := nuo.mutation.GroupID(); nuo.mutation.GroupCleared() && !ok {
|
if _, ok := nuo.mutation.GroupID(); nuo.mutation.GroupCleared() && !ok {
|
||||||
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
|
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
|
||||||
}
|
}
|
||||||
|
if _, ok := nuo.mutation.UserID(); nuo.mutation.UserCleared() && !ok {
|
||||||
|
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,41 +455,6 @@ func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err
|
||||||
if value, ok := nuo.mutation.IsActive(); ok {
|
if value, ok := nuo.mutation.IsActive(); ok {
|
||||||
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
_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)
|
|
||||||
}
|
|
||||||
if nuo.mutation.GroupCleared() {
|
if nuo.mutation.GroupCleared() {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
|
@ -525,6 +490,41 @@ func (nuo *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err
|
||||||
}
|
}
|
||||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||||
}
|
}
|
||||||
|
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}
|
_node = &Notifier{config: nuo.config}
|
||||||
_spec.Assign = _node.assignValues
|
_spec.Assign = _node.assignValues
|
||||||
_spec.ScanValues = _node.scanValues
|
_spec.ScanValues = _node.scanValues
|
||||||
|
|
|
@ -493,7 +493,7 @@ func init() {
|
||||||
// notifier.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
// notifier.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||||
notifier.UpdateDefaultUpdatedAt = notifierDescUpdatedAt.UpdateDefault.(func() time.Time)
|
notifier.UpdateDefaultUpdatedAt = notifierDescUpdatedAt.UpdateDefault.(func() time.Time)
|
||||||
// notifierDescName is the schema descriptor for name field.
|
// notifierDescName is the schema descriptor for name field.
|
||||||
notifierDescName := notifierFields[2].Descriptor()
|
notifierDescName := notifierFields[0].Descriptor()
|
||||||
// notifier.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
// notifier.NameValidator is a validator for the "name" field. It is called by the builders before save.
|
||||||
notifier.NameValidator = func() func(string) error {
|
notifier.NameValidator = func() func(string) error {
|
||||||
validators := notifierDescName.Validators
|
validators := notifierDescName.Validators
|
||||||
|
@ -511,7 +511,7 @@ func init() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
// notifierDescURL is the schema descriptor for url field.
|
// notifierDescURL is the schema descriptor for url field.
|
||||||
notifierDescURL := notifierFields[3].Descriptor()
|
notifierDescURL := notifierFields[1].Descriptor()
|
||||||
// notifier.URLValidator is a validator for the "url" field. It is called by the builders before save.
|
// notifier.URLValidator is a validator for the "url" field. It is called by the builders before save.
|
||||||
notifier.URLValidator = func() func(string) error {
|
notifier.URLValidator = func() func(string) error {
|
||||||
validators := notifierDescURL.Validators
|
validators := notifierDescURL.Validators
|
||||||
|
@ -529,7 +529,7 @@ func init() {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
// notifierDescIsActive is the schema descriptor for is_active field.
|
// notifierDescIsActive is the schema descriptor for is_active field.
|
||||||
notifierDescIsActive := notifierFields[4].Descriptor()
|
notifierDescIsActive := notifierFields[2].Descriptor()
|
||||||
// notifier.DefaultIsActive holds the default value on creation for the is_active field.
|
// notifier.DefaultIsActive holds the default value on creation for the is_active field.
|
||||||
notifier.DefaultIsActive = notifierDescIsActive.Default.(bool)
|
notifier.DefaultIsActive = notifierDescIsActive.Default.(bool)
|
||||||
// notifierDescID is the schema descriptor for id field.
|
// notifierDescID is the schema descriptor for id field.
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"entgo.io/ent/schema/edge"
|
"entgo.io/ent/schema/edge"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
"entgo.io/ent/schema/mixin"
|
"entgo.io/ent/schema/mixin"
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -56,15 +57,31 @@ func (Group) Edges() []ent.Edge {
|
||||||
// GroupMixin when embedded in an ent.Schema, adds a reference to
|
// GroupMixin when embedded in an ent.Schema, adds a reference to
|
||||||
// the Group entity.
|
// the Group entity.
|
||||||
type GroupMixin struct {
|
type GroupMixin struct {
|
||||||
ref string
|
ref string
|
||||||
|
field string
|
||||||
mixin.Schema
|
mixin.Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g GroupMixin) Edges() []ent.Edge {
|
func (g GroupMixin) Fields() []ent.Field {
|
||||||
return []ent.Edge{
|
if g.field != "" {
|
||||||
edge.From("group", Group.Type).
|
return []ent.Field{
|
||||||
Ref(g.ref).
|
field.UUID(g.field, uuid.UUID{}),
|
||||||
Unique().
|
}
|
||||||
Required(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g GroupMixin) Edges() []ent.Edge {
|
||||||
|
edge := edge.From("group", Group.Type).
|
||||||
|
Ref(g.ref).
|
||||||
|
Unique().
|
||||||
|
Required()
|
||||||
|
|
||||||
|
if g.field != "" {
|
||||||
|
edge = edge.Field(g.field)
|
||||||
|
}
|
||||||
|
|
||||||
|
return []ent.Edge{edge}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,9 @@ package schema
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
"entgo.io/ent/schema/edge"
|
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
"entgo.io/ent/schema/index"
|
"entgo.io/ent/schema/index"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,14 +15,20 @@ type Notifier struct {
|
||||||
func (Notifier) Mixin() []ent.Mixin {
|
func (Notifier) Mixin() []ent.Mixin {
|
||||||
return []ent.Mixin{
|
return []ent.Mixin{
|
||||||
mixins.BaseMixin{},
|
mixins.BaseMixin{},
|
||||||
|
GroupMixin{
|
||||||
|
ref: "notifiers",
|
||||||
|
field: "group_id",
|
||||||
|
},
|
||||||
|
UserMixin{
|
||||||
|
ref: "notifiers",
|
||||||
|
field: "user_id",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fields of the Notifier.
|
// Fields of the Notifier.
|
||||||
func (Notifier) Fields() []ent.Field {
|
func (Notifier) Fields() []ent.Field {
|
||||||
return []ent.Field{
|
return []ent.Field{
|
||||||
field.UUID("user_id", uuid.UUID{}),
|
|
||||||
field.UUID("group_id", uuid.UUID{}),
|
|
||||||
field.String("name").
|
field.String("name").
|
||||||
MaxLen(255).
|
MaxLen(255).
|
||||||
NotEmpty(),
|
NotEmpty(),
|
||||||
|
@ -37,22 +41,6 @@ func (Notifier) Fields() []ent.Field {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Edges of the Notifier.
|
|
||||||
func (Notifier) Edges() []ent.Edge {
|
|
||||||
return []ent.Edge{
|
|
||||||
edge.From("user", User.Type).
|
|
||||||
Field("user_id").
|
|
||||||
Ref("notifiers").
|
|
||||||
Required().
|
|
||||||
Unique(),
|
|
||||||
edge.From("group", Group.Type).
|
|
||||||
Field("group_id").
|
|
||||||
Ref("notifiers").
|
|
||||||
Required().
|
|
||||||
Unique(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (Notifier) Indexes() []ent.Index {
|
func (Notifier) Indexes() []ent.Index {
|
||||||
return []ent.Index{
|
return []ent.Index{
|
||||||
index.Fields("user_id"),
|
index.Fields("user_id"),
|
||||||
|
|
|
@ -5,6 +5,8 @@ import (
|
||||||
"entgo.io/ent/dialect/entsql"
|
"entgo.io/ent/dialect/entsql"
|
||||||
"entgo.io/ent/schema/edge"
|
"entgo.io/ent/schema/edge"
|
||||||
"entgo.io/ent/schema/field"
|
"entgo.io/ent/schema/field"
|
||||||
|
"entgo.io/ent/schema/mixin"
|
||||||
|
"github.com/google/uuid"
|
||||||
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
"github.com/hay-kot/homebox/backend/internal/data/ent/schema/mixins"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -59,3 +61,35 @@ func (User) Edges() []ent.Edge {
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserMixin when embedded in an ent.Schema, adds a reference to
|
||||||
|
// the Group entity.
|
||||||
|
type UserMixin struct {
|
||||||
|
ref string
|
||||||
|
field string
|
||||||
|
mixin.Schema
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g UserMixin) Fields() []ent.Field {
|
||||||
|
if g.field != "" {
|
||||||
|
return []ent.Field{
|
||||||
|
field.UUID(g.field, uuid.UUID{}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g UserMixin) Edges() []ent.Edge {
|
||||||
|
edge := edge.From("user", User.Type).
|
||||||
|
Ref(g.ref).
|
||||||
|
Unique().
|
||||||
|
Required()
|
||||||
|
|
||||||
|
if g.field != "" {
|
||||||
|
edge = edge.Field(g.field)
|
||||||
|
}
|
||||||
|
|
||||||
|
return []ent.Edge{edge}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue