| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660 |
- // 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/announcement"
- "github.com/Wei-Shaw/sub2api/ent/announcementread"
- "github.com/Wei-Shaw/sub2api/ent/user"
- )
- // AnnouncementReadCreate is the builder for creating a AnnouncementRead entity.
- type AnnouncementReadCreate struct {
- config
- mutation *AnnouncementReadMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetAnnouncementID sets the "announcement_id" field.
- func (_c *AnnouncementReadCreate) SetAnnouncementID(v int64) *AnnouncementReadCreate {
- _c.mutation.SetAnnouncementID(v)
- return _c
- }
- // SetUserID sets the "user_id" field.
- func (_c *AnnouncementReadCreate) SetUserID(v int64) *AnnouncementReadCreate {
- _c.mutation.SetUserID(v)
- return _c
- }
- // SetReadAt sets the "read_at" field.
- func (_c *AnnouncementReadCreate) SetReadAt(v time.Time) *AnnouncementReadCreate {
- _c.mutation.SetReadAt(v)
- return _c
- }
- // SetNillableReadAt sets the "read_at" field if the given value is not nil.
- func (_c *AnnouncementReadCreate) SetNillableReadAt(v *time.Time) *AnnouncementReadCreate {
- if v != nil {
- _c.SetReadAt(*v)
- }
- return _c
- }
- // SetCreatedAt sets the "created_at" field.
- func (_c *AnnouncementReadCreate) SetCreatedAt(v time.Time) *AnnouncementReadCreate {
- _c.mutation.SetCreatedAt(v)
- return _c
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (_c *AnnouncementReadCreate) SetNillableCreatedAt(v *time.Time) *AnnouncementReadCreate {
- if v != nil {
- _c.SetCreatedAt(*v)
- }
- return _c
- }
- // SetAnnouncement sets the "announcement" edge to the Announcement entity.
- func (_c *AnnouncementReadCreate) SetAnnouncement(v *Announcement) *AnnouncementReadCreate {
- return _c.SetAnnouncementID(v.ID)
- }
- // SetUser sets the "user" edge to the User entity.
- func (_c *AnnouncementReadCreate) SetUser(v *User) *AnnouncementReadCreate {
- return _c.SetUserID(v.ID)
- }
- // Mutation returns the AnnouncementReadMutation object of the builder.
- func (_c *AnnouncementReadCreate) Mutation() *AnnouncementReadMutation {
- return _c.mutation
- }
- // Save creates the AnnouncementRead in the database.
- func (_c *AnnouncementReadCreate) Save(ctx context.Context) (*AnnouncementRead, error) {
- _c.defaults()
- return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (_c *AnnouncementReadCreate) SaveX(ctx context.Context) *AnnouncementRead {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *AnnouncementReadCreate) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *AnnouncementReadCreate) 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 *AnnouncementReadCreate) defaults() {
- if _, ok := _c.mutation.ReadAt(); !ok {
- v := announcementread.DefaultReadAt()
- _c.mutation.SetReadAt(v)
- }
- if _, ok := _c.mutation.CreatedAt(); !ok {
- v := announcementread.DefaultCreatedAt()
- _c.mutation.SetCreatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (_c *AnnouncementReadCreate) check() error {
- if _, ok := _c.mutation.AnnouncementID(); !ok {
- return &ValidationError{Name: "announcement_id", err: errors.New(`ent: missing required field "AnnouncementRead.announcement_id"`)}
- }
- if _, ok := _c.mutation.UserID(); !ok {
- return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "AnnouncementRead.user_id"`)}
- }
- if _, ok := _c.mutation.ReadAt(); !ok {
- return &ValidationError{Name: "read_at", err: errors.New(`ent: missing required field "AnnouncementRead.read_at"`)}
- }
- if _, ok := _c.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AnnouncementRead.created_at"`)}
- }
- if len(_c.mutation.AnnouncementIDs()) == 0 {
- return &ValidationError{Name: "announcement", err: errors.New(`ent: missing required edge "AnnouncementRead.announcement"`)}
- }
- if len(_c.mutation.UserIDs()) == 0 {
- return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "AnnouncementRead.user"`)}
- }
- return nil
- }
- func (_c *AnnouncementReadCreate) sqlSave(ctx context.Context) (*AnnouncementRead, 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 *AnnouncementReadCreate) createSpec() (*AnnouncementRead, *sqlgraph.CreateSpec) {
- var (
- _node = &AnnouncementRead{config: _c.config}
- _spec = sqlgraph.NewCreateSpec(announcementread.Table, sqlgraph.NewFieldSpec(announcementread.FieldID, field.TypeInt64))
- )
- _spec.OnConflict = _c.conflict
- if value, ok := _c.mutation.ReadAt(); ok {
- _spec.SetField(announcementread.FieldReadAt, field.TypeTime, value)
- _node.ReadAt = value
- }
- if value, ok := _c.mutation.CreatedAt(); ok {
- _spec.SetField(announcementread.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if nodes := _c.mutation.AnnouncementIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: announcementread.AnnouncementTable,
- Columns: []string{announcementread.AnnouncementColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(announcement.FieldID, field.TypeInt64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.AnnouncementID = nodes[0]
- _spec.Edges = append(_spec.Edges, edge)
- }
- if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: announcementread.UserTable,
- Columns: []string{announcementread.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)
- }
- return _node, _spec
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.AnnouncementRead.Create().
- // SetAnnouncementID(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.AnnouncementReadUpsert) {
- // SetAnnouncementID(v+v).
- // }).
- // Exec(ctx)
- func (_c *AnnouncementReadCreate) OnConflict(opts ...sql.ConflictOption) *AnnouncementReadUpsertOne {
- _c.conflict = opts
- return &AnnouncementReadUpsertOne{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.AnnouncementRead.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *AnnouncementReadCreate) OnConflictColumns(columns ...string) *AnnouncementReadUpsertOne {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &AnnouncementReadUpsertOne{
- create: _c,
- }
- }
- type (
- // AnnouncementReadUpsertOne is the builder for "upsert"-ing
- // one AnnouncementRead node.
- AnnouncementReadUpsertOne struct {
- create *AnnouncementReadCreate
- }
- // AnnouncementReadUpsert is the "OnConflict" setter.
- AnnouncementReadUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetAnnouncementID sets the "announcement_id" field.
- func (u *AnnouncementReadUpsert) SetAnnouncementID(v int64) *AnnouncementReadUpsert {
- u.Set(announcementread.FieldAnnouncementID, v)
- return u
- }
- // UpdateAnnouncementID sets the "announcement_id" field to the value that was provided on create.
- func (u *AnnouncementReadUpsert) UpdateAnnouncementID() *AnnouncementReadUpsert {
- u.SetExcluded(announcementread.FieldAnnouncementID)
- return u
- }
- // SetUserID sets the "user_id" field.
- func (u *AnnouncementReadUpsert) SetUserID(v int64) *AnnouncementReadUpsert {
- u.Set(announcementread.FieldUserID, v)
- return u
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *AnnouncementReadUpsert) UpdateUserID() *AnnouncementReadUpsert {
- u.SetExcluded(announcementread.FieldUserID)
- return u
- }
- // SetReadAt sets the "read_at" field.
- func (u *AnnouncementReadUpsert) SetReadAt(v time.Time) *AnnouncementReadUpsert {
- u.Set(announcementread.FieldReadAt, v)
- return u
- }
- // UpdateReadAt sets the "read_at" field to the value that was provided on create.
- func (u *AnnouncementReadUpsert) UpdateReadAt() *AnnouncementReadUpsert {
- u.SetExcluded(announcementread.FieldReadAt)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create.
- // Using this option is equivalent to using:
- //
- // client.AnnouncementRead.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *AnnouncementReadUpsertOne) UpdateNewValues() *AnnouncementReadUpsertOne {
- 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(announcementread.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.AnnouncementRead.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *AnnouncementReadUpsertOne) Ignore() *AnnouncementReadUpsertOne {
- 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 *AnnouncementReadUpsertOne) DoNothing() *AnnouncementReadUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the AnnouncementReadCreate.OnConflict
- // documentation for more info.
- func (u *AnnouncementReadUpsertOne) Update(set func(*AnnouncementReadUpsert)) *AnnouncementReadUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&AnnouncementReadUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetAnnouncementID sets the "announcement_id" field.
- func (u *AnnouncementReadUpsertOne) SetAnnouncementID(v int64) *AnnouncementReadUpsertOne {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.SetAnnouncementID(v)
- })
- }
- // UpdateAnnouncementID sets the "announcement_id" field to the value that was provided on create.
- func (u *AnnouncementReadUpsertOne) UpdateAnnouncementID() *AnnouncementReadUpsertOne {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.UpdateAnnouncementID()
- })
- }
- // SetUserID sets the "user_id" field.
- func (u *AnnouncementReadUpsertOne) SetUserID(v int64) *AnnouncementReadUpsertOne {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.SetUserID(v)
- })
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *AnnouncementReadUpsertOne) UpdateUserID() *AnnouncementReadUpsertOne {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.UpdateUserID()
- })
- }
- // SetReadAt sets the "read_at" field.
- func (u *AnnouncementReadUpsertOne) SetReadAt(v time.Time) *AnnouncementReadUpsertOne {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.SetReadAt(v)
- })
- }
- // UpdateReadAt sets the "read_at" field to the value that was provided on create.
- func (u *AnnouncementReadUpsertOne) UpdateReadAt() *AnnouncementReadUpsertOne {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.UpdateReadAt()
- })
- }
- // Exec executes the query.
- func (u *AnnouncementReadUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for AnnouncementReadCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *AnnouncementReadUpsertOne) 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 *AnnouncementReadUpsertOne) 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 *AnnouncementReadUpsertOne) IDX(ctx context.Context) int64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // AnnouncementReadCreateBulk is the builder for creating many AnnouncementRead entities in bulk.
- type AnnouncementReadCreateBulk struct {
- config
- err error
- builders []*AnnouncementReadCreate
- conflict []sql.ConflictOption
- }
- // Save creates the AnnouncementRead entities in the database.
- func (_c *AnnouncementReadCreateBulk) Save(ctx context.Context) ([]*AnnouncementRead, error) {
- if _c.err != nil {
- return nil, _c.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
- nodes := make([]*AnnouncementRead, 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.(*AnnouncementReadMutation)
- 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 *AnnouncementReadCreateBulk) SaveX(ctx context.Context) []*AnnouncementRead {
- v, err := _c.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (_c *AnnouncementReadCreateBulk) Exec(ctx context.Context) error {
- _, err := _c.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (_c *AnnouncementReadCreateBulk) 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.AnnouncementRead.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.AnnouncementReadUpsert) {
- // SetAnnouncementID(v+v).
- // }).
- // Exec(ctx)
- func (_c *AnnouncementReadCreateBulk) OnConflict(opts ...sql.ConflictOption) *AnnouncementReadUpsertBulk {
- _c.conflict = opts
- return &AnnouncementReadUpsertBulk{
- create: _c,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.AnnouncementRead.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (_c *AnnouncementReadCreateBulk) OnConflictColumns(columns ...string) *AnnouncementReadUpsertBulk {
- _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
- return &AnnouncementReadUpsertBulk{
- create: _c,
- }
- }
- // AnnouncementReadUpsertBulk is the builder for "upsert"-ing
- // a bulk of AnnouncementRead nodes.
- type AnnouncementReadUpsertBulk struct {
- create *AnnouncementReadCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.AnnouncementRead.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // ).
- // Exec(ctx)
- func (u *AnnouncementReadUpsertBulk) UpdateNewValues() *AnnouncementReadUpsertBulk {
- 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(announcementread.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.AnnouncementRead.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *AnnouncementReadUpsertBulk) Ignore() *AnnouncementReadUpsertBulk {
- 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 *AnnouncementReadUpsertBulk) DoNothing() *AnnouncementReadUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the AnnouncementReadCreateBulk.OnConflict
- // documentation for more info.
- func (u *AnnouncementReadUpsertBulk) Update(set func(*AnnouncementReadUpsert)) *AnnouncementReadUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&AnnouncementReadUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetAnnouncementID sets the "announcement_id" field.
- func (u *AnnouncementReadUpsertBulk) SetAnnouncementID(v int64) *AnnouncementReadUpsertBulk {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.SetAnnouncementID(v)
- })
- }
- // UpdateAnnouncementID sets the "announcement_id" field to the value that was provided on create.
- func (u *AnnouncementReadUpsertBulk) UpdateAnnouncementID() *AnnouncementReadUpsertBulk {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.UpdateAnnouncementID()
- })
- }
- // SetUserID sets the "user_id" field.
- func (u *AnnouncementReadUpsertBulk) SetUserID(v int64) *AnnouncementReadUpsertBulk {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.SetUserID(v)
- })
- }
- // UpdateUserID sets the "user_id" field to the value that was provided on create.
- func (u *AnnouncementReadUpsertBulk) UpdateUserID() *AnnouncementReadUpsertBulk {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.UpdateUserID()
- })
- }
- // SetReadAt sets the "read_at" field.
- func (u *AnnouncementReadUpsertBulk) SetReadAt(v time.Time) *AnnouncementReadUpsertBulk {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.SetReadAt(v)
- })
- }
- // UpdateReadAt sets the "read_at" field to the value that was provided on create.
- func (u *AnnouncementReadUpsertBulk) UpdateReadAt() *AnnouncementReadUpsertBulk {
- return u.Update(func(s *AnnouncementReadUpsert) {
- s.UpdateReadAt()
- })
- }
- // Exec executes the query.
- func (u *AnnouncementReadUpsertBulk) 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 AnnouncementReadCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for AnnouncementReadCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *AnnouncementReadUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|