mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 23:21:00 +08:00
619 lines
18 KiB
Go
619 lines
18 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"polaris/ent/episode"
|
|
"polaris/ent/media"
|
|
"polaris/ent/predicate"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
)
|
|
|
|
// EpisodeUpdate is the builder for updating Episode entities.
|
|
type EpisodeUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *EpisodeMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the EpisodeUpdate builder.
|
|
func (eu *EpisodeUpdate) Where(ps ...predicate.Episode) *EpisodeUpdate {
|
|
eu.mutation.Where(ps...)
|
|
return eu
|
|
}
|
|
|
|
// SetMediaID sets the "media_id" field.
|
|
func (eu *EpisodeUpdate) SetMediaID(i int) *EpisodeUpdate {
|
|
eu.mutation.SetMediaID(i)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableMediaID sets the "media_id" field if the given value is not nil.
|
|
func (eu *EpisodeUpdate) SetNillableMediaID(i *int) *EpisodeUpdate {
|
|
if i != nil {
|
|
eu.SetMediaID(*i)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearMediaID clears the value of the "media_id" field.
|
|
func (eu *EpisodeUpdate) ClearMediaID() *EpisodeUpdate {
|
|
eu.mutation.ClearMediaID()
|
|
return eu
|
|
}
|
|
|
|
// SetSeasonNumber sets the "season_number" field.
|
|
func (eu *EpisodeUpdate) SetSeasonNumber(i int) *EpisodeUpdate {
|
|
eu.mutation.ResetSeasonNumber()
|
|
eu.mutation.SetSeasonNumber(i)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableSeasonNumber sets the "season_number" field if the given value is not nil.
|
|
func (eu *EpisodeUpdate) SetNillableSeasonNumber(i *int) *EpisodeUpdate {
|
|
if i != nil {
|
|
eu.SetSeasonNumber(*i)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// AddSeasonNumber adds i to the "season_number" field.
|
|
func (eu *EpisodeUpdate) AddSeasonNumber(i int) *EpisodeUpdate {
|
|
eu.mutation.AddSeasonNumber(i)
|
|
return eu
|
|
}
|
|
|
|
// SetEpisodeNumber sets the "episode_number" field.
|
|
func (eu *EpisodeUpdate) SetEpisodeNumber(i int) *EpisodeUpdate {
|
|
eu.mutation.ResetEpisodeNumber()
|
|
eu.mutation.SetEpisodeNumber(i)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableEpisodeNumber sets the "episode_number" field if the given value is not nil.
|
|
func (eu *EpisodeUpdate) SetNillableEpisodeNumber(i *int) *EpisodeUpdate {
|
|
if i != nil {
|
|
eu.SetEpisodeNumber(*i)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// AddEpisodeNumber adds i to the "episode_number" field.
|
|
func (eu *EpisodeUpdate) AddEpisodeNumber(i int) *EpisodeUpdate {
|
|
eu.mutation.AddEpisodeNumber(i)
|
|
return eu
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (eu *EpisodeUpdate) SetTitle(s string) *EpisodeUpdate {
|
|
eu.mutation.SetTitle(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableTitle sets the "title" field if the given value is not nil.
|
|
func (eu *EpisodeUpdate) SetNillableTitle(s *string) *EpisodeUpdate {
|
|
if s != nil {
|
|
eu.SetTitle(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetOverview sets the "overview" field.
|
|
func (eu *EpisodeUpdate) SetOverview(s string) *EpisodeUpdate {
|
|
eu.mutation.SetOverview(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableOverview sets the "overview" field if the given value is not nil.
|
|
func (eu *EpisodeUpdate) SetNillableOverview(s *string) *EpisodeUpdate {
|
|
if s != nil {
|
|
eu.SetOverview(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetAirDate sets the "air_date" field.
|
|
func (eu *EpisodeUpdate) SetAirDate(s string) *EpisodeUpdate {
|
|
eu.mutation.SetAirDate(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableAirDate sets the "air_date" field if the given value is not nil.
|
|
func (eu *EpisodeUpdate) SetNillableAirDate(s *string) *EpisodeUpdate {
|
|
if s != nil {
|
|
eu.SetAirDate(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (eu *EpisodeUpdate) SetStatus(e episode.Status) *EpisodeUpdate {
|
|
eu.mutation.SetStatus(e)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (eu *EpisodeUpdate) SetNillableStatus(e *episode.Status) *EpisodeUpdate {
|
|
if e != nil {
|
|
eu.SetStatus(*e)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// SetFileInStorage sets the "file_in_storage" field.
|
|
func (eu *EpisodeUpdate) SetFileInStorage(s string) *EpisodeUpdate {
|
|
eu.mutation.SetFileInStorage(s)
|
|
return eu
|
|
}
|
|
|
|
// SetNillableFileInStorage sets the "file_in_storage" field if the given value is not nil.
|
|
func (eu *EpisodeUpdate) SetNillableFileInStorage(s *string) *EpisodeUpdate {
|
|
if s != nil {
|
|
eu.SetFileInStorage(*s)
|
|
}
|
|
return eu
|
|
}
|
|
|
|
// ClearFileInStorage clears the value of the "file_in_storage" field.
|
|
func (eu *EpisodeUpdate) ClearFileInStorage() *EpisodeUpdate {
|
|
eu.mutation.ClearFileInStorage()
|
|
return eu
|
|
}
|
|
|
|
// SetMedia sets the "media" edge to the Media entity.
|
|
func (eu *EpisodeUpdate) SetMedia(m *Media) *EpisodeUpdate {
|
|
return eu.SetMediaID(m.ID)
|
|
}
|
|
|
|
// Mutation returns the EpisodeMutation object of the builder.
|
|
func (eu *EpisodeUpdate) Mutation() *EpisodeMutation {
|
|
return eu.mutation
|
|
}
|
|
|
|
// ClearMedia clears the "media" edge to the Media entity.
|
|
func (eu *EpisodeUpdate) ClearMedia() *EpisodeUpdate {
|
|
eu.mutation.ClearMedia()
|
|
return eu
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (eu *EpisodeUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, eu.sqlSave, eu.mutation, eu.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (eu *EpisodeUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := eu.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (eu *EpisodeUpdate) Exec(ctx context.Context) error {
|
|
_, err := eu.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (eu *EpisodeUpdate) ExecX(ctx context.Context) {
|
|
if err := eu.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (eu *EpisodeUpdate) check() error {
|
|
if v, ok := eu.mutation.Status(); ok {
|
|
if err := episode.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Episode.status": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (eu *EpisodeUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|
if err := eu.check(); err != nil {
|
|
return n, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(episode.Table, episode.Columns, sqlgraph.NewFieldSpec(episode.FieldID, field.TypeInt))
|
|
if ps := eu.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := eu.mutation.SeasonNumber(); ok {
|
|
_spec.SetField(episode.FieldSeasonNumber, field.TypeInt, value)
|
|
}
|
|
if value, ok := eu.mutation.AddedSeasonNumber(); ok {
|
|
_spec.AddField(episode.FieldSeasonNumber, field.TypeInt, value)
|
|
}
|
|
if value, ok := eu.mutation.EpisodeNumber(); ok {
|
|
_spec.SetField(episode.FieldEpisodeNumber, field.TypeInt, value)
|
|
}
|
|
if value, ok := eu.mutation.AddedEpisodeNumber(); ok {
|
|
_spec.AddField(episode.FieldEpisodeNumber, field.TypeInt, value)
|
|
}
|
|
if value, ok := eu.mutation.Title(); ok {
|
|
_spec.SetField(episode.FieldTitle, field.TypeString, value)
|
|
}
|
|
if value, ok := eu.mutation.Overview(); ok {
|
|
_spec.SetField(episode.FieldOverview, field.TypeString, value)
|
|
}
|
|
if value, ok := eu.mutation.AirDate(); ok {
|
|
_spec.SetField(episode.FieldAirDate, field.TypeString, value)
|
|
}
|
|
if value, ok := eu.mutation.Status(); ok {
|
|
_spec.SetField(episode.FieldStatus, field.TypeEnum, value)
|
|
}
|
|
if value, ok := eu.mutation.FileInStorage(); ok {
|
|
_spec.SetField(episode.FieldFileInStorage, field.TypeString, value)
|
|
}
|
|
if eu.mutation.FileInStorageCleared() {
|
|
_spec.ClearField(episode.FieldFileInStorage, field.TypeString)
|
|
}
|
|
if eu.mutation.MediaCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: episode.MediaTable,
|
|
Columns: []string{episode.MediaColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(media.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := eu.mutation.MediaIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: episode.MediaTable,
|
|
Columns: []string{episode.MediaColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(media.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, eu.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{episode.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
eu.mutation.done = true
|
|
return n, nil
|
|
}
|
|
|
|
// EpisodeUpdateOne is the builder for updating a single Episode entity.
|
|
type EpisodeUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *EpisodeMutation
|
|
}
|
|
|
|
// SetMediaID sets the "media_id" field.
|
|
func (euo *EpisodeUpdateOne) SetMediaID(i int) *EpisodeUpdateOne {
|
|
euo.mutation.SetMediaID(i)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableMediaID sets the "media_id" field if the given value is not nil.
|
|
func (euo *EpisodeUpdateOne) SetNillableMediaID(i *int) *EpisodeUpdateOne {
|
|
if i != nil {
|
|
euo.SetMediaID(*i)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearMediaID clears the value of the "media_id" field.
|
|
func (euo *EpisodeUpdateOne) ClearMediaID() *EpisodeUpdateOne {
|
|
euo.mutation.ClearMediaID()
|
|
return euo
|
|
}
|
|
|
|
// SetSeasonNumber sets the "season_number" field.
|
|
func (euo *EpisodeUpdateOne) SetSeasonNumber(i int) *EpisodeUpdateOne {
|
|
euo.mutation.ResetSeasonNumber()
|
|
euo.mutation.SetSeasonNumber(i)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableSeasonNumber sets the "season_number" field if the given value is not nil.
|
|
func (euo *EpisodeUpdateOne) SetNillableSeasonNumber(i *int) *EpisodeUpdateOne {
|
|
if i != nil {
|
|
euo.SetSeasonNumber(*i)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// AddSeasonNumber adds i to the "season_number" field.
|
|
func (euo *EpisodeUpdateOne) AddSeasonNumber(i int) *EpisodeUpdateOne {
|
|
euo.mutation.AddSeasonNumber(i)
|
|
return euo
|
|
}
|
|
|
|
// SetEpisodeNumber sets the "episode_number" field.
|
|
func (euo *EpisodeUpdateOne) SetEpisodeNumber(i int) *EpisodeUpdateOne {
|
|
euo.mutation.ResetEpisodeNumber()
|
|
euo.mutation.SetEpisodeNumber(i)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableEpisodeNumber sets the "episode_number" field if the given value is not nil.
|
|
func (euo *EpisodeUpdateOne) SetNillableEpisodeNumber(i *int) *EpisodeUpdateOne {
|
|
if i != nil {
|
|
euo.SetEpisodeNumber(*i)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// AddEpisodeNumber adds i to the "episode_number" field.
|
|
func (euo *EpisodeUpdateOne) AddEpisodeNumber(i int) *EpisodeUpdateOne {
|
|
euo.mutation.AddEpisodeNumber(i)
|
|
return euo
|
|
}
|
|
|
|
// SetTitle sets the "title" field.
|
|
func (euo *EpisodeUpdateOne) SetTitle(s string) *EpisodeUpdateOne {
|
|
euo.mutation.SetTitle(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableTitle sets the "title" field if the given value is not nil.
|
|
func (euo *EpisodeUpdateOne) SetNillableTitle(s *string) *EpisodeUpdateOne {
|
|
if s != nil {
|
|
euo.SetTitle(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetOverview sets the "overview" field.
|
|
func (euo *EpisodeUpdateOne) SetOverview(s string) *EpisodeUpdateOne {
|
|
euo.mutation.SetOverview(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableOverview sets the "overview" field if the given value is not nil.
|
|
func (euo *EpisodeUpdateOne) SetNillableOverview(s *string) *EpisodeUpdateOne {
|
|
if s != nil {
|
|
euo.SetOverview(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetAirDate sets the "air_date" field.
|
|
func (euo *EpisodeUpdateOne) SetAirDate(s string) *EpisodeUpdateOne {
|
|
euo.mutation.SetAirDate(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableAirDate sets the "air_date" field if the given value is not nil.
|
|
func (euo *EpisodeUpdateOne) SetNillableAirDate(s *string) *EpisodeUpdateOne {
|
|
if s != nil {
|
|
euo.SetAirDate(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (euo *EpisodeUpdateOne) SetStatus(e episode.Status) *EpisodeUpdateOne {
|
|
euo.mutation.SetStatus(e)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (euo *EpisodeUpdateOne) SetNillableStatus(e *episode.Status) *EpisodeUpdateOne {
|
|
if e != nil {
|
|
euo.SetStatus(*e)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// SetFileInStorage sets the "file_in_storage" field.
|
|
func (euo *EpisodeUpdateOne) SetFileInStorage(s string) *EpisodeUpdateOne {
|
|
euo.mutation.SetFileInStorage(s)
|
|
return euo
|
|
}
|
|
|
|
// SetNillableFileInStorage sets the "file_in_storage" field if the given value is not nil.
|
|
func (euo *EpisodeUpdateOne) SetNillableFileInStorage(s *string) *EpisodeUpdateOne {
|
|
if s != nil {
|
|
euo.SetFileInStorage(*s)
|
|
}
|
|
return euo
|
|
}
|
|
|
|
// ClearFileInStorage clears the value of the "file_in_storage" field.
|
|
func (euo *EpisodeUpdateOne) ClearFileInStorage() *EpisodeUpdateOne {
|
|
euo.mutation.ClearFileInStorage()
|
|
return euo
|
|
}
|
|
|
|
// SetMedia sets the "media" edge to the Media entity.
|
|
func (euo *EpisodeUpdateOne) SetMedia(m *Media) *EpisodeUpdateOne {
|
|
return euo.SetMediaID(m.ID)
|
|
}
|
|
|
|
// Mutation returns the EpisodeMutation object of the builder.
|
|
func (euo *EpisodeUpdateOne) Mutation() *EpisodeMutation {
|
|
return euo.mutation
|
|
}
|
|
|
|
// ClearMedia clears the "media" edge to the Media entity.
|
|
func (euo *EpisodeUpdateOne) ClearMedia() *EpisodeUpdateOne {
|
|
euo.mutation.ClearMedia()
|
|
return euo
|
|
}
|
|
|
|
// Where appends a list predicates to the EpisodeUpdate builder.
|
|
func (euo *EpisodeUpdateOne) Where(ps ...predicate.Episode) *EpisodeUpdateOne {
|
|
euo.mutation.Where(ps...)
|
|
return euo
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (euo *EpisodeUpdateOne) Select(field string, fields ...string) *EpisodeUpdateOne {
|
|
euo.fields = append([]string{field}, fields...)
|
|
return euo
|
|
}
|
|
|
|
// Save executes the query and returns the updated Episode entity.
|
|
func (euo *EpisodeUpdateOne) Save(ctx context.Context) (*Episode, error) {
|
|
return withHooks(ctx, euo.sqlSave, euo.mutation, euo.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (euo *EpisodeUpdateOne) SaveX(ctx context.Context) *Episode {
|
|
node, err := euo.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (euo *EpisodeUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := euo.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (euo *EpisodeUpdateOne) ExecX(ctx context.Context) {
|
|
if err := euo.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (euo *EpisodeUpdateOne) check() error {
|
|
if v, ok := euo.mutation.Status(); ok {
|
|
if err := episode.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Episode.status": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (euo *EpisodeUpdateOne) sqlSave(ctx context.Context) (_node *Episode, err error) {
|
|
if err := euo.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(episode.Table, episode.Columns, sqlgraph.NewFieldSpec(episode.FieldID, field.TypeInt))
|
|
id, ok := euo.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Episode.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := euo.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, episode.FieldID)
|
|
for _, f := range fields {
|
|
if !episode.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != episode.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := euo.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := euo.mutation.SeasonNumber(); ok {
|
|
_spec.SetField(episode.FieldSeasonNumber, field.TypeInt, value)
|
|
}
|
|
if value, ok := euo.mutation.AddedSeasonNumber(); ok {
|
|
_spec.AddField(episode.FieldSeasonNumber, field.TypeInt, value)
|
|
}
|
|
if value, ok := euo.mutation.EpisodeNumber(); ok {
|
|
_spec.SetField(episode.FieldEpisodeNumber, field.TypeInt, value)
|
|
}
|
|
if value, ok := euo.mutation.AddedEpisodeNumber(); ok {
|
|
_spec.AddField(episode.FieldEpisodeNumber, field.TypeInt, value)
|
|
}
|
|
if value, ok := euo.mutation.Title(); ok {
|
|
_spec.SetField(episode.FieldTitle, field.TypeString, value)
|
|
}
|
|
if value, ok := euo.mutation.Overview(); ok {
|
|
_spec.SetField(episode.FieldOverview, field.TypeString, value)
|
|
}
|
|
if value, ok := euo.mutation.AirDate(); ok {
|
|
_spec.SetField(episode.FieldAirDate, field.TypeString, value)
|
|
}
|
|
if value, ok := euo.mutation.Status(); ok {
|
|
_spec.SetField(episode.FieldStatus, field.TypeEnum, value)
|
|
}
|
|
if value, ok := euo.mutation.FileInStorage(); ok {
|
|
_spec.SetField(episode.FieldFileInStorage, field.TypeString, value)
|
|
}
|
|
if euo.mutation.FileInStorageCleared() {
|
|
_spec.ClearField(episode.FieldFileInStorage, field.TypeString)
|
|
}
|
|
if euo.mutation.MediaCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: episode.MediaTable,
|
|
Columns: []string{episode.MediaColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(media.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := euo.mutation.MediaIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: episode.MediaTable,
|
|
Columns: []string{episode.MediaColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(media.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &Episode{config: euo.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, euo.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{episode.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
euo.mutation.done = true
|
|
return _node, nil
|
|
}
|