Commit 13262a56 authored by yangjianbo's avatar yangjianbo
Browse files

feat(sora): 新增 Sora 平台支持并修复高危安全和性能问题



新增功能:
- 新增 Sora 账号管理和 OAuth 认证
- 新增 Sora 视频/图片生成 API 网关
- 新增 Sora 任务调度和缓存机制
- 新增 Sora 使用统计和计费支持
- 前端增加 Sora 平台配置界面

安全修复(代码审核):
- [SEC-001] 限制媒体下载响应体大小(图片 20MB、视频 200MB),防止 DoS 攻击
- [SEC-002] 限制 SDK API 响应大小(1MB),防止内存耗尽
- [SEC-003] 修复 SSRF 风险,添加 URL 验证并强制使用代理配置

BUG 修复(代码审核):
- [BUG-001] 修复 for 循环内 defer 累积导致的资源泄漏
- [BUG-002] 修复图片并发槽位获取失败时已持有锁未释放的永久泄漏

性能优化(代码审核):
- [PERF-001] 添加 Sentinel Token 缓存(3 分钟有效期),减少 PoW 计算开销

技术细节:
- 使用 io.LimitReader 限制所有外部输入的大小
- 添加 urlvalidator 验证防止 SSRF 攻击
- 使用 sync.Map 实现线程安全的包级缓存
- 优化并发槽位管理,添加 releaseAll 模式防止泄漏

