You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1326 lines
41 KiB
1326 lines
41 KiB
// 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/cloudreve/Cloudreve/v4/ent/mediaprocesstask"
|
|
"github.com/cloudreve/Cloudreve/v4/inventory/types"
|
|
)
|
|
|
|
// MediaProcessTaskCreate is the builder for creating a MediaProcessTask entity.
|
|
type MediaProcessTaskCreate struct {
|
|
config
|
|
mutation *MediaProcessTaskMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (mptc *MediaProcessTaskCreate) SetCreatedAt(t time.Time) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetCreatedAt(t)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableCreatedAt(t *time.Time) *MediaProcessTaskCreate {
|
|
if t != nil {
|
|
mptc.SetCreatedAt(*t)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (mptc *MediaProcessTaskCreate) SetUpdatedAt(t time.Time) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetUpdatedAt(t)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableUpdatedAt(t *time.Time) *MediaProcessTaskCreate {
|
|
if t != nil {
|
|
mptc.SetUpdatedAt(*t)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (mptc *MediaProcessTaskCreate) SetDeletedAt(t time.Time) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetDeletedAt(t)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableDeletedAt(t *time.Time) *MediaProcessTaskCreate {
|
|
if t != nil {
|
|
mptc.SetDeletedAt(*t)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetMediaType sets the "media_type" field.
|
|
func (mptc *MediaProcessTaskCreate) SetMediaType(mt mediaprocesstask.MediaType) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetMediaType(mt)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableMediaType sets the "media_type" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableMediaType(mt *mediaprocesstask.MediaType) *MediaProcessTaskCreate {
|
|
if mt != nil {
|
|
mptc.SetMediaType(*mt)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (mptc *MediaProcessTaskCreate) SetStatus(m mediaprocesstask.Status) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetStatus(m)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableStatus sets the "status" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableStatus(m *mediaprocesstask.Status) *MediaProcessTaskCreate {
|
|
if m != nil {
|
|
mptc.SetStatus(*m)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetEntityID sets the "entity_id" field.
|
|
func (mptc *MediaProcessTaskCreate) SetEntityID(i int) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetEntityID(i)
|
|
return mptc
|
|
}
|
|
|
|
// SetFileID sets the "file_id" field.
|
|
func (mptc *MediaProcessTaskCreate) SetFileID(i int) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetFileID(i)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableFileID sets the "file_id" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableFileID(i *int) *MediaProcessTaskCreate {
|
|
if i != nil {
|
|
mptc.SetFileID(*i)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetOwnerID sets the "owner_id" field.
|
|
func (mptc *MediaProcessTaskCreate) SetOwnerID(i int) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetOwnerID(i)
|
|
return mptc
|
|
}
|
|
|
|
// SetAttempts sets the "attempts" field.
|
|
func (mptc *MediaProcessTaskCreate) SetAttempts(i int) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetAttempts(i)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableAttempts sets the "attempts" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableAttempts(i *int) *MediaProcessTaskCreate {
|
|
if i != nil {
|
|
mptc.SetAttempts(*i)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetError sets the "error" field.
|
|
func (mptc *MediaProcessTaskCreate) SetError(s string) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetError(s)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableError sets the "error" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableError(s *string) *MediaProcessTaskCreate {
|
|
if s != nil {
|
|
mptc.SetError(*s)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetResultSize sets the "result_size" field.
|
|
func (mptc *MediaProcessTaskCreate) SetResultSize(i int64) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetResultSize(i)
|
|
return mptc
|
|
}
|
|
|
|
// SetNillableResultSize sets the "result_size" field if the given value is not nil.
|
|
func (mptc *MediaProcessTaskCreate) SetNillableResultSize(i *int64) *MediaProcessTaskCreate {
|
|
if i != nil {
|
|
mptc.SetResultSize(*i)
|
|
}
|
|
return mptc
|
|
}
|
|
|
|
// SetProps sets the "props" field.
|
|
func (mptc *MediaProcessTaskCreate) SetProps(tptp *types.MediaProcessTaskProps) *MediaProcessTaskCreate {
|
|
mptc.mutation.SetProps(tptp)
|
|
return mptc
|
|
}
|
|
|
|
// Mutation returns the MediaProcessTaskMutation object of the builder.
|
|
func (mptc *MediaProcessTaskCreate) Mutation() *MediaProcessTaskMutation {
|
|
return mptc.mutation
|
|
}
|
|
|
|
// Save creates the MediaProcessTask in the database.
|
|
func (mptc *MediaProcessTaskCreate) Save(ctx context.Context) (*MediaProcessTask, error) {
|
|
if err := mptc.defaults(); err != nil {
|
|
return nil, err
|
|
}
|
|
return withHooks(ctx, mptc.sqlSave, mptc.mutation, mptc.hooks)
|
|
}
|
|
|
|
// SaveX calls Save and panics if Save returns an error.
|
|
func (mptc *MediaProcessTaskCreate) SaveX(ctx context.Context) *MediaProcessTask {
|
|
v, err := mptc.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (mptc *MediaProcessTaskCreate) Exec(ctx context.Context) error {
|
|
_, err := mptc.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (mptc *MediaProcessTaskCreate) ExecX(ctx context.Context) {
|
|
if err := mptc.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (mptc *MediaProcessTaskCreate) defaults() error {
|
|
if _, ok := mptc.mutation.CreatedAt(); !ok {
|
|
if mediaprocesstask.DefaultCreatedAt == nil {
|
|
return fmt.Errorf("ent: uninitialized mediaprocesstask.DefaultCreatedAt (forgotten import ent/runtime?)")
|
|
}
|
|
v := mediaprocesstask.DefaultCreatedAt()
|
|
mptc.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := mptc.mutation.UpdatedAt(); !ok {
|
|
if mediaprocesstask.DefaultUpdatedAt == nil {
|
|
return fmt.Errorf("ent: uninitialized mediaprocesstask.DefaultUpdatedAt (forgotten import ent/runtime?)")
|
|
}
|
|
v := mediaprocesstask.DefaultUpdatedAt()
|
|
mptc.mutation.SetUpdatedAt(v)
|
|
}
|
|
if _, ok := mptc.mutation.MediaType(); !ok {
|
|
v := mediaprocesstask.DefaultMediaType
|
|
mptc.mutation.SetMediaType(v)
|
|
}
|
|
if _, ok := mptc.mutation.Status(); !ok {
|
|
v := mediaprocesstask.DefaultStatus
|
|
mptc.mutation.SetStatus(v)
|
|
}
|
|
if _, ok := mptc.mutation.Attempts(); !ok {
|
|
v := mediaprocesstask.DefaultAttempts
|
|
mptc.mutation.SetAttempts(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (mptc *MediaProcessTaskCreate) check() error {
|
|
if _, ok := mptc.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "MediaProcessTask.created_at"`)}
|
|
}
|
|
if _, ok := mptc.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "MediaProcessTask.updated_at"`)}
|
|
}
|
|
if _, ok := mptc.mutation.MediaType(); !ok {
|
|
return &ValidationError{Name: "media_type", err: errors.New(`ent: missing required field "MediaProcessTask.media_type"`)}
|
|
}
|
|
if v, ok := mptc.mutation.MediaType(); ok {
|
|
if err := mediaprocesstask.MediaTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "media_type", err: fmt.Errorf(`ent: validator failed for field "MediaProcessTask.media_type": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := mptc.mutation.Status(); !ok {
|
|
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "MediaProcessTask.status"`)}
|
|
}
|
|
if v, ok := mptc.mutation.Status(); ok {
|
|
if err := mediaprocesstask.StatusValidator(v); err != nil {
|
|
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "MediaProcessTask.status": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := mptc.mutation.EntityID(); !ok {
|
|
return &ValidationError{Name: "entity_id", err: errors.New(`ent: missing required field "MediaProcessTask.entity_id"`)}
|
|
}
|
|
if _, ok := mptc.mutation.OwnerID(); !ok {
|
|
return &ValidationError{Name: "owner_id", err: errors.New(`ent: missing required field "MediaProcessTask.owner_id"`)}
|
|
}
|
|
if _, ok := mptc.mutation.Attempts(); !ok {
|
|
return &ValidationError{Name: "attempts", err: errors.New(`ent: missing required field "MediaProcessTask.attempts"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (mptc *MediaProcessTaskCreate) sqlSave(ctx context.Context) (*MediaProcessTask, error) {
|
|
if err := mptc.check(); err != nil {
|
|
return nil, err
|
|
}
|
|
_node, _spec := mptc.createSpec()
|
|
if err := sqlgraph.CreateNode(ctx, mptc.driver, _spec); err != nil {
|
|
if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
id := _spec.ID.Value.(int64)
|
|
_node.ID = int(id)
|
|
mptc.mutation.id = &_node.ID
|
|
mptc.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (mptc *MediaProcessTaskCreate) createSpec() (*MediaProcessTask, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &MediaProcessTask{config: mptc.config}
|
|
_spec = sqlgraph.NewCreateSpec(mediaprocesstask.Table, sqlgraph.NewFieldSpec(mediaprocesstask.FieldID, field.TypeInt))
|
|
)
|
|
|
|
if id, ok := mptc.mutation.ID(); ok {
|
|
_node.ID = id
|
|
id64 := int64(id)
|
|
_spec.ID.Value = id64
|
|
}
|
|
|
|
_spec.OnConflict = mptc.conflict
|
|
if value, ok := mptc.mutation.CreatedAt(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := mptc.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if value, ok := mptc.mutation.DeletedAt(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = &value
|
|
}
|
|
if value, ok := mptc.mutation.MediaType(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldMediaType, field.TypeEnum, value)
|
|
_node.MediaType = value
|
|
}
|
|
if value, ok := mptc.mutation.Status(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldStatus, field.TypeEnum, value)
|
|
_node.Status = value
|
|
}
|
|
if value, ok := mptc.mutation.EntityID(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldEntityID, field.TypeInt, value)
|
|
_node.EntityID = value
|
|
}
|
|
if value, ok := mptc.mutation.FileID(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldFileID, field.TypeInt, value)
|
|
_node.FileID = value
|
|
}
|
|
if value, ok := mptc.mutation.OwnerID(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldOwnerID, field.TypeInt, value)
|
|
_node.OwnerID = value
|
|
}
|
|
if value, ok := mptc.mutation.Attempts(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldAttempts, field.TypeInt, value)
|
|
_node.Attempts = value
|
|
}
|
|
if value, ok := mptc.mutation.Error(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldError, field.TypeString, value)
|
|
_node.Error = value
|
|
}
|
|
if value, ok := mptc.mutation.ResultSize(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldResultSize, field.TypeInt64, value)
|
|
_node.ResultSize = value
|
|
}
|
|
if value, ok := mptc.mutation.Props(); ok {
|
|
_spec.SetField(mediaprocesstask.FieldProps, field.TypeJSON, value)
|
|
_node.Props = value
|
|
}
|
|
return _node, _spec
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.MediaProcessTask.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.MediaProcessTaskUpsert) {
|
|
// SetCreatedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (mptc *MediaProcessTaskCreate) OnConflict(opts ...sql.ConflictOption) *MediaProcessTaskUpsertOne {
|
|
mptc.conflict = opts
|
|
return &MediaProcessTaskUpsertOne{
|
|
create: mptc,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.MediaProcessTask.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (mptc *MediaProcessTaskCreate) OnConflictColumns(columns ...string) *MediaProcessTaskUpsertOne {
|
|
mptc.conflict = append(mptc.conflict, sql.ConflictColumns(columns...))
|
|
return &MediaProcessTaskUpsertOne{
|
|
create: mptc,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// MediaProcessTaskUpsertOne is the builder for "upsert"-ing
|
|
// one MediaProcessTask node.
|
|
MediaProcessTaskUpsertOne struct {
|
|
create *MediaProcessTaskCreate
|
|
}
|
|
|
|
// MediaProcessTaskUpsert is the "OnConflict" setter.
|
|
MediaProcessTaskUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MediaProcessTaskUpsert) SetUpdatedAt(v time.Time) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateUpdatedAt() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldUpdatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *MediaProcessTaskUpsert) SetDeletedAt(v time.Time) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldDeletedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateDeletedAt() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *MediaProcessTaskUpsert) ClearDeletedAt() *MediaProcessTaskUpsert {
|
|
u.SetNull(mediaprocesstask.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// SetMediaType sets the "media_type" field.
|
|
func (u *MediaProcessTaskUpsert) SetMediaType(v mediaprocesstask.MediaType) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldMediaType, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateMediaType sets the "media_type" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateMediaType() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldMediaType)
|
|
return u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *MediaProcessTaskUpsert) SetStatus(v mediaprocesstask.Status) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldStatus, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateStatus() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldStatus)
|
|
return u
|
|
}
|
|
|
|
// SetEntityID sets the "entity_id" field.
|
|
func (u *MediaProcessTaskUpsert) SetEntityID(v int) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldEntityID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEntityID sets the "entity_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateEntityID() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldEntityID)
|
|
return u
|
|
}
|
|
|
|
// AddEntityID adds v to the "entity_id" field.
|
|
func (u *MediaProcessTaskUpsert) AddEntityID(v int) *MediaProcessTaskUpsert {
|
|
u.Add(mediaprocesstask.FieldEntityID, v)
|
|
return u
|
|
}
|
|
|
|
// SetFileID sets the "file_id" field.
|
|
func (u *MediaProcessTaskUpsert) SetFileID(v int) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldFileID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateFileID sets the "file_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateFileID() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldFileID)
|
|
return u
|
|
}
|
|
|
|
// AddFileID adds v to the "file_id" field.
|
|
func (u *MediaProcessTaskUpsert) AddFileID(v int) *MediaProcessTaskUpsert {
|
|
u.Add(mediaprocesstask.FieldFileID, v)
|
|
return u
|
|
}
|
|
|
|
// ClearFileID clears the value of the "file_id" field.
|
|
func (u *MediaProcessTaskUpsert) ClearFileID() *MediaProcessTaskUpsert {
|
|
u.SetNull(mediaprocesstask.FieldFileID)
|
|
return u
|
|
}
|
|
|
|
// SetOwnerID sets the "owner_id" field.
|
|
func (u *MediaProcessTaskUpsert) SetOwnerID(v int) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldOwnerID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateOwnerID sets the "owner_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateOwnerID() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldOwnerID)
|
|
return u
|
|
}
|
|
|
|
// AddOwnerID adds v to the "owner_id" field.
|
|
func (u *MediaProcessTaskUpsert) AddOwnerID(v int) *MediaProcessTaskUpsert {
|
|
u.Add(mediaprocesstask.FieldOwnerID, v)
|
|
return u
|
|
}
|
|
|
|
// SetAttempts sets the "attempts" field.
|
|
func (u *MediaProcessTaskUpsert) SetAttempts(v int) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldAttempts, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateAttempts sets the "attempts" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateAttempts() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldAttempts)
|
|
return u
|
|
}
|
|
|
|
// AddAttempts adds v to the "attempts" field.
|
|
func (u *MediaProcessTaskUpsert) AddAttempts(v int) *MediaProcessTaskUpsert {
|
|
u.Add(mediaprocesstask.FieldAttempts, v)
|
|
return u
|
|
}
|
|
|
|
// SetError sets the "error" field.
|
|
func (u *MediaProcessTaskUpsert) SetError(v string) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldError, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateError sets the "error" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateError() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldError)
|
|
return u
|
|
}
|
|
|
|
// ClearError clears the value of the "error" field.
|
|
func (u *MediaProcessTaskUpsert) ClearError() *MediaProcessTaskUpsert {
|
|
u.SetNull(mediaprocesstask.FieldError)
|
|
return u
|
|
}
|
|
|
|
// SetResultSize sets the "result_size" field.
|
|
func (u *MediaProcessTaskUpsert) SetResultSize(v int64) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldResultSize, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateResultSize sets the "result_size" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateResultSize() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldResultSize)
|
|
return u
|
|
}
|
|
|
|
// AddResultSize adds v to the "result_size" field.
|
|
func (u *MediaProcessTaskUpsert) AddResultSize(v int64) *MediaProcessTaskUpsert {
|
|
u.Add(mediaprocesstask.FieldResultSize, v)
|
|
return u
|
|
}
|
|
|
|
// ClearResultSize clears the value of the "result_size" field.
|
|
func (u *MediaProcessTaskUpsert) ClearResultSize() *MediaProcessTaskUpsert {
|
|
u.SetNull(mediaprocesstask.FieldResultSize)
|
|
return u
|
|
}
|
|
|
|
// SetProps sets the "props" field.
|
|
func (u *MediaProcessTaskUpsert) SetProps(v *types.MediaProcessTaskProps) *MediaProcessTaskUpsert {
|
|
u.Set(mediaprocesstask.FieldProps, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateProps sets the "props" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsert) UpdateProps() *MediaProcessTaskUpsert {
|
|
u.SetExcluded(mediaprocesstask.FieldProps)
|
|
return u
|
|
}
|
|
|
|
// ClearProps clears the value of the "props" field.
|
|
func (u *MediaProcessTaskUpsert) ClearProps() *MediaProcessTaskUpsert {
|
|
u.SetNull(mediaprocesstask.FieldProps)
|
|
return u
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that were set on create.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.MediaProcessTask.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *MediaProcessTaskUpsertOne) UpdateNewValues() *MediaProcessTaskUpsertOne {
|
|
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.CreatedAt(); exists {
|
|
s.SetIgnore(mediaprocesstask.FieldCreatedAt)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.MediaProcessTask.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *MediaProcessTaskUpsertOne) Ignore() *MediaProcessTaskUpsertOne {
|
|
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 *MediaProcessTaskUpsertOne) DoNothing() *MediaProcessTaskUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the MediaProcessTaskCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *MediaProcessTaskUpsertOne) Update(set func(*MediaProcessTaskUpsert)) *MediaProcessTaskUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&MediaProcessTaskUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetUpdatedAt(v time.Time) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateUpdatedAt() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetDeletedAt(v time.Time) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateDeletedAt() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *MediaProcessTaskUpsertOne) ClearDeletedAt() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetMediaType sets the "media_type" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetMediaType(v mediaprocesstask.MediaType) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetMediaType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMediaType sets the "media_type" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateMediaType() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateMediaType()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetStatus(v mediaprocesstask.Status) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateStatus() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetEntityID sets the "entity_id" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetEntityID(v int) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetEntityID(v)
|
|
})
|
|
}
|
|
|
|
// AddEntityID adds v to the "entity_id" field.
|
|
func (u *MediaProcessTaskUpsertOne) AddEntityID(v int) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddEntityID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEntityID sets the "entity_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateEntityID() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateEntityID()
|
|
})
|
|
}
|
|
|
|
// SetFileID sets the "file_id" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetFileID(v int) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetFileID(v)
|
|
})
|
|
}
|
|
|
|
// AddFileID adds v to the "file_id" field.
|
|
func (u *MediaProcessTaskUpsertOne) AddFileID(v int) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddFileID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateFileID sets the "file_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateFileID() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateFileID()
|
|
})
|
|
}
|
|
|
|
// ClearFileID clears the value of the "file_id" field.
|
|
func (u *MediaProcessTaskUpsertOne) ClearFileID() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearFileID()
|
|
})
|
|
}
|
|
|
|
// SetOwnerID sets the "owner_id" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetOwnerID(v int) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetOwnerID(v)
|
|
})
|
|
}
|
|
|
|
// AddOwnerID adds v to the "owner_id" field.
|
|
func (u *MediaProcessTaskUpsertOne) AddOwnerID(v int) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddOwnerID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOwnerID sets the "owner_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateOwnerID() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateOwnerID()
|
|
})
|
|
}
|
|
|
|
// SetAttempts sets the "attempts" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetAttempts(v int) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetAttempts(v)
|
|
})
|
|
}
|
|
|
|
// AddAttempts adds v to the "attempts" field.
|
|
func (u *MediaProcessTaskUpsertOne) AddAttempts(v int) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddAttempts(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAttempts sets the "attempts" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateAttempts() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateAttempts()
|
|
})
|
|
}
|
|
|
|
// SetError sets the "error" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetError(v string) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetError(v)
|
|
})
|
|
}
|
|
|
|
// UpdateError sets the "error" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateError() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateError()
|
|
})
|
|
}
|
|
|
|
// ClearError clears the value of the "error" field.
|
|
func (u *MediaProcessTaskUpsertOne) ClearError() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearError()
|
|
})
|
|
}
|
|
|
|
// SetResultSize sets the "result_size" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetResultSize(v int64) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetResultSize(v)
|
|
})
|
|
}
|
|
|
|
// AddResultSize adds v to the "result_size" field.
|
|
func (u *MediaProcessTaskUpsertOne) AddResultSize(v int64) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddResultSize(v)
|
|
})
|
|
}
|
|
|
|
// UpdateResultSize sets the "result_size" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateResultSize() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateResultSize()
|
|
})
|
|
}
|
|
|
|
// ClearResultSize clears the value of the "result_size" field.
|
|
func (u *MediaProcessTaskUpsertOne) ClearResultSize() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearResultSize()
|
|
})
|
|
}
|
|
|
|
// SetProps sets the "props" field.
|
|
func (u *MediaProcessTaskUpsertOne) SetProps(v *types.MediaProcessTaskProps) *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetProps(v)
|
|
})
|
|
}
|
|
|
|
// UpdateProps sets the "props" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertOne) UpdateProps() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateProps()
|
|
})
|
|
}
|
|
|
|
// ClearProps clears the value of the "props" field.
|
|
func (u *MediaProcessTaskUpsertOne) ClearProps() *MediaProcessTaskUpsertOne {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearProps()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *MediaProcessTaskUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for MediaProcessTaskCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *MediaProcessTaskUpsertOne) 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 *MediaProcessTaskUpsertOne) ID(ctx context.Context) (id int, err error) {
|
|
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 *MediaProcessTaskUpsertOne) IDX(ctx context.Context) int {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
func (m *MediaProcessTaskCreate) SetRawID(t int) *MediaProcessTaskCreate {
|
|
m.mutation.SetRawID(t)
|
|
return m
|
|
}
|
|
|
|
// MediaProcessTaskCreateBulk is the builder for creating many MediaProcessTask entities in bulk.
|
|
type MediaProcessTaskCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*MediaProcessTaskCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the MediaProcessTask entities in the database.
|
|
func (mptcb *MediaProcessTaskCreateBulk) Save(ctx context.Context) ([]*MediaProcessTask, error) {
|
|
if mptcb.err != nil {
|
|
return nil, mptcb.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(mptcb.builders))
|
|
nodes := make([]*MediaProcessTask, len(mptcb.builders))
|
|
mutators := make([]Mutator, len(mptcb.builders))
|
|
for i := range mptcb.builders {
|
|
func(i int, root context.Context) {
|
|
builder := mptcb.builders[i]
|
|
builder.defaults()
|
|
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
|
mutation, ok := m.(*MediaProcessTaskMutation)
|
|
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, mptcb.builders[i+1].mutation)
|
|
} else {
|
|
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
|
spec.OnConflict = mptcb.conflict
|
|
// Invoke the actual operation on the latest mutation in the chain.
|
|
if err = sqlgraph.BatchCreate(ctx, mptcb.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
|
|
if specs[i].ID.Value != nil {
|
|
id := specs[i].ID.Value.(int64)
|
|
nodes[i].ID = int(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, mptcb.builders[0].mutation); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
return nodes, nil
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (mptcb *MediaProcessTaskCreateBulk) SaveX(ctx context.Context) []*MediaProcessTask {
|
|
v, err := mptcb.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (mptcb *MediaProcessTaskCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := mptcb.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (mptcb *MediaProcessTaskCreateBulk) ExecX(ctx context.Context) {
|
|
if err := mptcb.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
|
|
// of the `INSERT` statement. For example:
|
|
//
|
|
// client.MediaProcessTask.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.MediaProcessTaskUpsert) {
|
|
// SetCreatedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (mptcb *MediaProcessTaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *MediaProcessTaskUpsertBulk {
|
|
mptcb.conflict = opts
|
|
return &MediaProcessTaskUpsertBulk{
|
|
create: mptcb,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.MediaProcessTask.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (mptcb *MediaProcessTaskCreateBulk) OnConflictColumns(columns ...string) *MediaProcessTaskUpsertBulk {
|
|
mptcb.conflict = append(mptcb.conflict, sql.ConflictColumns(columns...))
|
|
return &MediaProcessTaskUpsertBulk{
|
|
create: mptcb,
|
|
}
|
|
}
|
|
|
|
// MediaProcessTaskUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of MediaProcessTask nodes.
|
|
type MediaProcessTaskUpsertBulk struct {
|
|
create *MediaProcessTaskCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.MediaProcessTask.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateNewValues() *MediaProcessTaskUpsertBulk {
|
|
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.CreatedAt(); exists {
|
|
s.SetIgnore(mediaprocesstask.FieldCreatedAt)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.MediaProcessTask.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *MediaProcessTaskUpsertBulk) Ignore() *MediaProcessTaskUpsertBulk {
|
|
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 *MediaProcessTaskUpsertBulk) DoNothing() *MediaProcessTaskUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the MediaProcessTaskCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *MediaProcessTaskUpsertBulk) Update(set func(*MediaProcessTaskUpsert)) *MediaProcessTaskUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&MediaProcessTaskUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetUpdatedAt(v time.Time) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateUpdatedAt() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetDeletedAt(v time.Time) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateDeletedAt() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *MediaProcessTaskUpsertBulk) ClearDeletedAt() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetMediaType sets the "media_type" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetMediaType(v mediaprocesstask.MediaType) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetMediaType(v)
|
|
})
|
|
}
|
|
|
|
// UpdateMediaType sets the "media_type" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateMediaType() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateMediaType()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetStatus(v mediaprocesstask.Status) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateStatus() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetEntityID sets the "entity_id" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetEntityID(v int) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetEntityID(v)
|
|
})
|
|
}
|
|
|
|
// AddEntityID adds v to the "entity_id" field.
|
|
func (u *MediaProcessTaskUpsertBulk) AddEntityID(v int) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddEntityID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEntityID sets the "entity_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateEntityID() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateEntityID()
|
|
})
|
|
}
|
|
|
|
// SetFileID sets the "file_id" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetFileID(v int) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetFileID(v)
|
|
})
|
|
}
|
|
|
|
// AddFileID adds v to the "file_id" field.
|
|
func (u *MediaProcessTaskUpsertBulk) AddFileID(v int) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddFileID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateFileID sets the "file_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateFileID() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateFileID()
|
|
})
|
|
}
|
|
|
|
// ClearFileID clears the value of the "file_id" field.
|
|
func (u *MediaProcessTaskUpsertBulk) ClearFileID() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearFileID()
|
|
})
|
|
}
|
|
|
|
// SetOwnerID sets the "owner_id" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetOwnerID(v int) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetOwnerID(v)
|
|
})
|
|
}
|
|
|
|
// AddOwnerID adds v to the "owner_id" field.
|
|
func (u *MediaProcessTaskUpsertBulk) AddOwnerID(v int) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddOwnerID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOwnerID sets the "owner_id" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateOwnerID() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateOwnerID()
|
|
})
|
|
}
|
|
|
|
// SetAttempts sets the "attempts" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetAttempts(v int) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetAttempts(v)
|
|
})
|
|
}
|
|
|
|
// AddAttempts adds v to the "attempts" field.
|
|
func (u *MediaProcessTaskUpsertBulk) AddAttempts(v int) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddAttempts(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAttempts sets the "attempts" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateAttempts() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateAttempts()
|
|
})
|
|
}
|
|
|
|
// SetError sets the "error" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetError(v string) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetError(v)
|
|
})
|
|
}
|
|
|
|
// UpdateError sets the "error" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateError() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateError()
|
|
})
|
|
}
|
|
|
|
// ClearError clears the value of the "error" field.
|
|
func (u *MediaProcessTaskUpsertBulk) ClearError() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearError()
|
|
})
|
|
}
|
|
|
|
// SetResultSize sets the "result_size" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetResultSize(v int64) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetResultSize(v)
|
|
})
|
|
}
|
|
|
|
// AddResultSize adds v to the "result_size" field.
|
|
func (u *MediaProcessTaskUpsertBulk) AddResultSize(v int64) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.AddResultSize(v)
|
|
})
|
|
}
|
|
|
|
// UpdateResultSize sets the "result_size" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateResultSize() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateResultSize()
|
|
})
|
|
}
|
|
|
|
// ClearResultSize clears the value of the "result_size" field.
|
|
func (u *MediaProcessTaskUpsertBulk) ClearResultSize() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearResultSize()
|
|
})
|
|
}
|
|
|
|
// SetProps sets the "props" field.
|
|
func (u *MediaProcessTaskUpsertBulk) SetProps(v *types.MediaProcessTaskProps) *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.SetProps(v)
|
|
})
|
|
}
|
|
|
|
// UpdateProps sets the "props" field to the value that was provided on create.
|
|
func (u *MediaProcessTaskUpsertBulk) UpdateProps() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.UpdateProps()
|
|
})
|
|
}
|
|
|
|
// ClearProps clears the value of the "props" field.
|
|
func (u *MediaProcessTaskUpsertBulk) ClearProps() *MediaProcessTaskUpsertBulk {
|
|
return u.Update(func(s *MediaProcessTaskUpsert) {
|
|
s.ClearProps()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *MediaProcessTaskUpsertBulk) 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 MediaProcessTaskCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("ent: missing options for MediaProcessTaskCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *MediaProcessTaskUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|