| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700 |
- // 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/group"
- "github.com/Wei-Shaw/sub2api/ent/usagelog"
- "github.com/Wei-Shaw/sub2api/ent/user"
- "github.com/Wei-Shaw/sub2api/ent/usersubscription"
- )
- // UserSubscriptionCreate is the builder for creating a UserSubscription entity.
- type UserSubscriptionCreate struct {
- config
- mutation *UserSubscriptionMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (_c *UserSubscriptionCreate) SetCreatedAt(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetCreatedAt(v)
- return _c
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableCreatedAt(v *time.Time) *UserSubscriptionCreate {
- if v != nil {
- _c.SetCreatedAt(*v)
- }
- return _c
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (_c *UserSubscriptionCreate) SetUpdatedAt(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetUpdatedAt(v)
- return _c
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableUpdatedAt(v *time.Time) *UserSubscriptionCreate {
- if v != nil {
- _c.SetUpdatedAt(*v)
- }
- return _c
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (_c *UserSubscriptionCreate) SetDeletedAt(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetDeletedAt(v)
- return _c
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableDeletedAt(v *time.Time) *UserSubscriptionCreate {
- if v != nil {
- _c.SetDeletedAt(*v)
- }
- return _c
- }
- // SetUserID sets the "user_id" field.
- func (_c *UserSubscriptionCreate) SetUserID(v int64) *UserSubscriptionCreate {
- _c.mutation.SetUserID(v)
- return _c
- }
- // SetGroupID sets the "group_id" field.
- func (_c *UserSubscriptionCreate) SetGroupID(v int64) *UserSubscriptionCreate {
- _c.mutation.SetGroupID(v)
- return _c
- }
- // SetStartsAt sets the "starts_at" field.
- func (_c *UserSubscriptionCreate) SetStartsAt(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetStartsAt(v)
- return _c
- }
- // SetExpiresAt sets the "expires_at" field.
- func (_c *UserSubscriptionCreate) SetExpiresAt(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetExpiresAt(v)
- return _c
- }
- // SetStatus sets the "status" field.
- func (_c *UserSubscriptionCreate) SetStatus(v string) *UserSubscriptionCreate {
- _c.mutation.SetStatus(v)
- return _c
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableStatus(v *string) *UserSubscriptionCreate {
- if v != nil {
- _c.SetStatus(*v)
- }
- return _c
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (_c *UserSubscriptionCreate) SetDailyWindowStart(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetDailyWindowStart(v)
- return _c
- }
- // SetNillableDailyWindowStart sets the "daily_window_start" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableDailyWindowStart(v *time.Time) *UserSubscriptionCreate {
- if v != nil {
- _c.SetDailyWindowStart(*v)
- }
- return _c
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (_c *UserSubscriptionCreate) SetWeeklyWindowStart(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetWeeklyWindowStart(v)
- return _c
- }
- // SetNillableWeeklyWindowStart sets the "weekly_window_start" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableWeeklyWindowStart(v *time.Time) *UserSubscriptionCreate {
- if v != nil {
- _c.SetWeeklyWindowStart(*v)
- }
- return _c
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (_c *UserSubscriptionCreate) SetMonthlyWindowStart(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetMonthlyWindowStart(v)
- return _c
- }
- // SetNillableMonthlyWindowStart sets the "monthly_window_start" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableMonthlyWindowStart(v *time.Time) *UserSubscriptionCreate {
- if v != nil {
- _c.SetMonthlyWindowStart(*v)
- }
- return _c
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (_c *UserSubscriptionCreate) SetDailyUsageUsd(v float64) *UserSubscriptionCreate {
- _c.mutation.SetDailyUsageUsd(v)
- return _c
- }
- // SetNillableDailyUsageUsd sets the "daily_usage_usd" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableDailyUsageUsd(v *float64) *UserSubscriptionCreate {
- if v != nil {
- _c.SetDailyUsageUsd(*v)
- }
- return _c
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (_c *UserSubscriptionCreate) SetWeeklyUsageUsd(v float64) *UserSubscriptionCreate {
- _c.mutation.SetWeeklyUsageUsd(v)
- return _c
- }
- // SetNillableWeeklyUsageUsd sets the "weekly_usage_usd" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableWeeklyUsageUsd(v *float64) *UserSubscriptionCreate {
- if v != nil {
- _c.SetWeeklyUsageUsd(*v)
- }
- return _c
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (_c *UserSubscriptionCreate) SetMonthlyUsageUsd(v float64) *UserSubscriptionCreate {
- _c.mutation.SetMonthlyUsageUsd(v)
- return _c
- }
- // SetNillableMonthlyUsageUsd sets the "monthly_usage_usd" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableMonthlyUsageUsd(v *float64) *UserSubscriptionCreate {
- if v != nil {
- _c.SetMonthlyUsageUsd(*v)
- }
- return _c
- }
- // SetAssignedBy sets the "assigned_by" field.
- func (_c *UserSubscriptionCreate) SetAssignedBy(v int64) *UserSubscriptionCreate {
- _c.mutation.SetAssignedBy(v)
- return _c
- }
- // SetNillableAssignedBy sets the "assigned_by" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableAssignedBy(v *int64) *UserSubscriptionCreate {
- if v != nil {
- _c.SetAssignedBy(*v)
- }
- return _c
- }
- // SetAssignedAt sets the "assigned_at" field.
- func (_c *UserSubscriptionCreate) SetAssignedAt(v time.Time) *UserSubscriptionCreate {
- _c.mutation.SetAssignedAt(v)
- return _c
- }
- // SetNillableAssignedAt sets the "assigned_at" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableAssignedAt(v *time.Time) *UserSubscriptionCreate {
- if v != nil {
- _c.SetAssignedAt(*v)
- }
- return _c
- }
- // SetNotes sets the "notes" field.
- func (_c *UserSubscriptionCreate) SetNotes(v string) *UserSubscriptionCreate {
- _c.mutation.SetNotes(v)
- return _c
- }
- // SetNillableNotes sets the "notes" field if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableNotes(v *string) *UserSubscriptionCreate {
- if v != nil {
- _c.SetNotes(*v)
- }
- return _c
- }
- // SetUser sets the "user" edge to the User entity.
- func (_c *UserSubscriptionCreate) SetUser(v *User) *UserSubscriptionCreate {
- return _c.SetUserID(v.ID)
- }
- // SetGroup sets the "group" edge to the Group entity.
- func (_c *UserSubscriptionCreate) SetGroup(v *Group) *UserSubscriptionCreate {
- return _c.SetGroupID(v.ID)
- }
- // SetAssignedByUserID sets the "assigned_by_user" edge to the User entity by ID.
- func (_c *UserSubscriptionCreate) SetAssignedByUserID(id int64) *UserSubscriptionCreate {
- _c.mutation.SetAssignedByUserID(id)
- return _c
- }
- // SetNillableAssignedByUserID sets the "assigned_by_user" edge to the User entity by ID if the given value is not nil.
- func (_c *UserSubscriptionCreate) SetNillableAssignedByUserID(id *int64) *UserSubscriptionCreate {
- if id != nil {
- _c = _c.SetAssignedByUserID(*id)
- }
- return _c
- }
- // SetAssignedByUser sets the "assigned_by_user" edge to the User entity.
- func (_c *UserSubscriptionCreate) SetAssignedByUser(v *User) *UserSubscriptionCreate {
- return _c.SetAssignedByUserID(v.ID)
- }
- // AddUsageLogIDs adds the "usage_logs" edge to the UsageLog entity by IDs.
- func (_c *UserSubscriptionCreate) AddUsageLogIDs(ids ...int64) *UserSubscriptionCreate {
- _c.mutation.AddUsageLogIDs(ids...)
- return _c
- }
- // AddUsageLogs adds the "usage_logs" edges to the UsageLog entity.
- func (_c *UserSubscriptionCreate) AddUsageLogs(v ...*UsageLog) *UserSubscriptionCreate {
- ids := make([]int64, len(v))
- for i := range v {
- ids[i] = v[i].ID
- }
- return _c.AddUsageLogIDs(ids...)
- }
- // Mutation returns the UserSubscriptionMutation object of the builder.
- func (_c *UserSubscriptionCreate) Mutation() *UserSubscriptionMutation {
- return _c.mutation
- }
- // Save creates the UserSubscription in the database.
- func (_c *UserSubscriptionCreate) Save(ctx context.Context) (*UserSubscription, error) {
- if err := _c.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *UserSubscriptionCreate) SaveX(ctx context.Context) *UserSubscription {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *UserSubscriptionCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *UserSubscriptionCreate) 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 *UserSubscriptionCreate) defaults() error {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- if usersubscription.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized usersubscription.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := usersubscription.DefaultCreatedAt()
- _c.mutation.SetCreatedAt(v)
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- if usersubscription.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized usersubscription.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := usersubscription.DefaultUpdatedAt()
- _c.mutation.SetUpdatedAt(v)
- }
- if _, ok := _c.mutation.Status(); !ok {
- v := usersubscription.DefaultStatus
- _c.mutation.SetStatus(v)
- }
- if _, ok := _c.mutation.DailyUsageUsd(); !ok {
- v := usersubscription.DefaultDailyUsageUsd
- _c.mutation.SetDailyUsageUsd(v)
- }
- if _, ok := _c.mutation.WeeklyUsageUsd(); !ok {
- v := usersubscription.DefaultWeeklyUsageUsd
- _c.mutation.SetWeeklyUsageUsd(v)
- }
- if _, ok := _c.mutation.MonthlyUsageUsd(); !ok {
- v := usersubscription.DefaultMonthlyUsageUsd
- _c.mutation.SetMonthlyUsageUsd(v)
- }
- if _, ok := _c.mutation.AssignedAt(); !ok {
- if usersubscription.DefaultAssignedAt == nil {
- return fmt.Errorf("ent: uninitialized usersubscription.DefaultAssignedAt (forgotten import ent/runtime?)")
- }
- v := usersubscription.DefaultAssignedAt()
- _c.mutation.SetAssignedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *UserSubscriptionCreate) check() error {
- if _, ok := _c.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UserSubscription.created_at"`)}
- }
- if _, ok := _c.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UserSubscription.updated_at"`)}
- }
- if _, ok := _c.mutation.UserID(); !ok {
- return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserSubscription.user_id"`)}
- }
- if _, ok := _c.mutation.GroupID(); !ok {
- return &ValidationError{Name: "group_id", err: errors.New(`ent: missing required field "UserSubscription.group_id"`)}
- }
- if _, ok := _c.mutation.StartsAt(); !ok {
- return &ValidationError{Name: "starts_at", err: errors.New(`ent: missing required field "UserSubscription.starts_at"`)}
- }
- if _, ok := _c.mutation.ExpiresAt(); !ok {
- return &ValidationError{Name: "expires_at", err: errors.New(`ent: missing required field "UserSubscription.expires_at"`)}
- }
- if _, ok := _c.mutation.Status(); !ok {
- return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "UserSubscription.status"`)}
- }
- if v, ok := _c.mutation.Status(); ok {
- if err := usersubscription.StatusValidator(v); err != nil {
- return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "UserSubscription.status": %w`, err)}
- }
- }
- if _, ok := _c.mutation.DailyUsageUsd(); !ok {
- return &ValidationError{Name: "daily_usage_usd", err: errors.New(`ent: missing required field "UserSubscription.daily_usage_usd"`)}
- }
- if _, ok := _c.mutation.WeeklyUsageUsd(); !ok {
- return &ValidationError{Name: "weekly_usage_usd", err: errors.New(`ent: missing required field "UserSubscription.weekly_usage_usd"`)}
- }
- if _, ok := _c.mutation.MonthlyUsageUsd(); !ok {
- return &ValidationError{Name: "monthly_usage_usd", err: errors.New(`ent: missing required field "UserSubscription.monthly_usage_usd"`)}
- }
- if _, ok := _c.mutation.AssignedAt(); !ok {
- return &ValidationError{Name: "assigned_at", err: errors.New(`ent: missing required field "UserSubscription.assigned_at"`)}
- }
- if len(_c.mutation.UserIDs()) == 0 {
- return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserSubscription.user"`)}
- }
- if len(_c.mutation.GroupIDs()) == 0 {
- return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "UserSubscription.group"`)}
- }
- return nil
- }
- func (_c *UserSubscriptionCreate) sqlSave(ctx context.Context) (*UserSubscription, 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 *UserSubscriptionCreate) createSpec() (*UserSubscription, *sqlgraph.CreateSpec) {
- var (
- _node = &UserSubscription{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(usersubscription.Table, sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.CreatedAt(); ok {
- _spec.SetField(usersubscription.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := _c.mutation.UpdatedAt(); ok {
- _spec.SetField(usersubscription.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := _c.mutation.DeletedAt(); ok {
- _spec.SetField(usersubscription.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = &value
- }
- if value, ok := _c.mutation.StartsAt(); ok {
- _spec.SetField(usersubscription.FieldStartsAt, field.TypeTime, value)
- _node.StartsAt = value
- }
- if value, ok := _c.mutation.ExpiresAt(); ok {
- _spec.SetField(usersubscription.FieldExpiresAt, field.TypeTime, value)
- _node.ExpiresAt = value
- }
- if value, ok := _c.mutation.Status(); ok {
- _spec.SetField(usersubscription.FieldStatus, field.TypeString, value)
- _node.Status = value
- }
- if value, ok := _c.mutation.DailyWindowStart(); ok {
- _spec.SetField(usersubscription.FieldDailyWindowStart, field.TypeTime, value)
- _node.DailyWindowStart = &value
- }
- if value, ok := _c.mutation.WeeklyWindowStart(); ok {
- _spec.SetField(usersubscription.FieldWeeklyWindowStart, field.TypeTime, value)
- _node.WeeklyWindowStart = &value
- }
- if value, ok := _c.mutation.MonthlyWindowStart(); ok {
- _spec.SetField(usersubscription.FieldMonthlyWindowStart, field.TypeTime, value)
- _node.MonthlyWindowStart = &value
- }
- if value, ok := _c.mutation.DailyUsageUsd(); ok {
- _spec.SetField(usersubscription.FieldDailyUsageUsd, field.TypeFloat64, value)
- _node.DailyUsageUsd = value
- }
- if value, ok := _c.mutation.WeeklyUsageUsd(); ok {
- _spec.SetField(usersubscription.FieldWeeklyUsageUsd, field.TypeFloat64, value)
- _node.WeeklyUsageUsd = value
- }
- if value, ok := _c.mutation.MonthlyUsageUsd(); ok {
- _spec.SetField(usersubscription.FieldMonthlyUsageUsd, field.TypeFloat64, value)
- _node.MonthlyUsageUsd = value
- }
- if value, ok := _c.mutation.AssignedAt(); ok {
- _spec.SetField(usersubscription.FieldAssignedAt, field.TypeTime, value)
- _node.AssignedAt = value
- }
- if value, ok := _c.mutation.Notes(); ok {
- _spec.SetField(usersubscription.FieldNotes, field.TypeString, value)
- _node.Notes = &value
- }
- if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usersubscription.UserTable,
- Columns: []string{usersubscription.UserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.UserID = nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usersubscription.GroupTable,
- Columns: []string{usersubscription.GroupColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.GroupID = nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.AssignedByUserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: usersubscription.AssignedByUserTable,
- Columns: []string{usersubscription.AssignedByUserColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.AssignedBy = &nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.UsageLogsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: usersubscription.UsageLogsTable,
- Columns: []string{usersubscription.UsageLogsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges = append(_spec.Edges, edge)
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.UserSubscription.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.UserSubscriptionUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *UserSubscriptionCreate) OnConflict(opts ...sql.ConflictOption) *UserSubscriptionUpsertOne {
- _c.conflict = opts
- return &UserSubscriptionUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.UserSubscription.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *UserSubscriptionCreate) OnConflictColumns(columns ...string) *UserSubscriptionUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &UserSubscriptionUpsertOne{
- create: _c,
- }
- }
- type (
- // UserSubscriptionUpsertOne is the builder for "upsert"-ing
- // one UserSubscription node.
- UserSubscriptionUpsertOne struct {
- create *UserSubscriptionCreate
- }
- // UserSubscriptionUpsert is the "OnConflict" setter.
- UserSubscriptionUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *UserSubscriptionUpsert) SetUpdatedAt(v time.Time) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateUpdatedAt() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldUpdatedAt)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *UserSubscriptionUpsert) SetDeletedAt(v time.Time) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateDeletedAt() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *UserSubscriptionUpsert) ClearDeletedAt() *UserSubscriptionUpsert {
- u.SetNull(usersubscription.FieldDeletedAt)
- return u
- }
- // SetUserID sets the "user_id" field.
- func (u *UserSubscriptionUpsert) SetUserID(v int64) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldUserID, v)
- return u
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateUserID() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldUserID)
- return u
- }
- // SetGroupID sets the "group_id" field.
- func (u *UserSubscriptionUpsert) SetGroupID(v int64) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldGroupID, v)
- return u
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateGroupID() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldGroupID)
- return u
- }
- // SetStartsAt sets the "starts_at" field.
- func (u *UserSubscriptionUpsert) SetStartsAt(v time.Time) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldStartsAt, v)
- return u
- }
- // UpdateStartsAt sets the "starts_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateStartsAt() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldStartsAt)
- return u
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *UserSubscriptionUpsert) SetExpiresAt(v time.Time) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldExpiresAt, v)
- return u
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateExpiresAt() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldExpiresAt)
- return u
- }
- // SetStatus sets the "status" field.
- func (u *UserSubscriptionUpsert) SetStatus(v string) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldStatus, v)
- return u
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateStatus() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldStatus)
- return u
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (u *UserSubscriptionUpsert) SetDailyWindowStart(v time.Time) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldDailyWindowStart, v)
- return u
- }
- // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateDailyWindowStart() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldDailyWindowStart)
- return u
- }
- // ClearDailyWindowStart clears the value of the "daily_window_start" field.
- func (u *UserSubscriptionUpsert) ClearDailyWindowStart() *UserSubscriptionUpsert {
- u.SetNull(usersubscription.FieldDailyWindowStart)
- return u
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (u *UserSubscriptionUpsert) SetWeeklyWindowStart(v time.Time) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldWeeklyWindowStart, v)
- return u
- }
- // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateWeeklyWindowStart() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldWeeklyWindowStart)
- return u
- }
- // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
- func (u *UserSubscriptionUpsert) ClearWeeklyWindowStart() *UserSubscriptionUpsert {
- u.SetNull(usersubscription.FieldWeeklyWindowStart)
- return u
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (u *UserSubscriptionUpsert) SetMonthlyWindowStart(v time.Time) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldMonthlyWindowStart, v)
- return u
- }
- // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateMonthlyWindowStart() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldMonthlyWindowStart)
- return u
- }
- // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
- func (u *UserSubscriptionUpsert) ClearMonthlyWindowStart() *UserSubscriptionUpsert {
- u.SetNull(usersubscription.FieldMonthlyWindowStart)
- return u
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (u *UserSubscriptionUpsert) SetDailyUsageUsd(v float64) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldDailyUsageUsd, v)
- return u
- }
- // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateDailyUsageUsd() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldDailyUsageUsd)
- return u
- }
- // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
- func (u *UserSubscriptionUpsert) AddDailyUsageUsd(v float64) *UserSubscriptionUpsert {
- u.Add(usersubscription.FieldDailyUsageUsd, v)
- return u
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (u *UserSubscriptionUpsert) SetWeeklyUsageUsd(v float64) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldWeeklyUsageUsd, v)
- return u
- }
- // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateWeeklyUsageUsd() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldWeeklyUsageUsd)
- return u
- }
- // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
- func (u *UserSubscriptionUpsert) AddWeeklyUsageUsd(v float64) *UserSubscriptionUpsert {
- u.Add(usersubscription.FieldWeeklyUsageUsd, v)
- return u
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (u *UserSubscriptionUpsert) SetMonthlyUsageUsd(v float64) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldMonthlyUsageUsd, v)
- return u
- }
- // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateMonthlyUsageUsd() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldMonthlyUsageUsd)
- return u
- }
- // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
- func (u *UserSubscriptionUpsert) AddMonthlyUsageUsd(v float64) *UserSubscriptionUpsert {
- u.Add(usersubscription.FieldMonthlyUsageUsd, v)
- return u
- }
- // SetAssignedBy sets the "assigned_by" field.
- func (u *UserSubscriptionUpsert) SetAssignedBy(v int64) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldAssignedBy, v)
- return u
- }
- // UpdateAssignedBy sets the "assigned_by" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateAssignedBy() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldAssignedBy)
- return u
- }
- // ClearAssignedBy clears the value of the "assigned_by" field.
- func (u *UserSubscriptionUpsert) ClearAssignedBy() *UserSubscriptionUpsert {
- u.SetNull(usersubscription.FieldAssignedBy)
- return u
- }
- // SetAssignedAt sets the "assigned_at" field.
- func (u *UserSubscriptionUpsert) SetAssignedAt(v time.Time) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldAssignedAt, v)
- return u
- }
- // UpdateAssignedAt sets the "assigned_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateAssignedAt() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldAssignedAt)
- return u
- }
- // SetNotes sets the "notes" field.
- func (u *UserSubscriptionUpsert) SetNotes(v string) *UserSubscriptionUpsert {
- u.Set(usersubscription.FieldNotes, v)
- return u
- }
- // UpdateNotes sets the "notes" field to the value that was provided on create.
- func (u *UserSubscriptionUpsert) UpdateNotes() *UserSubscriptionUpsert {
- u.SetExcluded(usersubscription.FieldNotes)
- return u
- }
- // ClearNotes clears the value of the "notes" field.
- func (u *UserSubscriptionUpsert) ClearNotes() *UserSubscriptionUpsert {
- u.SetNull(usersubscription.FieldNotes)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.UserSubscription.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *UserSubscriptionUpsertOne) UpdateNewValues() *UserSubscriptionUpsertOne {
- 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(usersubscription.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.UserSubscription.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *UserSubscriptionUpsertOne) Ignore() *UserSubscriptionUpsertOne {
- 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 *UserSubscriptionUpsertOne) DoNothing() *UserSubscriptionUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the UserSubscriptionCreate.OnConflict
- // documentation for more info.
- func (u *UserSubscriptionUpsertOne) Update(set func(*UserSubscriptionUpsert)) *UserSubscriptionUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&UserSubscriptionUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *UserSubscriptionUpsertOne) SetUpdatedAt(v time.Time) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateUpdatedAt() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *UserSubscriptionUpsertOne) SetDeletedAt(v time.Time) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateDeletedAt() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *UserSubscriptionUpsertOne) ClearDeletedAt() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetUserID sets the "user_id" field.
- func (u *UserSubscriptionUpsertOne) SetUserID(v int64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetUserID(v)
- })
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateUserID() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateUserID()
- })
- }
- // SetGroupID sets the "group_id" field.
- func (u *UserSubscriptionUpsertOne) SetGroupID(v int64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetGroupID(v)
- })
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateGroupID() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateGroupID()
- })
- }
- // SetStartsAt sets the "starts_at" field.
- func (u *UserSubscriptionUpsertOne) SetStartsAt(v time.Time) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetStartsAt(v)
- })
- }
- // UpdateStartsAt sets the "starts_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateStartsAt() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateStartsAt()
- })
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *UserSubscriptionUpsertOne) SetExpiresAt(v time.Time) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetExpiresAt(v)
- })
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateExpiresAt() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateExpiresAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *UserSubscriptionUpsertOne) SetStatus(v string) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateStatus() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateStatus()
- })
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (u *UserSubscriptionUpsertOne) SetDailyWindowStart(v time.Time) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetDailyWindowStart(v)
- })
- }
- // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateDailyWindowStart() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateDailyWindowStart()
- })
- }
- // ClearDailyWindowStart clears the value of the "daily_window_start" field.
- func (u *UserSubscriptionUpsertOne) ClearDailyWindowStart() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearDailyWindowStart()
- })
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (u *UserSubscriptionUpsertOne) SetWeeklyWindowStart(v time.Time) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetWeeklyWindowStart(v)
- })
- }
- // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateWeeklyWindowStart() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateWeeklyWindowStart()
- })
- }
- // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
- func (u *UserSubscriptionUpsertOne) ClearWeeklyWindowStart() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearWeeklyWindowStart()
- })
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (u *UserSubscriptionUpsertOne) SetMonthlyWindowStart(v time.Time) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetMonthlyWindowStart(v)
- })
- }
- // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateMonthlyWindowStart() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateMonthlyWindowStart()
- })
- }
- // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
- func (u *UserSubscriptionUpsertOne) ClearMonthlyWindowStart() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearMonthlyWindowStart()
- })
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (u *UserSubscriptionUpsertOne) SetDailyUsageUsd(v float64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetDailyUsageUsd(v)
- })
- }
- // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
- func (u *UserSubscriptionUpsertOne) AddDailyUsageUsd(v float64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.AddDailyUsageUsd(v)
- })
- }
- // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateDailyUsageUsd() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateDailyUsageUsd()
- })
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (u *UserSubscriptionUpsertOne) SetWeeklyUsageUsd(v float64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetWeeklyUsageUsd(v)
- })
- }
- // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
- func (u *UserSubscriptionUpsertOne) AddWeeklyUsageUsd(v float64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.AddWeeklyUsageUsd(v)
- })
- }
- // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateWeeklyUsageUsd() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateWeeklyUsageUsd()
- })
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (u *UserSubscriptionUpsertOne) SetMonthlyUsageUsd(v float64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetMonthlyUsageUsd(v)
- })
- }
- // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
- func (u *UserSubscriptionUpsertOne) AddMonthlyUsageUsd(v float64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.AddMonthlyUsageUsd(v)
- })
- }
- // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateMonthlyUsageUsd() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateMonthlyUsageUsd()
- })
- }
- // SetAssignedBy sets the "assigned_by" field.
- func (u *UserSubscriptionUpsertOne) SetAssignedBy(v int64) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetAssignedBy(v)
- })
- }
- // UpdateAssignedBy sets the "assigned_by" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateAssignedBy() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateAssignedBy()
- })
- }
- // ClearAssignedBy clears the value of the "assigned_by" field.
- func (u *UserSubscriptionUpsertOne) ClearAssignedBy() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearAssignedBy()
- })
- }
- // SetAssignedAt sets the "assigned_at" field.
- func (u *UserSubscriptionUpsertOne) SetAssignedAt(v time.Time) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetAssignedAt(v)
- })
- }
- // UpdateAssignedAt sets the "assigned_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateAssignedAt() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateAssignedAt()
- })
- }
- // SetNotes sets the "notes" field.
- func (u *UserSubscriptionUpsertOne) SetNotes(v string) *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetNotes(v)
- })
- }
- // UpdateNotes sets the "notes" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertOne) UpdateNotes() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateNotes()
- })
- }
- // ClearNotes clears the value of the "notes" field.
- func (u *UserSubscriptionUpsertOne) ClearNotes() *UserSubscriptionUpsertOne {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearNotes()
- })
- }
- // Exec executes the query.
- func (u *UserSubscriptionUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for UserSubscriptionCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *UserSubscriptionUpsertOne) 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 *UserSubscriptionUpsertOne) 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 *UserSubscriptionUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // UserSubscriptionCreateBulk is the builder for creating many UserSubscription entities in bulk.
- type UserSubscriptionCreateBulk struct {
- config
- err error
- builders []*UserSubscriptionCreate
- conflict []sql.ConflictOption
- }
- // Save creates the UserSubscription entities in the database.
- func (_c *UserSubscriptionCreateBulk) Save(ctx context.Context) ([]*UserSubscription, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*UserSubscription, 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.(*UserSubscriptionMutation)
- 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 *UserSubscriptionCreateBulk) SaveX(ctx context.Context) []*UserSubscription {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *UserSubscriptionCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *UserSubscriptionCreateBulk) 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.UserSubscription.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.UserSubscriptionUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (_c *UserSubscriptionCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserSubscriptionUpsertBulk {
- _c.conflict = opts
- return &UserSubscriptionUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.UserSubscription.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *UserSubscriptionCreateBulk) OnConflictColumns(columns ...string) *UserSubscriptionUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &UserSubscriptionUpsertBulk{
- create: _c,
- }
- }
- // UserSubscriptionUpsertBulk is the builder for "upsert"-ing
- // a bulk of UserSubscription nodes.
- type UserSubscriptionUpsertBulk struct {
- create *UserSubscriptionCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.UserSubscription.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *UserSubscriptionUpsertBulk) UpdateNewValues() *UserSubscriptionUpsertBulk {
- 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(usersubscription.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.UserSubscription.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *UserSubscriptionUpsertBulk) Ignore() *UserSubscriptionUpsertBulk {
- 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 *UserSubscriptionUpsertBulk) DoNothing() *UserSubscriptionUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the UserSubscriptionCreateBulk.OnConflict
- // documentation for more info.
- func (u *UserSubscriptionUpsertBulk) Update(set func(*UserSubscriptionUpsert)) *UserSubscriptionUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&UserSubscriptionUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *UserSubscriptionUpsertBulk) SetUpdatedAt(v time.Time) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateUpdatedAt() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *UserSubscriptionUpsertBulk) SetDeletedAt(v time.Time) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateDeletedAt() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *UserSubscriptionUpsertBulk) ClearDeletedAt() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetUserID sets the "user_id" field.
- func (u *UserSubscriptionUpsertBulk) SetUserID(v int64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetUserID(v)
- })
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateUserID() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateUserID()
- })
- }
- // SetGroupID sets the "group_id" field.
- func (u *UserSubscriptionUpsertBulk) SetGroupID(v int64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetGroupID(v)
- })
- }
- // UpdateGroupID sets the "group_id" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateGroupID() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateGroupID()
- })
- }
- // SetStartsAt sets the "starts_at" field.
- func (u *UserSubscriptionUpsertBulk) SetStartsAt(v time.Time) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetStartsAt(v)
- })
- }
- // UpdateStartsAt sets the "starts_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateStartsAt() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateStartsAt()
- })
- }
- // SetExpiresAt sets the "expires_at" field.
- func (u *UserSubscriptionUpsertBulk) SetExpiresAt(v time.Time) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetExpiresAt(v)
- })
- }
- // UpdateExpiresAt sets the "expires_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateExpiresAt() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateExpiresAt()
- })
- }
- // SetStatus sets the "status" field.
- func (u *UserSubscriptionUpsertBulk) SetStatus(v string) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetStatus(v)
- })
- }
- // UpdateStatus sets the "status" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateStatus() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateStatus()
- })
- }
- // SetDailyWindowStart sets the "daily_window_start" field.
- func (u *UserSubscriptionUpsertBulk) SetDailyWindowStart(v time.Time) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetDailyWindowStart(v)
- })
- }
- // UpdateDailyWindowStart sets the "daily_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateDailyWindowStart() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateDailyWindowStart()
- })
- }
- // ClearDailyWindowStart clears the value of the "daily_window_start" field.
- func (u *UserSubscriptionUpsertBulk) ClearDailyWindowStart() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearDailyWindowStart()
- })
- }
- // SetWeeklyWindowStart sets the "weekly_window_start" field.
- func (u *UserSubscriptionUpsertBulk) SetWeeklyWindowStart(v time.Time) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetWeeklyWindowStart(v)
- })
- }
- // UpdateWeeklyWindowStart sets the "weekly_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateWeeklyWindowStart() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateWeeklyWindowStart()
- })
- }
- // ClearWeeklyWindowStart clears the value of the "weekly_window_start" field.
- func (u *UserSubscriptionUpsertBulk) ClearWeeklyWindowStart() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearWeeklyWindowStart()
- })
- }
- // SetMonthlyWindowStart sets the "monthly_window_start" field.
- func (u *UserSubscriptionUpsertBulk) SetMonthlyWindowStart(v time.Time) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetMonthlyWindowStart(v)
- })
- }
- // UpdateMonthlyWindowStart sets the "monthly_window_start" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateMonthlyWindowStart() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateMonthlyWindowStart()
- })
- }
- // ClearMonthlyWindowStart clears the value of the "monthly_window_start" field.
- func (u *UserSubscriptionUpsertBulk) ClearMonthlyWindowStart() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearMonthlyWindowStart()
- })
- }
- // SetDailyUsageUsd sets the "daily_usage_usd" field.
- func (u *UserSubscriptionUpsertBulk) SetDailyUsageUsd(v float64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetDailyUsageUsd(v)
- })
- }
- // AddDailyUsageUsd adds v to the "daily_usage_usd" field.
- func (u *UserSubscriptionUpsertBulk) AddDailyUsageUsd(v float64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.AddDailyUsageUsd(v)
- })
- }
- // UpdateDailyUsageUsd sets the "daily_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateDailyUsageUsd() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateDailyUsageUsd()
- })
- }
- // SetWeeklyUsageUsd sets the "weekly_usage_usd" field.
- func (u *UserSubscriptionUpsertBulk) SetWeeklyUsageUsd(v float64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetWeeklyUsageUsd(v)
- })
- }
- // AddWeeklyUsageUsd adds v to the "weekly_usage_usd" field.
- func (u *UserSubscriptionUpsertBulk) AddWeeklyUsageUsd(v float64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.AddWeeklyUsageUsd(v)
- })
- }
- // UpdateWeeklyUsageUsd sets the "weekly_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateWeeklyUsageUsd() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateWeeklyUsageUsd()
- })
- }
- // SetMonthlyUsageUsd sets the "monthly_usage_usd" field.
- func (u *UserSubscriptionUpsertBulk) SetMonthlyUsageUsd(v float64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetMonthlyUsageUsd(v)
- })
- }
- // AddMonthlyUsageUsd adds v to the "monthly_usage_usd" field.
- func (u *UserSubscriptionUpsertBulk) AddMonthlyUsageUsd(v float64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.AddMonthlyUsageUsd(v)
- })
- }
- // UpdateMonthlyUsageUsd sets the "monthly_usage_usd" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateMonthlyUsageUsd() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateMonthlyUsageUsd()
- })
- }
- // SetAssignedBy sets the "assigned_by" field.
- func (u *UserSubscriptionUpsertBulk) SetAssignedBy(v int64) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetAssignedBy(v)
- })
- }
- // UpdateAssignedBy sets the "assigned_by" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateAssignedBy() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateAssignedBy()
- })
- }
- // ClearAssignedBy clears the value of the "assigned_by" field.
- func (u *UserSubscriptionUpsertBulk) ClearAssignedBy() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearAssignedBy()
- })
- }
- // SetAssignedAt sets the "assigned_at" field.
- func (u *UserSubscriptionUpsertBulk) SetAssignedAt(v time.Time) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetAssignedAt(v)
- })
- }
- // UpdateAssignedAt sets the "assigned_at" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateAssignedAt() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateAssignedAt()
- })
- }
- // SetNotes sets the "notes" field.
- func (u *UserSubscriptionUpsertBulk) SetNotes(v string) *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.SetNotes(v)
- })
- }
- // UpdateNotes sets the "notes" field to the value that was provided on create.
- func (u *UserSubscriptionUpsertBulk) UpdateNotes() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.UpdateNotes()
- })
- }
- // ClearNotes clears the value of the "notes" field.
- func (u *UserSubscriptionUpsertBulk) ClearNotes() *UserSubscriptionUpsertBulk {
- return u.Update(func(s *UserSubscriptionUpsert) {
- s.ClearNotes()
- })
- }
- // Exec executes the query.
- func (u *UserSubscriptionUpsertBulk) 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 UserSubscriptionCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for UserSubscriptionCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *UserSubscriptionUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|