影响范围:
- 后端:新增 Sora 相关数据模型、服务、网关和管理接口
- 前端:新增 Sora 平台配置、账号管理和监控界面
- 配置:新增 Sora 相关配置项和环境变量
Co-Authored-By: default avatarClaude Sonnet 4.5 <noreply@anthropic.com>
parent bece1b52
// 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/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/soraaccount"
)
// SoraAccountUpdate is the builder for updating SoraAccount entities.
type SoraAccountUpdate struct {
config
hooks []Hook
mutation *SoraAccountMutation
}
// Where appends a list predicates to the SoraAccountUpdate builder.
func (_u *SoraAccountUpdate) Where(ps ...predicate.SoraAccount) *SoraAccountUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *SoraAccountUpdate) SetUpdatedAt(v time.Time) *SoraAccountUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraAccountUpdate) SetAccountID(v int64) *SoraAccountUpdate {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableAccountID(v *int64) *SoraAccountUpdate {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraAccountUpdate) AddAccountID(v int64) *SoraAccountUpdate {
_u.mutation.AddAccountID(v)
return _u
}
// SetAccessToken sets the "access_token" field.
func (_u *SoraAccountUpdate) SetAccessToken(v string) *SoraAccountUpdate {
_u.mutation.SetAccessToken(v)
return _u
}
// SetNillableAccessToken sets the "access_token" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableAccessToken(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetAccessToken(*v)
}
return _u
}
// ClearAccessToken clears the value of the "access_token" field.
func (_u *SoraAccountUpdate) ClearAccessToken() *SoraAccountUpdate {
_u.mutation.ClearAccessToken()
return _u
}
// SetSessionToken sets the "session_token" field.
func (_u *SoraAccountUpdate) SetSessionToken(v string) *SoraAccountUpdate {
_u.mutation.SetSessionToken(v)
return _u
}
// SetNillableSessionToken sets the "session_token" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableSessionToken(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetSessionToken(*v)
}
return _u
}
// ClearSessionToken clears the value of the "session_token" field.
func (_u *SoraAccountUpdate) ClearSessionToken() *SoraAccountUpdate {
_u.mutation.ClearSessionToken()
return _u
}
// SetRefreshToken sets the "refresh_token" field.
func (_u *SoraAccountUpdate) SetRefreshToken(v string) *SoraAccountUpdate {
_u.mutation.SetRefreshToken(v)
return _u
}
// SetNillableRefreshToken sets the "refresh_token" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableRefreshToken(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetRefreshToken(*v)
}
return _u
}
// ClearRefreshToken clears the value of the "refresh_token" field.
func (_u *SoraAccountUpdate) ClearRefreshToken() *SoraAccountUpdate {
_u.mutation.ClearRefreshToken()
return _u
}
// SetClientID sets the "client_id" field.
func (_u *SoraAccountUpdate) SetClientID(v string) *SoraAccountUpdate {
_u.mutation.SetClientID(v)
return _u
}
// SetNillableClientID sets the "client_id" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableClientID(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetClientID(*v)
}
return _u
}
// ClearClientID clears the value of the "client_id" field.
func (_u *SoraAccountUpdate) ClearClientID() *SoraAccountUpdate {
_u.mutation.ClearClientID()
return _u
}
// SetEmail sets the "email" field.
func (_u *SoraAccountUpdate) SetEmail(v string) *SoraAccountUpdate {
_u.mutation.SetEmail(v)
return _u
}
// SetNillableEmail sets the "email" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableEmail(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetEmail(*v)
}
return _u
}
// ClearEmail clears the value of the "email" field.
func (_u *SoraAccountUpdate) ClearEmail() *SoraAccountUpdate {
_u.mutation.ClearEmail()
return _u
}
// SetUsername sets the "username" field.
func (_u *SoraAccountUpdate) SetUsername(v string) *SoraAccountUpdate {
_u.mutation.SetUsername(v)
return _u
}
// SetNillableUsername sets the "username" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableUsername(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetUsername(*v)
}
return _u
}
// ClearUsername clears the value of the "username" field.
func (_u *SoraAccountUpdate) ClearUsername() *SoraAccountUpdate {
_u.mutation.ClearUsername()
return _u
}
// SetRemark sets the "remark" field.
func (_u *SoraAccountUpdate) SetRemark(v string) *SoraAccountUpdate {
_u.mutation.SetRemark(v)
return _u
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableRemark(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetRemark(*v)
}
return _u
}
// ClearRemark clears the value of the "remark" field.
func (_u *SoraAccountUpdate) ClearRemark() *SoraAccountUpdate {
_u.mutation.ClearRemark()
return _u
}
// SetUseCount sets the "use_count" field.
func (_u *SoraAccountUpdate) SetUseCount(v int) *SoraAccountUpdate {
_u.mutation.ResetUseCount()
_u.mutation.SetUseCount(v)
return _u
}
// SetNillableUseCount sets the "use_count" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableUseCount(v *int) *SoraAccountUpdate {
if v != nil {
_u.SetUseCount(*v)
}
return _u
}
// AddUseCount adds value to the "use_count" field.
func (_u *SoraAccountUpdate) AddUseCount(v int) *SoraAccountUpdate {
_u.mutation.AddUseCount(v)
return _u
}
// SetPlanType sets the "plan_type" field.
func (_u *SoraAccountUpdate) SetPlanType(v string) *SoraAccountUpdate {
_u.mutation.SetPlanType(v)
return _u
}
// SetNillablePlanType sets the "plan_type" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillablePlanType(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetPlanType(*v)
}
return _u
}
// ClearPlanType clears the value of the "plan_type" field.
func (_u *SoraAccountUpdate) ClearPlanType() *SoraAccountUpdate {
_u.mutation.ClearPlanType()
return _u
}
// SetPlanTitle sets the "plan_title" field.
func (_u *SoraAccountUpdate) SetPlanTitle(v string) *SoraAccountUpdate {
_u.mutation.SetPlanTitle(v)
return _u
}
// SetNillablePlanTitle sets the "plan_title" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillablePlanTitle(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetPlanTitle(*v)
}
return _u
}
// ClearPlanTitle clears the value of the "plan_title" field.
func (_u *SoraAccountUpdate) ClearPlanTitle() *SoraAccountUpdate {
_u.mutation.ClearPlanTitle()
return _u
}
// SetSubscriptionEnd sets the "subscription_end" field.
func (_u *SoraAccountUpdate) SetSubscriptionEnd(v time.Time) *SoraAccountUpdate {
_u.mutation.SetSubscriptionEnd(v)
return _u
}
// SetNillableSubscriptionEnd sets the "subscription_end" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableSubscriptionEnd(v *time.Time) *SoraAccountUpdate {
if v != nil {
_u.SetSubscriptionEnd(*v)
}
return _u
}
// ClearSubscriptionEnd clears the value of the "subscription_end" field.
func (_u *SoraAccountUpdate) ClearSubscriptionEnd() *SoraAccountUpdate {
_u.mutation.ClearSubscriptionEnd()
return _u
}
// SetSoraSupported sets the "sora_supported" field.
func (_u *SoraAccountUpdate) SetSoraSupported(v bool) *SoraAccountUpdate {
_u.mutation.SetSoraSupported(v)
return _u
}
// SetNillableSoraSupported sets the "sora_supported" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableSoraSupported(v *bool) *SoraAccountUpdate {
if v != nil {
_u.SetSoraSupported(*v)
}
return _u
}
// SetSoraInviteCode sets the "sora_invite_code" field.
func (_u *SoraAccountUpdate) SetSoraInviteCode(v string) *SoraAccountUpdate {
_u.mutation.SetSoraInviteCode(v)
return _u
}
// SetNillableSoraInviteCode sets the "sora_invite_code" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableSoraInviteCode(v *string) *SoraAccountUpdate {
if v != nil {
_u.SetSoraInviteCode(*v)
}
return _u
}
// ClearSoraInviteCode clears the value of the "sora_invite_code" field.
func (_u *SoraAccountUpdate) ClearSoraInviteCode() *SoraAccountUpdate {
_u.mutation.ClearSoraInviteCode()
return _u
}
// SetSoraRedeemedCount sets the "sora_redeemed_count" field.
func (_u *SoraAccountUpdate) SetSoraRedeemedCount(v int) *SoraAccountUpdate {
_u.mutation.ResetSoraRedeemedCount()
_u.mutation.SetSoraRedeemedCount(v)
return _u
}
// SetNillableSoraRedeemedCount sets the "sora_redeemed_count" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableSoraRedeemedCount(v *int) *SoraAccountUpdate {
if v != nil {
_u.SetSoraRedeemedCount(*v)
}
return _u
}
// AddSoraRedeemedCount adds value to the "sora_redeemed_count" field.
func (_u *SoraAccountUpdate) AddSoraRedeemedCount(v int) *SoraAccountUpdate {
_u.mutation.AddSoraRedeemedCount(v)
return _u
}
// SetSoraRemainingCount sets the "sora_remaining_count" field.
func (_u *SoraAccountUpdate) SetSoraRemainingCount(v int) *SoraAccountUpdate {
_u.mutation.ResetSoraRemainingCount()
_u.mutation.SetSoraRemainingCount(v)
return _u
}
// SetNillableSoraRemainingCount sets the "sora_remaining_count" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableSoraRemainingCount(v *int) *SoraAccountUpdate {
if v != nil {
_u.SetSoraRemainingCount(*v)
}
return _u
}
// AddSoraRemainingCount adds value to the "sora_remaining_count" field.
func (_u *SoraAccountUpdate) AddSoraRemainingCount(v int) *SoraAccountUpdate {
_u.mutation.AddSoraRemainingCount(v)
return _u
}
// SetSoraTotalCount sets the "sora_total_count" field.
func (_u *SoraAccountUpdate) SetSoraTotalCount(v int) *SoraAccountUpdate {
_u.mutation.ResetSoraTotalCount()
_u.mutation.SetSoraTotalCount(v)
return _u
}
// SetNillableSoraTotalCount sets the "sora_total_count" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableSoraTotalCount(v *int) *SoraAccountUpdate {
if v != nil {
_u.SetSoraTotalCount(*v)
}
return _u
}
// AddSoraTotalCount adds value to the "sora_total_count" field.
func (_u *SoraAccountUpdate) AddSoraTotalCount(v int) *SoraAccountUpdate {
_u.mutation.AddSoraTotalCount(v)
return _u
}
// SetSoraCooldownUntil sets the "sora_cooldown_until" field.
func (_u *SoraAccountUpdate) SetSoraCooldownUntil(v time.Time) *SoraAccountUpdate {
_u.mutation.SetSoraCooldownUntil(v)
return _u
}
// SetNillableSoraCooldownUntil sets the "sora_cooldown_until" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableSoraCooldownUntil(v *time.Time) *SoraAccountUpdate {
if v != nil {
_u.SetSoraCooldownUntil(*v)
}
return _u
}
// ClearSoraCooldownUntil clears the value of the "sora_cooldown_until" field.
func (_u *SoraAccountUpdate) ClearSoraCooldownUntil() *SoraAccountUpdate {
_u.mutation.ClearSoraCooldownUntil()
return _u
}
// SetCooledUntil sets the "cooled_until" field.
func (_u *SoraAccountUpdate) SetCooledUntil(v time.Time) *SoraAccountUpdate {
_u.mutation.SetCooledUntil(v)
return _u
}
// SetNillableCooledUntil sets the "cooled_until" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableCooledUntil(v *time.Time) *SoraAccountUpdate {
if v != nil {
_u.SetCooledUntil(*v)
}
return _u
}
// ClearCooledUntil clears the value of the "cooled_until" field.
func (_u *SoraAccountUpdate) ClearCooledUntil() *SoraAccountUpdate {
_u.mutation.ClearCooledUntil()
return _u
}
// SetImageEnabled sets the "image_enabled" field.
func (_u *SoraAccountUpdate) SetImageEnabled(v bool) *SoraAccountUpdate {
_u.mutation.SetImageEnabled(v)
return _u
}
// SetNillableImageEnabled sets the "image_enabled" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableImageEnabled(v *bool) *SoraAccountUpdate {
if v != nil {
_u.SetImageEnabled(*v)
}
return _u
}
// SetVideoEnabled sets the "video_enabled" field.
func (_u *SoraAccountUpdate) SetVideoEnabled(v bool) *SoraAccountUpdate {
_u.mutation.SetVideoEnabled(v)
return _u
}
// SetNillableVideoEnabled sets the "video_enabled" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableVideoEnabled(v *bool) *SoraAccountUpdate {
if v != nil {
_u.SetVideoEnabled(*v)
}
return _u
}
// SetImageConcurrency sets the "image_concurrency" field.
func (_u *SoraAccountUpdate) SetImageConcurrency(v int) *SoraAccountUpdate {
_u.mutation.ResetImageConcurrency()
_u.mutation.SetImageConcurrency(v)
return _u
}
// SetNillableImageConcurrency sets the "image_concurrency" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableImageConcurrency(v *int) *SoraAccountUpdate {
if v != nil {
_u.SetImageConcurrency(*v)
}
return _u
}
// AddImageConcurrency adds value to the "image_concurrency" field.
func (_u *SoraAccountUpdate) AddImageConcurrency(v int) *SoraAccountUpdate {
_u.mutation.AddImageConcurrency(v)
return _u
}
// SetVideoConcurrency sets the "video_concurrency" field.
func (_u *SoraAccountUpdate) SetVideoConcurrency(v int) *SoraAccountUpdate {
_u.mutation.ResetVideoConcurrency()
_u.mutation.SetVideoConcurrency(v)
return _u
}
// SetNillableVideoConcurrency sets the "video_concurrency" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableVideoConcurrency(v *int) *SoraAccountUpdate {
if v != nil {
_u.SetVideoConcurrency(*v)
}
return _u
}
// AddVideoConcurrency adds value to the "video_concurrency" field.
func (_u *SoraAccountUpdate) AddVideoConcurrency(v int) *SoraAccountUpdate {
_u.mutation.AddVideoConcurrency(v)
return _u
}
// SetIsExpired sets the "is_expired" field.
func (_u *SoraAccountUpdate) SetIsExpired(v bool) *SoraAccountUpdate {
_u.mutation.SetIsExpired(v)
return _u
}
// SetNillableIsExpired sets the "is_expired" field if the given value is not nil.
func (_u *SoraAccountUpdate) SetNillableIsExpired(v *bool) *SoraAccountUpdate {
if v != nil {
_u.SetIsExpired(*v)
}
return _u
}
// Mutation returns the SoraAccountMutation object of the builder.
func (_u *SoraAccountUpdate) Mutation() *SoraAccountMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *SoraAccountUpdate) 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 *SoraAccountUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *SoraAccountUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraAccountUpdate) 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 *SoraAccountUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := soraaccount.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
func (_u *SoraAccountUpdate) sqlSave(ctx context.Context) (_node int, err error) {
_spec := sqlgraph.NewUpdateSpec(soraaccount.Table, soraaccount.Columns, sqlgraph.NewFieldSpec(soraaccount.FieldID, field.TypeInt64))
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(soraaccount.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soraaccount.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soraaccount.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AccessToken(); ok {
_spec.SetField(soraaccount.FieldAccessToken, field.TypeString, value)
}
if _u.mutation.AccessTokenCleared() {
_spec.ClearField(soraaccount.FieldAccessToken, field.TypeString)
}
if value, ok := _u.mutation.SessionToken(); ok {
_spec.SetField(soraaccount.FieldSessionToken, field.TypeString, value)
}
if _u.mutation.SessionTokenCleared() {
_spec.ClearField(soraaccount.FieldSessionToken, field.TypeString)
}
if value, ok := _u.mutation.RefreshToken(); ok {
_spec.SetField(soraaccount.FieldRefreshToken, field.TypeString, value)
}
if _u.mutation.RefreshTokenCleared() {
_spec.ClearField(soraaccount.FieldRefreshToken, field.TypeString)
}
if value, ok := _u.mutation.ClientID(); ok {
_spec.SetField(soraaccount.FieldClientID, field.TypeString, value)
}
if _u.mutation.ClientIDCleared() {
_spec.ClearField(soraaccount.FieldClientID, field.TypeString)
}
if value, ok := _u.mutation.Email(); ok {
_spec.SetField(soraaccount.FieldEmail, field.TypeString, value)
}
if _u.mutation.EmailCleared() {
_spec.ClearField(soraaccount.FieldEmail, field.TypeString)
}
if value, ok := _u.mutation.Username(); ok {
_spec.SetField(soraaccount.FieldUsername, field.TypeString, value)
}
if _u.mutation.UsernameCleared() {
_spec.ClearField(soraaccount.FieldUsername, field.TypeString)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(soraaccount.FieldRemark, field.TypeString, value)
}
if _u.mutation.RemarkCleared() {
_spec.ClearField(soraaccount.FieldRemark, field.TypeString)
}
if value, ok := _u.mutation.UseCount(); ok {
_spec.SetField(soraaccount.FieldUseCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedUseCount(); ok {
_spec.AddField(soraaccount.FieldUseCount, field.TypeInt, value)
}
if value, ok := _u.mutation.PlanType(); ok {
_spec.SetField(soraaccount.FieldPlanType, field.TypeString, value)
}
if _u.mutation.PlanTypeCleared() {
_spec.ClearField(soraaccount.FieldPlanType, field.TypeString)
}
if value, ok := _u.mutation.PlanTitle(); ok {
_spec.SetField(soraaccount.FieldPlanTitle, field.TypeString, value)
}
if _u.mutation.PlanTitleCleared() {
_spec.ClearField(soraaccount.FieldPlanTitle, field.TypeString)
}
if value, ok := _u.mutation.SubscriptionEnd(); ok {
_spec.SetField(soraaccount.FieldSubscriptionEnd, field.TypeTime, value)
}
if _u.mutation.SubscriptionEndCleared() {
_spec.ClearField(soraaccount.FieldSubscriptionEnd, field.TypeTime)
}
if value, ok := _u.mutation.SoraSupported(); ok {
_spec.SetField(soraaccount.FieldSoraSupported, field.TypeBool, value)
}
if value, ok := _u.mutation.SoraInviteCode(); ok {
_spec.SetField(soraaccount.FieldSoraInviteCode, field.TypeString, value)
}
if _u.mutation.SoraInviteCodeCleared() {
_spec.ClearField(soraaccount.FieldSoraInviteCode, field.TypeString)
}
if value, ok := _u.mutation.SoraRedeemedCount(); ok {
_spec.SetField(soraaccount.FieldSoraRedeemedCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedSoraRedeemedCount(); ok {
_spec.AddField(soraaccount.FieldSoraRedeemedCount, field.TypeInt, value)
}
if value, ok := _u.mutation.SoraRemainingCount(); ok {
_spec.SetField(soraaccount.FieldSoraRemainingCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedSoraRemainingCount(); ok {
_spec.AddField(soraaccount.FieldSoraRemainingCount, field.TypeInt, value)
}
if value, ok := _u.mutation.SoraTotalCount(); ok {
_spec.SetField(soraaccount.FieldSoraTotalCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedSoraTotalCount(); ok {
_spec.AddField(soraaccount.FieldSoraTotalCount, field.TypeInt, value)
}
if value, ok := _u.mutation.SoraCooldownUntil(); ok {
_spec.SetField(soraaccount.FieldSoraCooldownUntil, field.TypeTime, value)
}
if _u.mutation.SoraCooldownUntilCleared() {
_spec.ClearField(soraaccount.FieldSoraCooldownUntil, field.TypeTime)
}
if value, ok := _u.mutation.CooledUntil(); ok {
_spec.SetField(soraaccount.FieldCooledUntil, field.TypeTime, value)
}
if _u.mutation.CooledUntilCleared() {
_spec.ClearField(soraaccount.FieldCooledUntil, field.TypeTime)
}
if value, ok := _u.mutation.ImageEnabled(); ok {
_spec.SetField(soraaccount.FieldImageEnabled, field.TypeBool, value)
}
if value, ok := _u.mutation.VideoEnabled(); ok {
_spec.SetField(soraaccount.FieldVideoEnabled, field.TypeBool, value)
}
if value, ok := _u.mutation.ImageConcurrency(); ok {
_spec.SetField(soraaccount.FieldImageConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedImageConcurrency(); ok {
_spec.AddField(soraaccount.FieldImageConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.VideoConcurrency(); ok {
_spec.SetField(soraaccount.FieldVideoConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedVideoConcurrency(); ok {
_spec.AddField(soraaccount.FieldVideoConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.IsExpired(); ok {
_spec.SetField(soraaccount.FieldIsExpired, field.TypeBool, value)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{soraaccount.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// SoraAccountUpdateOne is the builder for updating a single SoraAccount entity.
type SoraAccountUpdateOne struct {
config
fields []string
hooks []Hook
mutation *SoraAccountMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *SoraAccountUpdateOne) SetUpdatedAt(v time.Time) *SoraAccountUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraAccountUpdateOne) SetAccountID(v int64) *SoraAccountUpdateOne {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableAccountID(v *int64) *SoraAccountUpdateOne {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraAccountUpdateOne) AddAccountID(v int64) *SoraAccountUpdateOne {
_u.mutation.AddAccountID(v)
return _u
}
// SetAccessToken sets the "access_token" field.
func (_u *SoraAccountUpdateOne) SetAccessToken(v string) *SoraAccountUpdateOne {
_u.mutation.SetAccessToken(v)
return _u
}
// SetNillableAccessToken sets the "access_token" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableAccessToken(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetAccessToken(*v)
}
return _u
}
// ClearAccessToken clears the value of the "access_token" field.
func (_u *SoraAccountUpdateOne) ClearAccessToken() *SoraAccountUpdateOne {
_u.mutation.ClearAccessToken()
return _u
}
// SetSessionToken sets the "session_token" field.
func (_u *SoraAccountUpdateOne) SetSessionToken(v string) *SoraAccountUpdateOne {
_u.mutation.SetSessionToken(v)
return _u
}
// SetNillableSessionToken sets the "session_token" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableSessionToken(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetSessionToken(*v)
}
return _u
}
// ClearSessionToken clears the value of the "session_token" field.
func (_u *SoraAccountUpdateOne) ClearSessionToken() *SoraAccountUpdateOne {
_u.mutation.ClearSessionToken()
return _u
}
// SetRefreshToken sets the "refresh_token" field.
func (_u *SoraAccountUpdateOne) SetRefreshToken(v string) *SoraAccountUpdateOne {
_u.mutation.SetRefreshToken(v)
return _u
}
// SetNillableRefreshToken sets the "refresh_token" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableRefreshToken(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetRefreshToken(*v)
}
return _u
}
// ClearRefreshToken clears the value of the "refresh_token" field.
func (_u *SoraAccountUpdateOne) ClearRefreshToken() *SoraAccountUpdateOne {
_u.mutation.ClearRefreshToken()
return _u
}
// SetClientID sets the "client_id" field.
func (_u *SoraAccountUpdateOne) SetClientID(v string) *SoraAccountUpdateOne {
_u.mutation.SetClientID(v)
return _u
}
// SetNillableClientID sets the "client_id" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableClientID(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetClientID(*v)
}
return _u
}
// ClearClientID clears the value of the "client_id" field.
func (_u *SoraAccountUpdateOne) ClearClientID() *SoraAccountUpdateOne {
_u.mutation.ClearClientID()
return _u
}
// SetEmail sets the "email" field.
func (_u *SoraAccountUpdateOne) SetEmail(v string) *SoraAccountUpdateOne {
_u.mutation.SetEmail(v)
return _u
}
// SetNillableEmail sets the "email" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableEmail(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetEmail(*v)
}
return _u
}
// ClearEmail clears the value of the "email" field.
func (_u *SoraAccountUpdateOne) ClearEmail() *SoraAccountUpdateOne {
_u.mutation.ClearEmail()
return _u
}
// SetUsername sets the "username" field.
func (_u *SoraAccountUpdateOne) SetUsername(v string) *SoraAccountUpdateOne {
_u.mutation.SetUsername(v)
return _u
}
// SetNillableUsername sets the "username" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableUsername(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetUsername(*v)
}
return _u
}
// ClearUsername clears the value of the "username" field.
func (_u *SoraAccountUpdateOne) ClearUsername() *SoraAccountUpdateOne {
_u.mutation.ClearUsername()
return _u
}
// SetRemark sets the "remark" field.
func (_u *SoraAccountUpdateOne) SetRemark(v string) *SoraAccountUpdateOne {
_u.mutation.SetRemark(v)
return _u
}
// SetNillableRemark sets the "remark" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableRemark(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetRemark(*v)
}
return _u
}
// ClearRemark clears the value of the "remark" field.
func (_u *SoraAccountUpdateOne) ClearRemark() *SoraAccountUpdateOne {
_u.mutation.ClearRemark()
return _u
}
// SetUseCount sets the "use_count" field.
func (_u *SoraAccountUpdateOne) SetUseCount(v int) *SoraAccountUpdateOne {
_u.mutation.ResetUseCount()
_u.mutation.SetUseCount(v)
return _u
}
// SetNillableUseCount sets the "use_count" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableUseCount(v *int) *SoraAccountUpdateOne {
if v != nil {
_u.SetUseCount(*v)
}
return _u
}
// AddUseCount adds value to the "use_count" field.
func (_u *SoraAccountUpdateOne) AddUseCount(v int) *SoraAccountUpdateOne {
_u.mutation.AddUseCount(v)
return _u
}
// SetPlanType sets the "plan_type" field.
func (_u *SoraAccountUpdateOne) SetPlanType(v string) *SoraAccountUpdateOne {
_u.mutation.SetPlanType(v)
return _u
}
// SetNillablePlanType sets the "plan_type" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillablePlanType(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetPlanType(*v)
}
return _u
}
// ClearPlanType clears the value of the "plan_type" field.
func (_u *SoraAccountUpdateOne) ClearPlanType() *SoraAccountUpdateOne {
_u.mutation.ClearPlanType()
return _u
}
// SetPlanTitle sets the "plan_title" field.
func (_u *SoraAccountUpdateOne) SetPlanTitle(v string) *SoraAccountUpdateOne {
_u.mutation.SetPlanTitle(v)
return _u
}
// SetNillablePlanTitle sets the "plan_title" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillablePlanTitle(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetPlanTitle(*v)
}
return _u
}
// ClearPlanTitle clears the value of the "plan_title" field.
func (_u *SoraAccountUpdateOne) ClearPlanTitle() *SoraAccountUpdateOne {
_u.mutation.ClearPlanTitle()
return _u
}
// SetSubscriptionEnd sets the "subscription_end" field.
func (_u *SoraAccountUpdateOne) SetSubscriptionEnd(v time.Time) *SoraAccountUpdateOne {
_u.mutation.SetSubscriptionEnd(v)
return _u
}
// SetNillableSubscriptionEnd sets the "subscription_end" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableSubscriptionEnd(v *time.Time) *SoraAccountUpdateOne {
if v != nil {
_u.SetSubscriptionEnd(*v)
}
return _u
}
// ClearSubscriptionEnd clears the value of the "subscription_end" field.
func (_u *SoraAccountUpdateOne) ClearSubscriptionEnd() *SoraAccountUpdateOne {
_u.mutation.ClearSubscriptionEnd()
return _u
}
// SetSoraSupported sets the "sora_supported" field.
func (_u *SoraAccountUpdateOne) SetSoraSupported(v bool) *SoraAccountUpdateOne {
_u.mutation.SetSoraSupported(v)
return _u
}
// SetNillableSoraSupported sets the "sora_supported" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableSoraSupported(v *bool) *SoraAccountUpdateOne {
if v != nil {
_u.SetSoraSupported(*v)
}
return _u
}
// SetSoraInviteCode sets the "sora_invite_code" field.
func (_u *SoraAccountUpdateOne) SetSoraInviteCode(v string) *SoraAccountUpdateOne {
_u.mutation.SetSoraInviteCode(v)
return _u
}
// SetNillableSoraInviteCode sets the "sora_invite_code" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableSoraInviteCode(v *string) *SoraAccountUpdateOne {
if v != nil {
_u.SetSoraInviteCode(*v)
}
return _u
}
// ClearSoraInviteCode clears the value of the "sora_invite_code" field.
func (_u *SoraAccountUpdateOne) ClearSoraInviteCode() *SoraAccountUpdateOne {
_u.mutation.ClearSoraInviteCode()
return _u
}
// SetSoraRedeemedCount sets the "sora_redeemed_count" field.
func (_u *SoraAccountUpdateOne) SetSoraRedeemedCount(v int) *SoraAccountUpdateOne {
_u.mutation.ResetSoraRedeemedCount()
_u.mutation.SetSoraRedeemedCount(v)
return _u
}
// SetNillableSoraRedeemedCount sets the "sora_redeemed_count" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableSoraRedeemedCount(v *int) *SoraAccountUpdateOne {
if v != nil {
_u.SetSoraRedeemedCount(*v)
}
return _u
}
// AddSoraRedeemedCount adds value to the "sora_redeemed_count" field.
func (_u *SoraAccountUpdateOne) AddSoraRedeemedCount(v int) *SoraAccountUpdateOne {
_u.mutation.AddSoraRedeemedCount(v)
return _u
}
// SetSoraRemainingCount sets the "sora_remaining_count" field.
func (_u *SoraAccountUpdateOne) SetSoraRemainingCount(v int) *SoraAccountUpdateOne {
_u.mutation.ResetSoraRemainingCount()
_u.mutation.SetSoraRemainingCount(v)
return _u
}
// SetNillableSoraRemainingCount sets the "sora_remaining_count" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableSoraRemainingCount(v *int) *SoraAccountUpdateOne {
if v != nil {
_u.SetSoraRemainingCount(*v)
}
return _u
}
// AddSoraRemainingCount adds value to the "sora_remaining_count" field.
func (_u *SoraAccountUpdateOne) AddSoraRemainingCount(v int) *SoraAccountUpdateOne {
_u.mutation.AddSoraRemainingCount(v)
return _u
}
// SetSoraTotalCount sets the "sora_total_count" field.
func (_u *SoraAccountUpdateOne) SetSoraTotalCount(v int) *SoraAccountUpdateOne {
_u.mutation.ResetSoraTotalCount()
_u.mutation.SetSoraTotalCount(v)
return _u
}
// SetNillableSoraTotalCount sets the "sora_total_count" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableSoraTotalCount(v *int) *SoraAccountUpdateOne {
if v != nil {
_u.SetSoraTotalCount(*v)
}
return _u
}
// AddSoraTotalCount adds value to the "sora_total_count" field.
func (_u *SoraAccountUpdateOne) AddSoraTotalCount(v int) *SoraAccountUpdateOne {
_u.mutation.AddSoraTotalCount(v)
return _u
}
// SetSoraCooldownUntil sets the "sora_cooldown_until" field.
func (_u *SoraAccountUpdateOne) SetSoraCooldownUntil(v time.Time) *SoraAccountUpdateOne {
_u.mutation.SetSoraCooldownUntil(v)
return _u
}
// SetNillableSoraCooldownUntil sets the "sora_cooldown_until" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableSoraCooldownUntil(v *time.Time) *SoraAccountUpdateOne {
if v != nil {
_u.SetSoraCooldownUntil(*v)
}
return _u
}
// ClearSoraCooldownUntil clears the value of the "sora_cooldown_until" field.
func (_u *SoraAccountUpdateOne) ClearSoraCooldownUntil() *SoraAccountUpdateOne {
_u.mutation.ClearSoraCooldownUntil()
return _u
}
// SetCooledUntil sets the "cooled_until" field.
func (_u *SoraAccountUpdateOne) SetCooledUntil(v time.Time) *SoraAccountUpdateOne {
_u.mutation.SetCooledUntil(v)
return _u
}
// SetNillableCooledUntil sets the "cooled_until" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableCooledUntil(v *time.Time) *SoraAccountUpdateOne {
if v != nil {
_u.SetCooledUntil(*v)
}
return _u
}
// ClearCooledUntil clears the value of the "cooled_until" field.
func (_u *SoraAccountUpdateOne) ClearCooledUntil() *SoraAccountUpdateOne {
_u.mutation.ClearCooledUntil()
return _u
}
// SetImageEnabled sets the "image_enabled" field.
func (_u *SoraAccountUpdateOne) SetImageEnabled(v bool) *SoraAccountUpdateOne {
_u.mutation.SetImageEnabled(v)
return _u
}
// SetNillableImageEnabled sets the "image_enabled" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableImageEnabled(v *bool) *SoraAccountUpdateOne {
if v != nil {
_u.SetImageEnabled(*v)
}
return _u
}
// SetVideoEnabled sets the "video_enabled" field.
func (_u *SoraAccountUpdateOne) SetVideoEnabled(v bool) *SoraAccountUpdateOne {
_u.mutation.SetVideoEnabled(v)
return _u
}
// SetNillableVideoEnabled sets the "video_enabled" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableVideoEnabled(v *bool) *SoraAccountUpdateOne {
if v != nil {
_u.SetVideoEnabled(*v)
}
return _u
}
// SetImageConcurrency sets the "image_concurrency" field.
func (_u *SoraAccountUpdateOne) SetImageConcurrency(v int) *SoraAccountUpdateOne {
_u.mutation.ResetImageConcurrency()
_u.mutation.SetImageConcurrency(v)
return _u
}
// SetNillableImageConcurrency sets the "image_concurrency" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableImageConcurrency(v *int) *SoraAccountUpdateOne {
if v != nil {
_u.SetImageConcurrency(*v)
}
return _u
}
// AddImageConcurrency adds value to the "image_concurrency" field.
func (_u *SoraAccountUpdateOne) AddImageConcurrency(v int) *SoraAccountUpdateOne {
_u.mutation.AddImageConcurrency(v)
return _u
}
// SetVideoConcurrency sets the "video_concurrency" field.
func (_u *SoraAccountUpdateOne) SetVideoConcurrency(v int) *SoraAccountUpdateOne {
_u.mutation.ResetVideoConcurrency()
_u.mutation.SetVideoConcurrency(v)
return _u
}
// SetNillableVideoConcurrency sets the "video_concurrency" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableVideoConcurrency(v *int) *SoraAccountUpdateOne {
if v != nil {
_u.SetVideoConcurrency(*v)
}
return _u
}
// AddVideoConcurrency adds value to the "video_concurrency" field.
func (_u *SoraAccountUpdateOne) AddVideoConcurrency(v int) *SoraAccountUpdateOne {
_u.mutation.AddVideoConcurrency(v)
return _u
}
// SetIsExpired sets the "is_expired" field.
func (_u *SoraAccountUpdateOne) SetIsExpired(v bool) *SoraAccountUpdateOne {
_u.mutation.SetIsExpired(v)
return _u
}
// SetNillableIsExpired sets the "is_expired" field if the given value is not nil.
func (_u *SoraAccountUpdateOne) SetNillableIsExpired(v *bool) *SoraAccountUpdateOne {
if v != nil {
_u.SetIsExpired(*v)
}
return _u
}
// Mutation returns the SoraAccountMutation object of the builder.
func (_u *SoraAccountUpdateOne) Mutation() *SoraAccountMutation {
return _u.mutation
}
// Where appends a list predicates to the SoraAccountUpdate builder.
func (_u *SoraAccountUpdateOne) Where(ps ...predicate.SoraAccount) *SoraAccountUpdateOne {
_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 *SoraAccountUpdateOne) Select(field string, fields ...string) *SoraAccountUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated SoraAccount entity.
func (_u *SoraAccountUpdateOne) Save(ctx context.Context) (*SoraAccount, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraAccountUpdateOne) SaveX(ctx context.Context) *SoraAccount {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *SoraAccountUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraAccountUpdateOne) 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 *SoraAccountUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := soraaccount.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
func (_u *SoraAccountUpdateOne) sqlSave(ctx context.Context) (_node *SoraAccount, err error) {
_spec := sqlgraph.NewUpdateSpec(soraaccount.Table, soraaccount.Columns, sqlgraph.NewFieldSpec(soraaccount.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SoraAccount.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, soraaccount.FieldID)
for _, f := range fields {
if !soraaccount.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != soraaccount.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(soraaccount.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soraaccount.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soraaccount.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AccessToken(); ok {
_spec.SetField(soraaccount.FieldAccessToken, field.TypeString, value)
}
if _u.mutation.AccessTokenCleared() {
_spec.ClearField(soraaccount.FieldAccessToken, field.TypeString)
}
if value, ok := _u.mutation.SessionToken(); ok {
_spec.SetField(soraaccount.FieldSessionToken, field.TypeString, value)
}
if _u.mutation.SessionTokenCleared() {
_spec.ClearField(soraaccount.FieldSessionToken, field.TypeString)
}
if value, ok := _u.mutation.RefreshToken(); ok {
_spec.SetField(soraaccount.FieldRefreshToken, field.TypeString, value)
}
if _u.mutation.RefreshTokenCleared() {
_spec.ClearField(soraaccount.FieldRefreshToken, field.TypeString)
}
if value, ok := _u.mutation.ClientID(); ok {
_spec.SetField(soraaccount.FieldClientID, field.TypeString, value)
}
if _u.mutation.ClientIDCleared() {
_spec.ClearField(soraaccount.FieldClientID, field.TypeString)
}
if value, ok := _u.mutation.Email(); ok {
_spec.SetField(soraaccount.FieldEmail, field.TypeString, value)
}
if _u.mutation.EmailCleared() {
_spec.ClearField(soraaccount.FieldEmail, field.TypeString)
}
if value, ok := _u.mutation.Username(); ok {
_spec.SetField(soraaccount.FieldUsername, field.TypeString, value)
}
if _u.mutation.UsernameCleared() {
_spec.ClearField(soraaccount.FieldUsername, field.TypeString)
}
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(soraaccount.FieldRemark, field.TypeString, value)
}
if _u.mutation.RemarkCleared() {
_spec.ClearField(soraaccount.FieldRemark, field.TypeString)
}
if value, ok := _u.mutation.UseCount(); ok {
_spec.SetField(soraaccount.FieldUseCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedUseCount(); ok {
_spec.AddField(soraaccount.FieldUseCount, field.TypeInt, value)
}
if value, ok := _u.mutation.PlanType(); ok {
_spec.SetField(soraaccount.FieldPlanType, field.TypeString, value)
}
if _u.mutation.PlanTypeCleared() {
_spec.ClearField(soraaccount.FieldPlanType, field.TypeString)
}
if value, ok := _u.mutation.PlanTitle(); ok {
_spec.SetField(soraaccount.FieldPlanTitle, field.TypeString, value)
}
if _u.mutation.PlanTitleCleared() {
_spec.ClearField(soraaccount.FieldPlanTitle, field.TypeString)
}
if value, ok := _u.mutation.SubscriptionEnd(); ok {
_spec.SetField(soraaccount.FieldSubscriptionEnd, field.TypeTime, value)
}
if _u.mutation.SubscriptionEndCleared() {
_spec.ClearField(soraaccount.FieldSubscriptionEnd, field.TypeTime)
}
if value, ok := _u.mutation.SoraSupported(); ok {
_spec.SetField(soraaccount.FieldSoraSupported, field.TypeBool, value)
}
if value, ok := _u.mutation.SoraInviteCode(); ok {
_spec.SetField(soraaccount.FieldSoraInviteCode, field.TypeString, value)
}
if _u.mutation.SoraInviteCodeCleared() {
_spec.ClearField(soraaccount.FieldSoraInviteCode, field.TypeString)
}
if value, ok := _u.mutation.SoraRedeemedCount(); ok {
_spec.SetField(soraaccount.FieldSoraRedeemedCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedSoraRedeemedCount(); ok {
_spec.AddField(soraaccount.FieldSoraRedeemedCount, field.TypeInt, value)
}
if value, ok := _u.mutation.SoraRemainingCount(); ok {
_spec.SetField(soraaccount.FieldSoraRemainingCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedSoraRemainingCount(); ok {
_spec.AddField(soraaccount.FieldSoraRemainingCount, field.TypeInt, value)
}
if value, ok := _u.mutation.SoraTotalCount(); ok {
_spec.SetField(soraaccount.FieldSoraTotalCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedSoraTotalCount(); ok {
_spec.AddField(soraaccount.FieldSoraTotalCount, field.TypeInt, value)
}
if value, ok := _u.mutation.SoraCooldownUntil(); ok {
_spec.SetField(soraaccount.FieldSoraCooldownUntil, field.TypeTime, value)
}
if _u.mutation.SoraCooldownUntilCleared() {
_spec.ClearField(soraaccount.FieldSoraCooldownUntil, field.TypeTime)
}
if value, ok := _u.mutation.CooledUntil(); ok {
_spec.SetField(soraaccount.FieldCooledUntil, field.TypeTime, value)
}
if _u.mutation.CooledUntilCleared() {
_spec.ClearField(soraaccount.FieldCooledUntil, field.TypeTime)
}
if value, ok := _u.mutation.ImageEnabled(); ok {
_spec.SetField(soraaccount.FieldImageEnabled, field.TypeBool, value)
}
if value, ok := _u.mutation.VideoEnabled(); ok {
_spec.SetField(soraaccount.FieldVideoEnabled, field.TypeBool, value)
}
if value, ok := _u.mutation.ImageConcurrency(); ok {
_spec.SetField(soraaccount.FieldImageConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedImageConcurrency(); ok {
_spec.AddField(soraaccount.FieldImageConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.VideoConcurrency(); ok {
_spec.SetField(soraaccount.FieldVideoConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedVideoConcurrency(); ok {
_spec.AddField(soraaccount.FieldVideoConcurrency, field.TypeInt, value)
}
if value, ok := _u.mutation.IsExpired(); ok {
_spec.SetField(soraaccount.FieldIsExpired, field.TypeBool, value)
}
_node = &SoraAccount{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{soraaccount.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
)
// SoraCacheFile is the model entity for the SoraCacheFile schema.
type SoraCacheFile struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// TaskID holds the value of the "task_id" field.
TaskID *string `json:"task_id,omitempty"`
// AccountID holds the value of the "account_id" field.
AccountID int64 `json:"account_id,omitempty"`
// UserID holds the value of the "user_id" field.
UserID int64 `json:"user_id,omitempty"`
// MediaType holds the value of the "media_type" field.
MediaType string `json:"media_type,omitempty"`
// OriginalURL holds the value of the "original_url" field.
OriginalURL string `json:"original_url,omitempty"`
// CachePath holds the value of the "cache_path" field.
CachePath string `json:"cache_path,omitempty"`
// CacheURL holds the value of the "cache_url" field.
CacheURL string `json:"cache_url,omitempty"`
// SizeBytes holds the value of the "size_bytes" field.
SizeBytes int64 `json:"size_bytes,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*SoraCacheFile) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case soracachefile.FieldID, soracachefile.FieldAccountID, soracachefile.FieldUserID, soracachefile.FieldSizeBytes:
values[i] = new(sql.NullInt64)
case soracachefile.FieldTaskID, soracachefile.FieldMediaType, soracachefile.FieldOriginalURL, soracachefile.FieldCachePath, soracachefile.FieldCacheURL:
values[i] = new(sql.NullString)
case soracachefile.FieldCreatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the SoraCacheFile fields.
func (_m *SoraCacheFile) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case soracachefile.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case soracachefile.FieldTaskID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field task_id", values[i])
} else if value.Valid {
_m.TaskID = new(string)
*_m.TaskID = value.String
}
case soracachefile.FieldAccountID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field account_id", values[i])
} else if value.Valid {
_m.AccountID = value.Int64
}
case soracachefile.FieldUserID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
_m.UserID = value.Int64
}
case soracachefile.FieldMediaType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field media_type", values[i])
} else if value.Valid {
_m.MediaType = value.String
}
case soracachefile.FieldOriginalURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field original_url", values[i])
} else if value.Valid {
_m.OriginalURL = value.String
}
case soracachefile.FieldCachePath:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field cache_path", values[i])
} else if value.Valid {
_m.CachePath = value.String
}
case soracachefile.FieldCacheURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field cache_url", values[i])
} else if value.Valid {
_m.CacheURL = value.String
}
case soracachefile.FieldSizeBytes:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field size_bytes", values[i])
} else if value.Valid {
_m.SizeBytes = value.Int64
}
case soracachefile.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the SoraCacheFile.
// This includes values selected through modifiers, order, etc.
func (_m *SoraCacheFile) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this SoraCacheFile.
// Note that you need to call SoraCacheFile.Unwrap() before calling this method if this SoraCacheFile
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *SoraCacheFile) Update() *SoraCacheFileUpdateOne {
return NewSoraCacheFileClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the SoraCacheFile entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *SoraCacheFile) Unwrap() *SoraCacheFile {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: SoraCacheFile is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *SoraCacheFile) String() string {
var builder strings.Builder
builder.WriteString("SoraCacheFile(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
if v := _m.TaskID; v != nil {
builder.WriteString("task_id=")
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("account_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AccountID))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
builder.WriteString(", ")
builder.WriteString("media_type=")
builder.WriteString(_m.MediaType)
builder.WriteString(", ")
builder.WriteString("original_url=")
builder.WriteString(_m.OriginalURL)
builder.WriteString(", ")
builder.WriteString("cache_path=")
builder.WriteString(_m.CachePath)
builder.WriteString(", ")
builder.WriteString("cache_url=")
builder.WriteString(_m.CacheURL)
builder.WriteString(", ")
builder.WriteString("size_bytes=")
builder.WriteString(fmt.Sprintf("%v", _m.SizeBytes))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// SoraCacheFiles is a parsable slice of SoraCacheFile.
type SoraCacheFiles []*SoraCacheFile
// Code generated by ent, DO NOT EDIT.
package soracachefile
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the soracachefile type in the database.
Label = "sora_cache_file"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldTaskID holds the string denoting the task_id field in the database.
FieldTaskID = "task_id"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldMediaType holds the string denoting the media_type field in the database.
FieldMediaType = "media_type"
// FieldOriginalURL holds the string denoting the original_url field in the database.
FieldOriginalURL = "original_url"
// FieldCachePath holds the string denoting the cache_path field in the database.
FieldCachePath = "cache_path"
// FieldCacheURL holds the string denoting the cache_url field in the database.
FieldCacheURL = "cache_url"
// FieldSizeBytes holds the string denoting the size_bytes field in the database.
FieldSizeBytes = "size_bytes"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// Table holds the table name of the soracachefile in the database.
Table = "sora_cache_files"
)
// Columns holds all SQL columns for soracachefile fields.
var Columns = []string{
FieldID,
FieldTaskID,
FieldAccountID,
FieldUserID,
FieldMediaType,
FieldOriginalURL,
FieldCachePath,
FieldCacheURL,
FieldSizeBytes,
FieldCreatedAt,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// TaskIDValidator is a validator for the "task_id" field. It is called by the builders before save.
TaskIDValidator func(string) error
// MediaTypeValidator is a validator for the "media_type" field. It is called by the builders before save.
MediaTypeValidator func(string) error
// DefaultSizeBytes holds the default value on creation for the "size_bytes" field.
DefaultSizeBytes int64
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the SoraCacheFile queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByTaskID orders the results by the task_id field.
func ByTaskID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTaskID, opts...).ToFunc()
}
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByMediaType orders the results by the media_type field.
func ByMediaType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldMediaType, opts...).ToFunc()
}
// ByOriginalURL orders the results by the original_url field.
func ByOriginalURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOriginalURL, opts...).ToFunc()
}
// ByCachePath orders the results by the cache_path field.
func ByCachePath(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCachePath, opts...).ToFunc()
}
// ByCacheURL orders the results by the cache_url field.
func ByCacheURL(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCacheURL, opts...).ToFunc()
}
// BySizeBytes orders the results by the size_bytes field.
func BySizeBytes(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSizeBytes, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// Code generated by ent, DO NOT EDIT.
package soracachefile
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldID, id))
}
// TaskID applies equality check predicate on the "task_id" field. It's identical to TaskIDEQ.
func TaskID(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldTaskID, v))
}
// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ.
func AccountID(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldAccountID, v))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldUserID, v))
}
// MediaType applies equality check predicate on the "media_type" field. It's identical to MediaTypeEQ.
func MediaType(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldMediaType, v))
}
// OriginalURL applies equality check predicate on the "original_url" field. It's identical to OriginalURLEQ.
func OriginalURL(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldOriginalURL, v))
}
// CachePath applies equality check predicate on the "cache_path" field. It's identical to CachePathEQ.
func CachePath(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCachePath, v))
}
// CacheURL applies equality check predicate on the "cache_url" field. It's identical to CacheURLEQ.
func CacheURL(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCacheURL, v))
}
// SizeBytes applies equality check predicate on the "size_bytes" field. It's identical to SizeBytesEQ.
func SizeBytes(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldSizeBytes, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCreatedAt, v))
}
// TaskIDEQ applies the EQ predicate on the "task_id" field.
func TaskIDEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldTaskID, v))
}
// TaskIDNEQ applies the NEQ predicate on the "task_id" field.
func TaskIDNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldTaskID, v))
}
// TaskIDIn applies the In predicate on the "task_id" field.
func TaskIDIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldTaskID, vs...))
}
// TaskIDNotIn applies the NotIn predicate on the "task_id" field.
func TaskIDNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldTaskID, vs...))
}
// TaskIDGT applies the GT predicate on the "task_id" field.
func TaskIDGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldTaskID, v))
}
// TaskIDGTE applies the GTE predicate on the "task_id" field.
func TaskIDGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldTaskID, v))
}
// TaskIDLT applies the LT predicate on the "task_id" field.
func TaskIDLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldTaskID, v))
}
// TaskIDLTE applies the LTE predicate on the "task_id" field.
func TaskIDLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldTaskID, v))
}
// TaskIDContains applies the Contains predicate on the "task_id" field.
func TaskIDContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldTaskID, v))
}
// TaskIDHasPrefix applies the HasPrefix predicate on the "task_id" field.
func TaskIDHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldTaskID, v))
}
// TaskIDHasSuffix applies the HasSuffix predicate on the "task_id" field.
func TaskIDHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldTaskID, v))
}
// TaskIDIsNil applies the IsNil predicate on the "task_id" field.
func TaskIDIsNil() predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIsNull(FieldTaskID))
}
// TaskIDNotNil applies the NotNil predicate on the "task_id" field.
func TaskIDNotNil() predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotNull(FieldTaskID))
}
// TaskIDEqualFold applies the EqualFold predicate on the "task_id" field.
func TaskIDEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldTaskID, v))
}
// TaskIDContainsFold applies the ContainsFold predicate on the "task_id" field.
func TaskIDContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldTaskID, v))
}
// AccountIDEQ applies the EQ predicate on the "account_id" field.
func AccountIDEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldAccountID, v))
}
// AccountIDNEQ applies the NEQ predicate on the "account_id" field.
func AccountIDNEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldAccountID, v))
}
// AccountIDIn applies the In predicate on the "account_id" field.
func AccountIDIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldAccountID, vs...))
}
// AccountIDNotIn applies the NotIn predicate on the "account_id" field.
func AccountIDNotIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldAccountID, vs...))
}
// AccountIDGT applies the GT predicate on the "account_id" field.
func AccountIDGT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldAccountID, v))
}
// AccountIDGTE applies the GTE predicate on the "account_id" field.
func AccountIDGTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldAccountID, v))
}
// AccountIDLT applies the LT predicate on the "account_id" field.
func AccountIDLT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldAccountID, v))
}
// AccountIDLTE applies the LTE predicate on the "account_id" field.
func AccountIDLTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldAccountID, v))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldUserID, vs...))
}
// UserIDGT applies the GT predicate on the "user_id" field.
func UserIDGT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldUserID, v))
}
// UserIDGTE applies the GTE predicate on the "user_id" field.
func UserIDGTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldUserID, v))
}
// UserIDLT applies the LT predicate on the "user_id" field.
func UserIDLT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldUserID, v))
}
// UserIDLTE applies the LTE predicate on the "user_id" field.
func UserIDLTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldUserID, v))
}
// MediaTypeEQ applies the EQ predicate on the "media_type" field.
func MediaTypeEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldMediaType, v))
}
// MediaTypeNEQ applies the NEQ predicate on the "media_type" field.
func MediaTypeNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldMediaType, v))
}
// MediaTypeIn applies the In predicate on the "media_type" field.
func MediaTypeIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldMediaType, vs...))
}
// MediaTypeNotIn applies the NotIn predicate on the "media_type" field.
func MediaTypeNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldMediaType, vs...))
}
// MediaTypeGT applies the GT predicate on the "media_type" field.
func MediaTypeGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldMediaType, v))
}
// MediaTypeGTE applies the GTE predicate on the "media_type" field.
func MediaTypeGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldMediaType, v))
}
// MediaTypeLT applies the LT predicate on the "media_type" field.
func MediaTypeLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldMediaType, v))
}
// MediaTypeLTE applies the LTE predicate on the "media_type" field.
func MediaTypeLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldMediaType, v))
}
// MediaTypeContains applies the Contains predicate on the "media_type" field.
func MediaTypeContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldMediaType, v))
}
// MediaTypeHasPrefix applies the HasPrefix predicate on the "media_type" field.
func MediaTypeHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldMediaType, v))
}
// MediaTypeHasSuffix applies the HasSuffix predicate on the "media_type" field.
func MediaTypeHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldMediaType, v))
}
// MediaTypeEqualFold applies the EqualFold predicate on the "media_type" field.
func MediaTypeEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldMediaType, v))
}
// MediaTypeContainsFold applies the ContainsFold predicate on the "media_type" field.
func MediaTypeContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldMediaType, v))
}
// OriginalURLEQ applies the EQ predicate on the "original_url" field.
func OriginalURLEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldOriginalURL, v))
}
// OriginalURLNEQ applies the NEQ predicate on the "original_url" field.
func OriginalURLNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldOriginalURL, v))
}
// OriginalURLIn applies the In predicate on the "original_url" field.
func OriginalURLIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldOriginalURL, vs...))
}
// OriginalURLNotIn applies the NotIn predicate on the "original_url" field.
func OriginalURLNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldOriginalURL, vs...))
}
// OriginalURLGT applies the GT predicate on the "original_url" field.
func OriginalURLGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldOriginalURL, v))
}
// OriginalURLGTE applies the GTE predicate on the "original_url" field.
func OriginalURLGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldOriginalURL, v))
}
// OriginalURLLT applies the LT predicate on the "original_url" field.
func OriginalURLLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldOriginalURL, v))
}
// OriginalURLLTE applies the LTE predicate on the "original_url" field.
func OriginalURLLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldOriginalURL, v))
}
// OriginalURLContains applies the Contains predicate on the "original_url" field.
func OriginalURLContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldOriginalURL, v))
}
// OriginalURLHasPrefix applies the HasPrefix predicate on the "original_url" field.
func OriginalURLHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldOriginalURL, v))
}
// OriginalURLHasSuffix applies the HasSuffix predicate on the "original_url" field.
func OriginalURLHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldOriginalURL, v))
}
// OriginalURLEqualFold applies the EqualFold predicate on the "original_url" field.
func OriginalURLEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldOriginalURL, v))
}
// OriginalURLContainsFold applies the ContainsFold predicate on the "original_url" field.
func OriginalURLContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldOriginalURL, v))
}
// CachePathEQ applies the EQ predicate on the "cache_path" field.
func CachePathEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCachePath, v))
}
// CachePathNEQ applies the NEQ predicate on the "cache_path" field.
func CachePathNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldCachePath, v))
}
// CachePathIn applies the In predicate on the "cache_path" field.
func CachePathIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldCachePath, vs...))
}
// CachePathNotIn applies the NotIn predicate on the "cache_path" field.
func CachePathNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldCachePath, vs...))
}
// CachePathGT applies the GT predicate on the "cache_path" field.
func CachePathGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldCachePath, v))
}
// CachePathGTE applies the GTE predicate on the "cache_path" field.
func CachePathGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldCachePath, v))
}
// CachePathLT applies the LT predicate on the "cache_path" field.
func CachePathLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldCachePath, v))
}
// CachePathLTE applies the LTE predicate on the "cache_path" field.
func CachePathLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldCachePath, v))
}
// CachePathContains applies the Contains predicate on the "cache_path" field.
func CachePathContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldCachePath, v))
}
// CachePathHasPrefix applies the HasPrefix predicate on the "cache_path" field.
func CachePathHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldCachePath, v))
}
// CachePathHasSuffix applies the HasSuffix predicate on the "cache_path" field.
func CachePathHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldCachePath, v))
}
// CachePathEqualFold applies the EqualFold predicate on the "cache_path" field.
func CachePathEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldCachePath, v))
}
// CachePathContainsFold applies the ContainsFold predicate on the "cache_path" field.
func CachePathContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldCachePath, v))
}
// CacheURLEQ applies the EQ predicate on the "cache_url" field.
func CacheURLEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCacheURL, v))
}
// CacheURLNEQ applies the NEQ predicate on the "cache_url" field.
func CacheURLNEQ(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldCacheURL, v))
}
// CacheURLIn applies the In predicate on the "cache_url" field.
func CacheURLIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldCacheURL, vs...))
}
// CacheURLNotIn applies the NotIn predicate on the "cache_url" field.
func CacheURLNotIn(vs ...string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldCacheURL, vs...))
}
// CacheURLGT applies the GT predicate on the "cache_url" field.
func CacheURLGT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldCacheURL, v))
}
// CacheURLGTE applies the GTE predicate on the "cache_url" field.
func CacheURLGTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldCacheURL, v))
}
// CacheURLLT applies the LT predicate on the "cache_url" field.
func CacheURLLT(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldCacheURL, v))
}
// CacheURLLTE applies the LTE predicate on the "cache_url" field.
func CacheURLLTE(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldCacheURL, v))
}
// CacheURLContains applies the Contains predicate on the "cache_url" field.
func CacheURLContains(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContains(FieldCacheURL, v))
}
// CacheURLHasPrefix applies the HasPrefix predicate on the "cache_url" field.
func CacheURLHasPrefix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasPrefix(FieldCacheURL, v))
}
// CacheURLHasSuffix applies the HasSuffix predicate on the "cache_url" field.
func CacheURLHasSuffix(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldHasSuffix(FieldCacheURL, v))
}
// CacheURLEqualFold applies the EqualFold predicate on the "cache_url" field.
func CacheURLEqualFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEqualFold(FieldCacheURL, v))
}
// CacheURLContainsFold applies the ContainsFold predicate on the "cache_url" field.
func CacheURLContainsFold(v string) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldContainsFold(FieldCacheURL, v))
}
// SizeBytesEQ applies the EQ predicate on the "size_bytes" field.
func SizeBytesEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldSizeBytes, v))
}
// SizeBytesNEQ applies the NEQ predicate on the "size_bytes" field.
func SizeBytesNEQ(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldSizeBytes, v))
}
// SizeBytesIn applies the In predicate on the "size_bytes" field.
func SizeBytesIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldSizeBytes, vs...))
}
// SizeBytesNotIn applies the NotIn predicate on the "size_bytes" field.
func SizeBytesNotIn(vs ...int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldSizeBytes, vs...))
}
// SizeBytesGT applies the GT predicate on the "size_bytes" field.
func SizeBytesGT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldSizeBytes, v))
}
// SizeBytesGTE applies the GTE predicate on the "size_bytes" field.
func SizeBytesGTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldSizeBytes, v))
}
// SizeBytesLT applies the LT predicate on the "size_bytes" field.
func SizeBytesLT(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldSizeBytes, v))
}
// SizeBytesLTE applies the LTE predicate on the "size_bytes" field.
func SizeBytesLTE(v int64) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldSizeBytes, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.FieldLTE(FieldCreatedAt, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.SoraCacheFile) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.SoraCacheFile) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.SoraCacheFile) predicate.SoraCacheFile {
return predicate.SoraCacheFile(sql.NotPredicates(p))
}
// 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/Wei-Shaw/sub2api/ent/soracachefile"
)
// SoraCacheFileCreate is the builder for creating a SoraCacheFile entity.
type SoraCacheFileCreate struct {
config
mutation *SoraCacheFileMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetTaskID sets the "task_id" field.
func (_c *SoraCacheFileCreate) SetTaskID(v string) *SoraCacheFileCreate {
_c.mutation.SetTaskID(v)
return _c
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_c *SoraCacheFileCreate) SetNillableTaskID(v *string) *SoraCacheFileCreate {
if v != nil {
_c.SetTaskID(*v)
}
return _c
}
// SetAccountID sets the "account_id" field.
func (_c *SoraCacheFileCreate) SetAccountID(v int64) *SoraCacheFileCreate {
_c.mutation.SetAccountID(v)
return _c
}
// SetUserID sets the "user_id" field.
func (_c *SoraCacheFileCreate) SetUserID(v int64) *SoraCacheFileCreate {
_c.mutation.SetUserID(v)
return _c
}
// SetMediaType sets the "media_type" field.
func (_c *SoraCacheFileCreate) SetMediaType(v string) *SoraCacheFileCreate {
_c.mutation.SetMediaType(v)
return _c
}
// SetOriginalURL sets the "original_url" field.
func (_c *SoraCacheFileCreate) SetOriginalURL(v string) *SoraCacheFileCreate {
_c.mutation.SetOriginalURL(v)
return _c
}
// SetCachePath sets the "cache_path" field.
func (_c *SoraCacheFileCreate) SetCachePath(v string) *SoraCacheFileCreate {
_c.mutation.SetCachePath(v)
return _c
}
// SetCacheURL sets the "cache_url" field.
func (_c *SoraCacheFileCreate) SetCacheURL(v string) *SoraCacheFileCreate {
_c.mutation.SetCacheURL(v)
return _c
}
// SetSizeBytes sets the "size_bytes" field.
func (_c *SoraCacheFileCreate) SetSizeBytes(v int64) *SoraCacheFileCreate {
_c.mutation.SetSizeBytes(v)
return _c
}
// SetNillableSizeBytes sets the "size_bytes" field if the given value is not nil.
func (_c *SoraCacheFileCreate) SetNillableSizeBytes(v *int64) *SoraCacheFileCreate {
if v != nil {
_c.SetSizeBytes(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *SoraCacheFileCreate) SetCreatedAt(v time.Time) *SoraCacheFileCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *SoraCacheFileCreate) SetNillableCreatedAt(v *time.Time) *SoraCacheFileCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// Mutation returns the SoraCacheFileMutation object of the builder.
func (_c *SoraCacheFileCreate) Mutation() *SoraCacheFileMutation {
return _c.mutation
}
// Save creates the SoraCacheFile in the database.
func (_c *SoraCacheFileCreate) Save(ctx context.Context) (*SoraCacheFile, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *SoraCacheFileCreate) SaveX(ctx context.Context) *SoraCacheFile {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SoraCacheFileCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SoraCacheFileCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *SoraCacheFileCreate) defaults() {
if _, ok := _c.mutation.SizeBytes(); !ok {
v := soracachefile.DefaultSizeBytes
_c.mutation.SetSizeBytes(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := soracachefile.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *SoraCacheFileCreate) check() error {
if v, ok := _c.mutation.TaskID(); ok {
if err := soracachefile.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.task_id": %w`, err)}
}
}
if _, ok := _c.mutation.AccountID(); !ok {
return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "SoraCacheFile.account_id"`)}
}
if _, ok := _c.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "SoraCacheFile.user_id"`)}
}
if _, ok := _c.mutation.MediaType(); !ok {
return &ValidationError{Name: "media_type", err: errors.New(`ent: missing required field "SoraCacheFile.media_type"`)}
}
if v, ok := _c.mutation.MediaType(); ok {
if err := soracachefile.MediaTypeValidator(v); err != nil {
return &ValidationError{Name: "media_type", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.media_type": %w`, err)}
}
}
if _, ok := _c.mutation.OriginalURL(); !ok {
return &ValidationError{Name: "original_url", err: errors.New(`ent: missing required field "SoraCacheFile.original_url"`)}
}
if _, ok := _c.mutation.CachePath(); !ok {
return &ValidationError{Name: "cache_path", err: errors.New(`ent: missing required field "SoraCacheFile.cache_path"`)}
}
if _, ok := _c.mutation.CacheURL(); !ok {
return &ValidationError{Name: "cache_url", err: errors.New(`ent: missing required field "SoraCacheFile.cache_url"`)}
}
if _, ok := _c.mutation.SizeBytes(); !ok {
return &ValidationError{Name: "size_bytes", err: errors.New(`ent: missing required field "SoraCacheFile.size_bytes"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SoraCacheFile.created_at"`)}
}
return nil
}
func (_c *SoraCacheFileCreate) sqlSave(ctx context.Context) (*SoraCacheFile, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *SoraCacheFileCreate) createSpec() (*SoraCacheFile, *sqlgraph.CreateSpec) {
var (
_node = &SoraCacheFile{config: _c.config}
_spec = sqlgraph.NewCreateSpec(soracachefile.Table, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.TaskID(); ok {
_spec.SetField(soracachefile.FieldTaskID, field.TypeString, value)
_node.TaskID = &value
}
if value, ok := _c.mutation.AccountID(); ok {
_spec.SetField(soracachefile.FieldAccountID, field.TypeInt64, value)
_node.AccountID = value
}
if value, ok := _c.mutation.UserID(); ok {
_spec.SetField(soracachefile.FieldUserID, field.TypeInt64, value)
_node.UserID = value
}
if value, ok := _c.mutation.MediaType(); ok {
_spec.SetField(soracachefile.FieldMediaType, field.TypeString, value)
_node.MediaType = value
}
if value, ok := _c.mutation.OriginalURL(); ok {
_spec.SetField(soracachefile.FieldOriginalURL, field.TypeString, value)
_node.OriginalURL = value
}
if value, ok := _c.mutation.CachePath(); ok {
_spec.SetField(soracachefile.FieldCachePath, field.TypeString, value)
_node.CachePath = value
}
if value, ok := _c.mutation.CacheURL(); ok {
_spec.SetField(soracachefile.FieldCacheURL, field.TypeString, value)
_node.CacheURL = value
}
if value, ok := _c.mutation.SizeBytes(); ok {
_spec.SetField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
_node.SizeBytes = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(soracachefile.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SoraCacheFile.Create().
// SetTaskID(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.SoraCacheFileUpsert) {
// SetTaskID(v+v).
// }).
// Exec(ctx)
func (_c *SoraCacheFileCreate) OnConflict(opts ...sql.ConflictOption) *SoraCacheFileUpsertOne {
_c.conflict = opts
return &SoraCacheFileUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SoraCacheFile.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SoraCacheFileCreate) OnConflictColumns(columns ...string) *SoraCacheFileUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SoraCacheFileUpsertOne{
create: _c,
}
}
type (
// SoraCacheFileUpsertOne is the builder for "upsert"-ing
// one SoraCacheFile node.
SoraCacheFileUpsertOne struct {
create *SoraCacheFileCreate
}
// SoraCacheFileUpsert is the "OnConflict" setter.
SoraCacheFileUpsert struct {
*sql.UpdateSet
}
)
// SetTaskID sets the "task_id" field.
func (u *SoraCacheFileUpsert) SetTaskID(v string) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldTaskID, v)
return u
}
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateTaskID() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldTaskID)
return u
}
// ClearTaskID clears the value of the "task_id" field.
func (u *SoraCacheFileUpsert) ClearTaskID() *SoraCacheFileUpsert {
u.SetNull(soracachefile.FieldTaskID)
return u
}
// SetAccountID sets the "account_id" field.
func (u *SoraCacheFileUpsert) SetAccountID(v int64) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldAccountID, v)
return u
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateAccountID() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldAccountID)
return u
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraCacheFileUpsert) AddAccountID(v int64) *SoraCacheFileUpsert {
u.Add(soracachefile.FieldAccountID, v)
return u
}
// SetUserID sets the "user_id" field.
func (u *SoraCacheFileUpsert) SetUserID(v int64) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldUserID, v)
return u
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateUserID() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldUserID)
return u
}
// AddUserID adds v to the "user_id" field.
func (u *SoraCacheFileUpsert) AddUserID(v int64) *SoraCacheFileUpsert {
u.Add(soracachefile.FieldUserID, v)
return u
}
// SetMediaType sets the "media_type" field.
func (u *SoraCacheFileUpsert) SetMediaType(v string) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldMediaType, v)
return u
}
// UpdateMediaType sets the "media_type" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateMediaType() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldMediaType)
return u
}
// SetOriginalURL sets the "original_url" field.
func (u *SoraCacheFileUpsert) SetOriginalURL(v string) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldOriginalURL, v)
return u
}
// UpdateOriginalURL sets the "original_url" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateOriginalURL() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldOriginalURL)
return u
}
// SetCachePath sets the "cache_path" field.
func (u *SoraCacheFileUpsert) SetCachePath(v string) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldCachePath, v)
return u
}
// UpdateCachePath sets the "cache_path" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateCachePath() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldCachePath)
return u
}
// SetCacheURL sets the "cache_url" field.
func (u *SoraCacheFileUpsert) SetCacheURL(v string) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldCacheURL, v)
return u
}
// UpdateCacheURL sets the "cache_url" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateCacheURL() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldCacheURL)
return u
}
// SetSizeBytes sets the "size_bytes" field.
func (u *SoraCacheFileUpsert) SetSizeBytes(v int64) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldSizeBytes, v)
return u
}
// UpdateSizeBytes sets the "size_bytes" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateSizeBytes() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldSizeBytes)
return u
}
// AddSizeBytes adds v to the "size_bytes" field.
func (u *SoraCacheFileUpsert) AddSizeBytes(v int64) *SoraCacheFileUpsert {
u.Add(soracachefile.FieldSizeBytes, v)
return u
}
// SetCreatedAt sets the "created_at" field.
func (u *SoraCacheFileUpsert) SetCreatedAt(v time.Time) *SoraCacheFileUpsert {
u.Set(soracachefile.FieldCreatedAt, v)
return u
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SoraCacheFileUpsert) UpdateCreatedAt() *SoraCacheFileUpsert {
u.SetExcluded(soracachefile.FieldCreatedAt)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.SoraCacheFile.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SoraCacheFileUpsertOne) UpdateNewValues() *SoraCacheFileUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SoraCacheFile.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SoraCacheFileUpsertOne) Ignore() *SoraCacheFileUpsertOne {
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 *SoraCacheFileUpsertOne) DoNothing() *SoraCacheFileUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SoraCacheFileCreate.OnConflict
// documentation for more info.
func (u *SoraCacheFileUpsertOne) Update(set func(*SoraCacheFileUpsert)) *SoraCacheFileUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SoraCacheFileUpsert{UpdateSet: update})
}))
return u
}
// SetTaskID sets the "task_id" field.
func (u *SoraCacheFileUpsertOne) SetTaskID(v string) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetTaskID(v)
})
}
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateTaskID() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateTaskID()
})
}
// ClearTaskID clears the value of the "task_id" field.
func (u *SoraCacheFileUpsertOne) ClearTaskID() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.ClearTaskID()
})
}
// SetAccountID sets the "account_id" field.
func (u *SoraCacheFileUpsertOne) SetAccountID(v int64) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetAccountID(v)
})
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraCacheFileUpsertOne) AddAccountID(v int64) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.AddAccountID(v)
})
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateAccountID() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateAccountID()
})
}
// SetUserID sets the "user_id" field.
func (u *SoraCacheFileUpsertOne) SetUserID(v int64) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetUserID(v)
})
}
// AddUserID adds v to the "user_id" field.
func (u *SoraCacheFileUpsertOne) AddUserID(v int64) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.AddUserID(v)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateUserID() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateUserID()
})
}
// SetMediaType sets the "media_type" field.
func (u *SoraCacheFileUpsertOne) SetMediaType(v string) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetMediaType(v)
})
}
// UpdateMediaType sets the "media_type" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateMediaType() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateMediaType()
})
}
// SetOriginalURL sets the "original_url" field.
func (u *SoraCacheFileUpsertOne) SetOriginalURL(v string) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetOriginalURL(v)
})
}
// UpdateOriginalURL sets the "original_url" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateOriginalURL() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateOriginalURL()
})
}
// SetCachePath sets the "cache_path" field.
func (u *SoraCacheFileUpsertOne) SetCachePath(v string) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetCachePath(v)
})
}
// UpdateCachePath sets the "cache_path" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateCachePath() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateCachePath()
})
}
// SetCacheURL sets the "cache_url" field.
func (u *SoraCacheFileUpsertOne) SetCacheURL(v string) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetCacheURL(v)
})
}
// UpdateCacheURL sets the "cache_url" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateCacheURL() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateCacheURL()
})
}
// SetSizeBytes sets the "size_bytes" field.
func (u *SoraCacheFileUpsertOne) SetSizeBytes(v int64) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetSizeBytes(v)
})
}
// AddSizeBytes adds v to the "size_bytes" field.
func (u *SoraCacheFileUpsertOne) AddSizeBytes(v int64) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.AddSizeBytes(v)
})
}
// UpdateSizeBytes sets the "size_bytes" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateSizeBytes() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateSizeBytes()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *SoraCacheFileUpsertOne) SetCreatedAt(v time.Time) *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SoraCacheFileUpsertOne) UpdateCreatedAt() *SoraCacheFileUpsertOne {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateCreatedAt()
})
}
// Exec executes the query.
func (u *SoraCacheFileUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SoraCacheFileCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SoraCacheFileUpsertOne) 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 *SoraCacheFileUpsertOne) ID(ctx context.Context) (id int64, 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 *SoraCacheFileUpsertOne) IDX(ctx context.Context) int64 {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// SoraCacheFileCreateBulk is the builder for creating many SoraCacheFile entities in bulk.
type SoraCacheFileCreateBulk struct {
config
err error
builders []*SoraCacheFileCreate
conflict []sql.ConflictOption
}
// Save creates the SoraCacheFile entities in the database.
func (_c *SoraCacheFileCreateBulk) Save(ctx context.Context) ([]*SoraCacheFile, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*SoraCacheFile, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SoraCacheFileMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *SoraCacheFileCreateBulk) SaveX(ctx context.Context) []*SoraCacheFile {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SoraCacheFileCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SoraCacheFileCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SoraCacheFile.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.SoraCacheFileUpsert) {
// SetTaskID(v+v).
// }).
// Exec(ctx)
func (_c *SoraCacheFileCreateBulk) OnConflict(opts ...sql.ConflictOption) *SoraCacheFileUpsertBulk {
_c.conflict = opts
return &SoraCacheFileUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SoraCacheFile.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SoraCacheFileCreateBulk) OnConflictColumns(columns ...string) *SoraCacheFileUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SoraCacheFileUpsertBulk{
create: _c,
}
}
// SoraCacheFileUpsertBulk is the builder for "upsert"-ing
// a bulk of SoraCacheFile nodes.
type SoraCacheFileUpsertBulk struct {
create *SoraCacheFileCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.SoraCacheFile.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SoraCacheFileUpsertBulk) UpdateNewValues() *SoraCacheFileUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SoraCacheFile.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SoraCacheFileUpsertBulk) Ignore() *SoraCacheFileUpsertBulk {
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 *SoraCacheFileUpsertBulk) DoNothing() *SoraCacheFileUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SoraCacheFileCreateBulk.OnConflict
// documentation for more info.
func (u *SoraCacheFileUpsertBulk) Update(set func(*SoraCacheFileUpsert)) *SoraCacheFileUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SoraCacheFileUpsert{UpdateSet: update})
}))
return u
}
// SetTaskID sets the "task_id" field.
func (u *SoraCacheFileUpsertBulk) SetTaskID(v string) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetTaskID(v)
})
}
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateTaskID() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateTaskID()
})
}
// ClearTaskID clears the value of the "task_id" field.
func (u *SoraCacheFileUpsertBulk) ClearTaskID() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.ClearTaskID()
})
}
// SetAccountID sets the "account_id" field.
func (u *SoraCacheFileUpsertBulk) SetAccountID(v int64) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetAccountID(v)
})
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraCacheFileUpsertBulk) AddAccountID(v int64) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.AddAccountID(v)
})
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateAccountID() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateAccountID()
})
}
// SetUserID sets the "user_id" field.
func (u *SoraCacheFileUpsertBulk) SetUserID(v int64) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetUserID(v)
})
}
// AddUserID adds v to the "user_id" field.
func (u *SoraCacheFileUpsertBulk) AddUserID(v int64) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.AddUserID(v)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateUserID() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateUserID()
})
}
// SetMediaType sets the "media_type" field.
func (u *SoraCacheFileUpsertBulk) SetMediaType(v string) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetMediaType(v)
})
}
// UpdateMediaType sets the "media_type" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateMediaType() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateMediaType()
})
}
// SetOriginalURL sets the "original_url" field.
func (u *SoraCacheFileUpsertBulk) SetOriginalURL(v string) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetOriginalURL(v)
})
}
// UpdateOriginalURL sets the "original_url" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateOriginalURL() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateOriginalURL()
})
}
// SetCachePath sets the "cache_path" field.
func (u *SoraCacheFileUpsertBulk) SetCachePath(v string) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetCachePath(v)
})
}
// UpdateCachePath sets the "cache_path" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateCachePath() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateCachePath()
})
}
// SetCacheURL sets the "cache_url" field.
func (u *SoraCacheFileUpsertBulk) SetCacheURL(v string) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetCacheURL(v)
})
}
// UpdateCacheURL sets the "cache_url" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateCacheURL() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateCacheURL()
})
}
// SetSizeBytes sets the "size_bytes" field.
func (u *SoraCacheFileUpsertBulk) SetSizeBytes(v int64) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetSizeBytes(v)
})
}
// AddSizeBytes adds v to the "size_bytes" field.
func (u *SoraCacheFileUpsertBulk) AddSizeBytes(v int64) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.AddSizeBytes(v)
})
}
// UpdateSizeBytes sets the "size_bytes" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateSizeBytes() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateSizeBytes()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *SoraCacheFileUpsertBulk) SetCreatedAt(v time.Time) *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.SetCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SoraCacheFileUpsertBulk) UpdateCreatedAt() *SoraCacheFileUpsertBulk {
return u.Update(func(s *SoraCacheFileUpsert) {
s.UpdateCreatedAt()
})
}
// Exec executes the query.
func (u *SoraCacheFileUpsertBulk) 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 SoraCacheFileCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SoraCacheFileCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SoraCacheFileUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
)
// SoraCacheFileDelete is the builder for deleting a SoraCacheFile entity.
type SoraCacheFileDelete struct {
config
hooks []Hook
mutation *SoraCacheFileMutation
}
// Where appends a list predicates to the SoraCacheFileDelete builder.
func (_d *SoraCacheFileDelete) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *SoraCacheFileDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraCacheFileDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *SoraCacheFileDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(soracachefile.Table, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
_d.mutation.done = true
return affected, err
}
// SoraCacheFileDeleteOne is the builder for deleting a single SoraCacheFile entity.
type SoraCacheFileDeleteOne struct {
_d *SoraCacheFileDelete
}
// Where appends a list predicates to the SoraCacheFileDelete builder.
func (_d *SoraCacheFileDeleteOne) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *SoraCacheFileDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{soracachefile.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraCacheFileDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
)
// SoraCacheFileQuery is the builder for querying SoraCacheFile entities.
type SoraCacheFileQuery struct {
config
ctx *QueryContext
order []soracachefile.OrderOption
inters []Interceptor
predicates []predicate.SoraCacheFile
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the SoraCacheFileQuery builder.
func (_q *SoraCacheFileQuery) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *SoraCacheFileQuery) Limit(limit int) *SoraCacheFileQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *SoraCacheFileQuery) Offset(offset int) *SoraCacheFileQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *SoraCacheFileQuery) Unique(unique bool) *SoraCacheFileQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *SoraCacheFileQuery) Order(o ...soracachefile.OrderOption) *SoraCacheFileQuery {
_q.order = append(_q.order, o...)
return _q
}
// First returns the first SoraCacheFile entity from the query.
// Returns a *NotFoundError when no SoraCacheFile was found.
func (_q *SoraCacheFileQuery) First(ctx context.Context) (*SoraCacheFile, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{soracachefile.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *SoraCacheFileQuery) FirstX(ctx context.Context) *SoraCacheFile {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first SoraCacheFile ID from the query.
// Returns a *NotFoundError when no SoraCacheFile ID was found.
func (_q *SoraCacheFileQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{soracachefile.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *SoraCacheFileQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single SoraCacheFile entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one SoraCacheFile entity is found.
// Returns a *NotFoundError when no SoraCacheFile entities are found.
func (_q *SoraCacheFileQuery) Only(ctx context.Context) (*SoraCacheFile, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{soracachefile.Label}
default:
return nil, &NotSingularError{soracachefile.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *SoraCacheFileQuery) OnlyX(ctx context.Context) *SoraCacheFile {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only SoraCacheFile ID in the query.
// Returns a *NotSingularError when more than one SoraCacheFile ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *SoraCacheFileQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{soracachefile.Label}
default:
err = &NotSingularError{soracachefile.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *SoraCacheFileQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of SoraCacheFiles.
func (_q *SoraCacheFileQuery) All(ctx context.Context) ([]*SoraCacheFile, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*SoraCacheFile, *SoraCacheFileQuery]()
return withInterceptors[[]*SoraCacheFile](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *SoraCacheFileQuery) AllX(ctx context.Context) []*SoraCacheFile {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of SoraCacheFile IDs.
func (_q *SoraCacheFileQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(soracachefile.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *SoraCacheFileQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *SoraCacheFileQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*SoraCacheFileQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *SoraCacheFileQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *SoraCacheFileQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *SoraCacheFileQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the SoraCacheFileQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *SoraCacheFileQuery) Clone() *SoraCacheFileQuery {
if _q == nil {
return nil
}
return &SoraCacheFileQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]soracachefile.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.SoraCacheFile{}, _q.predicates...),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// TaskID string `json:"task_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.SoraCacheFile.Query().
// GroupBy(soracachefile.FieldTaskID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *SoraCacheFileQuery) GroupBy(field string, fields ...string) *SoraCacheFileGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &SoraCacheFileGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = soracachefile.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// TaskID string `json:"task_id,omitempty"`
// }
//
// client.SoraCacheFile.Query().
// Select(soracachefile.FieldTaskID).
// Scan(ctx, &v)
func (_q *SoraCacheFileQuery) Select(fields ...string) *SoraCacheFileSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &SoraCacheFileSelect{SoraCacheFileQuery: _q}
sbuild.label = soracachefile.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a SoraCacheFileSelect configured with the given aggregations.
func (_q *SoraCacheFileQuery) Aggregate(fns ...AggregateFunc) *SoraCacheFileSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *SoraCacheFileQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !soracachefile.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *SoraCacheFileQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SoraCacheFile, error) {
var (
nodes = []*SoraCacheFile{}
_spec = _q.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*SoraCacheFile).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &SoraCacheFile{config: _q.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (_q *SoraCacheFileQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *SoraCacheFileQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(soracachefile.Table, soracachefile.Columns, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, soracachefile.FieldID)
for i := range fields {
if fields[i] != soracachefile.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *SoraCacheFileQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(soracachefile.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = soracachefile.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *SoraCacheFileQuery) ForUpdate(opts ...sql.LockOption) *SoraCacheFileQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *SoraCacheFileQuery) ForShare(opts ...sql.LockOption) *SoraCacheFileQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// SoraCacheFileGroupBy is the group-by builder for SoraCacheFile entities.
type SoraCacheFileGroupBy struct {
selector
build *SoraCacheFileQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *SoraCacheFileGroupBy) Aggregate(fns ...AggregateFunc) *SoraCacheFileGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *SoraCacheFileGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraCacheFileQuery, *SoraCacheFileGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *SoraCacheFileGroupBy) sqlScan(ctx context.Context, root *SoraCacheFileQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// SoraCacheFileSelect is the builder for selecting fields of SoraCacheFile entities.
type SoraCacheFileSelect struct {
*SoraCacheFileQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *SoraCacheFileSelect) Aggregate(fns ...AggregateFunc) *SoraCacheFileSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *SoraCacheFileSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraCacheFileQuery, *SoraCacheFileSelect](ctx, _s.SoraCacheFileQuery, _s, _s.inters, v)
}
func (_s *SoraCacheFileSelect) sqlScan(ctx context.Context, root *SoraCacheFileQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// 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/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/soracachefile"
)
// SoraCacheFileUpdate is the builder for updating SoraCacheFile entities.
type SoraCacheFileUpdate struct {
config
hooks []Hook
mutation *SoraCacheFileMutation
}
// Where appends a list predicates to the SoraCacheFileUpdate builder.
func (_u *SoraCacheFileUpdate) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetTaskID sets the "task_id" field.
func (_u *SoraCacheFileUpdate) SetTaskID(v string) *SoraCacheFileUpdate {
_u.mutation.SetTaskID(v)
return _u
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableTaskID(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetTaskID(*v)
}
return _u
}
// ClearTaskID clears the value of the "task_id" field.
func (_u *SoraCacheFileUpdate) ClearTaskID() *SoraCacheFileUpdate {
_u.mutation.ClearTaskID()
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraCacheFileUpdate) SetAccountID(v int64) *SoraCacheFileUpdate {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableAccountID(v *int64) *SoraCacheFileUpdate {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraCacheFileUpdate) AddAccountID(v int64) *SoraCacheFileUpdate {
_u.mutation.AddAccountID(v)
return _u
}
// SetUserID sets the "user_id" field.
func (_u *SoraCacheFileUpdate) SetUserID(v int64) *SoraCacheFileUpdate {
_u.mutation.ResetUserID()
_u.mutation.SetUserID(v)
return _u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableUserID(v *int64) *SoraCacheFileUpdate {
if v != nil {
_u.SetUserID(*v)
}
return _u
}
// AddUserID adds value to the "user_id" field.
func (_u *SoraCacheFileUpdate) AddUserID(v int64) *SoraCacheFileUpdate {
_u.mutation.AddUserID(v)
return _u
}
// SetMediaType sets the "media_type" field.
func (_u *SoraCacheFileUpdate) SetMediaType(v string) *SoraCacheFileUpdate {
_u.mutation.SetMediaType(v)
return _u
}
// SetNillableMediaType sets the "media_type" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableMediaType(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetMediaType(*v)
}
return _u
}
// SetOriginalURL sets the "original_url" field.
func (_u *SoraCacheFileUpdate) SetOriginalURL(v string) *SoraCacheFileUpdate {
_u.mutation.SetOriginalURL(v)
return _u
}
// SetNillableOriginalURL sets the "original_url" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableOriginalURL(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetOriginalURL(*v)
}
return _u
}
// SetCachePath sets the "cache_path" field.
func (_u *SoraCacheFileUpdate) SetCachePath(v string) *SoraCacheFileUpdate {
_u.mutation.SetCachePath(v)
return _u
}
// SetNillableCachePath sets the "cache_path" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableCachePath(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetCachePath(*v)
}
return _u
}
// SetCacheURL sets the "cache_url" field.
func (_u *SoraCacheFileUpdate) SetCacheURL(v string) *SoraCacheFileUpdate {
_u.mutation.SetCacheURL(v)
return _u
}
// SetNillableCacheURL sets the "cache_url" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableCacheURL(v *string) *SoraCacheFileUpdate {
if v != nil {
_u.SetCacheURL(*v)
}
return _u
}
// SetSizeBytes sets the "size_bytes" field.
func (_u *SoraCacheFileUpdate) SetSizeBytes(v int64) *SoraCacheFileUpdate {
_u.mutation.ResetSizeBytes()
_u.mutation.SetSizeBytes(v)
return _u
}
// SetNillableSizeBytes sets the "size_bytes" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableSizeBytes(v *int64) *SoraCacheFileUpdate {
if v != nil {
_u.SetSizeBytes(*v)
}
return _u
}
// AddSizeBytes adds value to the "size_bytes" field.
func (_u *SoraCacheFileUpdate) AddSizeBytes(v int64) *SoraCacheFileUpdate {
_u.mutation.AddSizeBytes(v)
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *SoraCacheFileUpdate) SetCreatedAt(v time.Time) *SoraCacheFileUpdate {
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *SoraCacheFileUpdate) SetNillableCreatedAt(v *time.Time) *SoraCacheFileUpdate {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// Mutation returns the SoraCacheFileMutation object of the builder.
func (_u *SoraCacheFileUpdate) Mutation() *SoraCacheFileMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *SoraCacheFileUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraCacheFileUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *SoraCacheFileUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraCacheFileUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *SoraCacheFileUpdate) check() error {
if v, ok := _u.mutation.TaskID(); ok {
if err := soracachefile.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.task_id": %w`, err)}
}
}
if v, ok := _u.mutation.MediaType(); ok {
if err := soracachefile.MediaTypeValidator(v); err != nil {
return &ValidationError{Name: "media_type", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.media_type": %w`, err)}
}
}
return nil
}
func (_u *SoraCacheFileUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(soracachefile.Table, soracachefile.Columns, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
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.TaskID(); ok {
_spec.SetField(soracachefile.FieldTaskID, field.TypeString, value)
}
if _u.mutation.TaskIDCleared() {
_spec.ClearField(soracachefile.FieldTaskID, field.TypeString)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soracachefile.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soracachefile.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.UserID(); ok {
_spec.SetField(soracachefile.FieldUserID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedUserID(); ok {
_spec.AddField(soracachefile.FieldUserID, field.TypeInt64, value)
}
if value, ok := _u.mutation.MediaType(); ok {
_spec.SetField(soracachefile.FieldMediaType, field.TypeString, value)
}
if value, ok := _u.mutation.OriginalURL(); ok {
_spec.SetField(soracachefile.FieldOriginalURL, field.TypeString, value)
}
if value, ok := _u.mutation.CachePath(); ok {
_spec.SetField(soracachefile.FieldCachePath, field.TypeString, value)
}
if value, ok := _u.mutation.CacheURL(); ok {
_spec.SetField(soracachefile.FieldCacheURL, field.TypeString, value)
}
if value, ok := _u.mutation.SizeBytes(); ok {
_spec.SetField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedSizeBytes(); ok {
_spec.AddField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(soracachefile.FieldCreatedAt, field.TypeTime, value)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{soracachefile.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// SoraCacheFileUpdateOne is the builder for updating a single SoraCacheFile entity.
type SoraCacheFileUpdateOne struct {
config
fields []string
hooks []Hook
mutation *SoraCacheFileMutation
}
// SetTaskID sets the "task_id" field.
func (_u *SoraCacheFileUpdateOne) SetTaskID(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetTaskID(v)
return _u
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableTaskID(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetTaskID(*v)
}
return _u
}
// ClearTaskID clears the value of the "task_id" field.
func (_u *SoraCacheFileUpdateOne) ClearTaskID() *SoraCacheFileUpdateOne {
_u.mutation.ClearTaskID()
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraCacheFileUpdateOne) SetAccountID(v int64) *SoraCacheFileUpdateOne {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableAccountID(v *int64) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraCacheFileUpdateOne) AddAccountID(v int64) *SoraCacheFileUpdateOne {
_u.mutation.AddAccountID(v)
return _u
}
// SetUserID sets the "user_id" field.
func (_u *SoraCacheFileUpdateOne) SetUserID(v int64) *SoraCacheFileUpdateOne {
_u.mutation.ResetUserID()
_u.mutation.SetUserID(v)
return _u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableUserID(v *int64) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetUserID(*v)
}
return _u
}
// AddUserID adds value to the "user_id" field.
func (_u *SoraCacheFileUpdateOne) AddUserID(v int64) *SoraCacheFileUpdateOne {
_u.mutation.AddUserID(v)
return _u
}
// SetMediaType sets the "media_type" field.
func (_u *SoraCacheFileUpdateOne) SetMediaType(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetMediaType(v)
return _u
}
// SetNillableMediaType sets the "media_type" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableMediaType(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetMediaType(*v)
}
return _u
}
// SetOriginalURL sets the "original_url" field.
func (_u *SoraCacheFileUpdateOne) SetOriginalURL(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetOriginalURL(v)
return _u
}
// SetNillableOriginalURL sets the "original_url" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableOriginalURL(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetOriginalURL(*v)
}
return _u
}
// SetCachePath sets the "cache_path" field.
func (_u *SoraCacheFileUpdateOne) SetCachePath(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetCachePath(v)
return _u
}
// SetNillableCachePath sets the "cache_path" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableCachePath(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetCachePath(*v)
}
return _u
}
// SetCacheURL sets the "cache_url" field.
func (_u *SoraCacheFileUpdateOne) SetCacheURL(v string) *SoraCacheFileUpdateOne {
_u.mutation.SetCacheURL(v)
return _u
}
// SetNillableCacheURL sets the "cache_url" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableCacheURL(v *string) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetCacheURL(*v)
}
return _u
}
// SetSizeBytes sets the "size_bytes" field.
func (_u *SoraCacheFileUpdateOne) SetSizeBytes(v int64) *SoraCacheFileUpdateOne {
_u.mutation.ResetSizeBytes()
_u.mutation.SetSizeBytes(v)
return _u
}
// SetNillableSizeBytes sets the "size_bytes" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableSizeBytes(v *int64) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetSizeBytes(*v)
}
return _u
}
// AddSizeBytes adds value to the "size_bytes" field.
func (_u *SoraCacheFileUpdateOne) AddSizeBytes(v int64) *SoraCacheFileUpdateOne {
_u.mutation.AddSizeBytes(v)
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *SoraCacheFileUpdateOne) SetCreatedAt(v time.Time) *SoraCacheFileUpdateOne {
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *SoraCacheFileUpdateOne) SetNillableCreatedAt(v *time.Time) *SoraCacheFileUpdateOne {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// Mutation returns the SoraCacheFileMutation object of the builder.
func (_u *SoraCacheFileUpdateOne) Mutation() *SoraCacheFileMutation {
return _u.mutation
}
// Where appends a list predicates to the SoraCacheFileUpdate builder.
func (_u *SoraCacheFileUpdateOne) Where(ps ...predicate.SoraCacheFile) *SoraCacheFileUpdateOne {
_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 *SoraCacheFileUpdateOne) Select(field string, fields ...string) *SoraCacheFileUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated SoraCacheFile entity.
func (_u *SoraCacheFileUpdateOne) Save(ctx context.Context) (*SoraCacheFile, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraCacheFileUpdateOne) SaveX(ctx context.Context) *SoraCacheFile {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *SoraCacheFileUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraCacheFileUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *SoraCacheFileUpdateOne) check() error {
if v, ok := _u.mutation.TaskID(); ok {
if err := soracachefile.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.task_id": %w`, err)}
}
}
if v, ok := _u.mutation.MediaType(); ok {
if err := soracachefile.MediaTypeValidator(v); err != nil {
return &ValidationError{Name: "media_type", err: fmt.Errorf(`ent: validator failed for field "SoraCacheFile.media_type": %w`, err)}
}
}
return nil
}
func (_u *SoraCacheFileUpdateOne) sqlSave(ctx context.Context) (_node *SoraCacheFile, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(soracachefile.Table, soracachefile.Columns, sqlgraph.NewFieldSpec(soracachefile.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SoraCacheFile.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, soracachefile.FieldID)
for _, f := range fields {
if !soracachefile.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != soracachefile.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.TaskID(); ok {
_spec.SetField(soracachefile.FieldTaskID, field.TypeString, value)
}
if _u.mutation.TaskIDCleared() {
_spec.ClearField(soracachefile.FieldTaskID, field.TypeString)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soracachefile.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soracachefile.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.UserID(); ok {
_spec.SetField(soracachefile.FieldUserID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedUserID(); ok {
_spec.AddField(soracachefile.FieldUserID, field.TypeInt64, value)
}
if value, ok := _u.mutation.MediaType(); ok {
_spec.SetField(soracachefile.FieldMediaType, field.TypeString, value)
}
if value, ok := _u.mutation.OriginalURL(); ok {
_spec.SetField(soracachefile.FieldOriginalURL, field.TypeString, value)
}
if value, ok := _u.mutation.CachePath(); ok {
_spec.SetField(soracachefile.FieldCachePath, field.TypeString, value)
}
if value, ok := _u.mutation.CacheURL(); ok {
_spec.SetField(soracachefile.FieldCacheURL, field.TypeString, value)
}
if value, ok := _u.mutation.SizeBytes(); ok {
_spec.SetField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedSizeBytes(); ok {
_spec.AddField(soracachefile.FieldSizeBytes, field.TypeInt64, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(soracachefile.FieldCreatedAt, field.TypeTime, value)
}
_node = &SoraCacheFile{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{soracachefile.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/soratask"
)
// SoraTask is the model entity for the SoraTask schema.
type SoraTask struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// TaskID holds the value of the "task_id" field.
TaskID string `json:"task_id,omitempty"`
// AccountID holds the value of the "account_id" field.
AccountID int64 `json:"account_id,omitempty"`
// Model holds the value of the "model" field.
Model string `json:"model,omitempty"`
// Prompt holds the value of the "prompt" field.
Prompt string `json:"prompt,omitempty"`
// Status holds the value of the "status" field.
Status string `json:"status,omitempty"`
// Progress holds the value of the "progress" field.
Progress float64 `json:"progress,omitempty"`
// ResultUrls holds the value of the "result_urls" field.
ResultUrls *string `json:"result_urls,omitempty"`
// ErrorMessage holds the value of the "error_message" field.
ErrorMessage *string `json:"error_message,omitempty"`
// RetryCount holds the value of the "retry_count" field.
RetryCount int `json:"retry_count,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// CompletedAt holds the value of the "completed_at" field.
CompletedAt *time.Time `json:"completed_at,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*SoraTask) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case soratask.FieldProgress:
values[i] = new(sql.NullFloat64)
case soratask.FieldID, soratask.FieldAccountID, soratask.FieldRetryCount:
values[i] = new(sql.NullInt64)
case soratask.FieldTaskID, soratask.FieldModel, soratask.FieldPrompt, soratask.FieldStatus, soratask.FieldResultUrls, soratask.FieldErrorMessage:
values[i] = new(sql.NullString)
case soratask.FieldCreatedAt, soratask.FieldCompletedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the SoraTask fields.
func (_m *SoraTask) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case soratask.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case soratask.FieldTaskID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field task_id", values[i])
} else if value.Valid {
_m.TaskID = value.String
}
case soratask.FieldAccountID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field account_id", values[i])
} else if value.Valid {
_m.AccountID = value.Int64
}
case soratask.FieldModel:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field model", values[i])
} else if value.Valid {
_m.Model = value.String
}
case soratask.FieldPrompt:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field prompt", values[i])
} else if value.Valid {
_m.Prompt = value.String
}
case soratask.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
_m.Status = value.String
}
case soratask.FieldProgress:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field progress", values[i])
} else if value.Valid {
_m.Progress = value.Float64
}
case soratask.FieldResultUrls:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field result_urls", values[i])
} else if value.Valid {
_m.ResultUrls = new(string)
*_m.ResultUrls = value.String
}
case soratask.FieldErrorMessage:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field error_message", values[i])
} else if value.Valid {
_m.ErrorMessage = new(string)
*_m.ErrorMessage = value.String
}
case soratask.FieldRetryCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field retry_count", values[i])
} else if value.Valid {
_m.RetryCount = int(value.Int64)
}
case soratask.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case soratask.FieldCompletedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field completed_at", values[i])
} else if value.Valid {
_m.CompletedAt = new(time.Time)
*_m.CompletedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the SoraTask.
// This includes values selected through modifiers, order, etc.
func (_m *SoraTask) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this SoraTask.
// Note that you need to call SoraTask.Unwrap() before calling this method if this SoraTask
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *SoraTask) Update() *SoraTaskUpdateOne {
return NewSoraTaskClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the SoraTask entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *SoraTask) Unwrap() *SoraTask {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: SoraTask is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *SoraTask) String() string {
var builder strings.Builder
builder.WriteString("SoraTask(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("task_id=")
builder.WriteString(_m.TaskID)
builder.WriteString(", ")
builder.WriteString("account_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AccountID))
builder.WriteString(", ")
builder.WriteString("model=")
builder.WriteString(_m.Model)
builder.WriteString(", ")
builder.WriteString("prompt=")
builder.WriteString(_m.Prompt)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(_m.Status)
builder.WriteString(", ")
builder.WriteString("progress=")
builder.WriteString(fmt.Sprintf("%v", _m.Progress))
builder.WriteString(", ")
if v := _m.ResultUrls; v != nil {
builder.WriteString("result_urls=")
builder.WriteString(*v)
}
builder.WriteString(", ")
if v := _m.ErrorMessage; v != nil {
builder.WriteString("error_message=")
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("retry_count=")
builder.WriteString(fmt.Sprintf("%v", _m.RetryCount))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
if v := _m.CompletedAt; v != nil {
builder.WriteString("completed_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteByte(')')
return builder.String()
}
// SoraTasks is a parsable slice of SoraTask.
type SoraTasks []*SoraTask
// Code generated by ent, DO NOT EDIT.
package soratask
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the soratask type in the database.
Label = "sora_task"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldTaskID holds the string denoting the task_id field in the database.
FieldTaskID = "task_id"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldModel holds the string denoting the model field in the database.
FieldModel = "model"
// FieldPrompt holds the string denoting the prompt field in the database.
FieldPrompt = "prompt"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
// FieldProgress holds the string denoting the progress field in the database.
FieldProgress = "progress"
// FieldResultUrls holds the string denoting the result_urls field in the database.
FieldResultUrls = "result_urls"
// FieldErrorMessage holds the string denoting the error_message field in the database.
FieldErrorMessage = "error_message"
// FieldRetryCount holds the string denoting the retry_count field in the database.
FieldRetryCount = "retry_count"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldCompletedAt holds the string denoting the completed_at field in the database.
FieldCompletedAt = "completed_at"
// Table holds the table name of the soratask in the database.
Table = "sora_tasks"
)
// Columns holds all SQL columns for soratask fields.
var Columns = []string{
FieldID,
FieldTaskID,
FieldAccountID,
FieldModel,
FieldPrompt,
FieldStatus,
FieldProgress,
FieldResultUrls,
FieldErrorMessage,
FieldRetryCount,
FieldCreatedAt,
FieldCompletedAt,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// TaskIDValidator is a validator for the "task_id" field. It is called by the builders before save.
TaskIDValidator func(string) error
// ModelValidator is a validator for the "model" field. It is called by the builders before save.
ModelValidator func(string) error
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus string
// StatusValidator is a validator for the "status" field. It is called by the builders before save.
StatusValidator func(string) error
// DefaultProgress holds the default value on creation for the "progress" field.
DefaultProgress float64
// DefaultRetryCount holds the default value on creation for the "retry_count" field.
DefaultRetryCount int
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the SoraTask queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByTaskID orders the results by the task_id field.
func ByTaskID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTaskID, opts...).ToFunc()
}
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByModel orders the results by the model field.
func ByModel(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldModel, opts...).ToFunc()
}
// ByPrompt orders the results by the prompt field.
func ByPrompt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPrompt, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
// ByProgress orders the results by the progress field.
func ByProgress(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProgress, opts...).ToFunc()
}
// ByResultUrls orders the results by the result_urls field.
func ByResultUrls(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldResultUrls, opts...).ToFunc()
}
// ByErrorMessage orders the results by the error_message field.
func ByErrorMessage(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldErrorMessage, opts...).ToFunc()
}
// ByRetryCount orders the results by the retry_count field.
func ByRetryCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRetryCount, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByCompletedAt orders the results by the completed_at field.
func ByCompletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCompletedAt, opts...).ToFunc()
}
// Code generated by ent, DO NOT EDIT.
package soratask
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldID, id))
}
// TaskID applies equality check predicate on the "task_id" field. It's identical to TaskIDEQ.
func TaskID(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldTaskID, v))
}
// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ.
func AccountID(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldAccountID, v))
}
// Model applies equality check predicate on the "model" field. It's identical to ModelEQ.
func Model(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldModel, v))
}
// Prompt applies equality check predicate on the "prompt" field. It's identical to PromptEQ.
func Prompt(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldPrompt, v))
}
// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
func Status(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldStatus, v))
}
// Progress applies equality check predicate on the "progress" field. It's identical to ProgressEQ.
func Progress(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldProgress, v))
}
// ResultUrls applies equality check predicate on the "result_urls" field. It's identical to ResultUrlsEQ.
func ResultUrls(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldResultUrls, v))
}
// ErrorMessage applies equality check predicate on the "error_message" field. It's identical to ErrorMessageEQ.
func ErrorMessage(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldErrorMessage, v))
}
// RetryCount applies equality check predicate on the "retry_count" field. It's identical to RetryCountEQ.
func RetryCount(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldRetryCount, v))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldCreatedAt, v))
}
// CompletedAt applies equality check predicate on the "completed_at" field. It's identical to CompletedAtEQ.
func CompletedAt(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldCompletedAt, v))
}
// TaskIDEQ applies the EQ predicate on the "task_id" field.
func TaskIDEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldTaskID, v))
}
// TaskIDNEQ applies the NEQ predicate on the "task_id" field.
func TaskIDNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldTaskID, v))
}
// TaskIDIn applies the In predicate on the "task_id" field.
func TaskIDIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldTaskID, vs...))
}
// TaskIDNotIn applies the NotIn predicate on the "task_id" field.
func TaskIDNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldTaskID, vs...))
}
// TaskIDGT applies the GT predicate on the "task_id" field.
func TaskIDGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldTaskID, v))
}
// TaskIDGTE applies the GTE predicate on the "task_id" field.
func TaskIDGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldTaskID, v))
}
// TaskIDLT applies the LT predicate on the "task_id" field.
func TaskIDLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldTaskID, v))
}
// TaskIDLTE applies the LTE predicate on the "task_id" field.
func TaskIDLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldTaskID, v))
}
// TaskIDContains applies the Contains predicate on the "task_id" field.
func TaskIDContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldTaskID, v))
}
// TaskIDHasPrefix applies the HasPrefix predicate on the "task_id" field.
func TaskIDHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldTaskID, v))
}
// TaskIDHasSuffix applies the HasSuffix predicate on the "task_id" field.
func TaskIDHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldTaskID, v))
}
// TaskIDEqualFold applies the EqualFold predicate on the "task_id" field.
func TaskIDEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldTaskID, v))
}
// TaskIDContainsFold applies the ContainsFold predicate on the "task_id" field.
func TaskIDContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldTaskID, v))
}
// AccountIDEQ applies the EQ predicate on the "account_id" field.
func AccountIDEQ(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldAccountID, v))
}
// AccountIDNEQ applies the NEQ predicate on the "account_id" field.
func AccountIDNEQ(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldAccountID, v))
}
// AccountIDIn applies the In predicate on the "account_id" field.
func AccountIDIn(vs ...int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldAccountID, vs...))
}
// AccountIDNotIn applies the NotIn predicate on the "account_id" field.
func AccountIDNotIn(vs ...int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldAccountID, vs...))
}
// AccountIDGT applies the GT predicate on the "account_id" field.
func AccountIDGT(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldAccountID, v))
}
// AccountIDGTE applies the GTE predicate on the "account_id" field.
func AccountIDGTE(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldAccountID, v))
}
// AccountIDLT applies the LT predicate on the "account_id" field.
func AccountIDLT(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldAccountID, v))
}
// AccountIDLTE applies the LTE predicate on the "account_id" field.
func AccountIDLTE(v int64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldAccountID, v))
}
// ModelEQ applies the EQ predicate on the "model" field.
func ModelEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldModel, v))
}
// ModelNEQ applies the NEQ predicate on the "model" field.
func ModelNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldModel, v))
}
// ModelIn applies the In predicate on the "model" field.
func ModelIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldModel, vs...))
}
// ModelNotIn applies the NotIn predicate on the "model" field.
func ModelNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldModel, vs...))
}
// ModelGT applies the GT predicate on the "model" field.
func ModelGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldModel, v))
}
// ModelGTE applies the GTE predicate on the "model" field.
func ModelGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldModel, v))
}
// ModelLT applies the LT predicate on the "model" field.
func ModelLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldModel, v))
}
// ModelLTE applies the LTE predicate on the "model" field.
func ModelLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldModel, v))
}
// ModelContains applies the Contains predicate on the "model" field.
func ModelContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldModel, v))
}
// ModelHasPrefix applies the HasPrefix predicate on the "model" field.
func ModelHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldModel, v))
}
// ModelHasSuffix applies the HasSuffix predicate on the "model" field.
func ModelHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldModel, v))
}
// ModelEqualFold applies the EqualFold predicate on the "model" field.
func ModelEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldModel, v))
}
// ModelContainsFold applies the ContainsFold predicate on the "model" field.
func ModelContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldModel, v))
}
// PromptEQ applies the EQ predicate on the "prompt" field.
func PromptEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldPrompt, v))
}
// PromptNEQ applies the NEQ predicate on the "prompt" field.
func PromptNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldPrompt, v))
}
// PromptIn applies the In predicate on the "prompt" field.
func PromptIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldPrompt, vs...))
}
// PromptNotIn applies the NotIn predicate on the "prompt" field.
func PromptNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldPrompt, vs...))
}
// PromptGT applies the GT predicate on the "prompt" field.
func PromptGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldPrompt, v))
}
// PromptGTE applies the GTE predicate on the "prompt" field.
func PromptGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldPrompt, v))
}
// PromptLT applies the LT predicate on the "prompt" field.
func PromptLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldPrompt, v))
}
// PromptLTE applies the LTE predicate on the "prompt" field.
func PromptLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldPrompt, v))
}
// PromptContains applies the Contains predicate on the "prompt" field.
func PromptContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldPrompt, v))
}
// PromptHasPrefix applies the HasPrefix predicate on the "prompt" field.
func PromptHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldPrompt, v))
}
// PromptHasSuffix applies the HasSuffix predicate on the "prompt" field.
func PromptHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldPrompt, v))
}
// PromptEqualFold applies the EqualFold predicate on the "prompt" field.
func PromptEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldPrompt, v))
}
// PromptContainsFold applies the ContainsFold predicate on the "prompt" field.
func PromptContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldPrompt, v))
}
// StatusEQ applies the EQ predicate on the "status" field.
func StatusEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldStatus, v))
}
// StatusNEQ applies the NEQ predicate on the "status" field.
func StatusNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldStatus, v))
}
// StatusIn applies the In predicate on the "status" field.
func StatusIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldStatus, vs...))
}
// StatusNotIn applies the NotIn predicate on the "status" field.
func StatusNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldStatus, vs...))
}
// StatusGT applies the GT predicate on the "status" field.
func StatusGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldStatus, v))
}
// StatusGTE applies the GTE predicate on the "status" field.
func StatusGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldStatus, v))
}
// StatusLT applies the LT predicate on the "status" field.
func StatusLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldStatus, v))
}
// StatusLTE applies the LTE predicate on the "status" field.
func StatusLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldStatus, v))
}
// StatusContains applies the Contains predicate on the "status" field.
func StatusContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldStatus, v))
}
// StatusHasPrefix applies the HasPrefix predicate on the "status" field.
func StatusHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldStatus, v))
}
// StatusHasSuffix applies the HasSuffix predicate on the "status" field.
func StatusHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldStatus, v))
}
// StatusEqualFold applies the EqualFold predicate on the "status" field.
func StatusEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldStatus, v))
}
// StatusContainsFold applies the ContainsFold predicate on the "status" field.
func StatusContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldStatus, v))
}
// ProgressEQ applies the EQ predicate on the "progress" field.
func ProgressEQ(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldProgress, v))
}
// ProgressNEQ applies the NEQ predicate on the "progress" field.
func ProgressNEQ(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldProgress, v))
}
// ProgressIn applies the In predicate on the "progress" field.
func ProgressIn(vs ...float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldProgress, vs...))
}
// ProgressNotIn applies the NotIn predicate on the "progress" field.
func ProgressNotIn(vs ...float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldProgress, vs...))
}
// ProgressGT applies the GT predicate on the "progress" field.
func ProgressGT(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldProgress, v))
}
// ProgressGTE applies the GTE predicate on the "progress" field.
func ProgressGTE(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldProgress, v))
}
// ProgressLT applies the LT predicate on the "progress" field.
func ProgressLT(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldProgress, v))
}
// ProgressLTE applies the LTE predicate on the "progress" field.
func ProgressLTE(v float64) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldProgress, v))
}
// ResultUrlsEQ applies the EQ predicate on the "result_urls" field.
func ResultUrlsEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldResultUrls, v))
}
// ResultUrlsNEQ applies the NEQ predicate on the "result_urls" field.
func ResultUrlsNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldResultUrls, v))
}
// ResultUrlsIn applies the In predicate on the "result_urls" field.
func ResultUrlsIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldResultUrls, vs...))
}
// ResultUrlsNotIn applies the NotIn predicate on the "result_urls" field.
func ResultUrlsNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldResultUrls, vs...))
}
// ResultUrlsGT applies the GT predicate on the "result_urls" field.
func ResultUrlsGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldResultUrls, v))
}
// ResultUrlsGTE applies the GTE predicate on the "result_urls" field.
func ResultUrlsGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldResultUrls, v))
}
// ResultUrlsLT applies the LT predicate on the "result_urls" field.
func ResultUrlsLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldResultUrls, v))
}
// ResultUrlsLTE applies the LTE predicate on the "result_urls" field.
func ResultUrlsLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldResultUrls, v))
}
// ResultUrlsContains applies the Contains predicate on the "result_urls" field.
func ResultUrlsContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldResultUrls, v))
}
// ResultUrlsHasPrefix applies the HasPrefix predicate on the "result_urls" field.
func ResultUrlsHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldResultUrls, v))
}
// ResultUrlsHasSuffix applies the HasSuffix predicate on the "result_urls" field.
func ResultUrlsHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldResultUrls, v))
}
// ResultUrlsIsNil applies the IsNil predicate on the "result_urls" field.
func ResultUrlsIsNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldIsNull(FieldResultUrls))
}
// ResultUrlsNotNil applies the NotNil predicate on the "result_urls" field.
func ResultUrlsNotNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotNull(FieldResultUrls))
}
// ResultUrlsEqualFold applies the EqualFold predicate on the "result_urls" field.
func ResultUrlsEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldResultUrls, v))
}
// ResultUrlsContainsFold applies the ContainsFold predicate on the "result_urls" field.
func ResultUrlsContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldResultUrls, v))
}
// ErrorMessageEQ applies the EQ predicate on the "error_message" field.
func ErrorMessageEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldErrorMessage, v))
}
// ErrorMessageNEQ applies the NEQ predicate on the "error_message" field.
func ErrorMessageNEQ(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldErrorMessage, v))
}
// ErrorMessageIn applies the In predicate on the "error_message" field.
func ErrorMessageIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldErrorMessage, vs...))
}
// ErrorMessageNotIn applies the NotIn predicate on the "error_message" field.
func ErrorMessageNotIn(vs ...string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldErrorMessage, vs...))
}
// ErrorMessageGT applies the GT predicate on the "error_message" field.
func ErrorMessageGT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldErrorMessage, v))
}
// ErrorMessageGTE applies the GTE predicate on the "error_message" field.
func ErrorMessageGTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldErrorMessage, v))
}
// ErrorMessageLT applies the LT predicate on the "error_message" field.
func ErrorMessageLT(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldErrorMessage, v))
}
// ErrorMessageLTE applies the LTE predicate on the "error_message" field.
func ErrorMessageLTE(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldErrorMessage, v))
}
// ErrorMessageContains applies the Contains predicate on the "error_message" field.
func ErrorMessageContains(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContains(FieldErrorMessage, v))
}
// ErrorMessageHasPrefix applies the HasPrefix predicate on the "error_message" field.
func ErrorMessageHasPrefix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasPrefix(FieldErrorMessage, v))
}
// ErrorMessageHasSuffix applies the HasSuffix predicate on the "error_message" field.
func ErrorMessageHasSuffix(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldHasSuffix(FieldErrorMessage, v))
}
// ErrorMessageIsNil applies the IsNil predicate on the "error_message" field.
func ErrorMessageIsNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldIsNull(FieldErrorMessage))
}
// ErrorMessageNotNil applies the NotNil predicate on the "error_message" field.
func ErrorMessageNotNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotNull(FieldErrorMessage))
}
// ErrorMessageEqualFold applies the EqualFold predicate on the "error_message" field.
func ErrorMessageEqualFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEqualFold(FieldErrorMessage, v))
}
// ErrorMessageContainsFold applies the ContainsFold predicate on the "error_message" field.
func ErrorMessageContainsFold(v string) predicate.SoraTask {
return predicate.SoraTask(sql.FieldContainsFold(FieldErrorMessage, v))
}
// RetryCountEQ applies the EQ predicate on the "retry_count" field.
func RetryCountEQ(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldRetryCount, v))
}
// RetryCountNEQ applies the NEQ predicate on the "retry_count" field.
func RetryCountNEQ(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldRetryCount, v))
}
// RetryCountIn applies the In predicate on the "retry_count" field.
func RetryCountIn(vs ...int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldRetryCount, vs...))
}
// RetryCountNotIn applies the NotIn predicate on the "retry_count" field.
func RetryCountNotIn(vs ...int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldRetryCount, vs...))
}
// RetryCountGT applies the GT predicate on the "retry_count" field.
func RetryCountGT(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldRetryCount, v))
}
// RetryCountGTE applies the GTE predicate on the "retry_count" field.
func RetryCountGTE(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldRetryCount, v))
}
// RetryCountLT applies the LT predicate on the "retry_count" field.
func RetryCountLT(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldRetryCount, v))
}
// RetryCountLTE applies the LTE predicate on the "retry_count" field.
func RetryCountLTE(v int) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldRetryCount, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldCreatedAt, v))
}
// CompletedAtEQ applies the EQ predicate on the "completed_at" field.
func CompletedAtEQ(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldEQ(FieldCompletedAt, v))
}
// CompletedAtNEQ applies the NEQ predicate on the "completed_at" field.
func CompletedAtNEQ(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNEQ(FieldCompletedAt, v))
}
// CompletedAtIn applies the In predicate on the "completed_at" field.
func CompletedAtIn(vs ...time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldIn(FieldCompletedAt, vs...))
}
// CompletedAtNotIn applies the NotIn predicate on the "completed_at" field.
func CompletedAtNotIn(vs ...time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotIn(FieldCompletedAt, vs...))
}
// CompletedAtGT applies the GT predicate on the "completed_at" field.
func CompletedAtGT(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGT(FieldCompletedAt, v))
}
// CompletedAtGTE applies the GTE predicate on the "completed_at" field.
func CompletedAtGTE(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldGTE(FieldCompletedAt, v))
}
// CompletedAtLT applies the LT predicate on the "completed_at" field.
func CompletedAtLT(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLT(FieldCompletedAt, v))
}
// CompletedAtLTE applies the LTE predicate on the "completed_at" field.
func CompletedAtLTE(v time.Time) predicate.SoraTask {
return predicate.SoraTask(sql.FieldLTE(FieldCompletedAt, v))
}
// CompletedAtIsNil applies the IsNil predicate on the "completed_at" field.
func CompletedAtIsNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldIsNull(FieldCompletedAt))
}
// CompletedAtNotNil applies the NotNil predicate on the "completed_at" field.
func CompletedAtNotNil() predicate.SoraTask {
return predicate.SoraTask(sql.FieldNotNull(FieldCompletedAt))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.SoraTask) predicate.SoraTask {
return predicate.SoraTask(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.SoraTask) predicate.SoraTask {
return predicate.SoraTask(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.SoraTask) predicate.SoraTask {
return predicate.SoraTask(sql.NotPredicates(p))
}
// 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/Wei-Shaw/sub2api/ent/soratask"
)
// SoraTaskCreate is the builder for creating a SoraTask entity.
type SoraTaskCreate struct {
config
mutation *SoraTaskMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetTaskID sets the "task_id" field.
func (_c *SoraTaskCreate) SetTaskID(v string) *SoraTaskCreate {
_c.mutation.SetTaskID(v)
return _c
}
// SetAccountID sets the "account_id" field.
func (_c *SoraTaskCreate) SetAccountID(v int64) *SoraTaskCreate {
_c.mutation.SetAccountID(v)
return _c
}
// SetModel sets the "model" field.
func (_c *SoraTaskCreate) SetModel(v string) *SoraTaskCreate {
_c.mutation.SetModel(v)
return _c
}
// SetPrompt sets the "prompt" field.
func (_c *SoraTaskCreate) SetPrompt(v string) *SoraTaskCreate {
_c.mutation.SetPrompt(v)
return _c
}
// SetStatus sets the "status" field.
func (_c *SoraTaskCreate) SetStatus(v string) *SoraTaskCreate {
_c.mutation.SetStatus(v)
return _c
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_c *SoraTaskCreate) SetNillableStatus(v *string) *SoraTaskCreate {
if v != nil {
_c.SetStatus(*v)
}
return _c
}
// SetProgress sets the "progress" field.
func (_c *SoraTaskCreate) SetProgress(v float64) *SoraTaskCreate {
_c.mutation.SetProgress(v)
return _c
}
// SetNillableProgress sets the "progress" field if the given value is not nil.
func (_c *SoraTaskCreate) SetNillableProgress(v *float64) *SoraTaskCreate {
if v != nil {
_c.SetProgress(*v)
}
return _c
}
// SetResultUrls sets the "result_urls" field.
func (_c *SoraTaskCreate) SetResultUrls(v string) *SoraTaskCreate {
_c.mutation.SetResultUrls(v)
return _c
}
// SetNillableResultUrls sets the "result_urls" field if the given value is not nil.
func (_c *SoraTaskCreate) SetNillableResultUrls(v *string) *SoraTaskCreate {
if v != nil {
_c.SetResultUrls(*v)
}
return _c
}
// SetErrorMessage sets the "error_message" field.
func (_c *SoraTaskCreate) SetErrorMessage(v string) *SoraTaskCreate {
_c.mutation.SetErrorMessage(v)
return _c
}
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
func (_c *SoraTaskCreate) SetNillableErrorMessage(v *string) *SoraTaskCreate {
if v != nil {
_c.SetErrorMessage(*v)
}
return _c
}
// SetRetryCount sets the "retry_count" field.
func (_c *SoraTaskCreate) SetRetryCount(v int) *SoraTaskCreate {
_c.mutation.SetRetryCount(v)
return _c
}
// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
func (_c *SoraTaskCreate) SetNillableRetryCount(v *int) *SoraTaskCreate {
if v != nil {
_c.SetRetryCount(*v)
}
return _c
}
// SetCreatedAt sets the "created_at" field.
func (_c *SoraTaskCreate) SetCreatedAt(v time.Time) *SoraTaskCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *SoraTaskCreate) SetNillableCreatedAt(v *time.Time) *SoraTaskCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetCompletedAt sets the "completed_at" field.
func (_c *SoraTaskCreate) SetCompletedAt(v time.Time) *SoraTaskCreate {
_c.mutation.SetCompletedAt(v)
return _c
}
// SetNillableCompletedAt sets the "completed_at" field if the given value is not nil.
func (_c *SoraTaskCreate) SetNillableCompletedAt(v *time.Time) *SoraTaskCreate {
if v != nil {
_c.SetCompletedAt(*v)
}
return _c
}
// Mutation returns the SoraTaskMutation object of the builder.
func (_c *SoraTaskCreate) Mutation() *SoraTaskMutation {
return _c.mutation
}
// Save creates the SoraTask in the database.
func (_c *SoraTaskCreate) Save(ctx context.Context) (*SoraTask, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *SoraTaskCreate) SaveX(ctx context.Context) *SoraTask {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SoraTaskCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SoraTaskCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *SoraTaskCreate) defaults() {
if _, ok := _c.mutation.Status(); !ok {
v := soratask.DefaultStatus
_c.mutation.SetStatus(v)
}
if _, ok := _c.mutation.Progress(); !ok {
v := soratask.DefaultProgress
_c.mutation.SetProgress(v)
}
if _, ok := _c.mutation.RetryCount(); !ok {
v := soratask.DefaultRetryCount
_c.mutation.SetRetryCount(v)
}
if _, ok := _c.mutation.CreatedAt(); !ok {
v := soratask.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *SoraTaskCreate) check() error {
if _, ok := _c.mutation.TaskID(); !ok {
return &ValidationError{Name: "task_id", err: errors.New(`ent: missing required field "SoraTask.task_id"`)}
}
if v, ok := _c.mutation.TaskID(); ok {
if err := soratask.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraTask.task_id": %w`, err)}
}
}
if _, ok := _c.mutation.AccountID(); !ok {
return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "SoraTask.account_id"`)}
}
if _, ok := _c.mutation.Model(); !ok {
return &ValidationError{Name: "model", err: errors.New(`ent: missing required field "SoraTask.model"`)}
}
if v, ok := _c.mutation.Model(); ok {
if err := soratask.ModelValidator(v); err != nil {
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "SoraTask.model": %w`, err)}
}
}
if _, ok := _c.mutation.Prompt(); !ok {
return &ValidationError{Name: "prompt", err: errors.New(`ent: missing required field "SoraTask.prompt"`)}
}
if _, ok := _c.mutation.Status(); !ok {
return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "SoraTask.status"`)}
}
if v, ok := _c.mutation.Status(); ok {
if err := soratask.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "SoraTask.status": %w`, err)}
}
}
if _, ok := _c.mutation.Progress(); !ok {
return &ValidationError{Name: "progress", err: errors.New(`ent: missing required field "SoraTask.progress"`)}
}
if _, ok := _c.mutation.RetryCount(); !ok {
return &ValidationError{Name: "retry_count", err: errors.New(`ent: missing required field "SoraTask.retry_count"`)}
}
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SoraTask.created_at"`)}
}
return nil
}
func (_c *SoraTaskCreate) sqlSave(ctx context.Context) (*SoraTask, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *SoraTaskCreate) createSpec() (*SoraTask, *sqlgraph.CreateSpec) {
var (
_node = &SoraTask{config: _c.config}
_spec = sqlgraph.NewCreateSpec(soratask.Table, sqlgraph.NewFieldSpec(soratask.FieldID, field.TypeInt64))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.TaskID(); ok {
_spec.SetField(soratask.FieldTaskID, field.TypeString, value)
_node.TaskID = value
}
if value, ok := _c.mutation.AccountID(); ok {
_spec.SetField(soratask.FieldAccountID, field.TypeInt64, value)
_node.AccountID = value
}
if value, ok := _c.mutation.Model(); ok {
_spec.SetField(soratask.FieldModel, field.TypeString, value)
_node.Model = value
}
if value, ok := _c.mutation.Prompt(); ok {
_spec.SetField(soratask.FieldPrompt, field.TypeString, value)
_node.Prompt = value
}
if value, ok := _c.mutation.Status(); ok {
_spec.SetField(soratask.FieldStatus, field.TypeString, value)
_node.Status = value
}
if value, ok := _c.mutation.Progress(); ok {
_spec.SetField(soratask.FieldProgress, field.TypeFloat64, value)
_node.Progress = value
}
if value, ok := _c.mutation.ResultUrls(); ok {
_spec.SetField(soratask.FieldResultUrls, field.TypeString, value)
_node.ResultUrls = &value
}
if value, ok := _c.mutation.ErrorMessage(); ok {
_spec.SetField(soratask.FieldErrorMessage, field.TypeString, value)
_node.ErrorMessage = &value
}
if value, ok := _c.mutation.RetryCount(); ok {
_spec.SetField(soratask.FieldRetryCount, field.TypeInt, value)
_node.RetryCount = value
}
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(soratask.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.CompletedAt(); ok {
_spec.SetField(soratask.FieldCompletedAt, field.TypeTime, value)
_node.CompletedAt = &value
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SoraTask.Create().
// SetTaskID(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.SoraTaskUpsert) {
// SetTaskID(v+v).
// }).
// Exec(ctx)
func (_c *SoraTaskCreate) OnConflict(opts ...sql.ConflictOption) *SoraTaskUpsertOne {
_c.conflict = opts
return &SoraTaskUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SoraTask.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SoraTaskCreate) OnConflictColumns(columns ...string) *SoraTaskUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SoraTaskUpsertOne{
create: _c,
}
}
type (
// SoraTaskUpsertOne is the builder for "upsert"-ing
// one SoraTask node.
SoraTaskUpsertOne struct {
create *SoraTaskCreate
}
// SoraTaskUpsert is the "OnConflict" setter.
SoraTaskUpsert struct {
*sql.UpdateSet
}
)
// SetTaskID sets the "task_id" field.
func (u *SoraTaskUpsert) SetTaskID(v string) *SoraTaskUpsert {
u.Set(soratask.FieldTaskID, v)
return u
}
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateTaskID() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldTaskID)
return u
}
// SetAccountID sets the "account_id" field.
func (u *SoraTaskUpsert) SetAccountID(v int64) *SoraTaskUpsert {
u.Set(soratask.FieldAccountID, v)
return u
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateAccountID() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldAccountID)
return u
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraTaskUpsert) AddAccountID(v int64) *SoraTaskUpsert {
u.Add(soratask.FieldAccountID, v)
return u
}
// SetModel sets the "model" field.
func (u *SoraTaskUpsert) SetModel(v string) *SoraTaskUpsert {
u.Set(soratask.FieldModel, v)
return u
}
// UpdateModel sets the "model" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateModel() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldModel)
return u
}
// SetPrompt sets the "prompt" field.
func (u *SoraTaskUpsert) SetPrompt(v string) *SoraTaskUpsert {
u.Set(soratask.FieldPrompt, v)
return u
}
// UpdatePrompt sets the "prompt" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdatePrompt() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldPrompt)
return u
}
// SetStatus sets the "status" field.
func (u *SoraTaskUpsert) SetStatus(v string) *SoraTaskUpsert {
u.Set(soratask.FieldStatus, v)
return u
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateStatus() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldStatus)
return u
}
// SetProgress sets the "progress" field.
func (u *SoraTaskUpsert) SetProgress(v float64) *SoraTaskUpsert {
u.Set(soratask.FieldProgress, v)
return u
}
// UpdateProgress sets the "progress" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateProgress() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldProgress)
return u
}
// AddProgress adds v to the "progress" field.
func (u *SoraTaskUpsert) AddProgress(v float64) *SoraTaskUpsert {
u.Add(soratask.FieldProgress, v)
return u
}
// SetResultUrls sets the "result_urls" field.
func (u *SoraTaskUpsert) SetResultUrls(v string) *SoraTaskUpsert {
u.Set(soratask.FieldResultUrls, v)
return u
}
// UpdateResultUrls sets the "result_urls" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateResultUrls() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldResultUrls)
return u
}
// ClearResultUrls clears the value of the "result_urls" field.
func (u *SoraTaskUpsert) ClearResultUrls() *SoraTaskUpsert {
u.SetNull(soratask.FieldResultUrls)
return u
}
// SetErrorMessage sets the "error_message" field.
func (u *SoraTaskUpsert) SetErrorMessage(v string) *SoraTaskUpsert {
u.Set(soratask.FieldErrorMessage, v)
return u
}
// UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateErrorMessage() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldErrorMessage)
return u
}
// ClearErrorMessage clears the value of the "error_message" field.
func (u *SoraTaskUpsert) ClearErrorMessage() *SoraTaskUpsert {
u.SetNull(soratask.FieldErrorMessage)
return u
}
// SetRetryCount sets the "retry_count" field.
func (u *SoraTaskUpsert) SetRetryCount(v int) *SoraTaskUpsert {
u.Set(soratask.FieldRetryCount, v)
return u
}
// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateRetryCount() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldRetryCount)
return u
}
// AddRetryCount adds v to the "retry_count" field.
func (u *SoraTaskUpsert) AddRetryCount(v int) *SoraTaskUpsert {
u.Add(soratask.FieldRetryCount, v)
return u
}
// SetCreatedAt sets the "created_at" field.
func (u *SoraTaskUpsert) SetCreatedAt(v time.Time) *SoraTaskUpsert {
u.Set(soratask.FieldCreatedAt, v)
return u
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateCreatedAt() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldCreatedAt)
return u
}
// SetCompletedAt sets the "completed_at" field.
func (u *SoraTaskUpsert) SetCompletedAt(v time.Time) *SoraTaskUpsert {
u.Set(soratask.FieldCompletedAt, v)
return u
}
// UpdateCompletedAt sets the "completed_at" field to the value that was provided on create.
func (u *SoraTaskUpsert) UpdateCompletedAt() *SoraTaskUpsert {
u.SetExcluded(soratask.FieldCompletedAt)
return u
}
// ClearCompletedAt clears the value of the "completed_at" field.
func (u *SoraTaskUpsert) ClearCompletedAt() *SoraTaskUpsert {
u.SetNull(soratask.FieldCompletedAt)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.SoraTask.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SoraTaskUpsertOne) UpdateNewValues() *SoraTaskUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SoraTask.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SoraTaskUpsertOne) Ignore() *SoraTaskUpsertOne {
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 *SoraTaskUpsertOne) DoNothing() *SoraTaskUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SoraTaskCreate.OnConflict
// documentation for more info.
func (u *SoraTaskUpsertOne) Update(set func(*SoraTaskUpsert)) *SoraTaskUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SoraTaskUpsert{UpdateSet: update})
}))
return u
}
// SetTaskID sets the "task_id" field.
func (u *SoraTaskUpsertOne) SetTaskID(v string) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetTaskID(v)
})
}
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateTaskID() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateTaskID()
})
}
// SetAccountID sets the "account_id" field.
func (u *SoraTaskUpsertOne) SetAccountID(v int64) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetAccountID(v)
})
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraTaskUpsertOne) AddAccountID(v int64) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.AddAccountID(v)
})
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateAccountID() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateAccountID()
})
}
// SetModel sets the "model" field.
func (u *SoraTaskUpsertOne) SetModel(v string) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetModel(v)
})
}
// UpdateModel sets the "model" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateModel() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateModel()
})
}
// SetPrompt sets the "prompt" field.
func (u *SoraTaskUpsertOne) SetPrompt(v string) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetPrompt(v)
})
}
// UpdatePrompt sets the "prompt" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdatePrompt() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdatePrompt()
})
}
// SetStatus sets the "status" field.
func (u *SoraTaskUpsertOne) SetStatus(v string) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateStatus() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateStatus()
})
}
// SetProgress sets the "progress" field.
func (u *SoraTaskUpsertOne) SetProgress(v float64) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetProgress(v)
})
}
// AddProgress adds v to the "progress" field.
func (u *SoraTaskUpsertOne) AddProgress(v float64) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.AddProgress(v)
})
}
// UpdateProgress sets the "progress" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateProgress() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateProgress()
})
}
// SetResultUrls sets the "result_urls" field.
func (u *SoraTaskUpsertOne) SetResultUrls(v string) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetResultUrls(v)
})
}
// UpdateResultUrls sets the "result_urls" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateResultUrls() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateResultUrls()
})
}
// ClearResultUrls clears the value of the "result_urls" field.
func (u *SoraTaskUpsertOne) ClearResultUrls() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.ClearResultUrls()
})
}
// SetErrorMessage sets the "error_message" field.
func (u *SoraTaskUpsertOne) SetErrorMessage(v string) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetErrorMessage(v)
})
}
// UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateErrorMessage() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateErrorMessage()
})
}
// ClearErrorMessage clears the value of the "error_message" field.
func (u *SoraTaskUpsertOne) ClearErrorMessage() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.ClearErrorMessage()
})
}
// SetRetryCount sets the "retry_count" field.
func (u *SoraTaskUpsertOne) SetRetryCount(v int) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetRetryCount(v)
})
}
// AddRetryCount adds v to the "retry_count" field.
func (u *SoraTaskUpsertOne) AddRetryCount(v int) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.AddRetryCount(v)
})
}
// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateRetryCount() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateRetryCount()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *SoraTaskUpsertOne) SetCreatedAt(v time.Time) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateCreatedAt() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateCreatedAt()
})
}
// SetCompletedAt sets the "completed_at" field.
func (u *SoraTaskUpsertOne) SetCompletedAt(v time.Time) *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.SetCompletedAt(v)
})
}
// UpdateCompletedAt sets the "completed_at" field to the value that was provided on create.
func (u *SoraTaskUpsertOne) UpdateCompletedAt() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateCompletedAt()
})
}
// ClearCompletedAt clears the value of the "completed_at" field.
func (u *SoraTaskUpsertOne) ClearCompletedAt() *SoraTaskUpsertOne {
return u.Update(func(s *SoraTaskUpsert) {
s.ClearCompletedAt()
})
}
// Exec executes the query.
func (u *SoraTaskUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SoraTaskCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SoraTaskUpsertOne) 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 *SoraTaskUpsertOne) ID(ctx context.Context) (id int64, 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 *SoraTaskUpsertOne) IDX(ctx context.Context) int64 {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// SoraTaskCreateBulk is the builder for creating many SoraTask entities in bulk.
type SoraTaskCreateBulk struct {
config
err error
builders []*SoraTaskCreate
conflict []sql.ConflictOption
}
// Save creates the SoraTask entities in the database.
func (_c *SoraTaskCreateBulk) Save(ctx context.Context) ([]*SoraTask, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*SoraTask, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SoraTaskMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *SoraTaskCreateBulk) SaveX(ctx context.Context) []*SoraTask {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SoraTaskCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SoraTaskCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SoraTask.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.SoraTaskUpsert) {
// SetTaskID(v+v).
// }).
// Exec(ctx)
func (_c *SoraTaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *SoraTaskUpsertBulk {
_c.conflict = opts
return &SoraTaskUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SoraTask.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SoraTaskCreateBulk) OnConflictColumns(columns ...string) *SoraTaskUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SoraTaskUpsertBulk{
create: _c,
}
}
// SoraTaskUpsertBulk is the builder for "upsert"-ing
// a bulk of SoraTask nodes.
type SoraTaskUpsertBulk struct {
create *SoraTaskCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.SoraTask.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SoraTaskUpsertBulk) UpdateNewValues() *SoraTaskUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SoraTask.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SoraTaskUpsertBulk) Ignore() *SoraTaskUpsertBulk {
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 *SoraTaskUpsertBulk) DoNothing() *SoraTaskUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SoraTaskCreateBulk.OnConflict
// documentation for more info.
func (u *SoraTaskUpsertBulk) Update(set func(*SoraTaskUpsert)) *SoraTaskUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SoraTaskUpsert{UpdateSet: update})
}))
return u
}
// SetTaskID sets the "task_id" field.
func (u *SoraTaskUpsertBulk) SetTaskID(v string) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetTaskID(v)
})
}
// UpdateTaskID sets the "task_id" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateTaskID() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateTaskID()
})
}
// SetAccountID sets the "account_id" field.
func (u *SoraTaskUpsertBulk) SetAccountID(v int64) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetAccountID(v)
})
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraTaskUpsertBulk) AddAccountID(v int64) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.AddAccountID(v)
})
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateAccountID() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateAccountID()
})
}
// SetModel sets the "model" field.
func (u *SoraTaskUpsertBulk) SetModel(v string) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetModel(v)
})
}
// UpdateModel sets the "model" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateModel() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateModel()
})
}
// SetPrompt sets the "prompt" field.
func (u *SoraTaskUpsertBulk) SetPrompt(v string) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetPrompt(v)
})
}
// UpdatePrompt sets the "prompt" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdatePrompt() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdatePrompt()
})
}
// SetStatus sets the "status" field.
func (u *SoraTaskUpsertBulk) SetStatus(v string) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetStatus(v)
})
}
// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateStatus() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateStatus()
})
}
// SetProgress sets the "progress" field.
func (u *SoraTaskUpsertBulk) SetProgress(v float64) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetProgress(v)
})
}
// AddProgress adds v to the "progress" field.
func (u *SoraTaskUpsertBulk) AddProgress(v float64) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.AddProgress(v)
})
}
// UpdateProgress sets the "progress" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateProgress() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateProgress()
})
}
// SetResultUrls sets the "result_urls" field.
func (u *SoraTaskUpsertBulk) SetResultUrls(v string) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetResultUrls(v)
})
}
// UpdateResultUrls sets the "result_urls" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateResultUrls() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateResultUrls()
})
}
// ClearResultUrls clears the value of the "result_urls" field.
func (u *SoraTaskUpsertBulk) ClearResultUrls() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.ClearResultUrls()
})
}
// SetErrorMessage sets the "error_message" field.
func (u *SoraTaskUpsertBulk) SetErrorMessage(v string) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetErrorMessage(v)
})
}
// UpdateErrorMessage sets the "error_message" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateErrorMessage() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateErrorMessage()
})
}
// ClearErrorMessage clears the value of the "error_message" field.
func (u *SoraTaskUpsertBulk) ClearErrorMessage() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.ClearErrorMessage()
})
}
// SetRetryCount sets the "retry_count" field.
func (u *SoraTaskUpsertBulk) SetRetryCount(v int) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetRetryCount(v)
})
}
// AddRetryCount adds v to the "retry_count" field.
func (u *SoraTaskUpsertBulk) AddRetryCount(v int) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.AddRetryCount(v)
})
}
// UpdateRetryCount sets the "retry_count" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateRetryCount() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateRetryCount()
})
}
// SetCreatedAt sets the "created_at" field.
func (u *SoraTaskUpsertBulk) SetCreatedAt(v time.Time) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetCreatedAt(v)
})
}
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateCreatedAt() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateCreatedAt()
})
}
// SetCompletedAt sets the "completed_at" field.
func (u *SoraTaskUpsertBulk) SetCompletedAt(v time.Time) *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.SetCompletedAt(v)
})
}
// UpdateCompletedAt sets the "completed_at" field to the value that was provided on create.
func (u *SoraTaskUpsertBulk) UpdateCompletedAt() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.UpdateCompletedAt()
})
}
// ClearCompletedAt clears the value of the "completed_at" field.
func (u *SoraTaskUpsertBulk) ClearCompletedAt() *SoraTaskUpsertBulk {
return u.Update(func(s *SoraTaskUpsert) {
s.ClearCompletedAt()
})
}
// Exec executes the query.
func (u *SoraTaskUpsertBulk) 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 SoraTaskCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SoraTaskCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SoraTaskUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/soratask"
)
// SoraTaskDelete is the builder for deleting a SoraTask entity.
type SoraTaskDelete struct {
config
hooks []Hook
mutation *SoraTaskMutation
}
// Where appends a list predicates to the SoraTaskDelete builder.
func (_d *SoraTaskDelete) Where(ps ...predicate.SoraTask) *SoraTaskDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *SoraTaskDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraTaskDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *SoraTaskDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(soratask.Table, sqlgraph.NewFieldSpec(soratask.FieldID, field.TypeInt64))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
_d.mutation.done = true
return affected, err
}
// SoraTaskDeleteOne is the builder for deleting a single SoraTask entity.
type SoraTaskDeleteOne struct {
_d *SoraTaskDelete
}
// Where appends a list predicates to the SoraTaskDelete builder.
func (_d *SoraTaskDeleteOne) Where(ps ...predicate.SoraTask) *SoraTaskDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *SoraTaskDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{soratask.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraTaskDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/soratask"
)
// SoraTaskQuery is the builder for querying SoraTask entities.
type SoraTaskQuery struct {
config
ctx *QueryContext
order []soratask.OrderOption
inters []Interceptor
predicates []predicate.SoraTask
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the SoraTaskQuery builder.
func (_q *SoraTaskQuery) Where(ps ...predicate.SoraTask) *SoraTaskQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *SoraTaskQuery) Limit(limit int) *SoraTaskQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *SoraTaskQuery) Offset(offset int) *SoraTaskQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *SoraTaskQuery) Unique(unique bool) *SoraTaskQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *SoraTaskQuery) Order(o ...soratask.OrderOption) *SoraTaskQuery {
_q.order = append(_q.order, o...)
return _q
}
// First returns the first SoraTask entity from the query.
// Returns a *NotFoundError when no SoraTask was found.
func (_q *SoraTaskQuery) First(ctx context.Context) (*SoraTask, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{soratask.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *SoraTaskQuery) FirstX(ctx context.Context) *SoraTask {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first SoraTask ID from the query.
// Returns a *NotFoundError when no SoraTask ID was found.
func (_q *SoraTaskQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{soratask.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *SoraTaskQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single SoraTask entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one SoraTask entity is found.
// Returns a *NotFoundError when no SoraTask entities are found.
func (_q *SoraTaskQuery) Only(ctx context.Context) (*SoraTask, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{soratask.Label}
default:
return nil, &NotSingularError{soratask.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *SoraTaskQuery) OnlyX(ctx context.Context) *SoraTask {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only SoraTask ID in the query.
// Returns a *NotSingularError when more than one SoraTask ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *SoraTaskQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{soratask.Label}
default:
err = &NotSingularError{soratask.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *SoraTaskQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of SoraTasks.
func (_q *SoraTaskQuery) All(ctx context.Context) ([]*SoraTask, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*SoraTask, *SoraTaskQuery]()
return withInterceptors[[]*SoraTask](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *SoraTaskQuery) AllX(ctx context.Context) []*SoraTask {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of SoraTask IDs.
func (_q *SoraTaskQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(soratask.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *SoraTaskQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *SoraTaskQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*SoraTaskQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *SoraTaskQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *SoraTaskQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *SoraTaskQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the SoraTaskQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *SoraTaskQuery) Clone() *SoraTaskQuery {
if _q == nil {
return nil
}
return &SoraTaskQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]soratask.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.SoraTask{}, _q.predicates...),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// TaskID string `json:"task_id,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.SoraTask.Query().
// GroupBy(soratask.FieldTaskID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *SoraTaskQuery) GroupBy(field string, fields ...string) *SoraTaskGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &SoraTaskGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = soratask.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// TaskID string `json:"task_id,omitempty"`
// }
//
// client.SoraTask.Query().
// Select(soratask.FieldTaskID).
// Scan(ctx, &v)
func (_q *SoraTaskQuery) Select(fields ...string) *SoraTaskSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &SoraTaskSelect{SoraTaskQuery: _q}
sbuild.label = soratask.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a SoraTaskSelect configured with the given aggregations.
func (_q *SoraTaskQuery) Aggregate(fns ...AggregateFunc) *SoraTaskSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *SoraTaskQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !soratask.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *SoraTaskQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SoraTask, error) {
var (
nodes = []*SoraTask{}
_spec = _q.querySpec()
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*SoraTask).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &SoraTask{config: _q.config}
nodes = append(nodes, node)
return node.assignValues(columns, values)
}
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
return nodes, nil
}
func (_q *SoraTaskQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *SoraTaskQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(soratask.Table, soratask.Columns, sqlgraph.NewFieldSpec(soratask.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, soratask.FieldID)
for i := range fields {
if fields[i] != soratask.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *SoraTaskQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(soratask.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = soratask.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *SoraTaskQuery) ForUpdate(opts ...sql.LockOption) *SoraTaskQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *SoraTaskQuery) ForShare(opts ...sql.LockOption) *SoraTaskQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// SoraTaskGroupBy is the group-by builder for SoraTask entities.
type SoraTaskGroupBy struct {
selector
build *SoraTaskQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *SoraTaskGroupBy) Aggregate(fns ...AggregateFunc) *SoraTaskGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *SoraTaskGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraTaskQuery, *SoraTaskGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *SoraTaskGroupBy) sqlScan(ctx context.Context, root *SoraTaskQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// SoraTaskSelect is the builder for selecting fields of SoraTask entities.
type SoraTaskSelect struct {
*SoraTaskQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *SoraTaskSelect) Aggregate(fns ...AggregateFunc) *SoraTaskSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *SoraTaskSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*SoraTaskQuery, *SoraTaskSelect](ctx, _s.SoraTaskQuery, _s, _s.inters, v)
}
func (_s *SoraTaskSelect) sqlScan(ctx context.Context, root *SoraTaskQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// 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/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/soratask"
)
// SoraTaskUpdate is the builder for updating SoraTask entities.
type SoraTaskUpdate struct {
config
hooks []Hook
mutation *SoraTaskMutation
}
// Where appends a list predicates to the SoraTaskUpdate builder.
func (_u *SoraTaskUpdate) Where(ps ...predicate.SoraTask) *SoraTaskUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetTaskID sets the "task_id" field.
func (_u *SoraTaskUpdate) SetTaskID(v string) *SoraTaskUpdate {
_u.mutation.SetTaskID(v)
return _u
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableTaskID(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetTaskID(*v)
}
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraTaskUpdate) SetAccountID(v int64) *SoraTaskUpdate {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableAccountID(v *int64) *SoraTaskUpdate {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraTaskUpdate) AddAccountID(v int64) *SoraTaskUpdate {
_u.mutation.AddAccountID(v)
return _u
}
// SetModel sets the "model" field.
func (_u *SoraTaskUpdate) SetModel(v string) *SoraTaskUpdate {
_u.mutation.SetModel(v)
return _u
}
// SetNillableModel sets the "model" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableModel(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetModel(*v)
}
return _u
}
// SetPrompt sets the "prompt" field.
func (_u *SoraTaskUpdate) SetPrompt(v string) *SoraTaskUpdate {
_u.mutation.SetPrompt(v)
return _u
}
// SetNillablePrompt sets the "prompt" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillablePrompt(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetPrompt(*v)
}
return _u
}
// SetStatus sets the "status" field.
func (_u *SoraTaskUpdate) SetStatus(v string) *SoraTaskUpdate {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableStatus(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetProgress sets the "progress" field.
func (_u *SoraTaskUpdate) SetProgress(v float64) *SoraTaskUpdate {
_u.mutation.ResetProgress()
_u.mutation.SetProgress(v)
return _u
}
// SetNillableProgress sets the "progress" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableProgress(v *float64) *SoraTaskUpdate {
if v != nil {
_u.SetProgress(*v)
}
return _u
}
// AddProgress adds value to the "progress" field.
func (_u *SoraTaskUpdate) AddProgress(v float64) *SoraTaskUpdate {
_u.mutation.AddProgress(v)
return _u
}
// SetResultUrls sets the "result_urls" field.
func (_u *SoraTaskUpdate) SetResultUrls(v string) *SoraTaskUpdate {
_u.mutation.SetResultUrls(v)
return _u
}
// SetNillableResultUrls sets the "result_urls" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableResultUrls(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetResultUrls(*v)
}
return _u
}
// ClearResultUrls clears the value of the "result_urls" field.
func (_u *SoraTaskUpdate) ClearResultUrls() *SoraTaskUpdate {
_u.mutation.ClearResultUrls()
return _u
}
// SetErrorMessage sets the "error_message" field.
func (_u *SoraTaskUpdate) SetErrorMessage(v string) *SoraTaskUpdate {
_u.mutation.SetErrorMessage(v)
return _u
}
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableErrorMessage(v *string) *SoraTaskUpdate {
if v != nil {
_u.SetErrorMessage(*v)
}
return _u
}
// ClearErrorMessage clears the value of the "error_message" field.
func (_u *SoraTaskUpdate) ClearErrorMessage() *SoraTaskUpdate {
_u.mutation.ClearErrorMessage()
return _u
}
// SetRetryCount sets the "retry_count" field.
func (_u *SoraTaskUpdate) SetRetryCount(v int) *SoraTaskUpdate {
_u.mutation.ResetRetryCount()
_u.mutation.SetRetryCount(v)
return _u
}
// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableRetryCount(v *int) *SoraTaskUpdate {
if v != nil {
_u.SetRetryCount(*v)
}
return _u
}
// AddRetryCount adds value to the "retry_count" field.
func (_u *SoraTaskUpdate) AddRetryCount(v int) *SoraTaskUpdate {
_u.mutation.AddRetryCount(v)
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *SoraTaskUpdate) SetCreatedAt(v time.Time) *SoraTaskUpdate {
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableCreatedAt(v *time.Time) *SoraTaskUpdate {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// SetCompletedAt sets the "completed_at" field.
func (_u *SoraTaskUpdate) SetCompletedAt(v time.Time) *SoraTaskUpdate {
_u.mutation.SetCompletedAt(v)
return _u
}
// SetNillableCompletedAt sets the "completed_at" field if the given value is not nil.
func (_u *SoraTaskUpdate) SetNillableCompletedAt(v *time.Time) *SoraTaskUpdate {
if v != nil {
_u.SetCompletedAt(*v)
}
return _u
}
// ClearCompletedAt clears the value of the "completed_at" field.
func (_u *SoraTaskUpdate) ClearCompletedAt() *SoraTaskUpdate {
_u.mutation.ClearCompletedAt()
return _u
}
// Mutation returns the SoraTaskMutation object of the builder.
func (_u *SoraTaskUpdate) Mutation() *SoraTaskMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *SoraTaskUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraTaskUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *SoraTaskUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraTaskUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *SoraTaskUpdate) check() error {
if v, ok := _u.mutation.TaskID(); ok {
if err := soratask.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraTask.task_id": %w`, err)}
}
}
if v, ok := _u.mutation.Model(); ok {
if err := soratask.ModelValidator(v); err != nil {
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "SoraTask.model": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := soratask.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "SoraTask.status": %w`, err)}
}
}
return nil
}
func (_u *SoraTaskUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(soratask.Table, soratask.Columns, sqlgraph.NewFieldSpec(soratask.FieldID, field.TypeInt64))
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.TaskID(); ok {
_spec.SetField(soratask.FieldTaskID, field.TypeString, value)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soratask.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soratask.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.Model(); ok {
_spec.SetField(soratask.FieldModel, field.TypeString, value)
}
if value, ok := _u.mutation.Prompt(); ok {
_spec.SetField(soratask.FieldPrompt, field.TypeString, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(soratask.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.Progress(); ok {
_spec.SetField(soratask.FieldProgress, field.TypeFloat64, value)
}
if value, ok := _u.mutation.AddedProgress(); ok {
_spec.AddField(soratask.FieldProgress, field.TypeFloat64, value)
}
if value, ok := _u.mutation.ResultUrls(); ok {
_spec.SetField(soratask.FieldResultUrls, field.TypeString, value)
}
if _u.mutation.ResultUrlsCleared() {
_spec.ClearField(soratask.FieldResultUrls, field.TypeString)
}
if value, ok := _u.mutation.ErrorMessage(); ok {
_spec.SetField(soratask.FieldErrorMessage, field.TypeString, value)
}
if _u.mutation.ErrorMessageCleared() {
_spec.ClearField(soratask.FieldErrorMessage, field.TypeString)
}
if value, ok := _u.mutation.RetryCount(); ok {
_spec.SetField(soratask.FieldRetryCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedRetryCount(); ok {
_spec.AddField(soratask.FieldRetryCount, field.TypeInt, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(soratask.FieldCreatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.CompletedAt(); ok {
_spec.SetField(soratask.FieldCompletedAt, field.TypeTime, value)
}
if _u.mutation.CompletedAtCleared() {
_spec.ClearField(soratask.FieldCompletedAt, field.TypeTime)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{soratask.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// SoraTaskUpdateOne is the builder for updating a single SoraTask entity.
type SoraTaskUpdateOne struct {
config
fields []string
hooks []Hook
mutation *SoraTaskMutation
}
// SetTaskID sets the "task_id" field.
func (_u *SoraTaskUpdateOne) SetTaskID(v string) *SoraTaskUpdateOne {
_u.mutation.SetTaskID(v)
return _u
}
// SetNillableTaskID sets the "task_id" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableTaskID(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetTaskID(*v)
}
return _u
}
// SetAccountID sets the "account_id" field.
func (_u *SoraTaskUpdateOne) SetAccountID(v int64) *SoraTaskUpdateOne {
_u.mutation.ResetAccountID()
_u.mutation.SetAccountID(v)
return _u
}
// SetNillableAccountID sets the "account_id" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableAccountID(v *int64) *SoraTaskUpdateOne {
if v != nil {
_u.SetAccountID(*v)
}
return _u
}
// AddAccountID adds value to the "account_id" field.
func (_u *SoraTaskUpdateOne) AddAccountID(v int64) *SoraTaskUpdateOne {
_u.mutation.AddAccountID(v)
return _u
}
// SetModel sets the "model" field.
func (_u *SoraTaskUpdateOne) SetModel(v string) *SoraTaskUpdateOne {
_u.mutation.SetModel(v)
return _u
}
// SetNillableModel sets the "model" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableModel(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetModel(*v)
}
return _u
}
// SetPrompt sets the "prompt" field.
func (_u *SoraTaskUpdateOne) SetPrompt(v string) *SoraTaskUpdateOne {
_u.mutation.SetPrompt(v)
return _u
}
// SetNillablePrompt sets the "prompt" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillablePrompt(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetPrompt(*v)
}
return _u
}
// SetStatus sets the "status" field.
func (_u *SoraTaskUpdateOne) SetStatus(v string) *SoraTaskUpdateOne {
_u.mutation.SetStatus(v)
return _u
}
// SetNillableStatus sets the "status" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableStatus(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetStatus(*v)
}
return _u
}
// SetProgress sets the "progress" field.
func (_u *SoraTaskUpdateOne) SetProgress(v float64) *SoraTaskUpdateOne {
_u.mutation.ResetProgress()
_u.mutation.SetProgress(v)
return _u
}
// SetNillableProgress sets the "progress" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableProgress(v *float64) *SoraTaskUpdateOne {
if v != nil {
_u.SetProgress(*v)
}
return _u
}
// AddProgress adds value to the "progress" field.
func (_u *SoraTaskUpdateOne) AddProgress(v float64) *SoraTaskUpdateOne {
_u.mutation.AddProgress(v)
return _u
}
// SetResultUrls sets the "result_urls" field.
func (_u *SoraTaskUpdateOne) SetResultUrls(v string) *SoraTaskUpdateOne {
_u.mutation.SetResultUrls(v)
return _u
}
// SetNillableResultUrls sets the "result_urls" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableResultUrls(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetResultUrls(*v)
}
return _u
}
// ClearResultUrls clears the value of the "result_urls" field.
func (_u *SoraTaskUpdateOne) ClearResultUrls() *SoraTaskUpdateOne {
_u.mutation.ClearResultUrls()
return _u
}
// SetErrorMessage sets the "error_message" field.
func (_u *SoraTaskUpdateOne) SetErrorMessage(v string) *SoraTaskUpdateOne {
_u.mutation.SetErrorMessage(v)
return _u
}
// SetNillableErrorMessage sets the "error_message" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableErrorMessage(v *string) *SoraTaskUpdateOne {
if v != nil {
_u.SetErrorMessage(*v)
}
return _u
}
// ClearErrorMessage clears the value of the "error_message" field.
func (_u *SoraTaskUpdateOne) ClearErrorMessage() *SoraTaskUpdateOne {
_u.mutation.ClearErrorMessage()
return _u
}
// SetRetryCount sets the "retry_count" field.
func (_u *SoraTaskUpdateOne) SetRetryCount(v int) *SoraTaskUpdateOne {
_u.mutation.ResetRetryCount()
_u.mutation.SetRetryCount(v)
return _u
}
// SetNillableRetryCount sets the "retry_count" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableRetryCount(v *int) *SoraTaskUpdateOne {
if v != nil {
_u.SetRetryCount(*v)
}
return _u
}
// AddRetryCount adds value to the "retry_count" field.
func (_u *SoraTaskUpdateOne) AddRetryCount(v int) *SoraTaskUpdateOne {
_u.mutation.AddRetryCount(v)
return _u
}
// SetCreatedAt sets the "created_at" field.
func (_u *SoraTaskUpdateOne) SetCreatedAt(v time.Time) *SoraTaskUpdateOne {
_u.mutation.SetCreatedAt(v)
return _u
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableCreatedAt(v *time.Time) *SoraTaskUpdateOne {
if v != nil {
_u.SetCreatedAt(*v)
}
return _u
}
// SetCompletedAt sets the "completed_at" field.
func (_u *SoraTaskUpdateOne) SetCompletedAt(v time.Time) *SoraTaskUpdateOne {
_u.mutation.SetCompletedAt(v)
return _u
}
// SetNillableCompletedAt sets the "completed_at" field if the given value is not nil.
func (_u *SoraTaskUpdateOne) SetNillableCompletedAt(v *time.Time) *SoraTaskUpdateOne {
if v != nil {
_u.SetCompletedAt(*v)
}
return _u
}
// ClearCompletedAt clears the value of the "completed_at" field.
func (_u *SoraTaskUpdateOne) ClearCompletedAt() *SoraTaskUpdateOne {
_u.mutation.ClearCompletedAt()
return _u
}
// Mutation returns the SoraTaskMutation object of the builder.
func (_u *SoraTaskUpdateOne) Mutation() *SoraTaskMutation {
return _u.mutation
}
// Where appends a list predicates to the SoraTaskUpdate builder.
func (_u *SoraTaskUpdateOne) Where(ps ...predicate.SoraTask) *SoraTaskUpdateOne {
_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 *SoraTaskUpdateOne) Select(field string, fields ...string) *SoraTaskUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated SoraTask entity.
func (_u *SoraTaskUpdateOne) Save(ctx context.Context) (*SoraTask, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *SoraTaskUpdateOne) SaveX(ctx context.Context) *SoraTask {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *SoraTaskUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *SoraTaskUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *SoraTaskUpdateOne) check() error {
if v, ok := _u.mutation.TaskID(); ok {
if err := soratask.TaskIDValidator(v); err != nil {
return &ValidationError{Name: "task_id", err: fmt.Errorf(`ent: validator failed for field "SoraTask.task_id": %w`, err)}
}
}
if v, ok := _u.mutation.Model(); ok {
if err := soratask.ModelValidator(v); err != nil {
return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "SoraTask.model": %w`, err)}
}
}
if v, ok := _u.mutation.Status(); ok {
if err := soratask.StatusValidator(v); err != nil {
return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "SoraTask.status": %w`, err)}
}
}
return nil
}
func (_u *SoraTaskUpdateOne) sqlSave(ctx context.Context) (_node *SoraTask, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(soratask.Table, soratask.Columns, sqlgraph.NewFieldSpec(soratask.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SoraTask.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, soratask.FieldID)
for _, f := range fields {
if !soratask.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != soratask.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.TaskID(); ok {
_spec.SetField(soratask.FieldTaskID, field.TypeString, value)
}
if value, ok := _u.mutation.AccountID(); ok {
_spec.SetField(soratask.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.AddedAccountID(); ok {
_spec.AddField(soratask.FieldAccountID, field.TypeInt64, value)
}
if value, ok := _u.mutation.Model(); ok {
_spec.SetField(soratask.FieldModel, field.TypeString, value)
}
if value, ok := _u.mutation.Prompt(); ok {
_spec.SetField(soratask.FieldPrompt, field.TypeString, value)
}
if value, ok := _u.mutation.Status(); ok {
_spec.SetField(soratask.FieldStatus, field.TypeString, value)
}
if value, ok := _u.mutation.Progress(); ok {
_spec.SetField(soratask.FieldProgress, field.TypeFloat64, value)
}
if value, ok := _u.mutation.AddedProgress(); ok {
_spec.AddField(soratask.FieldProgress, field.TypeFloat64, value)
}
if value, ok := _u.mutation.ResultUrls(); ok {
_spec.SetField(soratask.FieldResultUrls, field.TypeString, value)
}
if _u.mutation.ResultUrlsCleared() {
_spec.ClearField(soratask.FieldResultUrls, field.TypeString)
}
if value, ok := _u.mutation.ErrorMessage(); ok {
_spec.SetField(soratask.FieldErrorMessage, field.TypeString, value)
}
if _u.mutation.ErrorMessageCleared() {
_spec.ClearField(soratask.FieldErrorMessage, field.TypeString)
}
if value, ok := _u.mutation.RetryCount(); ok {
_spec.SetField(soratask.FieldRetryCount, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedRetryCount(); ok {
_spec.AddField(soratask.FieldRetryCount, field.TypeInt, value)
}
if value, ok := _u.mutation.CreatedAt(); ok {
_spec.SetField(soratask.FieldCreatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.CompletedAt(); ok {
_spec.SetField(soratask.FieldCompletedAt, field.TypeTime, value)
}
if _u.mutation.CompletedAtCleared() {
_spec.ClearField(soratask.FieldCompletedAt, field.TypeTime)
}
_node = &SoraTask{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{soratask.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/sorausagestat"
)
// SoraUsageStat is the model entity for the SoraUsageStat schema.
type SoraUsageStat struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// 关联 accounts 表的 ID
AccountID int64 `json:"account_id,omitempty"`
// ImageCount holds the value of the "image_count" field.
ImageCount int `json:"image_count,omitempty"`
// VideoCount holds the value of the "video_count" field.
VideoCount int `json:"video_count,omitempty"`
// ErrorCount holds the value of the "error_count" field.
ErrorCount int `json:"error_count,omitempty"`
// LastErrorAt holds the value of the "last_error_at" field.
LastErrorAt *time.Time `json:"last_error_at,omitempty"`
// TodayImageCount holds the value of the "today_image_count" field.
TodayImageCount int `json:"today_image_count,omitempty"`
// TodayVideoCount holds the value of the "today_video_count" field.
TodayVideoCount int `json:"today_video_count,omitempty"`
// TodayErrorCount holds the value of the "today_error_count" field.
TodayErrorCount int `json:"today_error_count,omitempty"`
// TodayDate holds the value of the "today_date" field.
TodayDate *time.Time `json:"today_date,omitempty"`
// ConsecutiveErrorCount holds the value of the "consecutive_error_count" field.
ConsecutiveErrorCount int `json:"consecutive_error_count,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*SoraUsageStat) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case sorausagestat.FieldID, sorausagestat.FieldAccountID, sorausagestat.FieldImageCount, sorausagestat.FieldVideoCount, sorausagestat.FieldErrorCount, sorausagestat.FieldTodayImageCount, sorausagestat.FieldTodayVideoCount, sorausagestat.FieldTodayErrorCount, sorausagestat.FieldConsecutiveErrorCount:
values[i] = new(sql.NullInt64)
case sorausagestat.FieldCreatedAt, sorausagestat.FieldUpdatedAt, sorausagestat.FieldLastErrorAt, sorausagestat.FieldTodayDate:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the SoraUsageStat fields.
func (_m *SoraUsageStat) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case sorausagestat.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case sorausagestat.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case sorausagestat.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case sorausagestat.FieldAccountID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field account_id", values[i])
} else if value.Valid {
_m.AccountID = value.Int64
}
case sorausagestat.FieldImageCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field image_count", values[i])
} else if value.Valid {
_m.ImageCount = int(value.Int64)
}
case sorausagestat.FieldVideoCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field video_count", values[i])
} else if value.Valid {
_m.VideoCount = int(value.Int64)
}
case sorausagestat.FieldErrorCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field error_count", values[i])
} else if value.Valid {
_m.ErrorCount = int(value.Int64)
}
case sorausagestat.FieldLastErrorAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field last_error_at", values[i])
} else if value.Valid {
_m.LastErrorAt = new(time.Time)
*_m.LastErrorAt = value.Time
}
case sorausagestat.FieldTodayImageCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field today_image_count", values[i])
} else if value.Valid {
_m.TodayImageCount = int(value.Int64)
}
case sorausagestat.FieldTodayVideoCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field today_video_count", values[i])
} else if value.Valid {
_m.TodayVideoCount = int(value.Int64)
}
case sorausagestat.FieldTodayErrorCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field today_error_count", values[i])
} else if value.Valid {
_m.TodayErrorCount = int(value.Int64)
}
case sorausagestat.FieldTodayDate:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field today_date", values[i])
} else if value.Valid {
_m.TodayDate = new(time.Time)
*_m.TodayDate = value.Time
}
case sorausagestat.FieldConsecutiveErrorCount:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field consecutive_error_count", values[i])
} else if value.Valid {
_m.ConsecutiveErrorCount = int(value.Int64)
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the SoraUsageStat.
// This includes values selected through modifiers, order, etc.
func (_m *SoraUsageStat) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this SoraUsageStat.
// Note that you need to call SoraUsageStat.Unwrap() before calling this method if this SoraUsageStat
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *SoraUsageStat) Update() *SoraUsageStatUpdateOne {
return NewSoraUsageStatClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the SoraUsageStat entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *SoraUsageStat) Unwrap() *SoraUsageStat {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: SoraUsageStat is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *SoraUsageStat) String() string {
var builder strings.Builder
builder.WriteString("SoraUsageStat(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("account_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AccountID))
builder.WriteString(", ")
builder.WriteString("image_count=")
builder.WriteString(fmt.Sprintf("%v", _m.ImageCount))
builder.WriteString(", ")
builder.WriteString("video_count=")
builder.WriteString(fmt.Sprintf("%v", _m.VideoCount))
builder.WriteString(", ")
builder.WriteString("error_count=")
builder.WriteString(fmt.Sprintf("%v", _m.ErrorCount))
builder.WriteString(", ")
if v := _m.LastErrorAt; v != nil {
builder.WriteString("last_error_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
builder.WriteString("today_image_count=")
builder.WriteString(fmt.Sprintf("%v", _m.TodayImageCount))
builder.WriteString(", ")
builder.WriteString("today_video_count=")
builder.WriteString(fmt.Sprintf("%v", _m.TodayVideoCount))
builder.WriteString(", ")
builder.WriteString("today_error_count=")
builder.WriteString(fmt.Sprintf("%v", _m.TodayErrorCount))
builder.WriteString(", ")
if v := _m.TodayDate; v != nil {
builder.WriteString("today_date=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
builder.WriteString("consecutive_error_count=")
builder.WriteString(fmt.Sprintf("%v", _m.ConsecutiveErrorCount))
builder.WriteByte(')')
return builder.String()
}
// SoraUsageStats is a parsable slice of SoraUsageStat.
type SoraUsageStats []*SoraUsageStat
// Code generated by ent, DO NOT EDIT.
package sorausagestat
import (
"time"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the sorausagestat type in the database.
Label = "sora_usage_stat"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt = "updated_at"
// FieldAccountID holds the string denoting the account_id field in the database.
FieldAccountID = "account_id"
// FieldImageCount holds the string denoting the image_count field in the database.
FieldImageCount = "image_count"
// FieldVideoCount holds the string denoting the video_count field in the database.
FieldVideoCount = "video_count"
// FieldErrorCount holds the string denoting the error_count field in the database.
FieldErrorCount = "error_count"
// FieldLastErrorAt holds the string denoting the last_error_at field in the database.
FieldLastErrorAt = "last_error_at"
// FieldTodayImageCount holds the string denoting the today_image_count field in the database.
FieldTodayImageCount = "today_image_count"
// FieldTodayVideoCount holds the string denoting the today_video_count field in the database.
FieldTodayVideoCount = "today_video_count"
// FieldTodayErrorCount holds the string denoting the today_error_count field in the database.
FieldTodayErrorCount = "today_error_count"
// FieldTodayDate holds the string denoting the today_date field in the database.
FieldTodayDate = "today_date"
// FieldConsecutiveErrorCount holds the string denoting the consecutive_error_count field in the database.
FieldConsecutiveErrorCount = "consecutive_error_count"
// Table holds the table name of the sorausagestat in the database.
Table = "sora_usage_stats"
)
// Columns holds all SQL columns for sorausagestat fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldAccountID,
FieldImageCount,
FieldVideoCount,
FieldErrorCount,
FieldLastErrorAt,
FieldTodayImageCount,
FieldTodayVideoCount,
FieldTodayErrorCount,
FieldTodayDate,
FieldConsecutiveErrorCount,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultImageCount holds the default value on creation for the "image_count" field.
DefaultImageCount int
// DefaultVideoCount holds the default value on creation for the "video_count" field.
DefaultVideoCount int
// DefaultErrorCount holds the default value on creation for the "error_count" field.
DefaultErrorCount int
// DefaultTodayImageCount holds the default value on creation for the "today_image_count" field.
DefaultTodayImageCount int
// DefaultTodayVideoCount holds the default value on creation for the "today_video_count" field.
DefaultTodayVideoCount int
// DefaultTodayErrorCount holds the default value on creation for the "today_error_count" field.
DefaultTodayErrorCount int
// DefaultConsecutiveErrorCount holds the default value on creation for the "consecutive_error_count" field.
DefaultConsecutiveErrorCount int
)
// OrderOption defines the ordering options for the SoraUsageStat queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}
// ByAccountID orders the results by the account_id field.
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
}
// ByImageCount orders the results by the image_count field.
func ByImageCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldImageCount, opts...).ToFunc()
}
// ByVideoCount orders the results by the video_count field.
func ByVideoCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVideoCount, opts...).ToFunc()
}
// ByErrorCount orders the results by the error_count field.
func ByErrorCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldErrorCount, opts...).ToFunc()
}
// ByLastErrorAt orders the results by the last_error_at field.
func ByLastErrorAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldLastErrorAt, opts...).ToFunc()
}
// ByTodayImageCount orders the results by the today_image_count field.
func ByTodayImageCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTodayImageCount, opts...).ToFunc()
}
// ByTodayVideoCount orders the results by the today_video_count field.
func ByTodayVideoCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTodayVideoCount, opts...).ToFunc()
}
// ByTodayErrorCount orders the results by the today_error_count field.
func ByTodayErrorCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTodayErrorCount, opts...).ToFunc()
}
// ByTodayDate orders the results by the today_date field.
func ByTodayDate(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTodayDate, opts...).ToFunc()
}
// ByConsecutiveErrorCount orders the results by the consecutive_error_count field.
func ByConsecutiveErrorCount(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldConsecutiveErrorCount, opts...).ToFunc()
}
// Code generated by ent, DO NOT EDIT.
package sorausagestat
import (
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldCreatedAt, v))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func UpdatedAt(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldUpdatedAt, v))
}
// AccountID applies equality check predicate on the "account_id" field. It's identical to AccountIDEQ.
func AccountID(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldAccountID, v))
}
// ImageCount applies equality check predicate on the "image_count" field. It's identical to ImageCountEQ.
func ImageCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldImageCount, v))
}
// VideoCount applies equality check predicate on the "video_count" field. It's identical to VideoCountEQ.
func VideoCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldVideoCount, v))
}
// ErrorCount applies equality check predicate on the "error_count" field. It's identical to ErrorCountEQ.
func ErrorCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldErrorCount, v))
}
// LastErrorAt applies equality check predicate on the "last_error_at" field. It's identical to LastErrorAtEQ.
func LastErrorAt(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldLastErrorAt, v))
}
// TodayImageCount applies equality check predicate on the "today_image_count" field. It's identical to TodayImageCountEQ.
func TodayImageCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayImageCount, v))
}
// TodayVideoCount applies equality check predicate on the "today_video_count" field. It's identical to TodayVideoCountEQ.
func TodayVideoCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayVideoCount, v))
}
// TodayErrorCount applies equality check predicate on the "today_error_count" field. It's identical to TodayErrorCountEQ.
func TodayErrorCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayErrorCount, v))
}
// TodayDate applies equality check predicate on the "today_date" field. It's identical to TodayDateEQ.
func TodayDate(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayDate, v))
}
// ConsecutiveErrorCount applies equality check predicate on the "consecutive_error_count" field. It's identical to ConsecutiveErrorCountEQ.
func ConsecutiveErrorCount(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldConsecutiveErrorCount, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldUpdatedAt, v))
}
// AccountIDEQ applies the EQ predicate on the "account_id" field.
func AccountIDEQ(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldAccountID, v))
}
// AccountIDNEQ applies the NEQ predicate on the "account_id" field.
func AccountIDNEQ(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldAccountID, v))
}
// AccountIDIn applies the In predicate on the "account_id" field.
func AccountIDIn(vs ...int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldAccountID, vs...))
}
// AccountIDNotIn applies the NotIn predicate on the "account_id" field.
func AccountIDNotIn(vs ...int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldAccountID, vs...))
}
// AccountIDGT applies the GT predicate on the "account_id" field.
func AccountIDGT(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldAccountID, v))
}
// AccountIDGTE applies the GTE predicate on the "account_id" field.
func AccountIDGTE(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldAccountID, v))
}
// AccountIDLT applies the LT predicate on the "account_id" field.
func AccountIDLT(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldAccountID, v))
}
// AccountIDLTE applies the LTE predicate on the "account_id" field.
func AccountIDLTE(v int64) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldAccountID, v))
}
// ImageCountEQ applies the EQ predicate on the "image_count" field.
func ImageCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldImageCount, v))
}
// ImageCountNEQ applies the NEQ predicate on the "image_count" field.
func ImageCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldImageCount, v))
}
// ImageCountIn applies the In predicate on the "image_count" field.
func ImageCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldImageCount, vs...))
}
// ImageCountNotIn applies the NotIn predicate on the "image_count" field.
func ImageCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldImageCount, vs...))
}
// ImageCountGT applies the GT predicate on the "image_count" field.
func ImageCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldImageCount, v))
}
// ImageCountGTE applies the GTE predicate on the "image_count" field.
func ImageCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldImageCount, v))
}
// ImageCountLT applies the LT predicate on the "image_count" field.
func ImageCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldImageCount, v))
}
// ImageCountLTE applies the LTE predicate on the "image_count" field.
func ImageCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldImageCount, v))
}
// VideoCountEQ applies the EQ predicate on the "video_count" field.
func VideoCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldVideoCount, v))
}
// VideoCountNEQ applies the NEQ predicate on the "video_count" field.
func VideoCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldVideoCount, v))
}
// VideoCountIn applies the In predicate on the "video_count" field.
func VideoCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldVideoCount, vs...))
}
// VideoCountNotIn applies the NotIn predicate on the "video_count" field.
func VideoCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldVideoCount, vs...))
}
// VideoCountGT applies the GT predicate on the "video_count" field.
func VideoCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldVideoCount, v))
}
// VideoCountGTE applies the GTE predicate on the "video_count" field.
func VideoCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldVideoCount, v))
}
// VideoCountLT applies the LT predicate on the "video_count" field.
func VideoCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldVideoCount, v))
}
// VideoCountLTE applies the LTE predicate on the "video_count" field.
func VideoCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldVideoCount, v))
}
// ErrorCountEQ applies the EQ predicate on the "error_count" field.
func ErrorCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldErrorCount, v))
}
// ErrorCountNEQ applies the NEQ predicate on the "error_count" field.
func ErrorCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldErrorCount, v))
}
// ErrorCountIn applies the In predicate on the "error_count" field.
func ErrorCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldErrorCount, vs...))
}
// ErrorCountNotIn applies the NotIn predicate on the "error_count" field.
func ErrorCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldErrorCount, vs...))
}
// ErrorCountGT applies the GT predicate on the "error_count" field.
func ErrorCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldErrorCount, v))
}
// ErrorCountGTE applies the GTE predicate on the "error_count" field.
func ErrorCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldErrorCount, v))
}
// ErrorCountLT applies the LT predicate on the "error_count" field.
func ErrorCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldErrorCount, v))
}
// ErrorCountLTE applies the LTE predicate on the "error_count" field.
func ErrorCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldErrorCount, v))
}
// LastErrorAtEQ applies the EQ predicate on the "last_error_at" field.
func LastErrorAtEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldLastErrorAt, v))
}
// LastErrorAtNEQ applies the NEQ predicate on the "last_error_at" field.
func LastErrorAtNEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldLastErrorAt, v))
}
// LastErrorAtIn applies the In predicate on the "last_error_at" field.
func LastErrorAtIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldLastErrorAt, vs...))
}
// LastErrorAtNotIn applies the NotIn predicate on the "last_error_at" field.
func LastErrorAtNotIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldLastErrorAt, vs...))
}
// LastErrorAtGT applies the GT predicate on the "last_error_at" field.
func LastErrorAtGT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldLastErrorAt, v))
}
// LastErrorAtGTE applies the GTE predicate on the "last_error_at" field.
func LastErrorAtGTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldLastErrorAt, v))
}
// LastErrorAtLT applies the LT predicate on the "last_error_at" field.
func LastErrorAtLT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldLastErrorAt, v))
}
// LastErrorAtLTE applies the LTE predicate on the "last_error_at" field.
func LastErrorAtLTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldLastErrorAt, v))
}
// LastErrorAtIsNil applies the IsNil predicate on the "last_error_at" field.
func LastErrorAtIsNil() predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIsNull(FieldLastErrorAt))
}
// LastErrorAtNotNil applies the NotNil predicate on the "last_error_at" field.
func LastErrorAtNotNil() predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotNull(FieldLastErrorAt))
}
// TodayImageCountEQ applies the EQ predicate on the "today_image_count" field.
func TodayImageCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayImageCount, v))
}
// TodayImageCountNEQ applies the NEQ predicate on the "today_image_count" field.
func TodayImageCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldTodayImageCount, v))
}
// TodayImageCountIn applies the In predicate on the "today_image_count" field.
func TodayImageCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldTodayImageCount, vs...))
}
// TodayImageCountNotIn applies the NotIn predicate on the "today_image_count" field.
func TodayImageCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldTodayImageCount, vs...))
}
// TodayImageCountGT applies the GT predicate on the "today_image_count" field.
func TodayImageCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldTodayImageCount, v))
}
// TodayImageCountGTE applies the GTE predicate on the "today_image_count" field.
func TodayImageCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldTodayImageCount, v))
}
// TodayImageCountLT applies the LT predicate on the "today_image_count" field.
func TodayImageCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldTodayImageCount, v))
}
// TodayImageCountLTE applies the LTE predicate on the "today_image_count" field.
func TodayImageCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldTodayImageCount, v))
}
// TodayVideoCountEQ applies the EQ predicate on the "today_video_count" field.
func TodayVideoCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayVideoCount, v))
}
// TodayVideoCountNEQ applies the NEQ predicate on the "today_video_count" field.
func TodayVideoCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldTodayVideoCount, v))
}
// TodayVideoCountIn applies the In predicate on the "today_video_count" field.
func TodayVideoCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldTodayVideoCount, vs...))
}
// TodayVideoCountNotIn applies the NotIn predicate on the "today_video_count" field.
func TodayVideoCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldTodayVideoCount, vs...))
}
// TodayVideoCountGT applies the GT predicate on the "today_video_count" field.
func TodayVideoCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldTodayVideoCount, v))
}
// TodayVideoCountGTE applies the GTE predicate on the "today_video_count" field.
func TodayVideoCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldTodayVideoCount, v))
}
// TodayVideoCountLT applies the LT predicate on the "today_video_count" field.
func TodayVideoCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldTodayVideoCount, v))
}
// TodayVideoCountLTE applies the LTE predicate on the "today_video_count" field.
func TodayVideoCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldTodayVideoCount, v))
}
// TodayErrorCountEQ applies the EQ predicate on the "today_error_count" field.
func TodayErrorCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayErrorCount, v))
}
// TodayErrorCountNEQ applies the NEQ predicate on the "today_error_count" field.
func TodayErrorCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldTodayErrorCount, v))
}
// TodayErrorCountIn applies the In predicate on the "today_error_count" field.
func TodayErrorCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldTodayErrorCount, vs...))
}
// TodayErrorCountNotIn applies the NotIn predicate on the "today_error_count" field.
func TodayErrorCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldTodayErrorCount, vs...))
}
// TodayErrorCountGT applies the GT predicate on the "today_error_count" field.
func TodayErrorCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldTodayErrorCount, v))
}
// TodayErrorCountGTE applies the GTE predicate on the "today_error_count" field.
func TodayErrorCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldTodayErrorCount, v))
}
// TodayErrorCountLT applies the LT predicate on the "today_error_count" field.
func TodayErrorCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldTodayErrorCount, v))
}
// TodayErrorCountLTE applies the LTE predicate on the "today_error_count" field.
func TodayErrorCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldTodayErrorCount, v))
}
// TodayDateEQ applies the EQ predicate on the "today_date" field.
func TodayDateEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldTodayDate, v))
}
// TodayDateNEQ applies the NEQ predicate on the "today_date" field.
func TodayDateNEQ(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldTodayDate, v))
}
// TodayDateIn applies the In predicate on the "today_date" field.
func TodayDateIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldTodayDate, vs...))
}
// TodayDateNotIn applies the NotIn predicate on the "today_date" field.
func TodayDateNotIn(vs ...time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldTodayDate, vs...))
}
// TodayDateGT applies the GT predicate on the "today_date" field.
func TodayDateGT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldTodayDate, v))
}
// TodayDateGTE applies the GTE predicate on the "today_date" field.
func TodayDateGTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldTodayDate, v))
}
// TodayDateLT applies the LT predicate on the "today_date" field.
func TodayDateLT(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldTodayDate, v))
}
// TodayDateLTE applies the LTE predicate on the "today_date" field.
func TodayDateLTE(v time.Time) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldTodayDate, v))
}
// TodayDateIsNil applies the IsNil predicate on the "today_date" field.
func TodayDateIsNil() predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIsNull(FieldTodayDate))
}
// TodayDateNotNil applies the NotNil predicate on the "today_date" field.
func TodayDateNotNil() predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotNull(FieldTodayDate))
}
// ConsecutiveErrorCountEQ applies the EQ predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldEQ(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountNEQ applies the NEQ predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountNEQ(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNEQ(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountIn applies the In predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldIn(FieldConsecutiveErrorCount, vs...))
}
// ConsecutiveErrorCountNotIn applies the NotIn predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountNotIn(vs ...int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldNotIn(FieldConsecutiveErrorCount, vs...))
}
// ConsecutiveErrorCountGT applies the GT predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountGT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGT(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountGTE applies the GTE predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountGTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldGTE(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountLT applies the LT predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountLT(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLT(FieldConsecutiveErrorCount, v))
}
// ConsecutiveErrorCountLTE applies the LTE predicate on the "consecutive_error_count" field.
func ConsecutiveErrorCountLTE(v int) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.FieldLTE(FieldConsecutiveErrorCount, v))
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.SoraUsageStat) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.SoraUsageStat) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.SoraUsageStat) predicate.SoraUsageStat {
return predicate.SoraUsageStat(sql.NotPredicates(p))
}
// 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/Wei-Shaw/sub2api/ent/sorausagestat"
)
// SoraUsageStatCreate is the builder for creating a SoraUsageStat entity.
type SoraUsageStatCreate struct {
config
mutation *SoraUsageStatMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (_c *SoraUsageStatCreate) SetCreatedAt(v time.Time) *SoraUsageStatCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableCreatedAt(v *time.Time) *SoraUsageStatCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *SoraUsageStatCreate) SetUpdatedAt(v time.Time) *SoraUsageStatCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableUpdatedAt(v *time.Time) *SoraUsageStatCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
return _c
}
// SetAccountID sets the "account_id" field.
func (_c *SoraUsageStatCreate) SetAccountID(v int64) *SoraUsageStatCreate {
_c.mutation.SetAccountID(v)
return _c
}
// SetImageCount sets the "image_count" field.
func (_c *SoraUsageStatCreate) SetImageCount(v int) *SoraUsageStatCreate {
_c.mutation.SetImageCount(v)
return _c
}
// SetNillableImageCount sets the "image_count" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableImageCount(v *int) *SoraUsageStatCreate {
if v != nil {
_c.SetImageCount(*v)
}
return _c
}
// SetVideoCount sets the "video_count" field.
func (_c *SoraUsageStatCreate) SetVideoCount(v int) *SoraUsageStatCreate {
_c.mutation.SetVideoCount(v)
return _c
}
// SetNillableVideoCount sets the "video_count" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableVideoCount(v *int) *SoraUsageStatCreate {
if v != nil {
_c.SetVideoCount(*v)
}
return _c
}
// SetErrorCount sets the "error_count" field.
func (_c *SoraUsageStatCreate) SetErrorCount(v int) *SoraUsageStatCreate {
_c.mutation.SetErrorCount(v)
return _c
}
// SetNillableErrorCount sets the "error_count" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableErrorCount(v *int) *SoraUsageStatCreate {
if v != nil {
_c.SetErrorCount(*v)
}
return _c
}
// SetLastErrorAt sets the "last_error_at" field.
func (_c *SoraUsageStatCreate) SetLastErrorAt(v time.Time) *SoraUsageStatCreate {
_c.mutation.SetLastErrorAt(v)
return _c
}
// SetNillableLastErrorAt sets the "last_error_at" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableLastErrorAt(v *time.Time) *SoraUsageStatCreate {
if v != nil {
_c.SetLastErrorAt(*v)
}
return _c
}
// SetTodayImageCount sets the "today_image_count" field.
func (_c *SoraUsageStatCreate) SetTodayImageCount(v int) *SoraUsageStatCreate {
_c.mutation.SetTodayImageCount(v)
return _c
}
// SetNillableTodayImageCount sets the "today_image_count" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableTodayImageCount(v *int) *SoraUsageStatCreate {
if v != nil {
_c.SetTodayImageCount(*v)
}
return _c
}
// SetTodayVideoCount sets the "today_video_count" field.
func (_c *SoraUsageStatCreate) SetTodayVideoCount(v int) *SoraUsageStatCreate {
_c.mutation.SetTodayVideoCount(v)
return _c
}
// SetNillableTodayVideoCount sets the "today_video_count" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableTodayVideoCount(v *int) *SoraUsageStatCreate {
if v != nil {
_c.SetTodayVideoCount(*v)
}
return _c
}
// SetTodayErrorCount sets the "today_error_count" field.
func (_c *SoraUsageStatCreate) SetTodayErrorCount(v int) *SoraUsageStatCreate {
_c.mutation.SetTodayErrorCount(v)
return _c
}
// SetNillableTodayErrorCount sets the "today_error_count" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableTodayErrorCount(v *int) *SoraUsageStatCreate {
if v != nil {
_c.SetTodayErrorCount(*v)
}
return _c
}
// SetTodayDate sets the "today_date" field.
func (_c *SoraUsageStatCreate) SetTodayDate(v time.Time) *SoraUsageStatCreate {
_c.mutation.SetTodayDate(v)
return _c
}
// SetNillableTodayDate sets the "today_date" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableTodayDate(v *time.Time) *SoraUsageStatCreate {
if v != nil {
_c.SetTodayDate(*v)
}
return _c
}
// SetConsecutiveErrorCount sets the "consecutive_error_count" field.
func (_c *SoraUsageStatCreate) SetConsecutiveErrorCount(v int) *SoraUsageStatCreate {
_c.mutation.SetConsecutiveErrorCount(v)
return _c
}
// SetNillableConsecutiveErrorCount sets the "consecutive_error_count" field if the given value is not nil.
func (_c *SoraUsageStatCreate) SetNillableConsecutiveErrorCount(v *int) *SoraUsageStatCreate {
if v != nil {
_c.SetConsecutiveErrorCount(*v)
}
return _c
}
// Mutation returns the SoraUsageStatMutation object of the builder.
func (_c *SoraUsageStatCreate) Mutation() *SoraUsageStatMutation {
return _c.mutation
}
// Save creates the SoraUsageStat in the database.
func (_c *SoraUsageStatCreate) Save(ctx context.Context) (*SoraUsageStat, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *SoraUsageStatCreate) SaveX(ctx context.Context) *SoraUsageStat {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SoraUsageStatCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SoraUsageStatCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *SoraUsageStatCreate) defaults() {
if _, ok := _c.mutation.CreatedAt(); !ok {
v := sorausagestat.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := sorausagestat.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.ImageCount(); !ok {
v := sorausagestat.DefaultImageCount
_c.mutation.SetImageCount(v)
}
if _, ok := _c.mutation.VideoCount(); !ok {
v := sorausagestat.DefaultVideoCount
_c.mutation.SetVideoCount(v)
}
if _, ok := _c.mutation.ErrorCount(); !ok {
v := sorausagestat.DefaultErrorCount
_c.mutation.SetErrorCount(v)
}
if _, ok := _c.mutation.TodayImageCount(); !ok {
v := sorausagestat.DefaultTodayImageCount
_c.mutation.SetTodayImageCount(v)
}
if _, ok := _c.mutation.TodayVideoCount(); !ok {
v := sorausagestat.DefaultTodayVideoCount
_c.mutation.SetTodayVideoCount(v)
}
if _, ok := _c.mutation.TodayErrorCount(); !ok {
v := sorausagestat.DefaultTodayErrorCount
_c.mutation.SetTodayErrorCount(v)
}
if _, ok := _c.mutation.ConsecutiveErrorCount(); !ok {
v := sorausagestat.DefaultConsecutiveErrorCount
_c.mutation.SetConsecutiveErrorCount(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *SoraUsageStatCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "SoraUsageStat.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "SoraUsageStat.updated_at"`)}
}
if _, ok := _c.mutation.AccountID(); !ok {
return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "SoraUsageStat.account_id"`)}
}
if _, ok := _c.mutation.ImageCount(); !ok {
return &ValidationError{Name: "image_count", err: errors.New(`ent: missing required field "SoraUsageStat.image_count"`)}
}
if _, ok := _c.mutation.VideoCount(); !ok {
return &ValidationError{Name: "video_count", err: errors.New(`ent: missing required field "SoraUsageStat.video_count"`)}
}
if _, ok := _c.mutation.ErrorCount(); !ok {
return &ValidationError{Name: "error_count", err: errors.New(`ent: missing required field "SoraUsageStat.error_count"`)}
}
if _, ok := _c.mutation.TodayImageCount(); !ok {
return &ValidationError{Name: "today_image_count", err: errors.New(`ent: missing required field "SoraUsageStat.today_image_count"`)}
}
if _, ok := _c.mutation.TodayVideoCount(); !ok {
return &ValidationError{Name: "today_video_count", err: errors.New(`ent: missing required field "SoraUsageStat.today_video_count"`)}
}
if _, ok := _c.mutation.TodayErrorCount(); !ok {
return &ValidationError{Name: "today_error_count", err: errors.New(`ent: missing required field "SoraUsageStat.today_error_count"`)}
}
if _, ok := _c.mutation.ConsecutiveErrorCount(); !ok {
return &ValidationError{Name: "consecutive_error_count", err: errors.New(`ent: missing required field "SoraUsageStat.consecutive_error_count"`)}
}
return nil
}
func (_c *SoraUsageStatCreate) sqlSave(ctx context.Context) (*SoraUsageStat, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *SoraUsageStatCreate) createSpec() (*SoraUsageStat, *sqlgraph.CreateSpec) {
var (
_node = &SoraUsageStat{config: _c.config}
_spec = sqlgraph.NewCreateSpec(sorausagestat.Table, sqlgraph.NewFieldSpec(sorausagestat.FieldID, field.TypeInt64))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(sorausagestat.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(sorausagestat.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.AccountID(); ok {
_spec.SetField(sorausagestat.FieldAccountID, field.TypeInt64, value)
_node.AccountID = value
}
if value, ok := _c.mutation.ImageCount(); ok {
_spec.SetField(sorausagestat.FieldImageCount, field.TypeInt, value)
_node.ImageCount = value
}
if value, ok := _c.mutation.VideoCount(); ok {
_spec.SetField(sorausagestat.FieldVideoCount, field.TypeInt, value)
_node.VideoCount = value
}
if value, ok := _c.mutation.ErrorCount(); ok {
_spec.SetField(sorausagestat.FieldErrorCount, field.TypeInt, value)
_node.ErrorCount = value
}
if value, ok := _c.mutation.LastErrorAt(); ok {
_spec.SetField(sorausagestat.FieldLastErrorAt, field.TypeTime, value)
_node.LastErrorAt = &value
}
if value, ok := _c.mutation.TodayImageCount(); ok {
_spec.SetField(sorausagestat.FieldTodayImageCount, field.TypeInt, value)
_node.TodayImageCount = value
}
if value, ok := _c.mutation.TodayVideoCount(); ok {
_spec.SetField(sorausagestat.FieldTodayVideoCount, field.TypeInt, value)
_node.TodayVideoCount = value
}
if value, ok := _c.mutation.TodayErrorCount(); ok {
_spec.SetField(sorausagestat.FieldTodayErrorCount, field.TypeInt, value)
_node.TodayErrorCount = value
}
if value, ok := _c.mutation.TodayDate(); ok {
_spec.SetField(sorausagestat.FieldTodayDate, field.TypeTime, value)
_node.TodayDate = &value
}
if value, ok := _c.mutation.ConsecutiveErrorCount(); ok {
_spec.SetField(sorausagestat.FieldConsecutiveErrorCount, field.TypeInt, value)
_node.ConsecutiveErrorCount = value
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SoraUsageStat.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.SoraUsageStatUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *SoraUsageStatCreate) OnConflict(opts ...sql.ConflictOption) *SoraUsageStatUpsertOne {
_c.conflict = opts
return &SoraUsageStatUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SoraUsageStat.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SoraUsageStatCreate) OnConflictColumns(columns ...string) *SoraUsageStatUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SoraUsageStatUpsertOne{
create: _c,
}
}
type (
// SoraUsageStatUpsertOne is the builder for "upsert"-ing
// one SoraUsageStat node.
SoraUsageStatUpsertOne struct {
create *SoraUsageStatCreate
}
// SoraUsageStatUpsert is the "OnConflict" setter.
SoraUsageStatUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *SoraUsageStatUpsert) SetUpdatedAt(v time.Time) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateUpdatedAt() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldUpdatedAt)
return u
}
// SetAccountID sets the "account_id" field.
func (u *SoraUsageStatUpsert) SetAccountID(v int64) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldAccountID, v)
return u
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateAccountID() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldAccountID)
return u
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraUsageStatUpsert) AddAccountID(v int64) *SoraUsageStatUpsert {
u.Add(sorausagestat.FieldAccountID, v)
return u
}
// SetImageCount sets the "image_count" field.
func (u *SoraUsageStatUpsert) SetImageCount(v int) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldImageCount, v)
return u
}
// UpdateImageCount sets the "image_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateImageCount() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldImageCount)
return u
}
// AddImageCount adds v to the "image_count" field.
func (u *SoraUsageStatUpsert) AddImageCount(v int) *SoraUsageStatUpsert {
u.Add(sorausagestat.FieldImageCount, v)
return u
}
// SetVideoCount sets the "video_count" field.
func (u *SoraUsageStatUpsert) SetVideoCount(v int) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldVideoCount, v)
return u
}
// UpdateVideoCount sets the "video_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateVideoCount() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldVideoCount)
return u
}
// AddVideoCount adds v to the "video_count" field.
func (u *SoraUsageStatUpsert) AddVideoCount(v int) *SoraUsageStatUpsert {
u.Add(sorausagestat.FieldVideoCount, v)
return u
}
// SetErrorCount sets the "error_count" field.
func (u *SoraUsageStatUpsert) SetErrorCount(v int) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldErrorCount, v)
return u
}
// UpdateErrorCount sets the "error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateErrorCount() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldErrorCount)
return u
}
// AddErrorCount adds v to the "error_count" field.
func (u *SoraUsageStatUpsert) AddErrorCount(v int) *SoraUsageStatUpsert {
u.Add(sorausagestat.FieldErrorCount, v)
return u
}
// SetLastErrorAt sets the "last_error_at" field.
func (u *SoraUsageStatUpsert) SetLastErrorAt(v time.Time) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldLastErrorAt, v)
return u
}
// UpdateLastErrorAt sets the "last_error_at" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateLastErrorAt() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldLastErrorAt)
return u
}
// ClearLastErrorAt clears the value of the "last_error_at" field.
func (u *SoraUsageStatUpsert) ClearLastErrorAt() *SoraUsageStatUpsert {
u.SetNull(sorausagestat.FieldLastErrorAt)
return u
}
// SetTodayImageCount sets the "today_image_count" field.
func (u *SoraUsageStatUpsert) SetTodayImageCount(v int) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldTodayImageCount, v)
return u
}
// UpdateTodayImageCount sets the "today_image_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateTodayImageCount() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldTodayImageCount)
return u
}
// AddTodayImageCount adds v to the "today_image_count" field.
func (u *SoraUsageStatUpsert) AddTodayImageCount(v int) *SoraUsageStatUpsert {
u.Add(sorausagestat.FieldTodayImageCount, v)
return u
}
// SetTodayVideoCount sets the "today_video_count" field.
func (u *SoraUsageStatUpsert) SetTodayVideoCount(v int) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldTodayVideoCount, v)
return u
}
// UpdateTodayVideoCount sets the "today_video_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateTodayVideoCount() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldTodayVideoCount)
return u
}
// AddTodayVideoCount adds v to the "today_video_count" field.
func (u *SoraUsageStatUpsert) AddTodayVideoCount(v int) *SoraUsageStatUpsert {
u.Add(sorausagestat.FieldTodayVideoCount, v)
return u
}
// SetTodayErrorCount sets the "today_error_count" field.
func (u *SoraUsageStatUpsert) SetTodayErrorCount(v int) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldTodayErrorCount, v)
return u
}
// UpdateTodayErrorCount sets the "today_error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateTodayErrorCount() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldTodayErrorCount)
return u
}
// AddTodayErrorCount adds v to the "today_error_count" field.
func (u *SoraUsageStatUpsert) AddTodayErrorCount(v int) *SoraUsageStatUpsert {
u.Add(sorausagestat.FieldTodayErrorCount, v)
return u
}
// SetTodayDate sets the "today_date" field.
func (u *SoraUsageStatUpsert) SetTodayDate(v time.Time) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldTodayDate, v)
return u
}
// UpdateTodayDate sets the "today_date" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateTodayDate() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldTodayDate)
return u
}
// ClearTodayDate clears the value of the "today_date" field.
func (u *SoraUsageStatUpsert) ClearTodayDate() *SoraUsageStatUpsert {
u.SetNull(sorausagestat.FieldTodayDate)
return u
}
// SetConsecutiveErrorCount sets the "consecutive_error_count" field.
func (u *SoraUsageStatUpsert) SetConsecutiveErrorCount(v int) *SoraUsageStatUpsert {
u.Set(sorausagestat.FieldConsecutiveErrorCount, v)
return u
}
// UpdateConsecutiveErrorCount sets the "consecutive_error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsert) UpdateConsecutiveErrorCount() *SoraUsageStatUpsert {
u.SetExcluded(sorausagestat.FieldConsecutiveErrorCount)
return u
}
// AddConsecutiveErrorCount adds v to the "consecutive_error_count" field.
func (u *SoraUsageStatUpsert) AddConsecutiveErrorCount(v int) *SoraUsageStatUpsert {
u.Add(sorausagestat.FieldConsecutiveErrorCount, v)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.SoraUsageStat.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SoraUsageStatUpsertOne) UpdateNewValues() *SoraUsageStatUpsertOne {
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(sorausagestat.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SoraUsageStat.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SoraUsageStatUpsertOne) Ignore() *SoraUsageStatUpsertOne {
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 *SoraUsageStatUpsertOne) DoNothing() *SoraUsageStatUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SoraUsageStatCreate.OnConflict
// documentation for more info.
func (u *SoraUsageStatUpsertOne) Update(set func(*SoraUsageStatUpsert)) *SoraUsageStatUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SoraUsageStatUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *SoraUsageStatUpsertOne) SetUpdatedAt(v time.Time) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateUpdatedAt() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateUpdatedAt()
})
}
// SetAccountID sets the "account_id" field.
func (u *SoraUsageStatUpsertOne) SetAccountID(v int64) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetAccountID(v)
})
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraUsageStatUpsertOne) AddAccountID(v int64) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddAccountID(v)
})
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateAccountID() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateAccountID()
})
}
// SetImageCount sets the "image_count" field.
func (u *SoraUsageStatUpsertOne) SetImageCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetImageCount(v)
})
}
// AddImageCount adds v to the "image_count" field.
func (u *SoraUsageStatUpsertOne) AddImageCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddImageCount(v)
})
}
// UpdateImageCount sets the "image_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateImageCount() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateImageCount()
})
}
// SetVideoCount sets the "video_count" field.
func (u *SoraUsageStatUpsertOne) SetVideoCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetVideoCount(v)
})
}
// AddVideoCount adds v to the "video_count" field.
func (u *SoraUsageStatUpsertOne) AddVideoCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddVideoCount(v)
})
}
// UpdateVideoCount sets the "video_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateVideoCount() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateVideoCount()
})
}
// SetErrorCount sets the "error_count" field.
func (u *SoraUsageStatUpsertOne) SetErrorCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetErrorCount(v)
})
}
// AddErrorCount adds v to the "error_count" field.
func (u *SoraUsageStatUpsertOne) AddErrorCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddErrorCount(v)
})
}
// UpdateErrorCount sets the "error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateErrorCount() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateErrorCount()
})
}
// SetLastErrorAt sets the "last_error_at" field.
func (u *SoraUsageStatUpsertOne) SetLastErrorAt(v time.Time) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetLastErrorAt(v)
})
}
// UpdateLastErrorAt sets the "last_error_at" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateLastErrorAt() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateLastErrorAt()
})
}
// ClearLastErrorAt clears the value of the "last_error_at" field.
func (u *SoraUsageStatUpsertOne) ClearLastErrorAt() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.ClearLastErrorAt()
})
}
// SetTodayImageCount sets the "today_image_count" field.
func (u *SoraUsageStatUpsertOne) SetTodayImageCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetTodayImageCount(v)
})
}
// AddTodayImageCount adds v to the "today_image_count" field.
func (u *SoraUsageStatUpsertOne) AddTodayImageCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddTodayImageCount(v)
})
}
// UpdateTodayImageCount sets the "today_image_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateTodayImageCount() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateTodayImageCount()
})
}
// SetTodayVideoCount sets the "today_video_count" field.
func (u *SoraUsageStatUpsertOne) SetTodayVideoCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetTodayVideoCount(v)
})
}
// AddTodayVideoCount adds v to the "today_video_count" field.
func (u *SoraUsageStatUpsertOne) AddTodayVideoCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddTodayVideoCount(v)
})
}
// UpdateTodayVideoCount sets the "today_video_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateTodayVideoCount() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateTodayVideoCount()
})
}
// SetTodayErrorCount sets the "today_error_count" field.
func (u *SoraUsageStatUpsertOne) SetTodayErrorCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetTodayErrorCount(v)
})
}
// AddTodayErrorCount adds v to the "today_error_count" field.
func (u *SoraUsageStatUpsertOne) AddTodayErrorCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddTodayErrorCount(v)
})
}
// UpdateTodayErrorCount sets the "today_error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateTodayErrorCount() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateTodayErrorCount()
})
}
// SetTodayDate sets the "today_date" field.
func (u *SoraUsageStatUpsertOne) SetTodayDate(v time.Time) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetTodayDate(v)
})
}
// UpdateTodayDate sets the "today_date" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateTodayDate() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateTodayDate()
})
}
// ClearTodayDate clears the value of the "today_date" field.
func (u *SoraUsageStatUpsertOne) ClearTodayDate() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.ClearTodayDate()
})
}
// SetConsecutiveErrorCount sets the "consecutive_error_count" field.
func (u *SoraUsageStatUpsertOne) SetConsecutiveErrorCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetConsecutiveErrorCount(v)
})
}
// AddConsecutiveErrorCount adds v to the "consecutive_error_count" field.
func (u *SoraUsageStatUpsertOne) AddConsecutiveErrorCount(v int) *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddConsecutiveErrorCount(v)
})
}
// UpdateConsecutiveErrorCount sets the "consecutive_error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertOne) UpdateConsecutiveErrorCount() *SoraUsageStatUpsertOne {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateConsecutiveErrorCount()
})
}
// Exec executes the query.
func (u *SoraUsageStatUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SoraUsageStatCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SoraUsageStatUpsertOne) 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 *SoraUsageStatUpsertOne) ID(ctx context.Context) (id int64, 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 *SoraUsageStatUpsertOne) IDX(ctx context.Context) int64 {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// SoraUsageStatCreateBulk is the builder for creating many SoraUsageStat entities in bulk.
type SoraUsageStatCreateBulk struct {
config
err error
builders []*SoraUsageStatCreate
conflict []sql.ConflictOption
}
// Save creates the SoraUsageStat entities in the database.
func (_c *SoraUsageStatCreateBulk) Save(ctx context.Context) ([]*SoraUsageStat, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*SoraUsageStat, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SoraUsageStatMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *SoraUsageStatCreateBulk) SaveX(ctx context.Context) []*SoraUsageStat {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *SoraUsageStatCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *SoraUsageStatCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.SoraUsageStat.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.SoraUsageStatUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *SoraUsageStatCreateBulk) OnConflict(opts ...sql.ConflictOption) *SoraUsageStatUpsertBulk {
_c.conflict = opts
return &SoraUsageStatUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.SoraUsageStat.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *SoraUsageStatCreateBulk) OnConflictColumns(columns ...string) *SoraUsageStatUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &SoraUsageStatUpsertBulk{
create: _c,
}
}
// SoraUsageStatUpsertBulk is the builder for "upsert"-ing
// a bulk of SoraUsageStat nodes.
type SoraUsageStatUpsertBulk struct {
create *SoraUsageStatCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.SoraUsageStat.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *SoraUsageStatUpsertBulk) UpdateNewValues() *SoraUsageStatUpsertBulk {
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(sorausagestat.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.SoraUsageStat.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *SoraUsageStatUpsertBulk) Ignore() *SoraUsageStatUpsertBulk {
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 *SoraUsageStatUpsertBulk) DoNothing() *SoraUsageStatUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the SoraUsageStatCreateBulk.OnConflict
// documentation for more info.
func (u *SoraUsageStatUpsertBulk) Update(set func(*SoraUsageStatUpsert)) *SoraUsageStatUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&SoraUsageStatUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *SoraUsageStatUpsertBulk) SetUpdatedAt(v time.Time) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateUpdatedAt() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateUpdatedAt()
})
}
// SetAccountID sets the "account_id" field.
func (u *SoraUsageStatUpsertBulk) SetAccountID(v int64) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetAccountID(v)
})
}
// AddAccountID adds v to the "account_id" field.
func (u *SoraUsageStatUpsertBulk) AddAccountID(v int64) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddAccountID(v)
})
}
// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateAccountID() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateAccountID()
})
}
// SetImageCount sets the "image_count" field.
func (u *SoraUsageStatUpsertBulk) SetImageCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetImageCount(v)
})
}
// AddImageCount adds v to the "image_count" field.
func (u *SoraUsageStatUpsertBulk) AddImageCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddImageCount(v)
})
}
// UpdateImageCount sets the "image_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateImageCount() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateImageCount()
})
}
// SetVideoCount sets the "video_count" field.
func (u *SoraUsageStatUpsertBulk) SetVideoCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetVideoCount(v)
})
}
// AddVideoCount adds v to the "video_count" field.
func (u *SoraUsageStatUpsertBulk) AddVideoCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddVideoCount(v)
})
}
// UpdateVideoCount sets the "video_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateVideoCount() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateVideoCount()
})
}
// SetErrorCount sets the "error_count" field.
func (u *SoraUsageStatUpsertBulk) SetErrorCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetErrorCount(v)
})
}
// AddErrorCount adds v to the "error_count" field.
func (u *SoraUsageStatUpsertBulk) AddErrorCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddErrorCount(v)
})
}
// UpdateErrorCount sets the "error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateErrorCount() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateErrorCount()
})
}
// SetLastErrorAt sets the "last_error_at" field.
func (u *SoraUsageStatUpsertBulk) SetLastErrorAt(v time.Time) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetLastErrorAt(v)
})
}
// UpdateLastErrorAt sets the "last_error_at" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateLastErrorAt() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateLastErrorAt()
})
}
// ClearLastErrorAt clears the value of the "last_error_at" field.
func (u *SoraUsageStatUpsertBulk) ClearLastErrorAt() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.ClearLastErrorAt()
})
}
// SetTodayImageCount sets the "today_image_count" field.
func (u *SoraUsageStatUpsertBulk) SetTodayImageCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetTodayImageCount(v)
})
}
// AddTodayImageCount adds v to the "today_image_count" field.
func (u *SoraUsageStatUpsertBulk) AddTodayImageCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddTodayImageCount(v)
})
}
// UpdateTodayImageCount sets the "today_image_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateTodayImageCount() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateTodayImageCount()
})
}
// SetTodayVideoCount sets the "today_video_count" field.
func (u *SoraUsageStatUpsertBulk) SetTodayVideoCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetTodayVideoCount(v)
})
}
// AddTodayVideoCount adds v to the "today_video_count" field.
func (u *SoraUsageStatUpsertBulk) AddTodayVideoCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddTodayVideoCount(v)
})
}
// UpdateTodayVideoCount sets the "today_video_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateTodayVideoCount() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateTodayVideoCount()
})
}
// SetTodayErrorCount sets the "today_error_count" field.
func (u *SoraUsageStatUpsertBulk) SetTodayErrorCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetTodayErrorCount(v)
})
}
// AddTodayErrorCount adds v to the "today_error_count" field.
func (u *SoraUsageStatUpsertBulk) AddTodayErrorCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddTodayErrorCount(v)
})
}
// UpdateTodayErrorCount sets the "today_error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateTodayErrorCount() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateTodayErrorCount()
})
}
// SetTodayDate sets the "today_date" field.
func (u *SoraUsageStatUpsertBulk) SetTodayDate(v time.Time) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetTodayDate(v)
})
}
// UpdateTodayDate sets the "today_date" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateTodayDate() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateTodayDate()
})
}
// ClearTodayDate clears the value of the "today_date" field.
func (u *SoraUsageStatUpsertBulk) ClearTodayDate() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.ClearTodayDate()
})
}
// SetConsecutiveErrorCount sets the "consecutive_error_count" field.
func (u *SoraUsageStatUpsertBulk) SetConsecutiveErrorCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.SetConsecutiveErrorCount(v)
})
}
// AddConsecutiveErrorCount adds v to the "consecutive_error_count" field.
func (u *SoraUsageStatUpsertBulk) AddConsecutiveErrorCount(v int) *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.AddConsecutiveErrorCount(v)
})
}
// UpdateConsecutiveErrorCount sets the "consecutive_error_count" field to the value that was provided on create.
func (u *SoraUsageStatUpsertBulk) UpdateConsecutiveErrorCount() *SoraUsageStatUpsertBulk {
return u.Update(func(s *SoraUsageStatUpsert) {
s.UpdateConsecutiveErrorCount()
})
}
// Exec executes the query.
func (u *SoraUsageStatUpsertBulk) 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 SoraUsageStatCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for SoraUsageStatCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *SoraUsageStatUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/sorausagestat"
)
// SoraUsageStatDelete is the builder for deleting a SoraUsageStat entity.
type SoraUsageStatDelete struct {
config
hooks []Hook
mutation *SoraUsageStatMutation
}
// Where appends a list predicates to the SoraUsageStatDelete builder.
func (_d *SoraUsageStatDelete) Where(ps ...predicate.SoraUsageStat) *SoraUsageStatDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *SoraUsageStatDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraUsageStatDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *SoraUsageStatDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(sorausagestat.Table, sqlgraph.NewFieldSpec(sorausagestat.FieldID, field.TypeInt64))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
_d.mutation.done = true
return affected, err
}
// SoraUsageStatDeleteOne is the builder for deleting a single SoraUsageStat entity.
type SoraUsageStatDeleteOne struct {
_d *SoraUsageStatDelete
}
// Where appends a list predicates to the SoraUsageStatDelete builder.
func (_d *SoraUsageStatDeleteOne) Where(ps ...predicate.SoraUsageStat) *SoraUsageStatDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *SoraUsageStatDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{sorausagestat.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *SoraUsageStatDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment