func (u *UpdateSet) Update(qb models.SceneWriter, screenshotSetter ScreenshotSetter) (*models.Scene, error) {
	if u.IsEmpty() {
		return nil, ErrEmptyUpdater
	}

	partial := u.Partial
	partial.ID = u.ID
	partial.UpdatedAt = &models.SQLiteTimestamp{
		Timestamp: time.Now(),
	}

	ret, err := qb.Update(partial)
	if err != nil {
		return nil, fmt.Errorf("error updating scene: %w", err)
	}

	if u.PerformerIDs != nil {
		if err := qb.UpdatePerformers(u.ID, u.PerformerIDs); err != nil {
			return nil, fmt.Errorf("error updating scene performers: %w", err)
		}
	}

	if u.TagIDs != nil {
		if err := qb.UpdateTags(u.ID, u.TagIDs); err != nil {
			return nil, fmt.Errorf("error updating scene tags: %w", err)
		}
	}

	if u.StashIDs != nil {
		if err := qb.UpdateStashIDs(u.ID, u.StashIDs); err != nil {
			return nil, fmt.Errorf("error updating scene stash_ids: %w", err)
		}
	}

	if u.CoverImage != nil {
		if err := qb.UpdateCover(u.ID, u.CoverImage); err != nil {
			return nil, fmt.Errorf("error updating scene cover: %w", err)
		}

		if err := screenshotSetter.SetScreenshot(ret, u.CoverImage); err != nil {
			return nil, fmt.Errorf("error setting scene screenshot: %w", err)
		}
	}

	return ret, nil
}
// Update updates a scene by updating the fields in the Partial field, then
// updates non-nil relationships. Returns an error if there is no work to
// be done.
Update updates a scene by updating the fields in the Partial field, then
updates non-nil relationships. Returns an error if there is no work to
be done.
// Update updates a scene by updating the fields in the Partial field then // updates non - nil relationships . Returns an error if there is no work to // be done .
func (u *UpdateSet) Update(qb models.SceneWriter, screenshotSetter ScreenshotSetter) (*models.Scene, error) {
	if u.IsEmpty() {
		return nil, ErrEmptyUpdater
	}
	partial := u.Partial
	partial.ID = u.ID
	partial.UpdatedAt = &models.SQLiteTimestamp{
		Timestamp: time.Now(),
	}
	ret, err := qb.Update(partial)
	if err != nil {
		return nil, fmt.Errorf("error updating scene: %w", err)
	}
	if u.PerformerIDs != nil {
		if err := qb.UpdatePerformers(u.ID, u.PerformerIDs); err != nil {
			return nil, fmt.Errorf("error updating scene performers: %w", err)
		}
	}
	if u.TagIDs != nil {
		if err := qb.UpdateTags(u.ID, u.TagIDs); err != nil {
			return nil, fmt.Errorf("error updating scene tags: %w", err)
		}
	}
	if u.StashIDs != nil {
		if err := qb.UpdateStashIDs(u.ID, u.StashIDs); err != nil {
			return nil, fmt.Errorf("error updating scene stash_ids: %w", err)
		}
	}
	if u.CoverImage != nil {
		if err := qb.UpdateCover(u.ID, u.CoverImage); err != nil {
			return nil, fmt.Errorf("error updating scene cover: %w", err)
		}
		if err := screenshotSetter.SetScreenshot(ret, u.CoverImage); err != nil {
			return nil, fmt.Errorf("error setting scene screenshot: %w", err)
		}
	}
	return ret, nil
}
func ( u * UpdateSet ) Update ( qb models . SceneWriter , screenshotSetter ScreenshotSetter ) ( * models . Scene , error ) { if u . IsEmpty ( ) { return nil , ErrEmptyUpdater } partial := u . Partial partial . ID = u . ID partial . UpdatedAt = & models . SQLiteTimestamp { Timestamp : time . Now ( ) , } ret , err := qb . Update ( partial ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if u . PerformerIDs != nil { if err := qb . UpdatePerformers ( u . ID , u . PerformerIDs ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } } if u . TagIDs != nil { if err := qb . UpdateTags ( u . ID , u . TagIDs ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } } if u . StashIDs != nil { if err := qb . UpdateStashIDs ( u . ID , u . StashIDs ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } } if u . CoverImage != nil { if err := qb . UpdateCover ( u . ID , u . CoverImage ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := screenshotSetter . SetScreenshot ( ret , u . CoverImage ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } } return ret , nil }
Update updates a scene by updating the fields in the Partial field, then
updates non-nil relationships.
Update updates a scene by updating the fields in the Partial field then updates non - nil relationships .