mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-23 04:09:15 +08:00
1609 lines
48 KiB
Go
1609 lines
48 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect"
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/chaitin/MonkeyCode/backend/consts"
|
|
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
|
|
"github.com/chaitin/MonkeyCode/backend/db/project"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projecttask"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/chaitin/MonkeyCode/backend/db/virtualmachine"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// GitIdentityCreate is the builder for creating a GitIdentity entity.
|
|
type GitIdentityCreate struct {
|
|
config
|
|
mutation *GitIdentityMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *GitIdentityCreate) SetDeletedAt(v time.Time) *GitIdentityCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableDeletedAt(v *time.Time) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_c *GitIdentityCreate) SetUserID(v uuid.UUID) *GitIdentityCreate {
|
|
_c.mutation.SetUserID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetPlatform sets the "platform" field.
|
|
func (_c *GitIdentityCreate) SetPlatform(v consts.GitPlatform) *GitIdentityCreate {
|
|
_c.mutation.SetPlatform(v)
|
|
return _c
|
|
}
|
|
|
|
// SetBaseURL sets the "base_url" field.
|
|
func (_c *GitIdentityCreate) SetBaseURL(v string) *GitIdentityCreate {
|
|
_c.mutation.SetBaseURL(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableBaseURL sets the "base_url" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableBaseURL(v *string) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetBaseURL(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAccessToken sets the "access_token" field.
|
|
func (_c *GitIdentityCreate) SetAccessToken(v string) *GitIdentityCreate {
|
|
_c.mutation.SetAccessToken(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableAccessToken sets the "access_token" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableAccessToken(v *string) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetAccessToken(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (_c *GitIdentityCreate) SetUsername(v string) *GitIdentityCreate {
|
|
_c.mutation.SetUsername(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUsername sets the "username" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableUsername(v *string) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetUsername(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_c *GitIdentityCreate) SetEmail(v string) *GitIdentityCreate {
|
|
_c.mutation.SetEmail(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableEmail(v *string) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetEmail(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetInstallationID sets the "installation_id" field.
|
|
func (_c *GitIdentityCreate) SetInstallationID(v int64) *GitIdentityCreate {
|
|
_c.mutation.SetInstallationID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableInstallationID sets the "installation_id" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableInstallationID(v *int64) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetInstallationID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetOrganizationID sets the "organization_id" field.
|
|
func (_c *GitIdentityCreate) SetOrganizationID(v string) *GitIdentityCreate {
|
|
_c.mutation.SetOrganizationID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableOrganizationID(v *string) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetOrganizationID(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (_c *GitIdentityCreate) SetRemark(v string) *GitIdentityCreate {
|
|
_c.mutation.SetRemark(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableRemark sets the "remark" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableRemark(v *string) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetRemark(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetOauthRefreshToken sets the "oauth_refresh_token" field.
|
|
func (_c *GitIdentityCreate) SetOauthRefreshToken(v string) *GitIdentityCreate {
|
|
_c.mutation.SetOauthRefreshToken(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableOauthRefreshToken sets the "oauth_refresh_token" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableOauthRefreshToken(v *string) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetOauthRefreshToken(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetOauthExpiresAt sets the "oauth_expires_at" field.
|
|
func (_c *GitIdentityCreate) SetOauthExpiresAt(v time.Time) *GitIdentityCreate {
|
|
_c.mutation.SetOauthExpiresAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableOauthExpiresAt sets the "oauth_expires_at" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableOauthExpiresAt(v *time.Time) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetOauthExpiresAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *GitIdentityCreate) SetCreatedAt(v time.Time) *GitIdentityCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableCreatedAt(v *time.Time) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *GitIdentityCreate) SetUpdatedAt(v time.Time) *GitIdentityCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *GitIdentityCreate) SetNillableUpdatedAt(v *time.Time) *GitIdentityCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *GitIdentityCreate) SetID(v uuid.UUID) *GitIdentityCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_c *GitIdentityCreate) SetUser(v *User) *GitIdentityCreate {
|
|
return _c.SetUserID(v.ID)
|
|
}
|
|
|
|
// AddProjectIDs adds the "projects" edge to the Project entity by IDs.
|
|
func (_c *GitIdentityCreate) AddProjectIDs(ids ...uuid.UUID) *GitIdentityCreate {
|
|
_c.mutation.AddProjectIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddProjects adds the "projects" edges to the Project entity.
|
|
func (_c *GitIdentityCreate) AddProjects(v ...*Project) *GitIdentityCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddProjectIDs(ids...)
|
|
}
|
|
|
|
// AddProjectTaskIDs adds the "project_tasks" edge to the ProjectTask entity by IDs.
|
|
func (_c *GitIdentityCreate) AddProjectTaskIDs(ids ...uuid.UUID) *GitIdentityCreate {
|
|
_c.mutation.AddProjectTaskIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddProjectTasks adds the "project_tasks" edges to the ProjectTask entity.
|
|
func (_c *GitIdentityCreate) AddProjectTasks(v ...*ProjectTask) *GitIdentityCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddProjectTaskIDs(ids...)
|
|
}
|
|
|
|
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by IDs.
|
|
func (_c *GitIdentityCreate) AddVMIDs(ids ...string) *GitIdentityCreate {
|
|
_c.mutation.AddVMIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddVms adds the "vms" edges to the VirtualMachine entity.
|
|
func (_c *GitIdentityCreate) AddVms(v ...*VirtualMachine) *GitIdentityCreate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddVMIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the GitIdentityMutation object of the builder.
|
|
func (_c *GitIdentityCreate) Mutation() *GitIdentityMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the GitIdentity in the database.
|
|
func (_c *GitIdentityCreate) Save(ctx context.Context) (*GitIdentity, 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 *GitIdentityCreate) SaveX(ctx context.Context) *GitIdentity {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *GitIdentityCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *GitIdentityCreate) 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 *GitIdentityCreate) defaults() error {
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
if gitidentity.DefaultCreatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized gitidentity.DefaultCreatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := gitidentity.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
if gitidentity.DefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized gitidentity.DefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := gitidentity.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *GitIdentityCreate) check() error {
|
|
if _, ok := _c.mutation.UserID(); !ok {
|
|
return &ValidationError{Name: "user_id", err: errors.New(`db: missing required field "GitIdentity.user_id"`)}
|
|
}
|
|
if _, ok := _c.mutation.Platform(); !ok {
|
|
return &ValidationError{Name: "platform", err: errors.New(`db: missing required field "GitIdentity.platform"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "GitIdentity.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "GitIdentity.updated_at"`)}
|
|
}
|
|
if len(_c.mutation.UserIDs()) == 0 {
|
|
return &ValidationError{Name: "user", err: errors.New(`db: missing required edge "GitIdentity.user"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *GitIdentityCreate) sqlSave(ctx context.Context) (*GitIdentity, 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
|
|
}
|
|
if _spec.ID.Value != nil {
|
|
if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
|
|
_node.ID = *id
|
|
} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
_c.mutation.id = &_node.ID
|
|
_c.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
func (_c *GitIdentityCreate) createSpec() (*GitIdentity, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &GitIdentity{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(gitidentity.Table, sqlgraph.NewFieldSpec(gitidentity.FieldID, field.TypeUUID))
|
|
)
|
|
_spec.OnConflict = _c.conflict
|
|
if id, ok := _c.mutation.ID(); ok {
|
|
_node.ID = id
|
|
_spec.ID.Value = &id
|
|
}
|
|
if value, ok := _c.mutation.DeletedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.Platform(); ok {
|
|
_spec.SetField(gitidentity.FieldPlatform, field.TypeString, value)
|
|
_node.Platform = value
|
|
}
|
|
if value, ok := _c.mutation.BaseURL(); ok {
|
|
_spec.SetField(gitidentity.FieldBaseURL, field.TypeString, value)
|
|
_node.BaseURL = value
|
|
}
|
|
if value, ok := _c.mutation.AccessToken(); ok {
|
|
_spec.SetField(gitidentity.FieldAccessToken, field.TypeString, value)
|
|
_node.AccessToken = value
|
|
}
|
|
if value, ok := _c.mutation.Username(); ok {
|
|
_spec.SetField(gitidentity.FieldUsername, field.TypeString, value)
|
|
_node.Username = value
|
|
}
|
|
if value, ok := _c.mutation.Email(); ok {
|
|
_spec.SetField(gitidentity.FieldEmail, field.TypeString, value)
|
|
_node.Email = value
|
|
}
|
|
if value, ok := _c.mutation.InstallationID(); ok {
|
|
_spec.SetField(gitidentity.FieldInstallationID, field.TypeInt64, value)
|
|
_node.InstallationID = value
|
|
}
|
|
if value, ok := _c.mutation.OrganizationID(); ok {
|
|
_spec.SetField(gitidentity.FieldOrganizationID, field.TypeString, value)
|
|
_node.OrganizationID = value
|
|
}
|
|
if value, ok := _c.mutation.Remark(); ok {
|
|
_spec.SetField(gitidentity.FieldRemark, field.TypeString, value)
|
|
_node.Remark = value
|
|
}
|
|
if value, ok := _c.mutation.OauthRefreshToken(); ok {
|
|
_spec.SetField(gitidentity.FieldOauthRefreshToken, field.TypeString, value)
|
|
_node.OauthRefreshToken = value
|
|
}
|
|
if value, ok := _c.mutation.OauthExpiresAt(); ok {
|
|
_spec.SetField(gitidentity.FieldOauthExpiresAt, field.TypeTime, value)
|
|
_node.OauthExpiresAt = &value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(gitidentity.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: gitidentity.UserTable,
|
|
Columns: []string{gitidentity.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
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.ProjectsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectsTable,
|
|
Columns: []string{gitidentity.ProjectsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(project.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.ProjectTasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.ProjectTasksTable,
|
|
Columns: []string{gitidentity.ProjectTasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projecttask.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.VmsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: gitidentity.VmsTable,
|
|
Columns: []string{gitidentity.VmsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(virtualmachine.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
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.GitIdentity.Create().
|
|
// SetDeletedAt(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.GitIdentityUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *GitIdentityCreate) OnConflict(opts ...sql.ConflictOption) *GitIdentityUpsertOne {
|
|
_c.conflict = opts
|
|
return &GitIdentityUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.GitIdentity.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *GitIdentityCreate) OnConflictColumns(columns ...string) *GitIdentityUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &GitIdentityUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// GitIdentityUpsertOne is the builder for "upsert"-ing
|
|
// one GitIdentity node.
|
|
GitIdentityUpsertOne struct {
|
|
create *GitIdentityCreate
|
|
}
|
|
|
|
// GitIdentityUpsert is the "OnConflict" setter.
|
|
GitIdentityUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *GitIdentityUpsert) SetDeletedAt(v time.Time) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldDeletedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateDeletedAt() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *GitIdentityUpsert) ClearDeletedAt() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *GitIdentityUpsert) SetUserID(v uuid.UUID) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldUserID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateUserID() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldUserID)
|
|
return u
|
|
}
|
|
|
|
// SetPlatform sets the "platform" field.
|
|
func (u *GitIdentityUpsert) SetPlatform(v consts.GitPlatform) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldPlatform, v)
|
|
return u
|
|
}
|
|
|
|
// UpdatePlatform sets the "platform" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdatePlatform() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldPlatform)
|
|
return u
|
|
}
|
|
|
|
// SetBaseURL sets the "base_url" field.
|
|
func (u *GitIdentityUpsert) SetBaseURL(v string) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldBaseURL, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateBaseURL sets the "base_url" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateBaseURL() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldBaseURL)
|
|
return u
|
|
}
|
|
|
|
// ClearBaseURL clears the value of the "base_url" field.
|
|
func (u *GitIdentityUpsert) ClearBaseURL() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldBaseURL)
|
|
return u
|
|
}
|
|
|
|
// SetAccessToken sets the "access_token" field.
|
|
func (u *GitIdentityUpsert) SetAccessToken(v string) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldAccessToken, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateAccessToken sets the "access_token" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateAccessToken() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldAccessToken)
|
|
return u
|
|
}
|
|
|
|
// ClearAccessToken clears the value of the "access_token" field.
|
|
func (u *GitIdentityUpsert) ClearAccessToken() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldAccessToken)
|
|
return u
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (u *GitIdentityUpsert) SetUsername(v string) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldUsername, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUsername sets the "username" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateUsername() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldUsername)
|
|
return u
|
|
}
|
|
|
|
// ClearUsername clears the value of the "username" field.
|
|
func (u *GitIdentityUpsert) ClearUsername() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldUsername)
|
|
return u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *GitIdentityUpsert) SetEmail(v string) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldEmail, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateEmail() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldEmail)
|
|
return u
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *GitIdentityUpsert) ClearEmail() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldEmail)
|
|
return u
|
|
}
|
|
|
|
// SetInstallationID sets the "installation_id" field.
|
|
func (u *GitIdentityUpsert) SetInstallationID(v int64) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldInstallationID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateInstallationID sets the "installation_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateInstallationID() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldInstallationID)
|
|
return u
|
|
}
|
|
|
|
// AddInstallationID adds v to the "installation_id" field.
|
|
func (u *GitIdentityUpsert) AddInstallationID(v int64) *GitIdentityUpsert {
|
|
u.Add(gitidentity.FieldInstallationID, v)
|
|
return u
|
|
}
|
|
|
|
// ClearInstallationID clears the value of the "installation_id" field.
|
|
func (u *GitIdentityUpsert) ClearInstallationID() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldInstallationID)
|
|
return u
|
|
}
|
|
|
|
// SetOrganizationID sets the "organization_id" field.
|
|
func (u *GitIdentityUpsert) SetOrganizationID(v string) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldOrganizationID, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateOrganizationID() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldOrganizationID)
|
|
return u
|
|
}
|
|
|
|
// ClearOrganizationID clears the value of the "organization_id" field.
|
|
func (u *GitIdentityUpsert) ClearOrganizationID() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldOrganizationID)
|
|
return u
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (u *GitIdentityUpsert) SetRemark(v string) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldRemark, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRemark sets the "remark" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateRemark() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldRemark)
|
|
return u
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (u *GitIdentityUpsert) ClearRemark() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldRemark)
|
|
return u
|
|
}
|
|
|
|
// SetOauthRefreshToken sets the "oauth_refresh_token" field.
|
|
func (u *GitIdentityUpsert) SetOauthRefreshToken(v string) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldOauthRefreshToken, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateOauthRefreshToken sets the "oauth_refresh_token" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateOauthRefreshToken() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldOauthRefreshToken)
|
|
return u
|
|
}
|
|
|
|
// ClearOauthRefreshToken clears the value of the "oauth_refresh_token" field.
|
|
func (u *GitIdentityUpsert) ClearOauthRefreshToken() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldOauthRefreshToken)
|
|
return u
|
|
}
|
|
|
|
// SetOauthExpiresAt sets the "oauth_expires_at" field.
|
|
func (u *GitIdentityUpsert) SetOauthExpiresAt(v time.Time) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldOauthExpiresAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateOauthExpiresAt sets the "oauth_expires_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateOauthExpiresAt() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldOauthExpiresAt)
|
|
return u
|
|
}
|
|
|
|
// ClearOauthExpiresAt clears the value of the "oauth_expires_at" field.
|
|
func (u *GitIdentityUpsert) ClearOauthExpiresAt() *GitIdentityUpsert {
|
|
u.SetNull(gitidentity.FieldOauthExpiresAt)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *GitIdentityUpsert) SetCreatedAt(v time.Time) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateCreatedAt() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *GitIdentityUpsert) SetUpdatedAt(v time.Time) *GitIdentityUpsert {
|
|
u.Set(gitidentity.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsert) UpdateUpdatedAt() *GitIdentityUpsert {
|
|
u.SetExcluded(gitidentity.FieldUpdatedAt)
|
|
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.GitIdentity.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(gitidentity.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *GitIdentityUpsertOne) UpdateNewValues() *GitIdentityUpsertOne {
|
|
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(gitidentity.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.GitIdentity.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *GitIdentityUpsertOne) Ignore() *GitIdentityUpsertOne {
|
|
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 *GitIdentityUpsertOne) DoNothing() *GitIdentityUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the GitIdentityCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *GitIdentityUpsertOne) Update(set func(*GitIdentityUpsert)) *GitIdentityUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&GitIdentityUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *GitIdentityUpsertOne) SetDeletedAt(v time.Time) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateDeletedAt() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *GitIdentityUpsertOne) ClearDeletedAt() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *GitIdentityUpsertOne) SetUserID(v uuid.UUID) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateUserID() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetPlatform sets the "platform" field.
|
|
func (u *GitIdentityUpsertOne) SetPlatform(v consts.GitPlatform) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetPlatform(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePlatform sets the "platform" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdatePlatform() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdatePlatform()
|
|
})
|
|
}
|
|
|
|
// SetBaseURL sets the "base_url" field.
|
|
func (u *GitIdentityUpsertOne) SetBaseURL(v string) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetBaseURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateBaseURL sets the "base_url" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateBaseURL() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateBaseURL()
|
|
})
|
|
}
|
|
|
|
// ClearBaseURL clears the value of the "base_url" field.
|
|
func (u *GitIdentityUpsertOne) ClearBaseURL() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearBaseURL()
|
|
})
|
|
}
|
|
|
|
// SetAccessToken sets the "access_token" field.
|
|
func (u *GitIdentityUpsertOne) SetAccessToken(v string) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetAccessToken(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAccessToken sets the "access_token" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateAccessToken() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateAccessToken()
|
|
})
|
|
}
|
|
|
|
// ClearAccessToken clears the value of the "access_token" field.
|
|
func (u *GitIdentityUpsertOne) ClearAccessToken() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearAccessToken()
|
|
})
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (u *GitIdentityUpsertOne) SetUsername(v string) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetUsername(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUsername sets the "username" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateUsername() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateUsername()
|
|
})
|
|
}
|
|
|
|
// ClearUsername clears the value of the "username" field.
|
|
func (u *GitIdentityUpsertOne) ClearUsername() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearUsername()
|
|
})
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *GitIdentityUpsertOne) SetEmail(v string) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetEmail(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateEmail() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateEmail()
|
|
})
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *GitIdentityUpsertOne) ClearEmail() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearEmail()
|
|
})
|
|
}
|
|
|
|
// SetInstallationID sets the "installation_id" field.
|
|
func (u *GitIdentityUpsertOne) SetInstallationID(v int64) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetInstallationID(v)
|
|
})
|
|
}
|
|
|
|
// AddInstallationID adds v to the "installation_id" field.
|
|
func (u *GitIdentityUpsertOne) AddInstallationID(v int64) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.AddInstallationID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateInstallationID sets the "installation_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateInstallationID() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateInstallationID()
|
|
})
|
|
}
|
|
|
|
// ClearInstallationID clears the value of the "installation_id" field.
|
|
func (u *GitIdentityUpsertOne) ClearInstallationID() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearInstallationID()
|
|
})
|
|
}
|
|
|
|
// SetOrganizationID sets the "organization_id" field.
|
|
func (u *GitIdentityUpsertOne) SetOrganizationID(v string) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetOrganizationID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateOrganizationID() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateOrganizationID()
|
|
})
|
|
}
|
|
|
|
// ClearOrganizationID clears the value of the "organization_id" field.
|
|
func (u *GitIdentityUpsertOne) ClearOrganizationID() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearOrganizationID()
|
|
})
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (u *GitIdentityUpsertOne) SetRemark(v string) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetRemark(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRemark sets the "remark" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateRemark() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateRemark()
|
|
})
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (u *GitIdentityUpsertOne) ClearRemark() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearRemark()
|
|
})
|
|
}
|
|
|
|
// SetOauthRefreshToken sets the "oauth_refresh_token" field.
|
|
func (u *GitIdentityUpsertOne) SetOauthRefreshToken(v string) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetOauthRefreshToken(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOauthRefreshToken sets the "oauth_refresh_token" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateOauthRefreshToken() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateOauthRefreshToken()
|
|
})
|
|
}
|
|
|
|
// ClearOauthRefreshToken clears the value of the "oauth_refresh_token" field.
|
|
func (u *GitIdentityUpsertOne) ClearOauthRefreshToken() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearOauthRefreshToken()
|
|
})
|
|
}
|
|
|
|
// SetOauthExpiresAt sets the "oauth_expires_at" field.
|
|
func (u *GitIdentityUpsertOne) SetOauthExpiresAt(v time.Time) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetOauthExpiresAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOauthExpiresAt sets the "oauth_expires_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateOauthExpiresAt() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateOauthExpiresAt()
|
|
})
|
|
}
|
|
|
|
// ClearOauthExpiresAt clears the value of the "oauth_expires_at" field.
|
|
func (u *GitIdentityUpsertOne) ClearOauthExpiresAt() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearOauthExpiresAt()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *GitIdentityUpsertOne) SetCreatedAt(v time.Time) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateCreatedAt() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *GitIdentityUpsertOne) SetUpdatedAt(v time.Time) *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertOne) UpdateUpdatedAt() *GitIdentityUpsertOne {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *GitIdentityUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for GitIdentityCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *GitIdentityUpsertOne) 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 *GitIdentityUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
|
|
if u.create.driver.Dialect() == dialect.MySQL {
|
|
// In case of "ON CONFLICT", there is no way to get back non-numeric ID
|
|
// fields from the database since MySQL does not support the RETURNING clause.
|
|
return id, errors.New("db: GitIdentityUpsertOne.ID is not supported by MySQL driver. Use GitIdentityUpsertOne.Exec instead")
|
|
}
|
|
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 *GitIdentityUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// GitIdentityCreateBulk is the builder for creating many GitIdentity entities in bulk.
|
|
type GitIdentityCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*GitIdentityCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the GitIdentity entities in the database.
|
|
func (_c *GitIdentityCreateBulk) Save(ctx context.Context) ([]*GitIdentity, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*GitIdentity, 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.(*GitIdentityMutation)
|
|
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
|
|
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 *GitIdentityCreateBulk) SaveX(ctx context.Context) []*GitIdentity {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *GitIdentityCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *GitIdentityCreateBulk) 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.GitIdentity.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.GitIdentityUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *GitIdentityCreateBulk) OnConflict(opts ...sql.ConflictOption) *GitIdentityUpsertBulk {
|
|
_c.conflict = opts
|
|
return &GitIdentityUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.GitIdentity.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *GitIdentityCreateBulk) OnConflictColumns(columns ...string) *GitIdentityUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &GitIdentityUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// GitIdentityUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of GitIdentity nodes.
|
|
type GitIdentityUpsertBulk struct {
|
|
create *GitIdentityCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.GitIdentity.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(gitidentity.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *GitIdentityUpsertBulk) UpdateNewValues() *GitIdentityUpsertBulk {
|
|
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(gitidentity.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.GitIdentity.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *GitIdentityUpsertBulk) Ignore() *GitIdentityUpsertBulk {
|
|
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 *GitIdentityUpsertBulk) DoNothing() *GitIdentityUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the GitIdentityCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *GitIdentityUpsertBulk) Update(set func(*GitIdentityUpsert)) *GitIdentityUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&GitIdentityUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *GitIdentityUpsertBulk) SetDeletedAt(v time.Time) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateDeletedAt() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *GitIdentityUpsertBulk) ClearDeletedAt() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (u *GitIdentityUpsertBulk) SetUserID(v uuid.UUID) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetUserID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUserID sets the "user_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateUserID() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateUserID()
|
|
})
|
|
}
|
|
|
|
// SetPlatform sets the "platform" field.
|
|
func (u *GitIdentityUpsertBulk) SetPlatform(v consts.GitPlatform) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetPlatform(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePlatform sets the "platform" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdatePlatform() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdatePlatform()
|
|
})
|
|
}
|
|
|
|
// SetBaseURL sets the "base_url" field.
|
|
func (u *GitIdentityUpsertBulk) SetBaseURL(v string) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetBaseURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateBaseURL sets the "base_url" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateBaseURL() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateBaseURL()
|
|
})
|
|
}
|
|
|
|
// ClearBaseURL clears the value of the "base_url" field.
|
|
func (u *GitIdentityUpsertBulk) ClearBaseURL() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearBaseURL()
|
|
})
|
|
}
|
|
|
|
// SetAccessToken sets the "access_token" field.
|
|
func (u *GitIdentityUpsertBulk) SetAccessToken(v string) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetAccessToken(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAccessToken sets the "access_token" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateAccessToken() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateAccessToken()
|
|
})
|
|
}
|
|
|
|
// ClearAccessToken clears the value of the "access_token" field.
|
|
func (u *GitIdentityUpsertBulk) ClearAccessToken() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearAccessToken()
|
|
})
|
|
}
|
|
|
|
// SetUsername sets the "username" field.
|
|
func (u *GitIdentityUpsertBulk) SetUsername(v string) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetUsername(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUsername sets the "username" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateUsername() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateUsername()
|
|
})
|
|
}
|
|
|
|
// ClearUsername clears the value of the "username" field.
|
|
func (u *GitIdentityUpsertBulk) ClearUsername() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearUsername()
|
|
})
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *GitIdentityUpsertBulk) SetEmail(v string) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetEmail(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateEmail() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateEmail()
|
|
})
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *GitIdentityUpsertBulk) ClearEmail() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearEmail()
|
|
})
|
|
}
|
|
|
|
// SetInstallationID sets the "installation_id" field.
|
|
func (u *GitIdentityUpsertBulk) SetInstallationID(v int64) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetInstallationID(v)
|
|
})
|
|
}
|
|
|
|
// AddInstallationID adds v to the "installation_id" field.
|
|
func (u *GitIdentityUpsertBulk) AddInstallationID(v int64) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.AddInstallationID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateInstallationID sets the "installation_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateInstallationID() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateInstallationID()
|
|
})
|
|
}
|
|
|
|
// ClearInstallationID clears the value of the "installation_id" field.
|
|
func (u *GitIdentityUpsertBulk) ClearInstallationID() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearInstallationID()
|
|
})
|
|
}
|
|
|
|
// SetOrganizationID sets the "organization_id" field.
|
|
func (u *GitIdentityUpsertBulk) SetOrganizationID(v string) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetOrganizationID(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateOrganizationID() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateOrganizationID()
|
|
})
|
|
}
|
|
|
|
// ClearOrganizationID clears the value of the "organization_id" field.
|
|
func (u *GitIdentityUpsertBulk) ClearOrganizationID() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearOrganizationID()
|
|
})
|
|
}
|
|
|
|
// SetRemark sets the "remark" field.
|
|
func (u *GitIdentityUpsertBulk) SetRemark(v string) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetRemark(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRemark sets the "remark" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateRemark() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateRemark()
|
|
})
|
|
}
|
|
|
|
// ClearRemark clears the value of the "remark" field.
|
|
func (u *GitIdentityUpsertBulk) ClearRemark() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearRemark()
|
|
})
|
|
}
|
|
|
|
// SetOauthRefreshToken sets the "oauth_refresh_token" field.
|
|
func (u *GitIdentityUpsertBulk) SetOauthRefreshToken(v string) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetOauthRefreshToken(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOauthRefreshToken sets the "oauth_refresh_token" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateOauthRefreshToken() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateOauthRefreshToken()
|
|
})
|
|
}
|
|
|
|
// ClearOauthRefreshToken clears the value of the "oauth_refresh_token" field.
|
|
func (u *GitIdentityUpsertBulk) ClearOauthRefreshToken() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearOauthRefreshToken()
|
|
})
|
|
}
|
|
|
|
// SetOauthExpiresAt sets the "oauth_expires_at" field.
|
|
func (u *GitIdentityUpsertBulk) SetOauthExpiresAt(v time.Time) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetOauthExpiresAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateOauthExpiresAt sets the "oauth_expires_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateOauthExpiresAt() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateOauthExpiresAt()
|
|
})
|
|
}
|
|
|
|
// ClearOauthExpiresAt clears the value of the "oauth_expires_at" field.
|
|
func (u *GitIdentityUpsertBulk) ClearOauthExpiresAt() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.ClearOauthExpiresAt()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *GitIdentityUpsertBulk) SetCreatedAt(v time.Time) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateCreatedAt() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *GitIdentityUpsertBulk) SetUpdatedAt(v time.Time) *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *GitIdentityUpsertBulk) UpdateUpdatedAt() *GitIdentityUpsertBulk {
|
|
return u.Update(func(s *GitIdentityUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *GitIdentityUpsertBulk) 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("db: OnConflict was set for builder %d. Set it on the GitIdentityCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for GitIdentityCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *GitIdentityUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|