mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-22 19:39:31 +08:00
1882 lines
53 KiB
Go
1882 lines
53 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/audit"
|
|
"github.com/chaitin/MonkeyCode/backend/db/gitbot"
|
|
"github.com/chaitin/MonkeyCode/backend/db/gitbotuser"
|
|
"github.com/chaitin/MonkeyCode/backend/db/gitidentity"
|
|
"github.com/chaitin/MonkeyCode/backend/db/host"
|
|
"github.com/chaitin/MonkeyCode/backend/db/image"
|
|
"github.com/chaitin/MonkeyCode/backend/db/mcpupstream"
|
|
"github.com/chaitin/MonkeyCode/backend/db/model"
|
|
"github.com/chaitin/MonkeyCode/backend/db/project"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectcollaborator"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectissue"
|
|
"github.com/chaitin/MonkeyCode/backend/db/projectissuecomment"
|
|
"github.com/chaitin/MonkeyCode/backend/db/task"
|
|
"github.com/chaitin/MonkeyCode/backend/db/taskmodelswitch"
|
|
"github.com/chaitin/MonkeyCode/backend/db/team"
|
|
"github.com/chaitin/MonkeyCode/backend/db/teamgroup"
|
|
"github.com/chaitin/MonkeyCode/backend/db/teamgroupmember"
|
|
"github.com/chaitin/MonkeyCode/backend/db/teammember"
|
|
"github.com/chaitin/MonkeyCode/backend/db/user"
|
|
"github.com/chaitin/MonkeyCode/backend/db/useridentity"
|
|
"github.com/chaitin/MonkeyCode/backend/db/virtualmachine"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// UserCreate is the builder for creating a User entity.
|
|
type UserCreate struct {
|
|
config
|
|
mutation *UserMutation
|
|
hooks []Hook
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (_c *UserCreate) SetDeletedAt(v time.Time) *UserCreate {
|
|
_c.mutation.SetDeletedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
|
|
func (_c *UserCreate) SetNillableDeletedAt(v *time.Time) *UserCreate {
|
|
if v != nil {
|
|
_c.SetDeletedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_c *UserCreate) SetName(v string) *UserCreate {
|
|
_c.mutation.SetName(v)
|
|
return _c
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (_c *UserCreate) SetEmail(v string) *UserCreate {
|
|
_c.mutation.SetEmail(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableEmail sets the "email" field if the given value is not nil.
|
|
func (_c *UserCreate) SetNillableEmail(v *string) *UserCreate {
|
|
if v != nil {
|
|
_c.SetEmail(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetAvatarURL sets the "avatar_url" field.
|
|
func (_c *UserCreate) SetAvatarURL(v string) *UserCreate {
|
|
_c.mutation.SetAvatarURL(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableAvatarURL sets the "avatar_url" field if the given value is not nil.
|
|
func (_c *UserCreate) SetNillableAvatarURL(v *string) *UserCreate {
|
|
if v != nil {
|
|
_c.SetAvatarURL(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (_c *UserCreate) SetPassword(v string) *UserCreate {
|
|
_c.mutation.SetPassword(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillablePassword sets the "password" field if the given value is not nil.
|
|
func (_c *UserCreate) SetNillablePassword(v *string) *UserCreate {
|
|
if v != nil {
|
|
_c.SetPassword(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (_c *UserCreate) SetRole(v consts.UserRole) *UserCreate {
|
|
_c.mutation.SetRole(v)
|
|
return _c
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (_c *UserCreate) SetStatus(v consts.UserStatus) *UserCreate {
|
|
_c.mutation.SetStatus(v)
|
|
return _c
|
|
}
|
|
|
|
// SetIsBlocked sets the "is_blocked" field.
|
|
func (_c *UserCreate) SetIsBlocked(v bool) *UserCreate {
|
|
_c.mutation.SetIsBlocked(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableIsBlocked sets the "is_blocked" field if the given value is not nil.
|
|
func (_c *UserCreate) SetNillableIsBlocked(v *bool) *UserCreate {
|
|
if v != nil {
|
|
_c.SetIsBlocked(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetDefaultConfigs sets the "default_configs" field.
|
|
func (_c *UserCreate) SetDefaultConfigs(v map[consts.DefaultConfigType]uuid.UUID) *UserCreate {
|
|
_c.mutation.SetDefaultConfigs(v)
|
|
return _c
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (_c *UserCreate) SetCreatedAt(v time.Time) *UserCreate {
|
|
_c.mutation.SetCreatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
|
|
func (_c *UserCreate) SetNillableCreatedAt(v *time.Time) *UserCreate {
|
|
if v != nil {
|
|
_c.SetCreatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_c *UserCreate) SetUpdatedAt(v time.Time) *UserCreate {
|
|
_c.mutation.SetUpdatedAt(v)
|
|
return _c
|
|
}
|
|
|
|
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
|
|
func (_c *UserCreate) SetNillableUpdatedAt(v *time.Time) *UserCreate {
|
|
if v != nil {
|
|
_c.SetUpdatedAt(*v)
|
|
}
|
|
return _c
|
|
}
|
|
|
|
// SetID sets the "id" field.
|
|
func (_c *UserCreate) SetID(v uuid.UUID) *UserCreate {
|
|
_c.mutation.SetID(v)
|
|
return _c
|
|
}
|
|
|
|
// AddIdentityIDs adds the "identities" edge to the UserIdentity entity by IDs.
|
|
func (_c *UserCreate) AddIdentityIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddIdentityIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddIdentities adds the "identities" edges to the UserIdentity entity.
|
|
func (_c *UserCreate) AddIdentities(v ...*UserIdentity) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddIdentityIDs(ids...)
|
|
}
|
|
|
|
// AddAuditIDs adds the "audits" edge to the Audit entity by IDs.
|
|
func (_c *UserCreate) AddAuditIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddAuditIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddAudits adds the "audits" edges to the Audit entity.
|
|
func (_c *UserCreate) AddAudits(v ...*Audit) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddAuditIDs(ids...)
|
|
}
|
|
|
|
// AddTeamIDs adds the "teams" edge to the Team entity by IDs.
|
|
func (_c *UserCreate) AddTeamIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddTeamIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddTeams adds the "teams" edges to the Team entity.
|
|
func (_c *UserCreate) AddTeams(v ...*Team) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddTeamIDs(ids...)
|
|
}
|
|
|
|
// AddGroupIDs adds the "groups" edge to the TeamGroup entity by IDs.
|
|
func (_c *UserCreate) AddGroupIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddGroupIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddGroups adds the "groups" edges to the TeamGroup entity.
|
|
func (_c *UserCreate) AddGroups(v ...*TeamGroup) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddGroupIDs(ids...)
|
|
}
|
|
|
|
// AddModelIDs adds the "models" edge to the Model entity by IDs.
|
|
func (_c *UserCreate) AddModelIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddModelIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddModels adds the "models" edges to the Model entity.
|
|
func (_c *UserCreate) AddModels(v ...*Model) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddModelIDs(ids...)
|
|
}
|
|
|
|
// AddImageIDs adds the "images" edge to the Image entity by IDs.
|
|
func (_c *UserCreate) AddImageIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddImageIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddImages adds the "images" edges to the Image entity.
|
|
func (_c *UserCreate) AddImages(v ...*Image) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddImageIDs(ids...)
|
|
}
|
|
|
|
// AddHostIDs adds the "hosts" edge to the Host entity by IDs.
|
|
func (_c *UserCreate) AddHostIDs(ids ...string) *UserCreate {
|
|
_c.mutation.AddHostIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddHosts adds the "hosts" edges to the Host entity.
|
|
func (_c *UserCreate) AddHosts(v ...*Host) *UserCreate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddHostIDs(ids...)
|
|
}
|
|
|
|
// AddVMIDs adds the "vms" edge to the VirtualMachine entity by IDs.
|
|
func (_c *UserCreate) AddVMIDs(ids ...string) *UserCreate {
|
|
_c.mutation.AddVMIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddVms adds the "vms" edges to the VirtualMachine entity.
|
|
func (_c *UserCreate) AddVms(v ...*VirtualMachine) *UserCreate {
|
|
ids := make([]string, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddVMIDs(ids...)
|
|
}
|
|
|
|
// AddTaskIDs adds the "tasks" edge to the Task entity by IDs.
|
|
func (_c *UserCreate) AddTaskIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddTaskIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddTasks adds the "tasks" edges to the Task entity.
|
|
func (_c *UserCreate) AddTasks(v ...*Task) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddTaskIDs(ids...)
|
|
}
|
|
|
|
// AddTaskModelSwitchIDs adds the "task_model_switches" edge to the TaskModelSwitch entity by IDs.
|
|
func (_c *UserCreate) AddTaskModelSwitchIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddTaskModelSwitchIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddTaskModelSwitches adds the "task_model_switches" edges to the TaskModelSwitch entity.
|
|
func (_c *UserCreate) AddTaskModelSwitches(v ...*TaskModelSwitch) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddTaskModelSwitchIDs(ids...)
|
|
}
|
|
|
|
// AddGitIdentityIDs adds the "git_identities" edge to the GitIdentity entity by IDs.
|
|
func (_c *UserCreate) AddGitIdentityIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddGitIdentityIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddGitIdentities adds the "git_identities" edges to the GitIdentity entity.
|
|
func (_c *UserCreate) AddGitIdentities(v ...*GitIdentity) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddGitIdentityIDs(ids...)
|
|
}
|
|
|
|
// AddProjectIDs adds the "projects" edge to the Project entity by IDs.
|
|
func (_c *UserCreate) AddProjectIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddProjectIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddProjects adds the "projects" edges to the Project entity.
|
|
func (_c *UserCreate) AddProjects(v ...*Project) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddProjectIDs(ids...)
|
|
}
|
|
|
|
// AddProjectIssueIDs adds the "project_issues" edge to the ProjectIssue entity by IDs.
|
|
func (_c *UserCreate) AddProjectIssueIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddProjectIssueIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddProjectIssues adds the "project_issues" edges to the ProjectIssue entity.
|
|
func (_c *UserCreate) AddProjectIssues(v ...*ProjectIssue) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddProjectIssueIDs(ids...)
|
|
}
|
|
|
|
// AddAssignedIssueIDs adds the "assigned_issues" edge to the ProjectIssue entity by IDs.
|
|
func (_c *UserCreate) AddAssignedIssueIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddAssignedIssueIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddAssignedIssues adds the "assigned_issues" edges to the ProjectIssue entity.
|
|
func (_c *UserCreate) AddAssignedIssues(v ...*ProjectIssue) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddAssignedIssueIDs(ids...)
|
|
}
|
|
|
|
// AddProjectCollaboratorIDs adds the "project_collaborators" edge to the ProjectCollaborator entity by IDs.
|
|
func (_c *UserCreate) AddProjectCollaboratorIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddProjectCollaboratorIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddProjectCollaborators adds the "project_collaborators" edges to the ProjectCollaborator entity.
|
|
func (_c *UserCreate) AddProjectCollaborators(v ...*ProjectCollaborator) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddProjectCollaboratorIDs(ids...)
|
|
}
|
|
|
|
// AddProjectIssueCommentIDs adds the "project_issue_comments" edge to the ProjectIssueComment entity by IDs.
|
|
func (_c *UserCreate) AddProjectIssueCommentIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddProjectIssueCommentIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddProjectIssueComments adds the "project_issue_comments" edges to the ProjectIssueComment entity.
|
|
func (_c *UserCreate) AddProjectIssueComments(v ...*ProjectIssueComment) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddProjectIssueCommentIDs(ids...)
|
|
}
|
|
|
|
// AddGitBotIDs adds the "git_bots" edge to the GitBot entity by IDs.
|
|
func (_c *UserCreate) AddGitBotIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddGitBotIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddGitBots adds the "git_bots" edges to the GitBot entity.
|
|
func (_c *UserCreate) AddGitBots(v ...*GitBot) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddGitBotIDs(ids...)
|
|
}
|
|
|
|
// AddMcpUpstreamIDs adds the "mcp_upstreams" edge to the MCPUpstream entity by IDs.
|
|
func (_c *UserCreate) AddMcpUpstreamIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddMcpUpstreamIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddMcpUpstreams adds the "mcp_upstreams" edges to the MCPUpstream entity.
|
|
func (_c *UserCreate) AddMcpUpstreams(v ...*MCPUpstream) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddMcpUpstreamIDs(ids...)
|
|
}
|
|
|
|
// AddTeamMemberIDs adds the "team_members" edge to the TeamMember entity by IDs.
|
|
func (_c *UserCreate) AddTeamMemberIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddTeamMemberIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddTeamMembers adds the "team_members" edges to the TeamMember entity.
|
|
func (_c *UserCreate) AddTeamMembers(v ...*TeamMember) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddTeamMemberIDs(ids...)
|
|
}
|
|
|
|
// AddTeamGroupMemberIDs adds the "team_group_members" edge to the TeamGroupMember entity by IDs.
|
|
func (_c *UserCreate) AddTeamGroupMemberIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddTeamGroupMemberIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddTeamGroupMembers adds the "team_group_members" edges to the TeamGroupMember entity.
|
|
func (_c *UserCreate) AddTeamGroupMembers(v ...*TeamGroupMember) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddTeamGroupMemberIDs(ids...)
|
|
}
|
|
|
|
// AddGitBotUserIDs adds the "git_bot_users" edge to the GitBotUser entity by IDs.
|
|
func (_c *UserCreate) AddGitBotUserIDs(ids ...uuid.UUID) *UserCreate {
|
|
_c.mutation.AddGitBotUserIDs(ids...)
|
|
return _c
|
|
}
|
|
|
|
// AddGitBotUsers adds the "git_bot_users" edges to the GitBotUser entity.
|
|
func (_c *UserCreate) AddGitBotUsers(v ...*GitBotUser) *UserCreate {
|
|
ids := make([]uuid.UUID, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _c.AddGitBotUserIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the UserMutation object of the builder.
|
|
func (_c *UserCreate) Mutation() *UserMutation {
|
|
return _c.mutation
|
|
}
|
|
|
|
// Save creates the User in the database.
|
|
func (_c *UserCreate) Save(ctx context.Context) (*User, 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 *UserCreate) SaveX(ctx context.Context) *User {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *UserCreate) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *UserCreate) 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 *UserCreate) defaults() error {
|
|
if _, ok := _c.mutation.IsBlocked(); !ok {
|
|
v := user.DefaultIsBlocked
|
|
_c.mutation.SetIsBlocked(v)
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
if user.DefaultCreatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized user.DefaultCreatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := user.DefaultCreatedAt()
|
|
_c.mutation.SetCreatedAt(v)
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
if user.DefaultUpdatedAt == nil {
|
|
return fmt.Errorf("db: uninitialized user.DefaultUpdatedAt (forgotten import db/runtime?)")
|
|
}
|
|
v := user.DefaultUpdatedAt()
|
|
_c.mutation.SetUpdatedAt(v)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_c *UserCreate) check() error {
|
|
if _, ok := _c.mutation.Name(); !ok {
|
|
return &ValidationError{Name: "name", err: errors.New(`db: missing required field "User.name"`)}
|
|
}
|
|
if v, ok := _c.mutation.Name(); ok {
|
|
if err := user.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`db: validator failed for field "User.name": %w`, err)}
|
|
}
|
|
}
|
|
if _, ok := _c.mutation.Role(); !ok {
|
|
return &ValidationError{Name: "role", err: errors.New(`db: missing required field "User.role"`)}
|
|
}
|
|
if _, ok := _c.mutation.Status(); !ok {
|
|
return &ValidationError{Name: "status", err: errors.New(`db: missing required field "User.status"`)}
|
|
}
|
|
if _, ok := _c.mutation.IsBlocked(); !ok {
|
|
return &ValidationError{Name: "is_blocked", err: errors.New(`db: missing required field "User.is_blocked"`)}
|
|
}
|
|
if _, ok := _c.mutation.CreatedAt(); !ok {
|
|
return &ValidationError{Name: "created_at", err: errors.New(`db: missing required field "User.created_at"`)}
|
|
}
|
|
if _, ok := _c.mutation.UpdatedAt(); !ok {
|
|
return &ValidationError{Name: "updated_at", err: errors.New(`db: missing required field "User.updated_at"`)}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_c *UserCreate) sqlSave(ctx context.Context) (*User, 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 *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
|
var (
|
|
_node = &User{config: _c.config}
|
|
_spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.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(user.FieldDeletedAt, field.TypeTime, value)
|
|
_node.DeletedAt = value
|
|
}
|
|
if value, ok := _c.mutation.Name(); ok {
|
|
_spec.SetField(user.FieldName, field.TypeString, value)
|
|
_node.Name = value
|
|
}
|
|
if value, ok := _c.mutation.Email(); ok {
|
|
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
|
_node.Email = value
|
|
}
|
|
if value, ok := _c.mutation.AvatarURL(); ok {
|
|
_spec.SetField(user.FieldAvatarURL, field.TypeString, value)
|
|
_node.AvatarURL = value
|
|
}
|
|
if value, ok := _c.mutation.Password(); ok {
|
|
_spec.SetField(user.FieldPassword, field.TypeString, value)
|
|
_node.Password = value
|
|
}
|
|
if value, ok := _c.mutation.Role(); ok {
|
|
_spec.SetField(user.FieldRole, field.TypeString, value)
|
|
_node.Role = value
|
|
}
|
|
if value, ok := _c.mutation.Status(); ok {
|
|
_spec.SetField(user.FieldStatus, field.TypeString, value)
|
|
_node.Status = value
|
|
}
|
|
if value, ok := _c.mutation.IsBlocked(); ok {
|
|
_spec.SetField(user.FieldIsBlocked, field.TypeBool, value)
|
|
_node.IsBlocked = value
|
|
}
|
|
if value, ok := _c.mutation.DefaultConfigs(); ok {
|
|
_spec.SetField(user.FieldDefaultConfigs, field.TypeJSON, value)
|
|
_node.DefaultConfigs = value
|
|
}
|
|
if value, ok := _c.mutation.CreatedAt(); ok {
|
|
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
|
_node.CreatedAt = value
|
|
}
|
|
if value, ok := _c.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
|
_node.UpdatedAt = value
|
|
}
|
|
if nodes := _c.mutation.IdentitiesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.IdentitiesTable,
|
|
Columns: []string{user.IdentitiesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(useridentity.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.AuditsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.AuditsTable,
|
|
Columns: []string{user.AuditsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(audit.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.TeamsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: user.TeamsTable,
|
|
Columns: user.TeamsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(team.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
createE := &TeamMemberCreate{config: _c.config, mutation: newTeamMemberMutation(_c.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.GroupsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: user.GroupsTable,
|
|
Columns: user.GroupsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(teamgroup.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
createE := &TeamGroupMemberCreate{config: _c.config, mutation: newTeamGroupMemberMutation(_c.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.ModelsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.ModelsTable,
|
|
Columns: []string{user.ModelsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(model.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.ImagesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.ImagesTable,
|
|
Columns: []string{user.ImagesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(image.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.HostsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.HostsTable,
|
|
Columns: []string{user.HostsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(host.FieldID, field.TypeString),
|
|
},
|
|
}
|
|
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: user.VmsTable,
|
|
Columns: []string{user.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)
|
|
}
|
|
if nodes := _c.mutation.TasksIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.TasksTable,
|
|
Columns: []string{user.TasksColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(task.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.TaskModelSwitchesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.TaskModelSwitchesTable,
|
|
Columns: []string{user.TaskModelSwitchesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(taskmodelswitch.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.GitIdentitiesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.GitIdentitiesTable,
|
|
Columns: []string{user.GitIdentitiesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitidentity.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.ProjectsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.ProjectsTable,
|
|
Columns: []string{user.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.ProjectIssuesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.ProjectIssuesTable,
|
|
Columns: []string{user.ProjectIssuesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissue.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.AssignedIssuesIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.AssignedIssuesTable,
|
|
Columns: []string{user.AssignedIssuesColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissue.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.ProjectCollaboratorsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.ProjectCollaboratorsTable,
|
|
Columns: []string{user.ProjectCollaboratorsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectcollaborator.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.ProjectIssueCommentsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.ProjectIssueCommentsTable,
|
|
Columns: []string{user.ProjectIssueCommentsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(projectissuecomment.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.GitBotsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: false,
|
|
Table: user.GitBotsTable,
|
|
Columns: user.GitBotsPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitbot.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
createE := &GitBotUserCreate{config: _c.config, mutation: newGitBotUserMutation(_c.config, OpCreate)}
|
|
createE.defaults()
|
|
_, specE := createE.createSpec()
|
|
edge.Target.Fields = specE.Fields
|
|
if specE.ID.Value != nil {
|
|
edge.Target.Fields = append(edge.Target.Fields, specE.ID)
|
|
}
|
|
_spec.Edges = append(_spec.Edges, edge)
|
|
}
|
|
if nodes := _c.mutation.McpUpstreamsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: user.McpUpstreamsTable,
|
|
Columns: []string{user.McpUpstreamsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(mcpupstream.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.TeamMembersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: user.TeamMembersTable,
|
|
Columns: []string{user.TeamMembersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(teammember.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.TeamGroupMembersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: user.TeamGroupMembersTable,
|
|
Columns: []string{user.TeamGroupMembersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(teamgroupmember.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.GitBotUsersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: true,
|
|
Table: user.GitBotUsersTable,
|
|
Columns: []string{user.GitBotUsersColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(gitbotuser.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
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.User.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.UserUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *UserCreate) OnConflict(opts ...sql.ConflictOption) *UserUpsertOne {
|
|
_c.conflict = opts
|
|
return &UserUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.User.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *UserCreate) OnConflictColumns(columns ...string) *UserUpsertOne {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &UserUpsertOne{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
type (
|
|
// UserUpsertOne is the builder for "upsert"-ing
|
|
// one User node.
|
|
UserUpsertOne struct {
|
|
create *UserCreate
|
|
}
|
|
|
|
// UserUpsert is the "OnConflict" setter.
|
|
UserUpsert struct {
|
|
*sql.UpdateSet
|
|
}
|
|
)
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *UserUpsert) SetDeletedAt(v time.Time) *UserUpsert {
|
|
u.Set(user.FieldDeletedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateDeletedAt() *UserUpsert {
|
|
u.SetExcluded(user.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *UserUpsert) ClearDeletedAt() *UserUpsert {
|
|
u.SetNull(user.FieldDeletedAt)
|
|
return u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *UserUpsert) SetName(v string) *UserUpsert {
|
|
u.Set(user.FieldName, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateName() *UserUpsert {
|
|
u.SetExcluded(user.FieldName)
|
|
return u
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *UserUpsert) SetEmail(v string) *UserUpsert {
|
|
u.Set(user.FieldEmail, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateEmail() *UserUpsert {
|
|
u.SetExcluded(user.FieldEmail)
|
|
return u
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *UserUpsert) ClearEmail() *UserUpsert {
|
|
u.SetNull(user.FieldEmail)
|
|
return u
|
|
}
|
|
|
|
// SetAvatarURL sets the "avatar_url" field.
|
|
func (u *UserUpsert) SetAvatarURL(v string) *UserUpsert {
|
|
u.Set(user.FieldAvatarURL, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateAvatarURL sets the "avatar_url" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateAvatarURL() *UserUpsert {
|
|
u.SetExcluded(user.FieldAvatarURL)
|
|
return u
|
|
}
|
|
|
|
// ClearAvatarURL clears the value of the "avatar_url" field.
|
|
func (u *UserUpsert) ClearAvatarURL() *UserUpsert {
|
|
u.SetNull(user.FieldAvatarURL)
|
|
return u
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (u *UserUpsert) SetPassword(v string) *UserUpsert {
|
|
u.Set(user.FieldPassword, v)
|
|
return u
|
|
}
|
|
|
|
// UpdatePassword sets the "password" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdatePassword() *UserUpsert {
|
|
u.SetExcluded(user.FieldPassword)
|
|
return u
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (u *UserUpsert) ClearPassword() *UserUpsert {
|
|
u.SetNull(user.FieldPassword)
|
|
return u
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (u *UserUpsert) SetRole(v consts.UserRole) *UserUpsert {
|
|
u.Set(user.FieldRole, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateRole sets the "role" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateRole() *UserUpsert {
|
|
u.SetExcluded(user.FieldRole)
|
|
return u
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *UserUpsert) SetStatus(v consts.UserStatus) *UserUpsert {
|
|
u.Set(user.FieldStatus, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateStatus() *UserUpsert {
|
|
u.SetExcluded(user.FieldStatus)
|
|
return u
|
|
}
|
|
|
|
// SetIsBlocked sets the "is_blocked" field.
|
|
func (u *UserUpsert) SetIsBlocked(v bool) *UserUpsert {
|
|
u.Set(user.FieldIsBlocked, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateIsBlocked sets the "is_blocked" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateIsBlocked() *UserUpsert {
|
|
u.SetExcluded(user.FieldIsBlocked)
|
|
return u
|
|
}
|
|
|
|
// SetDefaultConfigs sets the "default_configs" field.
|
|
func (u *UserUpsert) SetDefaultConfigs(v map[consts.DefaultConfigType]uuid.UUID) *UserUpsert {
|
|
u.Set(user.FieldDefaultConfigs, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateDefaultConfigs sets the "default_configs" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateDefaultConfigs() *UserUpsert {
|
|
u.SetExcluded(user.FieldDefaultConfigs)
|
|
return u
|
|
}
|
|
|
|
// ClearDefaultConfigs clears the value of the "default_configs" field.
|
|
func (u *UserUpsert) ClearDefaultConfigs() *UserUpsert {
|
|
u.SetNull(user.FieldDefaultConfigs)
|
|
return u
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *UserUpsert) SetCreatedAt(v time.Time) *UserUpsert {
|
|
u.Set(user.FieldCreatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateCreatedAt() *UserUpsert {
|
|
u.SetExcluded(user.FieldCreatedAt)
|
|
return u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *UserUpsert) SetUpdatedAt(v time.Time) *UserUpsert {
|
|
u.Set(user.FieldUpdatedAt, v)
|
|
return u
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *UserUpsert) UpdateUpdatedAt() *UserUpsert {
|
|
u.SetExcluded(user.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.User.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(user.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *UserUpsertOne) UpdateNewValues() *UserUpsertOne {
|
|
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(user.FieldID)
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.User.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *UserUpsertOne) Ignore() *UserUpsertOne {
|
|
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 *UserUpsertOne) DoNothing() *UserUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the UserCreate.OnConflict
|
|
// documentation for more info.
|
|
func (u *UserUpsertOne) Update(set func(*UserUpsert)) *UserUpsertOne {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&UserUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *UserUpsertOne) SetDeletedAt(v time.Time) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateDeletedAt() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *UserUpsertOne) ClearDeletedAt() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *UserUpsertOne) SetName(v string) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateName() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *UserUpsertOne) SetEmail(v string) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetEmail(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateEmail() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateEmail()
|
|
})
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *UserUpsertOne) ClearEmail() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearEmail()
|
|
})
|
|
}
|
|
|
|
// SetAvatarURL sets the "avatar_url" field.
|
|
func (u *UserUpsertOne) SetAvatarURL(v string) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetAvatarURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAvatarURL sets the "avatar_url" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateAvatarURL() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateAvatarURL()
|
|
})
|
|
}
|
|
|
|
// ClearAvatarURL clears the value of the "avatar_url" field.
|
|
func (u *UserUpsertOne) ClearAvatarURL() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearAvatarURL()
|
|
})
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (u *UserUpsertOne) SetPassword(v string) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetPassword(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePassword sets the "password" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdatePassword() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdatePassword()
|
|
})
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (u *UserUpsertOne) ClearPassword() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearPassword()
|
|
})
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (u *UserUpsertOne) SetRole(v consts.UserRole) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetRole(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRole sets the "role" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateRole() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateRole()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *UserUpsertOne) SetStatus(v consts.UserStatus) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateStatus() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetIsBlocked sets the "is_blocked" field.
|
|
func (u *UserUpsertOne) SetIsBlocked(v bool) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetIsBlocked(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsBlocked sets the "is_blocked" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateIsBlocked() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateIsBlocked()
|
|
})
|
|
}
|
|
|
|
// SetDefaultConfigs sets the "default_configs" field.
|
|
func (u *UserUpsertOne) SetDefaultConfigs(v map[consts.DefaultConfigType]uuid.UUID) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetDefaultConfigs(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDefaultConfigs sets the "default_configs" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateDefaultConfigs() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateDefaultConfigs()
|
|
})
|
|
}
|
|
|
|
// ClearDefaultConfigs clears the value of the "default_configs" field.
|
|
func (u *UserUpsertOne) ClearDefaultConfigs() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearDefaultConfigs()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *UserUpsertOne) SetCreatedAt(v time.Time) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateCreatedAt() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *UserUpsertOne) SetUpdatedAt(v time.Time) *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *UserUpsertOne) UpdateUpdatedAt() *UserUpsertOne {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *UserUpsertOne) Exec(ctx context.Context) error {
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for UserCreate.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *UserUpsertOne) 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 *UserUpsertOne) 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: UserUpsertOne.ID is not supported by MySQL driver. Use UserUpsertOne.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 *UserUpsertOne) IDX(ctx context.Context) uuid.UUID {
|
|
id, err := u.ID(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return id
|
|
}
|
|
|
|
// UserCreateBulk is the builder for creating many User entities in bulk.
|
|
type UserCreateBulk struct {
|
|
config
|
|
err error
|
|
builders []*UserCreate
|
|
conflict []sql.ConflictOption
|
|
}
|
|
|
|
// Save creates the User entities in the database.
|
|
func (_c *UserCreateBulk) Save(ctx context.Context) ([]*User, error) {
|
|
if _c.err != nil {
|
|
return nil, _c.err
|
|
}
|
|
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
|
nodes := make([]*User, 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.(*UserMutation)
|
|
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 *UserCreateBulk) SaveX(ctx context.Context) []*User {
|
|
v, err := _c.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return v
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_c *UserCreateBulk) Exec(ctx context.Context) error {
|
|
_, err := _c.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_c *UserCreateBulk) 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.User.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.UserUpsert) {
|
|
// SetDeletedAt(v+v).
|
|
// }).
|
|
// Exec(ctx)
|
|
func (_c *UserCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserUpsertBulk {
|
|
_c.conflict = opts
|
|
return &UserUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// OnConflictColumns calls `OnConflict` and configures the columns
|
|
// as conflict target. Using this option is equivalent to using:
|
|
//
|
|
// client.User.Create().
|
|
// OnConflict(sql.ConflictColumns(columns...)).
|
|
// Exec(ctx)
|
|
func (_c *UserCreateBulk) OnConflictColumns(columns ...string) *UserUpsertBulk {
|
|
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
|
|
return &UserUpsertBulk{
|
|
create: _c,
|
|
}
|
|
}
|
|
|
|
// UserUpsertBulk is the builder for "upsert"-ing
|
|
// a bulk of User nodes.
|
|
type UserUpsertBulk struct {
|
|
create *UserCreateBulk
|
|
}
|
|
|
|
// UpdateNewValues updates the mutable fields using the new values that
|
|
// were set on create. Using this option is equivalent to using:
|
|
//
|
|
// client.User.Create().
|
|
// OnConflict(
|
|
// sql.ResolveWithNewValues(),
|
|
// sql.ResolveWith(func(u *sql.UpdateSet) {
|
|
// u.SetIgnore(user.FieldID)
|
|
// }),
|
|
// ).
|
|
// Exec(ctx)
|
|
func (u *UserUpsertBulk) UpdateNewValues() *UserUpsertBulk {
|
|
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(user.FieldID)
|
|
}
|
|
}
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// Ignore sets each column to itself in case of conflict.
|
|
// Using this option is equivalent to using:
|
|
//
|
|
// client.User.Create().
|
|
// OnConflict(sql.ResolveWithIgnore()).
|
|
// Exec(ctx)
|
|
func (u *UserUpsertBulk) Ignore() *UserUpsertBulk {
|
|
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 *UserUpsertBulk) DoNothing() *UserUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.DoNothing())
|
|
return u
|
|
}
|
|
|
|
// Update allows overriding fields `UPDATE` values. See the UserCreateBulk.OnConflict
|
|
// documentation for more info.
|
|
func (u *UserUpsertBulk) Update(set func(*UserUpsert)) *UserUpsertBulk {
|
|
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
|
|
set(&UserUpsert{UpdateSet: update})
|
|
}))
|
|
return u
|
|
}
|
|
|
|
// SetDeletedAt sets the "deleted_at" field.
|
|
func (u *UserUpsertBulk) SetDeletedAt(v time.Time) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetDeletedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateDeletedAt() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateDeletedAt()
|
|
})
|
|
}
|
|
|
|
// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
func (u *UserUpsertBulk) ClearDeletedAt() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearDeletedAt()
|
|
})
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (u *UserUpsertBulk) SetName(v string) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetName(v)
|
|
})
|
|
}
|
|
|
|
// UpdateName sets the "name" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateName() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateName()
|
|
})
|
|
}
|
|
|
|
// SetEmail sets the "email" field.
|
|
func (u *UserUpsertBulk) SetEmail(v string) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetEmail(v)
|
|
})
|
|
}
|
|
|
|
// UpdateEmail sets the "email" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateEmail() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateEmail()
|
|
})
|
|
}
|
|
|
|
// ClearEmail clears the value of the "email" field.
|
|
func (u *UserUpsertBulk) ClearEmail() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearEmail()
|
|
})
|
|
}
|
|
|
|
// SetAvatarURL sets the "avatar_url" field.
|
|
func (u *UserUpsertBulk) SetAvatarURL(v string) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetAvatarURL(v)
|
|
})
|
|
}
|
|
|
|
// UpdateAvatarURL sets the "avatar_url" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateAvatarURL() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateAvatarURL()
|
|
})
|
|
}
|
|
|
|
// ClearAvatarURL clears the value of the "avatar_url" field.
|
|
func (u *UserUpsertBulk) ClearAvatarURL() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearAvatarURL()
|
|
})
|
|
}
|
|
|
|
// SetPassword sets the "password" field.
|
|
func (u *UserUpsertBulk) SetPassword(v string) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetPassword(v)
|
|
})
|
|
}
|
|
|
|
// UpdatePassword sets the "password" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdatePassword() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdatePassword()
|
|
})
|
|
}
|
|
|
|
// ClearPassword clears the value of the "password" field.
|
|
func (u *UserUpsertBulk) ClearPassword() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearPassword()
|
|
})
|
|
}
|
|
|
|
// SetRole sets the "role" field.
|
|
func (u *UserUpsertBulk) SetRole(v consts.UserRole) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetRole(v)
|
|
})
|
|
}
|
|
|
|
// UpdateRole sets the "role" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateRole() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateRole()
|
|
})
|
|
}
|
|
|
|
// SetStatus sets the "status" field.
|
|
func (u *UserUpsertBulk) SetStatus(v consts.UserStatus) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetStatus(v)
|
|
})
|
|
}
|
|
|
|
// UpdateStatus sets the "status" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateStatus() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateStatus()
|
|
})
|
|
}
|
|
|
|
// SetIsBlocked sets the "is_blocked" field.
|
|
func (u *UserUpsertBulk) SetIsBlocked(v bool) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetIsBlocked(v)
|
|
})
|
|
}
|
|
|
|
// UpdateIsBlocked sets the "is_blocked" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateIsBlocked() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateIsBlocked()
|
|
})
|
|
}
|
|
|
|
// SetDefaultConfigs sets the "default_configs" field.
|
|
func (u *UserUpsertBulk) SetDefaultConfigs(v map[consts.DefaultConfigType]uuid.UUID) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetDefaultConfigs(v)
|
|
})
|
|
}
|
|
|
|
// UpdateDefaultConfigs sets the "default_configs" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateDefaultConfigs() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateDefaultConfigs()
|
|
})
|
|
}
|
|
|
|
// ClearDefaultConfigs clears the value of the "default_configs" field.
|
|
func (u *UserUpsertBulk) ClearDefaultConfigs() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.ClearDefaultConfigs()
|
|
})
|
|
}
|
|
|
|
// SetCreatedAt sets the "created_at" field.
|
|
func (u *UserUpsertBulk) SetCreatedAt(v time.Time) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetCreatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateCreatedAt() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateCreatedAt()
|
|
})
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (u *UserUpsertBulk) SetUpdatedAt(v time.Time) *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.SetUpdatedAt(v)
|
|
})
|
|
}
|
|
|
|
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
|
|
func (u *UserUpsertBulk) UpdateUpdatedAt() *UserUpsertBulk {
|
|
return u.Update(func(s *UserUpsert) {
|
|
s.UpdateUpdatedAt()
|
|
})
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (u *UserUpsertBulk) 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 UserCreateBulk instead", i)
|
|
}
|
|
}
|
|
if len(u.create.conflict) == 0 {
|
|
return errors.New("db: missing options for UserCreateBulk.OnConflict")
|
|
}
|
|
return u.create.Exec(ctx)
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (u *UserUpsertBulk) ExecX(ctx context.Context) {
|
|
if err := u.create.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|