[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
398
backend/ent/contributorrole_update.go
Normal file
398
backend/ent/contributorrole_update.go
Normal file
|
@ -0,0 +1,398 @@
|
|||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"tss-rocks-be/ent/contributorrole"
|
||||
"tss-rocks-be/ent/postcontributor"
|
||||
"tss-rocks-be/ent/predicate"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
)
|
||||
|
||||
// ContributorRoleUpdate is the builder for updating ContributorRole entities.
|
||||
type ContributorRoleUpdate struct {
|
||||
config
|
||||
hooks []Hook
|
||||
mutation *ContributorRoleMutation
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ContributorRoleUpdate builder.
|
||||
func (cru *ContributorRoleUpdate) Where(ps ...predicate.ContributorRole) *ContributorRoleUpdate {
|
||||
cru.mutation.Where(ps...)
|
||||
return cru
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (cru *ContributorRoleUpdate) SetName(s string) *ContributorRoleUpdate {
|
||||
cru.mutation.SetName(s)
|
||||
return cru
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (cru *ContributorRoleUpdate) SetNillableName(s *string) *ContributorRoleUpdate {
|
||||
if s != nil {
|
||||
cru.SetName(*s)
|
||||
}
|
||||
return cru
|
||||
}
|
||||
|
||||
// AddPostContributorIDs adds the "post_contributors" edge to the PostContributor entity by IDs.
|
||||
func (cru *ContributorRoleUpdate) AddPostContributorIDs(ids ...int) *ContributorRoleUpdate {
|
||||
cru.mutation.AddPostContributorIDs(ids...)
|
||||
return cru
|
||||
}
|
||||
|
||||
// AddPostContributors adds the "post_contributors" edges to the PostContributor entity.
|
||||
func (cru *ContributorRoleUpdate) AddPostContributors(p ...*PostContributor) *ContributorRoleUpdate {
|
||||
ids := make([]int, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
return cru.AddPostContributorIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ContributorRoleMutation object of the builder.
|
||||
func (cru *ContributorRoleUpdate) Mutation() *ContributorRoleMutation {
|
||||
return cru.mutation
|
||||
}
|
||||
|
||||
// ClearPostContributors clears all "post_contributors" edges to the PostContributor entity.
|
||||
func (cru *ContributorRoleUpdate) ClearPostContributors() *ContributorRoleUpdate {
|
||||
cru.mutation.ClearPostContributors()
|
||||
return cru
|
||||
}
|
||||
|
||||
// RemovePostContributorIDs removes the "post_contributors" edge to PostContributor entities by IDs.
|
||||
func (cru *ContributorRoleUpdate) RemovePostContributorIDs(ids ...int) *ContributorRoleUpdate {
|
||||
cru.mutation.RemovePostContributorIDs(ids...)
|
||||
return cru
|
||||
}
|
||||
|
||||
// RemovePostContributors removes "post_contributors" edges to PostContributor entities.
|
||||
func (cru *ContributorRoleUpdate) RemovePostContributors(p ...*PostContributor) *ContributorRoleUpdate {
|
||||
ids := make([]int, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
return cru.RemovePostContributorIDs(ids...)
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (cru *ContributorRoleUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, cru.sqlSave, cru.mutation, cru.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cru *ContributorRoleUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := cru.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return affected
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (cru *ContributorRoleUpdate) Exec(ctx context.Context) error {
|
||||
_, err := cru.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cru *ContributorRoleUpdate) ExecX(ctx context.Context) {
|
||||
if err := cru.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cru *ContributorRoleUpdate) check() error {
|
||||
if v, ok := cru.mutation.Name(); ok {
|
||||
if err := contributorrole.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ContributorRole.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cru *ContributorRoleUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
if err := cru.check(); err != nil {
|
||||
return n, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(contributorrole.Table, contributorrole.Columns, sqlgraph.NewFieldSpec(contributorrole.FieldID, field.TypeInt))
|
||||
if ps := cru.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cru.mutation.Name(); ok {
|
||||
_spec.SetField(contributorrole.FieldName, field.TypeString, value)
|
||||
}
|
||||
if cru.mutation.PostContributorsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: contributorrole.PostContributorsTable,
|
||||
Columns: []string{contributorrole.PostContributorsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cru.mutation.RemovedPostContributorsIDs(); len(nodes) > 0 && !cru.mutation.PostContributorsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: contributorrole.PostContributorsTable,
|
||||
Columns: []string{contributorrole.PostContributorsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cru.mutation.PostContributorsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: contributorrole.PostContributorsTable,
|
||||
Columns: []string{contributorrole.PostContributorsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
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, cru.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{contributorrole.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
cru.mutation.done = true
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// ContributorRoleUpdateOne is the builder for updating a single ContributorRole entity.
|
||||
type ContributorRoleUpdateOne struct {
|
||||
config
|
||||
fields []string
|
||||
hooks []Hook
|
||||
mutation *ContributorRoleMutation
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (cruo *ContributorRoleUpdateOne) SetName(s string) *ContributorRoleUpdateOne {
|
||||
cruo.mutation.SetName(s)
|
||||
return cruo
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (cruo *ContributorRoleUpdateOne) SetNillableName(s *string) *ContributorRoleUpdateOne {
|
||||
if s != nil {
|
||||
cruo.SetName(*s)
|
||||
}
|
||||
return cruo
|
||||
}
|
||||
|
||||
// AddPostContributorIDs adds the "post_contributors" edge to the PostContributor entity by IDs.
|
||||
func (cruo *ContributorRoleUpdateOne) AddPostContributorIDs(ids ...int) *ContributorRoleUpdateOne {
|
||||
cruo.mutation.AddPostContributorIDs(ids...)
|
||||
return cruo
|
||||
}
|
||||
|
||||
// AddPostContributors adds the "post_contributors" edges to the PostContributor entity.
|
||||
func (cruo *ContributorRoleUpdateOne) AddPostContributors(p ...*PostContributor) *ContributorRoleUpdateOne {
|
||||
ids := make([]int, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
return cruo.AddPostContributorIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the ContributorRoleMutation object of the builder.
|
||||
func (cruo *ContributorRoleUpdateOne) Mutation() *ContributorRoleMutation {
|
||||
return cruo.mutation
|
||||
}
|
||||
|
||||
// ClearPostContributors clears all "post_contributors" edges to the PostContributor entity.
|
||||
func (cruo *ContributorRoleUpdateOne) ClearPostContributors() *ContributorRoleUpdateOne {
|
||||
cruo.mutation.ClearPostContributors()
|
||||
return cruo
|
||||
}
|
||||
|
||||
// RemovePostContributorIDs removes the "post_contributors" edge to PostContributor entities by IDs.
|
||||
func (cruo *ContributorRoleUpdateOne) RemovePostContributorIDs(ids ...int) *ContributorRoleUpdateOne {
|
||||
cruo.mutation.RemovePostContributorIDs(ids...)
|
||||
return cruo
|
||||
}
|
||||
|
||||
// RemovePostContributors removes "post_contributors" edges to PostContributor entities.
|
||||
func (cruo *ContributorRoleUpdateOne) RemovePostContributors(p ...*PostContributor) *ContributorRoleUpdateOne {
|
||||
ids := make([]int, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
}
|
||||
return cruo.RemovePostContributorIDs(ids...)
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the ContributorRoleUpdate builder.
|
||||
func (cruo *ContributorRoleUpdateOne) Where(ps ...predicate.ContributorRole) *ContributorRoleUpdateOne {
|
||||
cruo.mutation.Where(ps...)
|
||||
return cruo
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (cruo *ContributorRoleUpdateOne) Select(field string, fields ...string) *ContributorRoleUpdateOne {
|
||||
cruo.fields = append([]string{field}, fields...)
|
||||
return cruo
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated ContributorRole entity.
|
||||
func (cruo *ContributorRoleUpdateOne) Save(ctx context.Context) (*ContributorRole, error) {
|
||||
return withHooks(ctx, cruo.sqlSave, cruo.mutation, cruo.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (cruo *ContributorRoleUpdateOne) SaveX(ctx context.Context) *ContributorRole {
|
||||
node, err := cruo.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (cruo *ContributorRoleUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := cruo.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (cruo *ContributorRoleUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := cruo.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (cruo *ContributorRoleUpdateOne) check() error {
|
||||
if v, ok := cruo.mutation.Name(); ok {
|
||||
if err := contributorrole.NameValidator(v); err != nil {
|
||||
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "ContributorRole.name": %w`, err)}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cruo *ContributorRoleUpdateOne) sqlSave(ctx context.Context) (_node *ContributorRole, err error) {
|
||||
if err := cruo.check(); err != nil {
|
||||
return _node, err
|
||||
}
|
||||
_spec := sqlgraph.NewUpdateSpec(contributorrole.Table, contributorrole.Columns, sqlgraph.NewFieldSpec(contributorrole.FieldID, field.TypeInt))
|
||||
id, ok := cruo.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ContributorRole.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := cruo.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, contributorrole.FieldID)
|
||||
for _, f := range fields {
|
||||
if !contributorrole.ValidColumn(f) {
|
||||
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
if f != contributorrole.FieldID {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := cruo.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := cruo.mutation.Name(); ok {
|
||||
_spec.SetField(contributorrole.FieldName, field.TypeString, value)
|
||||
}
|
||||
if cruo.mutation.PostContributorsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: contributorrole.PostContributorsTable,
|
||||
Columns: []string{contributorrole.PostContributorsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cruo.mutation.RemovedPostContributorsIDs(); len(nodes) > 0 && !cruo.mutation.PostContributorsCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: contributorrole.PostContributorsTable,
|
||||
Columns: []string{contributorrole.PostContributorsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := cruo.mutation.PostContributorsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
Table: contributorrole.PostContributorsTable,
|
||||
Columns: []string{contributorrole.PostContributorsColumn},
|
||||
Bidi: false,
|
||||
Target: &sqlgraph.EdgeTarget{
|
||||
IDSpec: sqlgraph.NewFieldSpec(postcontributor.FieldID, field.TypeInt),
|
||||
},
|
||||
}
|
||||
for _, k := range nodes {
|
||||
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_node = &ContributorRole{config: cruo.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, cruo.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{contributorrole.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
cruo.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue