Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
report_create.go30.3 kB
// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/account" "github.com/Southclaws/storyden/internal/ent/report" "github.com/rs/xid" ) // ReportCreate is the builder for creating a Report entity. type ReportCreate struct { config mutation *ReportMutation hooks []Hook conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. func (_c *ReportCreate) SetCreatedAt(v time.Time) *ReportCreate { _c.mutation.SetCreatedAt(v) return _c } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (_c *ReportCreate) SetNillableCreatedAt(v *time.Time) *ReportCreate { if v != nil { _c.SetCreatedAt(*v) } return _c } // SetUpdatedAt sets the "updated_at" field. func (_c *ReportCreate) SetUpdatedAt(v time.Time) *ReportCreate { _c.mutation.SetUpdatedAt(v) return _c } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (_c *ReportCreate) SetNillableUpdatedAt(v *time.Time) *ReportCreate { if v != nil { _c.SetUpdatedAt(*v) } return _c } // SetTargetID sets the "target_id" field. func (_c *ReportCreate) SetTargetID(v xid.ID) *ReportCreate { _c.mutation.SetTargetID(v) return _c } // SetTargetKind sets the "target_kind" field. func (_c *ReportCreate) SetTargetKind(v string) *ReportCreate { _c.mutation.SetTargetKind(v) return _c } // SetReportedByID sets the "reported_by_id" field. func (_c *ReportCreate) SetReportedByID(v xid.ID) *ReportCreate { _c.mutation.SetReportedByID(v) return _c } // SetHandledByID sets the "handled_by_id" field. func (_c *ReportCreate) SetHandledByID(v xid.ID) *ReportCreate { _c.mutation.SetHandledByID(v) return _c } // SetNillableHandledByID sets the "handled_by_id" field if the given value is not nil. func (_c *ReportCreate) SetNillableHandledByID(v *xid.ID) *ReportCreate { if v != nil { _c.SetHandledByID(*v) } return _c } // SetComment sets the "comment" field. func (_c *ReportCreate) SetComment(v string) *ReportCreate { _c.mutation.SetComment(v) return _c } // SetNillableComment sets the "comment" field if the given value is not nil. func (_c *ReportCreate) SetNillableComment(v *string) *ReportCreate { if v != nil { _c.SetComment(*v) } return _c } // SetReason sets the "reason" field. func (_c *ReportCreate) SetReason(v string) *ReportCreate { _c.mutation.SetReason(v) return _c } // SetNillableReason sets the "reason" field if the given value is not nil. func (_c *ReportCreate) SetNillableReason(v *string) *ReportCreate { if v != nil { _c.SetReason(*v) } return _c } // SetStatus sets the "status" field. func (_c *ReportCreate) SetStatus(v string) *ReportCreate { _c.mutation.SetStatus(v) return _c } // SetNillableStatus sets the "status" field if the given value is not nil. func (_c *ReportCreate) SetNillableStatus(v *string) *ReportCreate { if v != nil { _c.SetStatus(*v) } return _c } // SetID sets the "id" field. func (_c *ReportCreate) SetID(v xid.ID) *ReportCreate { _c.mutation.SetID(v) return _c } // SetNillableID sets the "id" field if the given value is not nil. func (_c *ReportCreate) SetNillableID(v *xid.ID) *ReportCreate { if v != nil { _c.SetID(*v) } return _c } // SetReportedBy sets the "reported_by" edge to the Account entity. func (_c *ReportCreate) SetReportedBy(v *Account) *ReportCreate { return _c.SetReportedByID(v.ID) } // SetHandledBy sets the "handled_by" edge to the Account entity. func (_c *ReportCreate) SetHandledBy(v *Account) *ReportCreate { return _c.SetHandledByID(v.ID) } // Mutation returns the ReportMutation object of the builder. func (_c *ReportCreate) Mutation() *ReportMutation { return _c.mutation } // Save creates the Report in the database. func (_c *ReportCreate) Save(ctx context.Context) (*Report, error) { _c.defaults() return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. func (_c *ReportCreate) SaveX(ctx context.Context) *Report { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *ReportCreate) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *ReportCreate) ExecX(ctx context.Context) { if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (_c *ReportCreate) defaults() { if _, ok := _c.mutation.CreatedAt(); !ok { v := report.DefaultCreatedAt() _c.mutation.SetCreatedAt(v) } if _, ok := _c.mutation.UpdatedAt(); !ok { v := report.DefaultUpdatedAt() _c.mutation.SetUpdatedAt(v) } if _, ok := _c.mutation.Status(); !ok { v := report.DefaultStatus _c.mutation.SetStatus(v) } if _, ok := _c.mutation.ID(); !ok { v := report.DefaultID() _c.mutation.SetID(v) } } // check runs all checks and user-defined validators on the builder. func (_c *ReportCreate) check() error { if _, ok := _c.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Report.created_at"`)} } if _, ok := _c.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Report.updated_at"`)} } if _, ok := _c.mutation.TargetID(); !ok { return &ValidationError{Name: "target_id", err: errors.New(`ent: missing required field "Report.target_id"`)} } if _, ok := _c.mutation.TargetKind(); !ok { return &ValidationError{Name: "target_kind", err: errors.New(`ent: missing required field "Report.target_kind"`)} } if _, ok := _c.mutation.ReportedByID(); !ok { return &ValidationError{Name: "reported_by_id", err: errors.New(`ent: missing required field "Report.reported_by_id"`)} } if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Report.status"`)} } if v, ok := _c.mutation.ID(); ok { if err := report.IDValidator(v.String()); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Report.id": %w`, err)} } } if len(_c.mutation.ReportedByIDs()) == 0 { return &ValidationError{Name: "reported_by", err: errors.New(`ent: missing required edge "Report.reported_by"`)} } return nil } func (_c *ReportCreate) sqlSave(ctx context.Context) (*Report, error) { if err := _c.check(); err != nil { return nil, err } _node, _spec := _c.createSpec() if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } if _spec.ID.Value != nil { if id, ok := _spec.ID.Value.(*xid.ID); ok { _node.ID = *id } else if err := _node.ID.Scan(_spec.ID.Value); err != nil { return nil, err } } _c.mutation.id = &_node.ID _c.mutation.done = true return _node, nil } func (_c *ReportCreate) createSpec() (*Report, *sqlgraph.CreateSpec) { var ( _node = &Report{config: _c.config} _spec = sqlgraph.NewCreateSpec(report.Table, sqlgraph.NewFieldSpec(report.FieldID, field.TypeString)) ) _spec.OnConflict = _c.conflict if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = &id } if value, ok := _c.mutation.CreatedAt(); ok { _spec.SetField(report.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := _c.mutation.UpdatedAt(); ok { _spec.SetField(report.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := _c.mutation.TargetID(); ok { _spec.SetField(report.FieldTargetID, field.TypeString, value) _node.TargetID = value } if value, ok := _c.mutation.TargetKind(); ok { _spec.SetField(report.FieldTargetKind, field.TypeString, value) _node.TargetKind = value } if value, ok := _c.mutation.Comment(); ok { _spec.SetField(report.FieldComment, field.TypeString, value) _node.Comment = &value } if value, ok := _c.mutation.Reason(); ok { _spec.SetField(report.FieldReason, field.TypeString, value) _node.Reason = &value } if value, ok := _c.mutation.Status(); ok { _spec.SetField(report.FieldStatus, field.TypeString, value) _node.Status = value } if nodes := _c.mutation.ReportedByIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: report.ReportedByTable, Columns: []string{report.ReportedByColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _node.ReportedByID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.HandledByIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: report.HandledByTable, Columns: []string{report.HandledByColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _node.HandledByID = &nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.Report.Create(). // SetCreatedAt(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.ReportUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (_c *ReportCreate) OnConflict(opts ...sql.ConflictOption) *ReportUpsertOne { _c.conflict = opts return &ReportUpsertOne{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Report.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *ReportCreate) OnConflictColumns(columns ...string) *ReportUpsertOne { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &ReportUpsertOne{ create: _c, } } type ( // ReportUpsertOne is the builder for "upsert"-ing // one Report node. ReportUpsertOne struct { create *ReportCreate } // ReportUpsert is the "OnConflict" setter. ReportUpsert struct { *sql.UpdateSet } ) // SetUpdatedAt sets the "updated_at" field. func (u *ReportUpsert) SetUpdatedAt(v time.Time) *ReportUpsert { u.Set(report.FieldUpdatedAt, v) return u } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *ReportUpsert) UpdateUpdatedAt() *ReportUpsert { u.SetExcluded(report.FieldUpdatedAt) return u } // SetTargetID sets the "target_id" field. func (u *ReportUpsert) SetTargetID(v xid.ID) *ReportUpsert { u.Set(report.FieldTargetID, v) return u } // UpdateTargetID sets the "target_id" field to the value that was provided on create. func (u *ReportUpsert) UpdateTargetID() *ReportUpsert { u.SetExcluded(report.FieldTargetID) return u } // SetTargetKind sets the "target_kind" field. func (u *ReportUpsert) SetTargetKind(v string) *ReportUpsert { u.Set(report.FieldTargetKind, v) return u } // UpdateTargetKind sets the "target_kind" field to the value that was provided on create. func (u *ReportUpsert) UpdateTargetKind() *ReportUpsert { u.SetExcluded(report.FieldTargetKind) return u } // SetReportedByID sets the "reported_by_id" field. func (u *ReportUpsert) SetReportedByID(v xid.ID) *ReportUpsert { u.Set(report.FieldReportedByID, v) return u } // UpdateReportedByID sets the "reported_by_id" field to the value that was provided on create. func (u *ReportUpsert) UpdateReportedByID() *ReportUpsert { u.SetExcluded(report.FieldReportedByID) return u } // SetHandledByID sets the "handled_by_id" field. func (u *ReportUpsert) SetHandledByID(v xid.ID) *ReportUpsert { u.Set(report.FieldHandledByID, v) return u } // UpdateHandledByID sets the "handled_by_id" field to the value that was provided on create. func (u *ReportUpsert) UpdateHandledByID() *ReportUpsert { u.SetExcluded(report.FieldHandledByID) return u } // ClearHandledByID clears the value of the "handled_by_id" field. func (u *ReportUpsert) ClearHandledByID() *ReportUpsert { u.SetNull(report.FieldHandledByID) return u } // SetComment sets the "comment" field. func (u *ReportUpsert) SetComment(v string) *ReportUpsert { u.Set(report.FieldComment, v) return u } // UpdateComment sets the "comment" field to the value that was provided on create. func (u *ReportUpsert) UpdateComment() *ReportUpsert { u.SetExcluded(report.FieldComment) return u } // ClearComment clears the value of the "comment" field. func (u *ReportUpsert) ClearComment() *ReportUpsert { u.SetNull(report.FieldComment) return u } // SetReason sets the "reason" field. func (u *ReportUpsert) SetReason(v string) *ReportUpsert { u.Set(report.FieldReason, v) return u } // UpdateReason sets the "reason" field to the value that was provided on create. func (u *ReportUpsert) UpdateReason() *ReportUpsert { u.SetExcluded(report.FieldReason) return u } // ClearReason clears the value of the "reason" field. func (u *ReportUpsert) ClearReason() *ReportUpsert { u.SetNull(report.FieldReason) return u } // SetStatus sets the "status" field. func (u *ReportUpsert) SetStatus(v string) *ReportUpsert { u.Set(report.FieldStatus, v) return u } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *ReportUpsert) UpdateStatus() *ReportUpsert { u.SetExcluded(report.FieldStatus) return u } // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // // client.Report.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(report.FieldID) // }), // ). // Exec(ctx) func (u *ReportUpsertOne) UpdateNewValues() *ReportUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(report.FieldID) } if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(report.FieldCreatedAt) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Report.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *ReportUpsertOne) Ignore() *ReportUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *ReportUpsertOne) DoNothing() *ReportUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the ReportCreate.OnConflict // documentation for more info. func (u *ReportUpsertOne) Update(set func(*ReportUpsert)) *ReportUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&ReportUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *ReportUpsertOne) SetUpdatedAt(v time.Time) *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *ReportUpsertOne) UpdateUpdatedAt() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.UpdateUpdatedAt() }) } // SetTargetID sets the "target_id" field. func (u *ReportUpsertOne) SetTargetID(v xid.ID) *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.SetTargetID(v) }) } // UpdateTargetID sets the "target_id" field to the value that was provided on create. func (u *ReportUpsertOne) UpdateTargetID() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.UpdateTargetID() }) } // SetTargetKind sets the "target_kind" field. func (u *ReportUpsertOne) SetTargetKind(v string) *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.SetTargetKind(v) }) } // UpdateTargetKind sets the "target_kind" field to the value that was provided on create. func (u *ReportUpsertOne) UpdateTargetKind() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.UpdateTargetKind() }) } // SetReportedByID sets the "reported_by_id" field. func (u *ReportUpsertOne) SetReportedByID(v xid.ID) *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.SetReportedByID(v) }) } // UpdateReportedByID sets the "reported_by_id" field to the value that was provided on create. func (u *ReportUpsertOne) UpdateReportedByID() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.UpdateReportedByID() }) } // SetHandledByID sets the "handled_by_id" field. func (u *ReportUpsertOne) SetHandledByID(v xid.ID) *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.SetHandledByID(v) }) } // UpdateHandledByID sets the "handled_by_id" field to the value that was provided on create. func (u *ReportUpsertOne) UpdateHandledByID() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.UpdateHandledByID() }) } // ClearHandledByID clears the value of the "handled_by_id" field. func (u *ReportUpsertOne) ClearHandledByID() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.ClearHandledByID() }) } // SetComment sets the "comment" field. func (u *ReportUpsertOne) SetComment(v string) *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.SetComment(v) }) } // UpdateComment sets the "comment" field to the value that was provided on create. func (u *ReportUpsertOne) UpdateComment() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.UpdateComment() }) } // ClearComment clears the value of the "comment" field. func (u *ReportUpsertOne) ClearComment() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.ClearComment() }) } // SetReason sets the "reason" field. func (u *ReportUpsertOne) SetReason(v string) *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.SetReason(v) }) } // UpdateReason sets the "reason" field to the value that was provided on create. func (u *ReportUpsertOne) UpdateReason() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.UpdateReason() }) } // ClearReason clears the value of the "reason" field. func (u *ReportUpsertOne) ClearReason() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.ClearReason() }) } // SetStatus sets the "status" field. func (u *ReportUpsertOne) SetStatus(v string) *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.SetStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *ReportUpsertOne) UpdateStatus() *ReportUpsertOne { return u.Update(func(s *ReportUpsert) { s.UpdateStatus() }) } // Exec executes the query. func (u *ReportUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for ReportCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *ReportUpsertOne) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } } // Exec executes the UPSERT query and returns the inserted/updated ID. func (u *ReportUpsertOne) ID(ctx context.Context) (id xid.ID, err error) { if u.create.driver.Dialect() == dialect.MySQL { // In case of "ON CONFLICT", there is no way to get back non-numeric ID // fields from the database since MySQL does not support the RETURNING clause. return id, errors.New("ent: ReportUpsertOne.ID is not supported by MySQL driver. Use ReportUpsertOne.Exec instead") } node, err := u.create.Save(ctx) if err != nil { return id, err } return node.ID, nil } // IDX is like ID, but panics if an error occurs. func (u *ReportUpsertOne) IDX(ctx context.Context) xid.ID { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // ReportCreateBulk is the builder for creating many Report entities in bulk. type ReportCreateBulk struct { config err error builders []*ReportCreate conflict []sql.ConflictOption } // Save creates the Report entities in the database. func (_c *ReportCreateBulk) Save(ctx context.Context) ([]*Report, error) { if _c.err != nil { return nil, _c.err } specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) nodes := make([]*Report, len(_c.builders)) mutators := make([]Mutator, len(_c.builders)) for i := range _c.builders { func(i int, root context.Context) { builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*ReportMutation) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } if err := builder.check(); err != nil { return nil, err } builder.mutation = mutation var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = _c.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } } } if err != nil { return nil, err } mutation.id = &nodes[i].ID mutation.done = true return nodes[i], nil }) for i := len(builder.hooks) - 1; i >= 0; i-- { mut = builder.hooks[i](mut) } mutators[i] = mut }(i, ctx) } if len(mutators) > 0 { if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } return nodes, nil } // SaveX is like Save, but panics if an error occurs. func (_c *ReportCreateBulk) SaveX(ctx context.Context) []*Report { v, err := _c.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (_c *ReportCreateBulk) Exec(ctx context.Context) error { _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_c *ReportCreateBulk) ExecX(ctx context.Context) { if err := _c.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.Report.CreateBulk(builders...). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.ReportUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (_c *ReportCreateBulk) OnConflict(opts ...sql.ConflictOption) *ReportUpsertBulk { _c.conflict = opts return &ReportUpsertBulk{ create: _c, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Report.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (_c *ReportCreateBulk) OnConflictColumns(columns ...string) *ReportUpsertBulk { _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...)) return &ReportUpsertBulk{ create: _c, } } // ReportUpsertBulk is the builder for "upsert"-ing // a bulk of Report nodes. type ReportUpsertBulk struct { create *ReportCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.Report.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(report.FieldID) // }), // ). // Exec(ctx) func (u *ReportUpsertBulk) UpdateNewValues() *ReportUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { for _, b := range u.create.builders { if _, exists := b.mutation.ID(); exists { s.SetIgnore(report.FieldID) } if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(report.FieldCreatedAt) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Report.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *ReportUpsertBulk) Ignore() *ReportUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *ReportUpsertBulk) DoNothing() *ReportUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the ReportCreateBulk.OnConflict // documentation for more info. func (u *ReportUpsertBulk) Update(set func(*ReportUpsert)) *ReportUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&ReportUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *ReportUpsertBulk) SetUpdatedAt(v time.Time) *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *ReportUpsertBulk) UpdateUpdatedAt() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.UpdateUpdatedAt() }) } // SetTargetID sets the "target_id" field. func (u *ReportUpsertBulk) SetTargetID(v xid.ID) *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.SetTargetID(v) }) } // UpdateTargetID sets the "target_id" field to the value that was provided on create. func (u *ReportUpsertBulk) UpdateTargetID() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.UpdateTargetID() }) } // SetTargetKind sets the "target_kind" field. func (u *ReportUpsertBulk) SetTargetKind(v string) *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.SetTargetKind(v) }) } // UpdateTargetKind sets the "target_kind" field to the value that was provided on create. func (u *ReportUpsertBulk) UpdateTargetKind() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.UpdateTargetKind() }) } // SetReportedByID sets the "reported_by_id" field. func (u *ReportUpsertBulk) SetReportedByID(v xid.ID) *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.SetReportedByID(v) }) } // UpdateReportedByID sets the "reported_by_id" field to the value that was provided on create. func (u *ReportUpsertBulk) UpdateReportedByID() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.UpdateReportedByID() }) } // SetHandledByID sets the "handled_by_id" field. func (u *ReportUpsertBulk) SetHandledByID(v xid.ID) *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.SetHandledByID(v) }) } // UpdateHandledByID sets the "handled_by_id" field to the value that was provided on create. func (u *ReportUpsertBulk) UpdateHandledByID() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.UpdateHandledByID() }) } // ClearHandledByID clears the value of the "handled_by_id" field. func (u *ReportUpsertBulk) ClearHandledByID() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.ClearHandledByID() }) } // SetComment sets the "comment" field. func (u *ReportUpsertBulk) SetComment(v string) *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.SetComment(v) }) } // UpdateComment sets the "comment" field to the value that was provided on create. func (u *ReportUpsertBulk) UpdateComment() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.UpdateComment() }) } // ClearComment clears the value of the "comment" field. func (u *ReportUpsertBulk) ClearComment() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.ClearComment() }) } // SetReason sets the "reason" field. func (u *ReportUpsertBulk) SetReason(v string) *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.SetReason(v) }) } // UpdateReason sets the "reason" field to the value that was provided on create. func (u *ReportUpsertBulk) UpdateReason() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.UpdateReason() }) } // ClearReason clears the value of the "reason" field. func (u *ReportUpsertBulk) ClearReason() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.ClearReason() }) } // SetStatus sets the "status" field. func (u *ReportUpsertBulk) SetStatus(v string) *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.SetStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *ReportUpsertBulk) UpdateStatus() *ReportUpsertBulk { return u.Update(func(s *ReportUpsert) { s.UpdateStatus() }) } // Exec executes the query. func (u *ReportUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { return u.create.err } for i, b := range u.create.builders { if len(b.conflict) != 0 { return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ReportCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for ReportCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *ReportUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Southclaws/storyden'

If you have feedback or need assistance with the MCP directory API, please join our Discord server