1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/agent"
- "wechat-api/ent/apikey"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // ApiKeyCreate is the builder for creating a ApiKey entity.
- type ApiKeyCreate struct {
- config
- mutation *ApiKeyMutation
- hooks []Hook
- conflict []sql.ConflictOption
- }
- // SetCreatedAt sets the "created_at" field.
- func (akc *ApiKeyCreate) SetCreatedAt(t time.Time) *ApiKeyCreate {
- akc.mutation.SetCreatedAt(t)
- return akc
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableCreatedAt(t *time.Time) *ApiKeyCreate {
- if t != nil {
- akc.SetCreatedAt(*t)
- }
- return akc
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (akc *ApiKeyCreate) SetUpdatedAt(t time.Time) *ApiKeyCreate {
- akc.mutation.SetUpdatedAt(t)
- return akc
- }
- // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableUpdatedAt(t *time.Time) *ApiKeyCreate {
- if t != nil {
- akc.SetUpdatedAt(*t)
- }
- return akc
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (akc *ApiKeyCreate) SetDeletedAt(t time.Time) *ApiKeyCreate {
- akc.mutation.SetDeletedAt(t)
- return akc
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableDeletedAt(t *time.Time) *ApiKeyCreate {
- if t != nil {
- akc.SetDeletedAt(*t)
- }
- return akc
- }
- // SetTitle sets the "title" field.
- func (akc *ApiKeyCreate) SetTitle(s string) *ApiKeyCreate {
- akc.mutation.SetTitle(s)
- return akc
- }
- // SetNillableTitle sets the "title" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableTitle(s *string) *ApiKeyCreate {
- if s != nil {
- akc.SetTitle(*s)
- }
- return akc
- }
- // SetKey sets the "key" field.
- func (akc *ApiKeyCreate) SetKey(s string) *ApiKeyCreate {
- akc.mutation.SetKey(s)
- return akc
- }
- // SetNillableKey sets the "key" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableKey(s *string) *ApiKeyCreate {
- if s != nil {
- akc.SetKey(*s)
- }
- return akc
- }
- // SetOrganizationID sets the "organization_id" field.
- func (akc *ApiKeyCreate) SetOrganizationID(u uint64) *ApiKeyCreate {
- akc.mutation.SetOrganizationID(u)
- return akc
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableOrganizationID(u *uint64) *ApiKeyCreate {
- if u != nil {
- akc.SetOrganizationID(*u)
- }
- return akc
- }
- // SetAgentID sets the "agent_id" field.
- func (akc *ApiKeyCreate) SetAgentID(u uint64) *ApiKeyCreate {
- akc.mutation.SetAgentID(u)
- return akc
- }
- // SetNillableAgentID sets the "agent_id" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableAgentID(u *uint64) *ApiKeyCreate {
- if u != nil {
- akc.SetAgentID(*u)
- }
- return akc
- }
- // SetCustomAgentBase sets the "custom_agent_base" field.
- func (akc *ApiKeyCreate) SetCustomAgentBase(s string) *ApiKeyCreate {
- akc.mutation.SetCustomAgentBase(s)
- return akc
- }
- // SetNillableCustomAgentBase sets the "custom_agent_base" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableCustomAgentBase(s *string) *ApiKeyCreate {
- if s != nil {
- akc.SetCustomAgentBase(*s)
- }
- return akc
- }
- // SetCustomAgentKey sets the "custom_agent_key" field.
- func (akc *ApiKeyCreate) SetCustomAgentKey(s string) *ApiKeyCreate {
- akc.mutation.SetCustomAgentKey(s)
- return akc
- }
- // SetNillableCustomAgentKey sets the "custom_agent_key" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableCustomAgentKey(s *string) *ApiKeyCreate {
- if s != nil {
- akc.SetCustomAgentKey(*s)
- }
- return akc
- }
- // SetOpenaiBase sets the "openai_base" field.
- func (akc *ApiKeyCreate) SetOpenaiBase(s string) *ApiKeyCreate {
- akc.mutation.SetOpenaiBase(s)
- return akc
- }
- // SetNillableOpenaiBase sets the "openai_base" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableOpenaiBase(s *string) *ApiKeyCreate {
- if s != nil {
- akc.SetOpenaiBase(*s)
- }
- return akc
- }
- // SetOpenaiKey sets the "openai_key" field.
- func (akc *ApiKeyCreate) SetOpenaiKey(s string) *ApiKeyCreate {
- akc.mutation.SetOpenaiKey(s)
- return akc
- }
- // SetNillableOpenaiKey sets the "openai_key" field if the given value is not nil.
- func (akc *ApiKeyCreate) SetNillableOpenaiKey(s *string) *ApiKeyCreate {
- if s != nil {
- akc.SetOpenaiKey(*s)
- }
- return akc
- }
- // SetID sets the "id" field.
- func (akc *ApiKeyCreate) SetID(u uint64) *ApiKeyCreate {
- akc.mutation.SetID(u)
- return akc
- }
- // SetAgent sets the "agent" edge to the Agent entity.
- func (akc *ApiKeyCreate) SetAgent(a *Agent) *ApiKeyCreate {
- return akc.SetAgentID(a.ID)
- }
- // Mutation returns the ApiKeyMutation object of the builder.
- func (akc *ApiKeyCreate) Mutation() *ApiKeyMutation {
- return akc.mutation
- }
- // Save creates the ApiKey in the database.
- func (akc *ApiKeyCreate) Save(ctx context.Context) (*ApiKey, error) {
- if err := akc.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, akc.sqlSave, akc.mutation, akc.hooks)
- }
- // SaveX calls Save and panics if Save returns an error.
- func (akc *ApiKeyCreate) SaveX(ctx context.Context) *ApiKey {
- v, err := akc.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (akc *ApiKeyCreate) Exec(ctx context.Context) error {
- _, err := akc.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (akc *ApiKeyCreate) ExecX(ctx context.Context) {
- if err := akc.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (akc *ApiKeyCreate) defaults() error {
- if _, ok := akc.mutation.CreatedAt(); !ok {
- if apikey.DefaultCreatedAt == nil {
- return fmt.Errorf("ent: uninitialized apikey.DefaultCreatedAt (forgotten import ent/runtime?)")
- }
- v := apikey.DefaultCreatedAt()
- akc.mutation.SetCreatedAt(v)
- }
- if _, ok := akc.mutation.UpdatedAt(); !ok {
- if apikey.DefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized apikey.DefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := apikey.DefaultUpdatedAt()
- akc.mutation.SetUpdatedAt(v)
- }
- if _, ok := akc.mutation.Title(); !ok {
- v := apikey.DefaultTitle
- akc.mutation.SetTitle(v)
- }
- if _, ok := akc.mutation.Key(); !ok {
- v := apikey.DefaultKey
- akc.mutation.SetKey(v)
- }
- if _, ok := akc.mutation.OrganizationID(); !ok {
- v := apikey.DefaultOrganizationID
- akc.mutation.SetOrganizationID(v)
- }
- if _, ok := akc.mutation.AgentID(); !ok {
- v := apikey.DefaultAgentID
- akc.mutation.SetAgentID(v)
- }
- if _, ok := akc.mutation.CustomAgentBase(); !ok {
- v := apikey.DefaultCustomAgentBase
- akc.mutation.SetCustomAgentBase(v)
- }
- if _, ok := akc.mutation.CustomAgentKey(); !ok {
- v := apikey.DefaultCustomAgentKey
- akc.mutation.SetCustomAgentKey(v)
- }
- if _, ok := akc.mutation.OpenaiBase(); !ok {
- v := apikey.DefaultOpenaiBase
- akc.mutation.SetOpenaiBase(v)
- }
- if _, ok := akc.mutation.OpenaiKey(); !ok {
- v := apikey.DefaultOpenaiKey
- akc.mutation.SetOpenaiKey(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (akc *ApiKeyCreate) check() error {
- if _, ok := akc.mutation.CreatedAt(); !ok {
- return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "ApiKey.created_at"`)}
- }
- if _, ok := akc.mutation.UpdatedAt(); !ok {
- return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "ApiKey.updated_at"`)}
- }
- if _, ok := akc.mutation.OrganizationID(); !ok {
- return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "ApiKey.organization_id"`)}
- }
- if _, ok := akc.mutation.AgentID(); !ok {
- return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "ApiKey.agent_id"`)}
- }
- if _, ok := akc.mutation.AgentID(); !ok {
- return &ValidationError{Name: "agent", err: errors.New(`ent: missing required edge "ApiKey.agent"`)}
- }
- return nil
- }
- func (akc *ApiKeyCreate) sqlSave(ctx context.Context) (*ApiKey, error) {
- if err := akc.check(); err != nil {
- return nil, err
- }
- _node, _spec := akc.createSpec()
- if err := sqlgraph.CreateNode(ctx, akc.driver, _spec); err != nil {
- if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- if _spec.ID.Value != _node.ID {
- id := _spec.ID.Value.(int64)
- _node.ID = uint64(id)
- }
- akc.mutation.id = &_node.ID
- akc.mutation.done = true
- return _node, nil
- }
- func (akc *ApiKeyCreate) createSpec() (*ApiKey, *sqlgraph.CreateSpec) {
- var (
- _node = &ApiKey{config: akc.config}
- _spec = sqlgraph.NewCreateSpec(apikey.Table, sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeUint64))
- )
- _spec.OnConflict = akc.conflict
- if id, ok := akc.mutation.ID(); ok {
- _node.ID = id
- _spec.ID.Value = id
- }
- if value, ok := akc.mutation.CreatedAt(); ok {
- _spec.SetField(apikey.FieldCreatedAt, field.TypeTime, value)
- _node.CreatedAt = value
- }
- if value, ok := akc.mutation.UpdatedAt(); ok {
- _spec.SetField(apikey.FieldUpdatedAt, field.TypeTime, value)
- _node.UpdatedAt = value
- }
- if value, ok := akc.mutation.DeletedAt(); ok {
- _spec.SetField(apikey.FieldDeletedAt, field.TypeTime, value)
- _node.DeletedAt = value
- }
- if value, ok := akc.mutation.Title(); ok {
- _spec.SetField(apikey.FieldTitle, field.TypeString, value)
- _node.Title = value
- }
- if value, ok := akc.mutation.Key(); ok {
- _spec.SetField(apikey.FieldKey, field.TypeString, value)
- _node.Key = value
- }
- if value, ok := akc.mutation.OrganizationID(); ok {
- _spec.SetField(apikey.FieldOrganizationID, field.TypeUint64, value)
- _node.OrganizationID = value
- }
- if value, ok := akc.mutation.CustomAgentBase(); ok {
- _spec.SetField(apikey.FieldCustomAgentBase, field.TypeString, value)
- _node.CustomAgentBase = value
- }
- if value, ok := akc.mutation.CustomAgentKey(); ok {
- _spec.SetField(apikey.FieldCustomAgentKey, field.TypeString, value)
- _node.CustomAgentKey = value
- }
- if value, ok := akc.mutation.OpenaiBase(); ok {
- _spec.SetField(apikey.FieldOpenaiBase, field.TypeString, value)
- _node.OpenaiBase = value
- }
- if value, ok := akc.mutation.OpenaiKey(); ok {
- _spec.SetField(apikey.FieldOpenaiKey, field.TypeString, value)
- _node.OpenaiKey = value
- }
- if nodes := akc.mutation.AgentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: apikey.AgentTable,
- Columns: []string{apikey.AgentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _node.AgentID = 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.ApiKey.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.ApiKeyUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (akc *ApiKeyCreate) OnConflict(opts ...sql.ConflictOption) *ApiKeyUpsertOne {
- akc.conflict = opts
- return &ApiKeyUpsertOne{
- create: akc,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.ApiKey.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (akc *ApiKeyCreate) OnConflictColumns(columns ...string) *ApiKeyUpsertOne {
- akc.conflict = append(akc.conflict, sql.ConflictColumns(columns...))
- return &ApiKeyUpsertOne{
- create: akc,
- }
- }
- type (
- // ApiKeyUpsertOne is the builder for "upsert"-ing
- // one ApiKey node.
- ApiKeyUpsertOne struct {
- create *ApiKeyCreate
- }
- // ApiKeyUpsert is the "OnConflict" setter.
- ApiKeyUpsert struct {
- *sql.UpdateSet
- }
- )
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ApiKeyUpsert) SetUpdatedAt(v time.Time) *ApiKeyUpsert {
- u.Set(apikey.FieldUpdatedAt, v)
- return u
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateUpdatedAt() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldUpdatedAt)
- return u
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *ApiKeyUpsert) SetDeletedAt(v time.Time) *ApiKeyUpsert {
- u.Set(apikey.FieldDeletedAt, v)
- return u
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateDeletedAt() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldDeletedAt)
- return u
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *ApiKeyUpsert) ClearDeletedAt() *ApiKeyUpsert {
- u.SetNull(apikey.FieldDeletedAt)
- return u
- }
- // SetTitle sets the "title" field.
- func (u *ApiKeyUpsert) SetTitle(v string) *ApiKeyUpsert {
- u.Set(apikey.FieldTitle, v)
- return u
- }
- // UpdateTitle sets the "title" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateTitle() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldTitle)
- return u
- }
- // ClearTitle clears the value of the "title" field.
- func (u *ApiKeyUpsert) ClearTitle() *ApiKeyUpsert {
- u.SetNull(apikey.FieldTitle)
- return u
- }
- // SetKey sets the "key" field.
- func (u *ApiKeyUpsert) SetKey(v string) *ApiKeyUpsert {
- u.Set(apikey.FieldKey, v)
- return u
- }
- // UpdateKey sets the "key" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateKey() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldKey)
- return u
- }
- // ClearKey clears the value of the "key" field.
- func (u *ApiKeyUpsert) ClearKey() *ApiKeyUpsert {
- u.SetNull(apikey.FieldKey)
- return u
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *ApiKeyUpsert) SetOrganizationID(v uint64) *ApiKeyUpsert {
- u.Set(apikey.FieldOrganizationID, v)
- return u
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateOrganizationID() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldOrganizationID)
- return u
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *ApiKeyUpsert) AddOrganizationID(v uint64) *ApiKeyUpsert {
- u.Add(apikey.FieldOrganizationID, v)
- return u
- }
- // SetAgentID sets the "agent_id" field.
- func (u *ApiKeyUpsert) SetAgentID(v uint64) *ApiKeyUpsert {
- u.Set(apikey.FieldAgentID, v)
- return u
- }
- // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateAgentID() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldAgentID)
- return u
- }
- // SetCustomAgentBase sets the "custom_agent_base" field.
- func (u *ApiKeyUpsert) SetCustomAgentBase(v string) *ApiKeyUpsert {
- u.Set(apikey.FieldCustomAgentBase, v)
- return u
- }
- // UpdateCustomAgentBase sets the "custom_agent_base" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateCustomAgentBase() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldCustomAgentBase)
- return u
- }
- // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
- func (u *ApiKeyUpsert) ClearCustomAgentBase() *ApiKeyUpsert {
- u.SetNull(apikey.FieldCustomAgentBase)
- return u
- }
- // SetCustomAgentKey sets the "custom_agent_key" field.
- func (u *ApiKeyUpsert) SetCustomAgentKey(v string) *ApiKeyUpsert {
- u.Set(apikey.FieldCustomAgentKey, v)
- return u
- }
- // UpdateCustomAgentKey sets the "custom_agent_key" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateCustomAgentKey() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldCustomAgentKey)
- return u
- }
- // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
- func (u *ApiKeyUpsert) ClearCustomAgentKey() *ApiKeyUpsert {
- u.SetNull(apikey.FieldCustomAgentKey)
- return u
- }
- // SetOpenaiBase sets the "openai_base" field.
- func (u *ApiKeyUpsert) SetOpenaiBase(v string) *ApiKeyUpsert {
- u.Set(apikey.FieldOpenaiBase, v)
- return u
- }
- // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateOpenaiBase() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldOpenaiBase)
- return u
- }
- // ClearOpenaiBase clears the value of the "openai_base" field.
- func (u *ApiKeyUpsert) ClearOpenaiBase() *ApiKeyUpsert {
- u.SetNull(apikey.FieldOpenaiBase)
- return u
- }
- // SetOpenaiKey sets the "openai_key" field.
- func (u *ApiKeyUpsert) SetOpenaiKey(v string) *ApiKeyUpsert {
- u.Set(apikey.FieldOpenaiKey, v)
- return u
- }
- // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
- func (u *ApiKeyUpsert) UpdateOpenaiKey() *ApiKeyUpsert {
- u.SetExcluded(apikey.FieldOpenaiKey)
- return u
- }
- // ClearOpenaiKey clears the value of the "openai_key" field.
- func (u *ApiKeyUpsert) ClearOpenaiKey() *ApiKeyUpsert {
- u.SetNull(apikey.FieldOpenaiKey)
- return u
- }
- // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
- // Using this option is equivalent to using:
- //
- // client.ApiKey.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(apikey.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *ApiKeyUpsertOne) UpdateNewValues() *ApiKeyUpsertOne {
- 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.ID(); exists {
- s.SetIgnore(apikey.FieldID)
- }
- if _, exists := u.create.mutation.CreatedAt(); exists {
- s.SetIgnore(apikey.FieldCreatedAt)
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.ApiKey.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ApiKeyUpsertOne) Ignore() *ApiKeyUpsertOne {
- 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 *ApiKeyUpsertOne) DoNothing() *ApiKeyUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ApiKeyCreate.OnConflict
- // documentation for more info.
- func (u *ApiKeyUpsertOne) Update(set func(*ApiKeyUpsert)) *ApiKeyUpsertOne {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ApiKeyUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ApiKeyUpsertOne) SetUpdatedAt(v time.Time) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateUpdatedAt() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *ApiKeyUpsertOne) SetDeletedAt(v time.Time) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateDeletedAt() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *ApiKeyUpsertOne) ClearDeletedAt() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetTitle sets the "title" field.
- func (u *ApiKeyUpsertOne) SetTitle(v string) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetTitle(v)
- })
- }
- // UpdateTitle sets the "title" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateTitle() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateTitle()
- })
- }
- // ClearTitle clears the value of the "title" field.
- func (u *ApiKeyUpsertOne) ClearTitle() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearTitle()
- })
- }
- // SetKey sets the "key" field.
- func (u *ApiKeyUpsertOne) SetKey(v string) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetKey(v)
- })
- }
- // UpdateKey sets the "key" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateKey() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateKey()
- })
- }
- // ClearKey clears the value of the "key" field.
- func (u *ApiKeyUpsertOne) ClearKey() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearKey()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *ApiKeyUpsertOne) SetOrganizationID(v uint64) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *ApiKeyUpsertOne) AddOrganizationID(v uint64) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateOrganizationID() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetAgentID sets the "agent_id" field.
- func (u *ApiKeyUpsertOne) SetAgentID(v uint64) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetAgentID(v)
- })
- }
- // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateAgentID() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateAgentID()
- })
- }
- // SetCustomAgentBase sets the "custom_agent_base" field.
- func (u *ApiKeyUpsertOne) SetCustomAgentBase(v string) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetCustomAgentBase(v)
- })
- }
- // UpdateCustomAgentBase sets the "custom_agent_base" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateCustomAgentBase() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateCustomAgentBase()
- })
- }
- // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
- func (u *ApiKeyUpsertOne) ClearCustomAgentBase() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearCustomAgentBase()
- })
- }
- // SetCustomAgentKey sets the "custom_agent_key" field.
- func (u *ApiKeyUpsertOne) SetCustomAgentKey(v string) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetCustomAgentKey(v)
- })
- }
- // UpdateCustomAgentKey sets the "custom_agent_key" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateCustomAgentKey() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateCustomAgentKey()
- })
- }
- // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
- func (u *ApiKeyUpsertOne) ClearCustomAgentKey() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearCustomAgentKey()
- })
- }
- // SetOpenaiBase sets the "openai_base" field.
- func (u *ApiKeyUpsertOne) SetOpenaiBase(v string) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetOpenaiBase(v)
- })
- }
- // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateOpenaiBase() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateOpenaiBase()
- })
- }
- // ClearOpenaiBase clears the value of the "openai_base" field.
- func (u *ApiKeyUpsertOne) ClearOpenaiBase() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearOpenaiBase()
- })
- }
- // SetOpenaiKey sets the "openai_key" field.
- func (u *ApiKeyUpsertOne) SetOpenaiKey(v string) *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetOpenaiKey(v)
- })
- }
- // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
- func (u *ApiKeyUpsertOne) UpdateOpenaiKey() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateOpenaiKey()
- })
- }
- // ClearOpenaiKey clears the value of the "openai_key" field.
- func (u *ApiKeyUpsertOne) ClearOpenaiKey() *ApiKeyUpsertOne {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearOpenaiKey()
- })
- }
- // Exec executes the query.
- func (u *ApiKeyUpsertOne) Exec(ctx context.Context) error {
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ApiKeyCreate.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ApiKeyUpsertOne) 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 *ApiKeyUpsertOne) ID(ctx context.Context) (id uint64, 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 *ApiKeyUpsertOne) IDX(ctx context.Context) uint64 {
- id, err := u.ID(ctx)
- if err != nil {
- panic(err)
- }
- return id
- }
- // ApiKeyCreateBulk is the builder for creating many ApiKey entities in bulk.
- type ApiKeyCreateBulk struct {
- config
- err error
- builders []*ApiKeyCreate
- conflict []sql.ConflictOption
- }
- // Save creates the ApiKey entities in the database.
- func (akcb *ApiKeyCreateBulk) Save(ctx context.Context) ([]*ApiKey, error) {
- if akcb.err != nil {
- return nil, akcb.err
- }
- specs := make([]*sqlgraph.CreateSpec, len(akcb.builders))
- nodes := make([]*ApiKey, len(akcb.builders))
- mutators := make([]Mutator, len(akcb.builders))
- for i := range akcb.builders {
- func(i int, root context.Context) {
- builder := akcb.builders[i]
- builder.defaults()
- var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
- mutation, ok := m.(*ApiKeyMutation)
- 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, akcb.builders[i+1].mutation)
- } else {
- spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
- spec.OnConflict = akcb.conflict
- // Invoke the actual operation on the latest mutation in the chain.
- if err = sqlgraph.BatchCreate(ctx, akcb.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 && nodes[i].ID == 0 {
- id := specs[i].ID.Value.(int64)
- nodes[i].ID = uint64(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, akcb.builders[0].mutation); err != nil {
- return nil, err
- }
- }
- return nodes, nil
- }
- // SaveX is like Save, but panics if an error occurs.
- func (akcb *ApiKeyCreateBulk) SaveX(ctx context.Context) []*ApiKey {
- v, err := akcb.Save(ctx)
- if err != nil {
- panic(err)
- }
- return v
- }
- // Exec executes the query.
- func (akcb *ApiKeyCreateBulk) Exec(ctx context.Context) error {
- _, err := akcb.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (akcb *ApiKeyCreateBulk) ExecX(ctx context.Context) {
- if err := akcb.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
- // of the `INSERT` statement. For example:
- //
- // client.ApiKey.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.ApiKeyUpsert) {
- // SetCreatedAt(v+v).
- // }).
- // Exec(ctx)
- func (akcb *ApiKeyCreateBulk) OnConflict(opts ...sql.ConflictOption) *ApiKeyUpsertBulk {
- akcb.conflict = opts
- return &ApiKeyUpsertBulk{
- create: akcb,
- }
- }
- // OnConflictColumns calls `OnConflict` and configures the columns
- // as conflict target. Using this option is equivalent to using:
- //
- // client.ApiKey.Create().
- // OnConflict(sql.ConflictColumns(columns...)).
- // Exec(ctx)
- func (akcb *ApiKeyCreateBulk) OnConflictColumns(columns ...string) *ApiKeyUpsertBulk {
- akcb.conflict = append(akcb.conflict, sql.ConflictColumns(columns...))
- return &ApiKeyUpsertBulk{
- create: akcb,
- }
- }
- // ApiKeyUpsertBulk is the builder for "upsert"-ing
- // a bulk of ApiKey nodes.
- type ApiKeyUpsertBulk struct {
- create *ApiKeyCreateBulk
- }
- // UpdateNewValues updates the mutable fields using the new values that
- // were set on create. Using this option is equivalent to using:
- //
- // client.ApiKey.Create().
- // OnConflict(
- // sql.ResolveWithNewValues(),
- // sql.ResolveWith(func(u *sql.UpdateSet) {
- // u.SetIgnore(apikey.FieldID)
- // }),
- // ).
- // Exec(ctx)
- func (u *ApiKeyUpsertBulk) UpdateNewValues() *ApiKeyUpsertBulk {
- 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.ID(); exists {
- s.SetIgnore(apikey.FieldID)
- }
- if _, exists := b.mutation.CreatedAt(); exists {
- s.SetIgnore(apikey.FieldCreatedAt)
- }
- }
- }))
- return u
- }
- // Ignore sets each column to itself in case of conflict.
- // Using this option is equivalent to using:
- //
- // client.ApiKey.Create().
- // OnConflict(sql.ResolveWithIgnore()).
- // Exec(ctx)
- func (u *ApiKeyUpsertBulk) Ignore() *ApiKeyUpsertBulk {
- 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 *ApiKeyUpsertBulk) DoNothing() *ApiKeyUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.DoNothing())
- return u
- }
- // Update allows overriding fields `UPDATE` values. See the ApiKeyCreateBulk.OnConflict
- // documentation for more info.
- func (u *ApiKeyUpsertBulk) Update(set func(*ApiKeyUpsert)) *ApiKeyUpsertBulk {
- u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
- set(&ApiKeyUpsert{UpdateSet: update})
- }))
- return u
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (u *ApiKeyUpsertBulk) SetUpdatedAt(v time.Time) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetUpdatedAt(v)
- })
- }
- // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateUpdatedAt() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateUpdatedAt()
- })
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (u *ApiKeyUpsertBulk) SetDeletedAt(v time.Time) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetDeletedAt(v)
- })
- }
- // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateDeletedAt() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateDeletedAt()
- })
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (u *ApiKeyUpsertBulk) ClearDeletedAt() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearDeletedAt()
- })
- }
- // SetTitle sets the "title" field.
- func (u *ApiKeyUpsertBulk) SetTitle(v string) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetTitle(v)
- })
- }
- // UpdateTitle sets the "title" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateTitle() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateTitle()
- })
- }
- // ClearTitle clears the value of the "title" field.
- func (u *ApiKeyUpsertBulk) ClearTitle() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearTitle()
- })
- }
- // SetKey sets the "key" field.
- func (u *ApiKeyUpsertBulk) SetKey(v string) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetKey(v)
- })
- }
- // UpdateKey sets the "key" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateKey() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateKey()
- })
- }
- // ClearKey clears the value of the "key" field.
- func (u *ApiKeyUpsertBulk) ClearKey() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearKey()
- })
- }
- // SetOrganizationID sets the "organization_id" field.
- func (u *ApiKeyUpsertBulk) SetOrganizationID(v uint64) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetOrganizationID(v)
- })
- }
- // AddOrganizationID adds v to the "organization_id" field.
- func (u *ApiKeyUpsertBulk) AddOrganizationID(v uint64) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.AddOrganizationID(v)
- })
- }
- // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateOrganizationID() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateOrganizationID()
- })
- }
- // SetAgentID sets the "agent_id" field.
- func (u *ApiKeyUpsertBulk) SetAgentID(v uint64) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetAgentID(v)
- })
- }
- // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateAgentID() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateAgentID()
- })
- }
- // SetCustomAgentBase sets the "custom_agent_base" field.
- func (u *ApiKeyUpsertBulk) SetCustomAgentBase(v string) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetCustomAgentBase(v)
- })
- }
- // UpdateCustomAgentBase sets the "custom_agent_base" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateCustomAgentBase() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateCustomAgentBase()
- })
- }
- // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
- func (u *ApiKeyUpsertBulk) ClearCustomAgentBase() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearCustomAgentBase()
- })
- }
- // SetCustomAgentKey sets the "custom_agent_key" field.
- func (u *ApiKeyUpsertBulk) SetCustomAgentKey(v string) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetCustomAgentKey(v)
- })
- }
- // UpdateCustomAgentKey sets the "custom_agent_key" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateCustomAgentKey() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateCustomAgentKey()
- })
- }
- // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
- func (u *ApiKeyUpsertBulk) ClearCustomAgentKey() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearCustomAgentKey()
- })
- }
- // SetOpenaiBase sets the "openai_base" field.
- func (u *ApiKeyUpsertBulk) SetOpenaiBase(v string) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetOpenaiBase(v)
- })
- }
- // UpdateOpenaiBase sets the "openai_base" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateOpenaiBase() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateOpenaiBase()
- })
- }
- // ClearOpenaiBase clears the value of the "openai_base" field.
- func (u *ApiKeyUpsertBulk) ClearOpenaiBase() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearOpenaiBase()
- })
- }
- // SetOpenaiKey sets the "openai_key" field.
- func (u *ApiKeyUpsertBulk) SetOpenaiKey(v string) *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.SetOpenaiKey(v)
- })
- }
- // UpdateOpenaiKey sets the "openai_key" field to the value that was provided on create.
- func (u *ApiKeyUpsertBulk) UpdateOpenaiKey() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.UpdateOpenaiKey()
- })
- }
- // ClearOpenaiKey clears the value of the "openai_key" field.
- func (u *ApiKeyUpsertBulk) ClearOpenaiKey() *ApiKeyUpsertBulk {
- return u.Update(func(s *ApiKeyUpsert) {
- s.ClearOpenaiKey()
- })
- }
- // Exec executes the query.
- func (u *ApiKeyUpsertBulk) 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 ApiKeyCreateBulk instead", i)
- }
- }
- if len(u.create.conflict) == 0 {
- return errors.New("ent: missing options for ApiKeyCreateBulk.OnConflict")
- }
- return u.create.Exec(ctx)
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (u *ApiKeyUpsertBulk) ExecX(ctx context.Context) {
- if err := u.create.Exec(ctx); err != nil {
- panic(err)
- }
- }
|