refactor schema edges

This commit is contained in:
Hayden 2023-03-06 11:43:56 -09:00
parent ccd40ffcac
commit 883468e04c
No known key found for this signature in database
GPG key ID: 17CF79474E257545
12 changed files with 499 additions and 460 deletions

View file

@ -17,29 +17,22 @@ const (
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"
// FieldGroupID holds the string denoting the group_id field in the database.
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 = "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"
// EdgeGroup holds the string denoting the group edge name in mutations.
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 = "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 = "notifiers"
// GroupInverseTable is the table name for the Group entity.
@ -47,6 +40,13 @@ const (
GroupInverseTable = "groups"
// GroupColumn is the table column denoting the group relation/edge.
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.
@ -54,8 +54,8 @@ var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldUserID,
FieldGroupID,
FieldUserID,
FieldName,
FieldURL,
FieldIsActive,

View file

@ -66,16 +66,16 @@ 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))
}
// GroupID applies equality check predicate on the "group_id" field. It's identical to GroupIDEQ.
func GroupID(v uuid.UUID) predicate.Notifier {
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.
func Name(v string) predicate.Notifier {
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))
}
// 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.
func GroupIDEQ(v uuid.UUID) predicate.Notifier {
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...))
}
// 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))
@ -351,33 +351,6 @@ 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)
}
})
})
}
// HasGroup applies the HasEdge predicate on the "group" edge.
func HasGroup() predicate.Notifier {
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.
func And(predicates ...predicate.Notifier) predicate.Notifier {
return predicate.Notifier(func(s *sql.Selector) {