Skip to main content
Glama

Storyden

by Southclaws
Mozilla Public License 2.0
227
event_update.go43.8 kB
// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" "github.com/Southclaws/storyden/internal/ent/asset" "github.com/Southclaws/storyden/internal/ent/event" "github.com/Southclaws/storyden/internal/ent/eventparticipant" "github.com/Southclaws/storyden/internal/ent/post" "github.com/Southclaws/storyden/internal/ent/predicate" "github.com/rs/xid" ) // EventUpdate is the builder for updating Event entities. type EventUpdate struct { config hooks []Hook mutation *EventMutation modifiers []func(*sql.UpdateBuilder) } // Where appends a list predicates to the EventUpdate builder. func (_u *EventUpdate) Where(ps ...predicate.Event) *EventUpdate { _u.mutation.Where(ps...) return _u } // SetUpdatedAt sets the "updated_at" field. func (_u *EventUpdate) SetUpdatedAt(v time.Time) *EventUpdate { _u.mutation.SetUpdatedAt(v) return _u } // SetDeletedAt sets the "deleted_at" field. func (_u *EventUpdate) SetDeletedAt(v time.Time) *EventUpdate { _u.mutation.SetDeletedAt(v) return _u } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (_u *EventUpdate) SetNillableDeletedAt(v *time.Time) *EventUpdate { if v != nil { _u.SetDeletedAt(*v) } return _u } // ClearDeletedAt clears the value of the "deleted_at" field. func (_u *EventUpdate) ClearDeletedAt() *EventUpdate { _u.mutation.ClearDeletedAt() return _u } // SetIndexedAt sets the "indexed_at" field. func (_u *EventUpdate) SetIndexedAt(v time.Time) *EventUpdate { _u.mutation.SetIndexedAt(v) return _u } // SetNillableIndexedAt sets the "indexed_at" field if the given value is not nil. func (_u *EventUpdate) SetNillableIndexedAt(v *time.Time) *EventUpdate { if v != nil { _u.SetIndexedAt(*v) } return _u } // ClearIndexedAt clears the value of the "indexed_at" field. func (_u *EventUpdate) ClearIndexedAt() *EventUpdate { _u.mutation.ClearIndexedAt() return _u } // SetName sets the "name" field. func (_u *EventUpdate) SetName(v string) *EventUpdate { _u.mutation.SetName(v) return _u } // SetNillableName sets the "name" field if the given value is not nil. func (_u *EventUpdate) SetNillableName(v *string) *EventUpdate { if v != nil { _u.SetName(*v) } return _u } // SetSlug sets the "slug" field. func (_u *EventUpdate) SetSlug(v string) *EventUpdate { _u.mutation.SetSlug(v) return _u } // SetNillableSlug sets the "slug" field if the given value is not nil. func (_u *EventUpdate) SetNillableSlug(v *string) *EventUpdate { if v != nil { _u.SetSlug(*v) } return _u } // SetDescription sets the "description" field. func (_u *EventUpdate) SetDescription(v string) *EventUpdate { _u.mutation.SetDescription(v) return _u } // SetNillableDescription sets the "description" field if the given value is not nil. func (_u *EventUpdate) SetNillableDescription(v *string) *EventUpdate { if v != nil { _u.SetDescription(*v) } return _u } // ClearDescription clears the value of the "description" field. func (_u *EventUpdate) ClearDescription() *EventUpdate { _u.mutation.ClearDescription() return _u } // SetStartTime sets the "start_time" field. func (_u *EventUpdate) SetStartTime(v time.Time) *EventUpdate { _u.mutation.SetStartTime(v) return _u } // SetNillableStartTime sets the "start_time" field if the given value is not nil. func (_u *EventUpdate) SetNillableStartTime(v *time.Time) *EventUpdate { if v != nil { _u.SetStartTime(*v) } return _u } // SetEndTime sets the "end_time" field. func (_u *EventUpdate) SetEndTime(v time.Time) *EventUpdate { _u.mutation.SetEndTime(v) return _u } // SetNillableEndTime sets the "end_time" field if the given value is not nil. func (_u *EventUpdate) SetNillableEndTime(v *time.Time) *EventUpdate { if v != nil { _u.SetEndTime(*v) } return _u } // SetParticipationPolicy sets the "participation_policy" field. func (_u *EventUpdate) SetParticipationPolicy(v string) *EventUpdate { _u.mutation.SetParticipationPolicy(v) return _u } // SetNillableParticipationPolicy sets the "participation_policy" field if the given value is not nil. func (_u *EventUpdate) SetNillableParticipationPolicy(v *string) *EventUpdate { if v != nil { _u.SetParticipationPolicy(*v) } return _u } // SetVisibility sets the "visibility" field. func (_u *EventUpdate) SetVisibility(v event.Visibility) *EventUpdate { _u.mutation.SetVisibility(v) return _u } // SetNillableVisibility sets the "visibility" field if the given value is not nil. func (_u *EventUpdate) SetNillableVisibility(v *event.Visibility) *EventUpdate { if v != nil { _u.SetVisibility(*v) } return _u } // SetLocationType sets the "location_type" field. func (_u *EventUpdate) SetLocationType(v string) *EventUpdate { _u.mutation.SetLocationType(v) return _u } // SetNillableLocationType sets the "location_type" field if the given value is not nil. func (_u *EventUpdate) SetNillableLocationType(v *string) *EventUpdate { if v != nil { _u.SetLocationType(*v) } return _u } // ClearLocationType clears the value of the "location_type" field. func (_u *EventUpdate) ClearLocationType() *EventUpdate { _u.mutation.ClearLocationType() return _u } // SetLocationName sets the "location_name" field. func (_u *EventUpdate) SetLocationName(v string) *EventUpdate { _u.mutation.SetLocationName(v) return _u } // SetNillableLocationName sets the "location_name" field if the given value is not nil. func (_u *EventUpdate) SetNillableLocationName(v *string) *EventUpdate { if v != nil { _u.SetLocationName(*v) } return _u } // ClearLocationName clears the value of the "location_name" field. func (_u *EventUpdate) ClearLocationName() *EventUpdate { _u.mutation.ClearLocationName() return _u } // SetLocationAddress sets the "location_address" field. func (_u *EventUpdate) SetLocationAddress(v string) *EventUpdate { _u.mutation.SetLocationAddress(v) return _u } // SetNillableLocationAddress sets the "location_address" field if the given value is not nil. func (_u *EventUpdate) SetNillableLocationAddress(v *string) *EventUpdate { if v != nil { _u.SetLocationAddress(*v) } return _u } // ClearLocationAddress clears the value of the "location_address" field. func (_u *EventUpdate) ClearLocationAddress() *EventUpdate { _u.mutation.ClearLocationAddress() return _u } // SetLocationLatitude sets the "location_latitude" field. func (_u *EventUpdate) SetLocationLatitude(v float64) *EventUpdate { _u.mutation.ResetLocationLatitude() _u.mutation.SetLocationLatitude(v) return _u } // SetNillableLocationLatitude sets the "location_latitude" field if the given value is not nil. func (_u *EventUpdate) SetNillableLocationLatitude(v *float64) *EventUpdate { if v != nil { _u.SetLocationLatitude(*v) } return _u } // AddLocationLatitude adds value to the "location_latitude" field. func (_u *EventUpdate) AddLocationLatitude(v float64) *EventUpdate { _u.mutation.AddLocationLatitude(v) return _u } // ClearLocationLatitude clears the value of the "location_latitude" field. func (_u *EventUpdate) ClearLocationLatitude() *EventUpdate { _u.mutation.ClearLocationLatitude() return _u } // SetLocationLongitude sets the "location_longitude" field. func (_u *EventUpdate) SetLocationLongitude(v float64) *EventUpdate { _u.mutation.ResetLocationLongitude() _u.mutation.SetLocationLongitude(v) return _u } // SetNillableLocationLongitude sets the "location_longitude" field if the given value is not nil. func (_u *EventUpdate) SetNillableLocationLongitude(v *float64) *EventUpdate { if v != nil { _u.SetLocationLongitude(*v) } return _u } // AddLocationLongitude adds value to the "location_longitude" field. func (_u *EventUpdate) AddLocationLongitude(v float64) *EventUpdate { _u.mutation.AddLocationLongitude(v) return _u } // ClearLocationLongitude clears the value of the "location_longitude" field. func (_u *EventUpdate) ClearLocationLongitude() *EventUpdate { _u.mutation.ClearLocationLongitude() return _u } // SetLocationURL sets the "location_url" field. func (_u *EventUpdate) SetLocationURL(v string) *EventUpdate { _u.mutation.SetLocationURL(v) return _u } // SetNillableLocationURL sets the "location_url" field if the given value is not nil. func (_u *EventUpdate) SetNillableLocationURL(v *string) *EventUpdate { if v != nil { _u.SetLocationURL(*v) } return _u } // ClearLocationURL clears the value of the "location_url" field. func (_u *EventUpdate) ClearLocationURL() *EventUpdate { _u.mutation.ClearLocationURL() return _u } // SetCapacity sets the "capacity" field. func (_u *EventUpdate) SetCapacity(v int) *EventUpdate { _u.mutation.ResetCapacity() _u.mutation.SetCapacity(v) return _u } // SetNillableCapacity sets the "capacity" field if the given value is not nil. func (_u *EventUpdate) SetNillableCapacity(v *int) *EventUpdate { if v != nil { _u.SetCapacity(*v) } return _u } // AddCapacity adds value to the "capacity" field. func (_u *EventUpdate) AddCapacity(v int) *EventUpdate { _u.mutation.AddCapacity(v) return _u } // ClearCapacity clears the value of the "capacity" field. func (_u *EventUpdate) ClearCapacity() *EventUpdate { _u.mutation.ClearCapacity() return _u } // SetMetadata sets the "metadata" field. func (_u *EventUpdate) SetMetadata(v map[string]interface{}) *EventUpdate { _u.mutation.SetMetadata(v) return _u } // ClearMetadata clears the value of the "metadata" field. func (_u *EventUpdate) ClearMetadata() *EventUpdate { _u.mutation.ClearMetadata() return _u } // AddParticipantIDs adds the "participants" edge to the EventParticipant entity by IDs. func (_u *EventUpdate) AddParticipantIDs(ids ...xid.ID) *EventUpdate { _u.mutation.AddParticipantIDs(ids...) return _u } // AddParticipants adds the "participants" edges to the EventParticipant entity. func (_u *EventUpdate) AddParticipants(v ...*EventParticipant) *EventUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddParticipantIDs(ids...) } // SetThreadID sets the "thread" edge to the Post entity by ID. func (_u *EventUpdate) SetThreadID(id xid.ID) *EventUpdate { _u.mutation.SetThreadID(id) return _u } // SetThread sets the "thread" edge to the Post entity. func (_u *EventUpdate) SetThread(v *Post) *EventUpdate { return _u.SetThreadID(v.ID) } // SetPrimaryImageID sets the "primary_image" edge to the Asset entity by ID. func (_u *EventUpdate) SetPrimaryImageID(id xid.ID) *EventUpdate { _u.mutation.SetPrimaryImageID(id) return _u } // SetNillablePrimaryImageID sets the "primary_image" edge to the Asset entity by ID if the given value is not nil. func (_u *EventUpdate) SetNillablePrimaryImageID(id *xid.ID) *EventUpdate { if id != nil { _u = _u.SetPrimaryImageID(*id) } return _u } // SetPrimaryImage sets the "primary_image" edge to the Asset entity. func (_u *EventUpdate) SetPrimaryImage(v *Asset) *EventUpdate { return _u.SetPrimaryImageID(v.ID) } // Mutation returns the EventMutation object of the builder. func (_u *EventUpdate) Mutation() *EventMutation { return _u.mutation } // ClearParticipants clears all "participants" edges to the EventParticipant entity. func (_u *EventUpdate) ClearParticipants() *EventUpdate { _u.mutation.ClearParticipants() return _u } // RemoveParticipantIDs removes the "participants" edge to EventParticipant entities by IDs. func (_u *EventUpdate) RemoveParticipantIDs(ids ...xid.ID) *EventUpdate { _u.mutation.RemoveParticipantIDs(ids...) return _u } // RemoveParticipants removes "participants" edges to EventParticipant entities. func (_u *EventUpdate) RemoveParticipants(v ...*EventParticipant) *EventUpdate { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveParticipantIDs(ids...) } // ClearThread clears the "thread" edge to the Post entity. func (_u *EventUpdate) ClearThread() *EventUpdate { _u.mutation.ClearThread() return _u } // ClearPrimaryImage clears the "primary_image" edge to the Asset entity. func (_u *EventUpdate) ClearPrimaryImage() *EventUpdate { _u.mutation.ClearPrimaryImage() return _u } // Save executes the query and returns the number of nodes affected by the update operation. func (_u *EventUpdate) Save(ctx context.Context) (int, error) { _u.defaults() return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *EventUpdate) SaveX(ctx context.Context) int { affected, err := _u.Save(ctx) if err != nil { panic(err) } return affected } // Exec executes the query. func (_u *EventUpdate) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *EventUpdate) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (_u *EventUpdate) defaults() { if _, ok := _u.mutation.UpdatedAt(); !ok { v := event.UpdateDefaultUpdatedAt() _u.mutation.SetUpdatedAt(v) } } // check runs all checks and user-defined validators on the builder. func (_u *EventUpdate) check() error { if v, ok := _u.mutation.Visibility(); ok { if err := event.VisibilityValidator(v); err != nil { return &ValidationError{Name: "visibility", err: fmt.Errorf(`ent: validator failed for field "Event.visibility": %w`, err)} } } if _u.mutation.ThreadCleared() && len(_u.mutation.ThreadIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Event.thread"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (_u *EventUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EventUpdate { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *EventUpdate) sqlSave(ctx context.Context) (_node int, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(event.Table, event.Columns, sqlgraph.NewFieldSpec(event.FieldID, field.TypeString)) if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.UpdatedAt(); ok { _spec.SetField(event.FieldUpdatedAt, field.TypeTime, value) } if value, ok := _u.mutation.DeletedAt(); ok { _spec.SetField(event.FieldDeletedAt, field.TypeTime, value) } if _u.mutation.DeletedAtCleared() { _spec.ClearField(event.FieldDeletedAt, field.TypeTime) } if value, ok := _u.mutation.IndexedAt(); ok { _spec.SetField(event.FieldIndexedAt, field.TypeTime, value) } if _u.mutation.IndexedAtCleared() { _spec.ClearField(event.FieldIndexedAt, field.TypeTime) } if value, ok := _u.mutation.Name(); ok { _spec.SetField(event.FieldName, field.TypeString, value) } if value, ok := _u.mutation.Slug(); ok { _spec.SetField(event.FieldSlug, field.TypeString, value) } if value, ok := _u.mutation.Description(); ok { _spec.SetField(event.FieldDescription, field.TypeString, value) } if _u.mutation.DescriptionCleared() { _spec.ClearField(event.FieldDescription, field.TypeString) } if value, ok := _u.mutation.StartTime(); ok { _spec.SetField(event.FieldStartTime, field.TypeTime, value) } if value, ok := _u.mutation.EndTime(); ok { _spec.SetField(event.FieldEndTime, field.TypeTime, value) } if value, ok := _u.mutation.ParticipationPolicy(); ok { _spec.SetField(event.FieldParticipationPolicy, field.TypeString, value) } if value, ok := _u.mutation.Visibility(); ok { _spec.SetField(event.FieldVisibility, field.TypeEnum, value) } if value, ok := _u.mutation.LocationType(); ok { _spec.SetField(event.FieldLocationType, field.TypeString, value) } if _u.mutation.LocationTypeCleared() { _spec.ClearField(event.FieldLocationType, field.TypeString) } if value, ok := _u.mutation.LocationName(); ok { _spec.SetField(event.FieldLocationName, field.TypeString, value) } if _u.mutation.LocationNameCleared() { _spec.ClearField(event.FieldLocationName, field.TypeString) } if value, ok := _u.mutation.LocationAddress(); ok { _spec.SetField(event.FieldLocationAddress, field.TypeString, value) } if _u.mutation.LocationAddressCleared() { _spec.ClearField(event.FieldLocationAddress, field.TypeString) } if value, ok := _u.mutation.LocationLatitude(); ok { _spec.SetField(event.FieldLocationLatitude, field.TypeFloat64, value) } if value, ok := _u.mutation.AddedLocationLatitude(); ok { _spec.AddField(event.FieldLocationLatitude, field.TypeFloat64, value) } if _u.mutation.LocationLatitudeCleared() { _spec.ClearField(event.FieldLocationLatitude, field.TypeFloat64) } if value, ok := _u.mutation.LocationLongitude(); ok { _spec.SetField(event.FieldLocationLongitude, field.TypeFloat64, value) } if value, ok := _u.mutation.AddedLocationLongitude(); ok { _spec.AddField(event.FieldLocationLongitude, field.TypeFloat64, value) } if _u.mutation.LocationLongitudeCleared() { _spec.ClearField(event.FieldLocationLongitude, field.TypeFloat64) } if value, ok := _u.mutation.LocationURL(); ok { _spec.SetField(event.FieldLocationURL, field.TypeString, value) } if _u.mutation.LocationURLCleared() { _spec.ClearField(event.FieldLocationURL, field.TypeString) } if value, ok := _u.mutation.Capacity(); ok { _spec.SetField(event.FieldCapacity, field.TypeInt, value) } if value, ok := _u.mutation.AddedCapacity(); ok { _spec.AddField(event.FieldCapacity, field.TypeInt, value) } if _u.mutation.CapacityCleared() { _spec.ClearField(event.FieldCapacity, field.TypeInt) } if value, ok := _u.mutation.Metadata(); ok { _spec.SetField(event.FieldMetadata, field.TypeJSON, value) } if _u.mutation.MetadataCleared() { _spec.ClearField(event.FieldMetadata, field.TypeJSON) } if _u.mutation.ParticipantsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: event.ParticipantsTable, Columns: []string{event.ParticipantsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(eventparticipant.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedParticipantsIDs(); len(nodes) > 0 && !_u.mutation.ParticipantsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: event.ParticipantsTable, Columns: []string{event.ParticipantsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(eventparticipant.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ParticipantsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: event.ParticipantsTable, Columns: []string{event.ParticipantsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(eventparticipant.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ThreadCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: event.ThreadTable, Columns: []string{event.ThreadColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ThreadIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: event.ThreadTable, Columns: []string{event.ThreadColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PrimaryImageCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: event.PrimaryImageTable, Columns: []string{event.PrimaryImageColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.PrimaryImageIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: event.PrimaryImageTable, Columns: []string{event.PrimaryImageColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{event.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return 0, err } _u.mutation.done = true return _node, nil } // EventUpdateOne is the builder for updating a single Event entity. type EventUpdateOne struct { config fields []string hooks []Hook mutation *EventMutation modifiers []func(*sql.UpdateBuilder) } // SetUpdatedAt sets the "updated_at" field. func (_u *EventUpdateOne) SetUpdatedAt(v time.Time) *EventUpdateOne { _u.mutation.SetUpdatedAt(v) return _u } // SetDeletedAt sets the "deleted_at" field. func (_u *EventUpdateOne) SetDeletedAt(v time.Time) *EventUpdateOne { _u.mutation.SetDeletedAt(v) return _u } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableDeletedAt(v *time.Time) *EventUpdateOne { if v != nil { _u.SetDeletedAt(*v) } return _u } // ClearDeletedAt clears the value of the "deleted_at" field. func (_u *EventUpdateOne) ClearDeletedAt() *EventUpdateOne { _u.mutation.ClearDeletedAt() return _u } // SetIndexedAt sets the "indexed_at" field. func (_u *EventUpdateOne) SetIndexedAt(v time.Time) *EventUpdateOne { _u.mutation.SetIndexedAt(v) return _u } // SetNillableIndexedAt sets the "indexed_at" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableIndexedAt(v *time.Time) *EventUpdateOne { if v != nil { _u.SetIndexedAt(*v) } return _u } // ClearIndexedAt clears the value of the "indexed_at" field. func (_u *EventUpdateOne) ClearIndexedAt() *EventUpdateOne { _u.mutation.ClearIndexedAt() return _u } // SetName sets the "name" field. func (_u *EventUpdateOne) SetName(v string) *EventUpdateOne { _u.mutation.SetName(v) return _u } // SetNillableName sets the "name" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableName(v *string) *EventUpdateOne { if v != nil { _u.SetName(*v) } return _u } // SetSlug sets the "slug" field. func (_u *EventUpdateOne) SetSlug(v string) *EventUpdateOne { _u.mutation.SetSlug(v) return _u } // SetNillableSlug sets the "slug" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableSlug(v *string) *EventUpdateOne { if v != nil { _u.SetSlug(*v) } return _u } // SetDescription sets the "description" field. func (_u *EventUpdateOne) SetDescription(v string) *EventUpdateOne { _u.mutation.SetDescription(v) return _u } // SetNillableDescription sets the "description" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableDescription(v *string) *EventUpdateOne { if v != nil { _u.SetDescription(*v) } return _u } // ClearDescription clears the value of the "description" field. func (_u *EventUpdateOne) ClearDescription() *EventUpdateOne { _u.mutation.ClearDescription() return _u } // SetStartTime sets the "start_time" field. func (_u *EventUpdateOne) SetStartTime(v time.Time) *EventUpdateOne { _u.mutation.SetStartTime(v) return _u } // SetNillableStartTime sets the "start_time" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableStartTime(v *time.Time) *EventUpdateOne { if v != nil { _u.SetStartTime(*v) } return _u } // SetEndTime sets the "end_time" field. func (_u *EventUpdateOne) SetEndTime(v time.Time) *EventUpdateOne { _u.mutation.SetEndTime(v) return _u } // SetNillableEndTime sets the "end_time" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableEndTime(v *time.Time) *EventUpdateOne { if v != nil { _u.SetEndTime(*v) } return _u } // SetParticipationPolicy sets the "participation_policy" field. func (_u *EventUpdateOne) SetParticipationPolicy(v string) *EventUpdateOne { _u.mutation.SetParticipationPolicy(v) return _u } // SetNillableParticipationPolicy sets the "participation_policy" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableParticipationPolicy(v *string) *EventUpdateOne { if v != nil { _u.SetParticipationPolicy(*v) } return _u } // SetVisibility sets the "visibility" field. func (_u *EventUpdateOne) SetVisibility(v event.Visibility) *EventUpdateOne { _u.mutation.SetVisibility(v) return _u } // SetNillableVisibility sets the "visibility" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableVisibility(v *event.Visibility) *EventUpdateOne { if v != nil { _u.SetVisibility(*v) } return _u } // SetLocationType sets the "location_type" field. func (_u *EventUpdateOne) SetLocationType(v string) *EventUpdateOne { _u.mutation.SetLocationType(v) return _u } // SetNillableLocationType sets the "location_type" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableLocationType(v *string) *EventUpdateOne { if v != nil { _u.SetLocationType(*v) } return _u } // ClearLocationType clears the value of the "location_type" field. func (_u *EventUpdateOne) ClearLocationType() *EventUpdateOne { _u.mutation.ClearLocationType() return _u } // SetLocationName sets the "location_name" field. func (_u *EventUpdateOne) SetLocationName(v string) *EventUpdateOne { _u.mutation.SetLocationName(v) return _u } // SetNillableLocationName sets the "location_name" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableLocationName(v *string) *EventUpdateOne { if v != nil { _u.SetLocationName(*v) } return _u } // ClearLocationName clears the value of the "location_name" field. func (_u *EventUpdateOne) ClearLocationName() *EventUpdateOne { _u.mutation.ClearLocationName() return _u } // SetLocationAddress sets the "location_address" field. func (_u *EventUpdateOne) SetLocationAddress(v string) *EventUpdateOne { _u.mutation.SetLocationAddress(v) return _u } // SetNillableLocationAddress sets the "location_address" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableLocationAddress(v *string) *EventUpdateOne { if v != nil { _u.SetLocationAddress(*v) } return _u } // ClearLocationAddress clears the value of the "location_address" field. func (_u *EventUpdateOne) ClearLocationAddress() *EventUpdateOne { _u.mutation.ClearLocationAddress() return _u } // SetLocationLatitude sets the "location_latitude" field. func (_u *EventUpdateOne) SetLocationLatitude(v float64) *EventUpdateOne { _u.mutation.ResetLocationLatitude() _u.mutation.SetLocationLatitude(v) return _u } // SetNillableLocationLatitude sets the "location_latitude" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableLocationLatitude(v *float64) *EventUpdateOne { if v != nil { _u.SetLocationLatitude(*v) } return _u } // AddLocationLatitude adds value to the "location_latitude" field. func (_u *EventUpdateOne) AddLocationLatitude(v float64) *EventUpdateOne { _u.mutation.AddLocationLatitude(v) return _u } // ClearLocationLatitude clears the value of the "location_latitude" field. func (_u *EventUpdateOne) ClearLocationLatitude() *EventUpdateOne { _u.mutation.ClearLocationLatitude() return _u } // SetLocationLongitude sets the "location_longitude" field. func (_u *EventUpdateOne) SetLocationLongitude(v float64) *EventUpdateOne { _u.mutation.ResetLocationLongitude() _u.mutation.SetLocationLongitude(v) return _u } // SetNillableLocationLongitude sets the "location_longitude" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableLocationLongitude(v *float64) *EventUpdateOne { if v != nil { _u.SetLocationLongitude(*v) } return _u } // AddLocationLongitude adds value to the "location_longitude" field. func (_u *EventUpdateOne) AddLocationLongitude(v float64) *EventUpdateOne { _u.mutation.AddLocationLongitude(v) return _u } // ClearLocationLongitude clears the value of the "location_longitude" field. func (_u *EventUpdateOne) ClearLocationLongitude() *EventUpdateOne { _u.mutation.ClearLocationLongitude() return _u } // SetLocationURL sets the "location_url" field. func (_u *EventUpdateOne) SetLocationURL(v string) *EventUpdateOne { _u.mutation.SetLocationURL(v) return _u } // SetNillableLocationURL sets the "location_url" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableLocationURL(v *string) *EventUpdateOne { if v != nil { _u.SetLocationURL(*v) } return _u } // ClearLocationURL clears the value of the "location_url" field. func (_u *EventUpdateOne) ClearLocationURL() *EventUpdateOne { _u.mutation.ClearLocationURL() return _u } // SetCapacity sets the "capacity" field. func (_u *EventUpdateOne) SetCapacity(v int) *EventUpdateOne { _u.mutation.ResetCapacity() _u.mutation.SetCapacity(v) return _u } // SetNillableCapacity sets the "capacity" field if the given value is not nil. func (_u *EventUpdateOne) SetNillableCapacity(v *int) *EventUpdateOne { if v != nil { _u.SetCapacity(*v) } return _u } // AddCapacity adds value to the "capacity" field. func (_u *EventUpdateOne) AddCapacity(v int) *EventUpdateOne { _u.mutation.AddCapacity(v) return _u } // ClearCapacity clears the value of the "capacity" field. func (_u *EventUpdateOne) ClearCapacity() *EventUpdateOne { _u.mutation.ClearCapacity() return _u } // SetMetadata sets the "metadata" field. func (_u *EventUpdateOne) SetMetadata(v map[string]interface{}) *EventUpdateOne { _u.mutation.SetMetadata(v) return _u } // ClearMetadata clears the value of the "metadata" field. func (_u *EventUpdateOne) ClearMetadata() *EventUpdateOne { _u.mutation.ClearMetadata() return _u } // AddParticipantIDs adds the "participants" edge to the EventParticipant entity by IDs. func (_u *EventUpdateOne) AddParticipantIDs(ids ...xid.ID) *EventUpdateOne { _u.mutation.AddParticipantIDs(ids...) return _u } // AddParticipants adds the "participants" edges to the EventParticipant entity. func (_u *EventUpdateOne) AddParticipants(v ...*EventParticipant) *EventUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.AddParticipantIDs(ids...) } // SetThreadID sets the "thread" edge to the Post entity by ID. func (_u *EventUpdateOne) SetThreadID(id xid.ID) *EventUpdateOne { _u.mutation.SetThreadID(id) return _u } // SetThread sets the "thread" edge to the Post entity. func (_u *EventUpdateOne) SetThread(v *Post) *EventUpdateOne { return _u.SetThreadID(v.ID) } // SetPrimaryImageID sets the "primary_image" edge to the Asset entity by ID. func (_u *EventUpdateOne) SetPrimaryImageID(id xid.ID) *EventUpdateOne { _u.mutation.SetPrimaryImageID(id) return _u } // SetNillablePrimaryImageID sets the "primary_image" edge to the Asset entity by ID if the given value is not nil. func (_u *EventUpdateOne) SetNillablePrimaryImageID(id *xid.ID) *EventUpdateOne { if id != nil { _u = _u.SetPrimaryImageID(*id) } return _u } // SetPrimaryImage sets the "primary_image" edge to the Asset entity. func (_u *EventUpdateOne) SetPrimaryImage(v *Asset) *EventUpdateOne { return _u.SetPrimaryImageID(v.ID) } // Mutation returns the EventMutation object of the builder. func (_u *EventUpdateOne) Mutation() *EventMutation { return _u.mutation } // ClearParticipants clears all "participants" edges to the EventParticipant entity. func (_u *EventUpdateOne) ClearParticipants() *EventUpdateOne { _u.mutation.ClearParticipants() return _u } // RemoveParticipantIDs removes the "participants" edge to EventParticipant entities by IDs. func (_u *EventUpdateOne) RemoveParticipantIDs(ids ...xid.ID) *EventUpdateOne { _u.mutation.RemoveParticipantIDs(ids...) return _u } // RemoveParticipants removes "participants" edges to EventParticipant entities. func (_u *EventUpdateOne) RemoveParticipants(v ...*EventParticipant) *EventUpdateOne { ids := make([]xid.ID, len(v)) for i := range v { ids[i] = v[i].ID } return _u.RemoveParticipantIDs(ids...) } // ClearThread clears the "thread" edge to the Post entity. func (_u *EventUpdateOne) ClearThread() *EventUpdateOne { _u.mutation.ClearThread() return _u } // ClearPrimaryImage clears the "primary_image" edge to the Asset entity. func (_u *EventUpdateOne) ClearPrimaryImage() *EventUpdateOne { _u.mutation.ClearPrimaryImage() return _u } // Where appends a list predicates to the EventUpdate builder. func (_u *EventUpdateOne) Where(ps ...predicate.Event) *EventUpdateOne { _u.mutation.Where(ps...) return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (_u *EventUpdateOne) Select(field string, fields ...string) *EventUpdateOne { _u.fields = append([]string{field}, fields...) return _u } // Save executes the query and returns the updated Event entity. func (_u *EventUpdateOne) Save(ctx context.Context) (*Event, error) { _u.defaults() return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. func (_u *EventUpdateOne) SaveX(ctx context.Context) *Event { node, err := _u.Save(ctx) if err != nil { panic(err) } return node } // Exec executes the query on the entity. func (_u *EventUpdateOne) Exec(ctx context.Context) error { _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (_u *EventUpdateOne) ExecX(ctx context.Context) { if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (_u *EventUpdateOne) defaults() { if _, ok := _u.mutation.UpdatedAt(); !ok { v := event.UpdateDefaultUpdatedAt() _u.mutation.SetUpdatedAt(v) } } // check runs all checks and user-defined validators on the builder. func (_u *EventUpdateOne) check() error { if v, ok := _u.mutation.Visibility(); ok { if err := event.VisibilityValidator(v); err != nil { return &ValidationError{Name: "visibility", err: fmt.Errorf(`ent: validator failed for field "Event.visibility": %w`, err)} } } if _u.mutation.ThreadCleared() && len(_u.mutation.ThreadIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Event.thread"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. func (_u *EventUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *EventUpdateOne { _u.modifiers = append(_u.modifiers, modifiers...) return _u } func (_u *EventUpdateOne) sqlSave(ctx context.Context) (_node *Event, err error) { if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(event.Table, event.Columns, sqlgraph.NewFieldSpec(event.FieldID, field.TypeString)) id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Event.id" for update`)} } _spec.Node.ID.Value = id if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, event.FieldID) for _, f := range fields { if !event.ValidColumn(f) { return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } if f != event.FieldID { _spec.Node.Columns = append(_spec.Node.Columns, f) } } } if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } if value, ok := _u.mutation.UpdatedAt(); ok { _spec.SetField(event.FieldUpdatedAt, field.TypeTime, value) } if value, ok := _u.mutation.DeletedAt(); ok { _spec.SetField(event.FieldDeletedAt, field.TypeTime, value) } if _u.mutation.DeletedAtCleared() { _spec.ClearField(event.FieldDeletedAt, field.TypeTime) } if value, ok := _u.mutation.IndexedAt(); ok { _spec.SetField(event.FieldIndexedAt, field.TypeTime, value) } if _u.mutation.IndexedAtCleared() { _spec.ClearField(event.FieldIndexedAt, field.TypeTime) } if value, ok := _u.mutation.Name(); ok { _spec.SetField(event.FieldName, field.TypeString, value) } if value, ok := _u.mutation.Slug(); ok { _spec.SetField(event.FieldSlug, field.TypeString, value) } if value, ok := _u.mutation.Description(); ok { _spec.SetField(event.FieldDescription, field.TypeString, value) } if _u.mutation.DescriptionCleared() { _spec.ClearField(event.FieldDescription, field.TypeString) } if value, ok := _u.mutation.StartTime(); ok { _spec.SetField(event.FieldStartTime, field.TypeTime, value) } if value, ok := _u.mutation.EndTime(); ok { _spec.SetField(event.FieldEndTime, field.TypeTime, value) } if value, ok := _u.mutation.ParticipationPolicy(); ok { _spec.SetField(event.FieldParticipationPolicy, field.TypeString, value) } if value, ok := _u.mutation.Visibility(); ok { _spec.SetField(event.FieldVisibility, field.TypeEnum, value) } if value, ok := _u.mutation.LocationType(); ok { _spec.SetField(event.FieldLocationType, field.TypeString, value) } if _u.mutation.LocationTypeCleared() { _spec.ClearField(event.FieldLocationType, field.TypeString) } if value, ok := _u.mutation.LocationName(); ok { _spec.SetField(event.FieldLocationName, field.TypeString, value) } if _u.mutation.LocationNameCleared() { _spec.ClearField(event.FieldLocationName, field.TypeString) } if value, ok := _u.mutation.LocationAddress(); ok { _spec.SetField(event.FieldLocationAddress, field.TypeString, value) } if _u.mutation.LocationAddressCleared() { _spec.ClearField(event.FieldLocationAddress, field.TypeString) } if value, ok := _u.mutation.LocationLatitude(); ok { _spec.SetField(event.FieldLocationLatitude, field.TypeFloat64, value) } if value, ok := _u.mutation.AddedLocationLatitude(); ok { _spec.AddField(event.FieldLocationLatitude, field.TypeFloat64, value) } if _u.mutation.LocationLatitudeCleared() { _spec.ClearField(event.FieldLocationLatitude, field.TypeFloat64) } if value, ok := _u.mutation.LocationLongitude(); ok { _spec.SetField(event.FieldLocationLongitude, field.TypeFloat64, value) } if value, ok := _u.mutation.AddedLocationLongitude(); ok { _spec.AddField(event.FieldLocationLongitude, field.TypeFloat64, value) } if _u.mutation.LocationLongitudeCleared() { _spec.ClearField(event.FieldLocationLongitude, field.TypeFloat64) } if value, ok := _u.mutation.LocationURL(); ok { _spec.SetField(event.FieldLocationURL, field.TypeString, value) } if _u.mutation.LocationURLCleared() { _spec.ClearField(event.FieldLocationURL, field.TypeString) } if value, ok := _u.mutation.Capacity(); ok { _spec.SetField(event.FieldCapacity, field.TypeInt, value) } if value, ok := _u.mutation.AddedCapacity(); ok { _spec.AddField(event.FieldCapacity, field.TypeInt, value) } if _u.mutation.CapacityCleared() { _spec.ClearField(event.FieldCapacity, field.TypeInt) } if value, ok := _u.mutation.Metadata(); ok { _spec.SetField(event.FieldMetadata, field.TypeJSON, value) } if _u.mutation.MetadataCleared() { _spec.ClearField(event.FieldMetadata, field.TypeJSON) } if _u.mutation.ParticipantsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: event.ParticipantsTable, Columns: []string{event.ParticipantsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(eventparticipant.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedParticipantsIDs(); len(nodes) > 0 && !_u.mutation.ParticipantsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: event.ParticipantsTable, Columns: []string{event.ParticipantsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(eventparticipant.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ParticipantsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, Table: event.ParticipantsTable, Columns: []string{event.ParticipantsColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(eventparticipant.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ThreadCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: event.ThreadTable, Columns: []string{event.ThreadColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ThreadIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: event.ThreadTable, Columns: []string{event.ThreadColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(post.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PrimaryImageCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: event.PrimaryImageTable, Columns: []string{event.PrimaryImageColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.PrimaryImageIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: event.PrimaryImageTable, Columns: []string{event.PrimaryImageColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(asset.FieldID, field.TypeString), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(_u.modifiers...) _node = &Event{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{event.Label} } else if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } _u.mutation.done = true return _node, nil }

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