This was an epically long change, and a terrible idea, but it compiles. This was essentially a cascade that came about because I can't blend jet and bob in the same transaction. In for a penny, I guess...
5616 lines
148 KiB
Go
5616 lines
148 KiB
Go
// Code generated by BobGen psql v0.42.5. DO NOT EDIT.
|
|
// This file is meant to be re-generated in place and/or deleted at any time.
|
|
|
|
package models
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"io"
|
|
"time"
|
|
|
|
"github.com/Gleipnir-Technology/bob"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/dialect"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/dm"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/sm"
|
|
"github.com/Gleipnir-Technology/bob/dialect/psql/um"
|
|
"github.com/Gleipnir-Technology/bob/expr"
|
|
"github.com/Gleipnir-Technology/bob/orm"
|
|
"github.com/Gleipnir-Technology/bob/types/pgtypes"
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
|
"github.com/aarondl/opt/null"
|
|
"github.com/aarondl/opt/omit"
|
|
"github.com/aarondl/opt/omitnull"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// User is an object representing the database table.
|
|
type User struct {
|
|
ID int32 `db:"id,pk" `
|
|
ArcgisAccessToken null.Val[string] `db:"arcgis_access_token" `
|
|
ArcgisLicense null.Val[enums.Arcgislicensetype] `db:"arcgis_license" `
|
|
ArcgisRefreshToken null.Val[string] `db:"arcgis_refresh_token" `
|
|
ArcgisRefreshTokenExpires null.Val[time.Time] `db:"arcgis_refresh_token_expires" `
|
|
ArcgisRole null.Val[string] `db:"arcgis_role" `
|
|
DisplayName string `db:"display_name" `
|
|
Email null.Val[string] `db:"email" `
|
|
OrganizationID int32 `db:"organization_id" `
|
|
Username string `db:"username" `
|
|
PasswordHashType enums.Hashtype `db:"password_hash_type" `
|
|
PasswordHash string `db:"password_hash" `
|
|
Role enums.Userrole `db:"role" `
|
|
Avatar null.Val[uuid.UUID] `db:"avatar" `
|
|
IsActive bool `db:"is_active" `
|
|
IsDronePilot bool `db:"is_drone_pilot" `
|
|
IsWarrant bool `db:"is_warrant" `
|
|
|
|
R userR `db:"-" `
|
|
}
|
|
|
|
// UserSlice is an alias for a slice of pointers to User.
|
|
// This should almost always be used instead of []*User.
|
|
type UserSlice []*User
|
|
|
|
// Users contains methods to work with the user_ table
|
|
var Users = psql.NewTablex[*User, UserSlice, *UserSetter]("", "user_", buildUserColumns("user_"))
|
|
|
|
// UsersQuery is a query on the user_ table
|
|
type UsersQuery = *psql.ViewQuery[*User, UserSlice]
|
|
|
|
// userR is where relationships are stored.
|
|
type userR struct {
|
|
CreatorTextJobs CommsTextJobSlice // comms.text_job.text_job_creator_id_fkey
|
|
CommunicationLogEntries CommunicationLogEntrySlice // communication_log_entry.communication_log_entry_user__fkey
|
|
CreatorComplianceReportRequests ComplianceReportRequestSlice // compliance_report_request.compliance_report_request_creator_fkey
|
|
CreatorFeatures FeatureSlice // feature.feature_creator_id_fkey
|
|
CommitterFiles FileuploadFileSlice // fileupload.file.file_committer_fkey
|
|
CreatorFiles FileuploadFileSlice // fileupload.file.file_creator_id_fkey
|
|
FileuploadPool FileuploadPoolSlice // fileupload.pool.pool_creator_id_fkey
|
|
CreatorLeads LeadSlice // lead.lead_creator_fkey
|
|
ImpersonatorLogImpersonations LogImpersonationSlice // log_impersonation.log_impersonation_impersonator_id_fkey
|
|
TargetLogImpersonations LogImpersonationSlice // log_impersonation.log_impersonation_target_id_fkey
|
|
CreatorNoteAudios NoteAudioSlice // note_audio.note_audio_creator_id_fkey
|
|
DeletorNoteAudios NoteAudioSlice // note_audio.note_audio_deletor_id_fkey
|
|
CreatorNoteImages NoteImageSlice // note_image.note_image_creator_id_fkey
|
|
DeletorNoteImages NoteImageSlice // note_image.note_image_deletor_id_fkey
|
|
UserNotifications NotificationSlice // notification.notification_user_id_fkey
|
|
ReviewerNuisanceOlds PublicreportNuisanceOldSlice // publicreport.nuisance_old.nuisance_reviewer_id_fkey
|
|
ReviewerReports PublicreportReportSlice // publicreport.report.report_reviewer_id_fkey
|
|
UserReportLogs PublicreportReportLogSlice // publicreport.report_log.report_log_user_id_fkey
|
|
ReviewerWaterOlds PublicreportWaterOldSlice // publicreport.water_old.water_reviewer_id_fkey
|
|
CreatorReportTexts ReportTextSlice // report_text.report_text_creator_id_fkey
|
|
CreatorResidents ResidentSlice // resident.resident_creator_fkey
|
|
CreatorReviewTasks ReviewTaskSlice // review_task.review_task_creator_id_fkey
|
|
ReviewerReviewTasks ReviewTaskSlice // review_task.review_task_reviewer_id_fkey
|
|
AddressorSignals SignalSlice // signal.signal_addressor_fkey
|
|
CreatorSignals SignalSlice // signal.signal_creator_fkey
|
|
CreatorSites SiteSlice // site.site_creator_id_fkey
|
|
Organization *Organization // user_.user__organization_id_fkey
|
|
}
|
|
|
|
func buildUserColumns(alias string) userColumns {
|
|
return userColumns{
|
|
ColumnsExpr: expr.NewColumnsExpr(
|
|
"id", "arcgis_access_token", "arcgis_license", "arcgis_refresh_token", "arcgis_refresh_token_expires", "arcgis_role", "display_name", "email", "organization_id", "username", "password_hash_type", "password_hash", "role", "avatar", "is_active", "is_drone_pilot", "is_warrant",
|
|
).WithParent("user_"),
|
|
tableAlias: alias,
|
|
ID: psql.Quote(alias, "id"),
|
|
ArcgisAccessToken: psql.Quote(alias, "arcgis_access_token"),
|
|
ArcgisLicense: psql.Quote(alias, "arcgis_license"),
|
|
ArcgisRefreshToken: psql.Quote(alias, "arcgis_refresh_token"),
|
|
ArcgisRefreshTokenExpires: psql.Quote(alias, "arcgis_refresh_token_expires"),
|
|
ArcgisRole: psql.Quote(alias, "arcgis_role"),
|
|
DisplayName: psql.Quote(alias, "display_name"),
|
|
Email: psql.Quote(alias, "email"),
|
|
OrganizationID: psql.Quote(alias, "organization_id"),
|
|
Username: psql.Quote(alias, "username"),
|
|
PasswordHashType: psql.Quote(alias, "password_hash_type"),
|
|
PasswordHash: psql.Quote(alias, "password_hash"),
|
|
Role: psql.Quote(alias, "role"),
|
|
Avatar: psql.Quote(alias, "avatar"),
|
|
IsActive: psql.Quote(alias, "is_active"),
|
|
IsDronePilot: psql.Quote(alias, "is_drone_pilot"),
|
|
IsWarrant: psql.Quote(alias, "is_warrant"),
|
|
}
|
|
}
|
|
|
|
type userColumns struct {
|
|
expr.ColumnsExpr
|
|
tableAlias string
|
|
ID psql.Expression
|
|
ArcgisAccessToken psql.Expression
|
|
ArcgisLicense psql.Expression
|
|
ArcgisRefreshToken psql.Expression
|
|
ArcgisRefreshTokenExpires psql.Expression
|
|
ArcgisRole psql.Expression
|
|
DisplayName psql.Expression
|
|
Email psql.Expression
|
|
OrganizationID psql.Expression
|
|
Username psql.Expression
|
|
PasswordHashType psql.Expression
|
|
PasswordHash psql.Expression
|
|
Role psql.Expression
|
|
Avatar psql.Expression
|
|
IsActive psql.Expression
|
|
IsDronePilot psql.Expression
|
|
IsWarrant psql.Expression
|
|
}
|
|
|
|
func (c userColumns) Alias() string {
|
|
return c.tableAlias
|
|
}
|
|
|
|
func (userColumns) AliasedAs(alias string) userColumns {
|
|
return buildUserColumns(alias)
|
|
}
|
|
|
|
// UserSetter is used for insert/upsert/update operations
|
|
// All values are optional, and do not have to be set
|
|
// Generated columns are not included
|
|
type UserSetter struct {
|
|
ID omit.Val[int32] `db:"id,pk" `
|
|
ArcgisAccessToken omitnull.Val[string] `db:"arcgis_access_token" `
|
|
ArcgisLicense omitnull.Val[enums.Arcgislicensetype] `db:"arcgis_license" `
|
|
ArcgisRefreshToken omitnull.Val[string] `db:"arcgis_refresh_token" `
|
|
ArcgisRefreshTokenExpires omitnull.Val[time.Time] `db:"arcgis_refresh_token_expires" `
|
|
ArcgisRole omitnull.Val[string] `db:"arcgis_role" `
|
|
DisplayName omit.Val[string] `db:"display_name" `
|
|
Email omitnull.Val[string] `db:"email" `
|
|
OrganizationID omit.Val[int32] `db:"organization_id" `
|
|
Username omit.Val[string] `db:"username" `
|
|
PasswordHashType omit.Val[enums.Hashtype] `db:"password_hash_type" `
|
|
PasswordHash omit.Val[string] `db:"password_hash" `
|
|
Role omit.Val[enums.Userrole] `db:"role" `
|
|
Avatar omitnull.Val[uuid.UUID] `db:"avatar" `
|
|
IsActive omit.Val[bool] `db:"is_active" `
|
|
IsDronePilot omit.Val[bool] `db:"is_drone_pilot" `
|
|
IsWarrant omit.Val[bool] `db:"is_warrant" `
|
|
}
|
|
|
|
func (s UserSetter) SetColumns() []string {
|
|
vals := make([]string, 0, 17)
|
|
if s.ID.IsValue() {
|
|
vals = append(vals, "id")
|
|
}
|
|
if !s.ArcgisAccessToken.IsUnset() {
|
|
vals = append(vals, "arcgis_access_token")
|
|
}
|
|
if !s.ArcgisLicense.IsUnset() {
|
|
vals = append(vals, "arcgis_license")
|
|
}
|
|
if !s.ArcgisRefreshToken.IsUnset() {
|
|
vals = append(vals, "arcgis_refresh_token")
|
|
}
|
|
if !s.ArcgisRefreshTokenExpires.IsUnset() {
|
|
vals = append(vals, "arcgis_refresh_token_expires")
|
|
}
|
|
if !s.ArcgisRole.IsUnset() {
|
|
vals = append(vals, "arcgis_role")
|
|
}
|
|
if s.DisplayName.IsValue() {
|
|
vals = append(vals, "display_name")
|
|
}
|
|
if !s.Email.IsUnset() {
|
|
vals = append(vals, "email")
|
|
}
|
|
if s.OrganizationID.IsValue() {
|
|
vals = append(vals, "organization_id")
|
|
}
|
|
if s.Username.IsValue() {
|
|
vals = append(vals, "username")
|
|
}
|
|
if s.PasswordHashType.IsValue() {
|
|
vals = append(vals, "password_hash_type")
|
|
}
|
|
if s.PasswordHash.IsValue() {
|
|
vals = append(vals, "password_hash")
|
|
}
|
|
if s.Role.IsValue() {
|
|
vals = append(vals, "role")
|
|
}
|
|
if !s.Avatar.IsUnset() {
|
|
vals = append(vals, "avatar")
|
|
}
|
|
if s.IsActive.IsValue() {
|
|
vals = append(vals, "is_active")
|
|
}
|
|
if s.IsDronePilot.IsValue() {
|
|
vals = append(vals, "is_drone_pilot")
|
|
}
|
|
if s.IsWarrant.IsValue() {
|
|
vals = append(vals, "is_warrant")
|
|
}
|
|
return vals
|
|
}
|
|
|
|
func (s UserSetter) Overwrite(t *User) {
|
|
if s.ID.IsValue() {
|
|
t.ID = s.ID.MustGet()
|
|
}
|
|
if !s.ArcgisAccessToken.IsUnset() {
|
|
t.ArcgisAccessToken = s.ArcgisAccessToken.MustGetNull()
|
|
}
|
|
if !s.ArcgisLicense.IsUnset() {
|
|
t.ArcgisLicense = s.ArcgisLicense.MustGetNull()
|
|
}
|
|
if !s.ArcgisRefreshToken.IsUnset() {
|
|
t.ArcgisRefreshToken = s.ArcgisRefreshToken.MustGetNull()
|
|
}
|
|
if !s.ArcgisRefreshTokenExpires.IsUnset() {
|
|
t.ArcgisRefreshTokenExpires = s.ArcgisRefreshTokenExpires.MustGetNull()
|
|
}
|
|
if !s.ArcgisRole.IsUnset() {
|
|
t.ArcgisRole = s.ArcgisRole.MustGetNull()
|
|
}
|
|
if s.DisplayName.IsValue() {
|
|
t.DisplayName = s.DisplayName.MustGet()
|
|
}
|
|
if !s.Email.IsUnset() {
|
|
t.Email = s.Email.MustGetNull()
|
|
}
|
|
if s.OrganizationID.IsValue() {
|
|
t.OrganizationID = s.OrganizationID.MustGet()
|
|
}
|
|
if s.Username.IsValue() {
|
|
t.Username = s.Username.MustGet()
|
|
}
|
|
if s.PasswordHashType.IsValue() {
|
|
t.PasswordHashType = s.PasswordHashType.MustGet()
|
|
}
|
|
if s.PasswordHash.IsValue() {
|
|
t.PasswordHash = s.PasswordHash.MustGet()
|
|
}
|
|
if s.Role.IsValue() {
|
|
t.Role = s.Role.MustGet()
|
|
}
|
|
if !s.Avatar.IsUnset() {
|
|
t.Avatar = s.Avatar.MustGetNull()
|
|
}
|
|
if s.IsActive.IsValue() {
|
|
t.IsActive = s.IsActive.MustGet()
|
|
}
|
|
if s.IsDronePilot.IsValue() {
|
|
t.IsDronePilot = s.IsDronePilot.MustGet()
|
|
}
|
|
if s.IsWarrant.IsValue() {
|
|
t.IsWarrant = s.IsWarrant.MustGet()
|
|
}
|
|
}
|
|
|
|
func (s *UserSetter) Apply(q *dialect.InsertQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return Users.BeforeInsertHooks.RunHooks(ctx, exec, s)
|
|
})
|
|
|
|
q.AppendValues(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
vals := make([]bob.Expression, 17)
|
|
if s.ID.IsValue() {
|
|
vals[0] = psql.Arg(s.ID.MustGet())
|
|
} else {
|
|
vals[0] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ArcgisAccessToken.IsUnset() {
|
|
vals[1] = psql.Arg(s.ArcgisAccessToken.MustGetNull())
|
|
} else {
|
|
vals[1] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ArcgisLicense.IsUnset() {
|
|
vals[2] = psql.Arg(s.ArcgisLicense.MustGetNull())
|
|
} else {
|
|
vals[2] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ArcgisRefreshToken.IsUnset() {
|
|
vals[3] = psql.Arg(s.ArcgisRefreshToken.MustGetNull())
|
|
} else {
|
|
vals[3] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ArcgisRefreshTokenExpires.IsUnset() {
|
|
vals[4] = psql.Arg(s.ArcgisRefreshTokenExpires.MustGetNull())
|
|
} else {
|
|
vals[4] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.ArcgisRole.IsUnset() {
|
|
vals[5] = psql.Arg(s.ArcgisRole.MustGetNull())
|
|
} else {
|
|
vals[5] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.DisplayName.IsValue() {
|
|
vals[6] = psql.Arg(s.DisplayName.MustGet())
|
|
} else {
|
|
vals[6] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Email.IsUnset() {
|
|
vals[7] = psql.Arg(s.Email.MustGetNull())
|
|
} else {
|
|
vals[7] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.OrganizationID.IsValue() {
|
|
vals[8] = psql.Arg(s.OrganizationID.MustGet())
|
|
} else {
|
|
vals[8] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Username.IsValue() {
|
|
vals[9] = psql.Arg(s.Username.MustGet())
|
|
} else {
|
|
vals[9] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.PasswordHashType.IsValue() {
|
|
vals[10] = psql.Arg(s.PasswordHashType.MustGet())
|
|
} else {
|
|
vals[10] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.PasswordHash.IsValue() {
|
|
vals[11] = psql.Arg(s.PasswordHash.MustGet())
|
|
} else {
|
|
vals[11] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.Role.IsValue() {
|
|
vals[12] = psql.Arg(s.Role.MustGet())
|
|
} else {
|
|
vals[12] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if !s.Avatar.IsUnset() {
|
|
vals[13] = psql.Arg(s.Avatar.MustGetNull())
|
|
} else {
|
|
vals[13] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.IsActive.IsValue() {
|
|
vals[14] = psql.Arg(s.IsActive.MustGet())
|
|
} else {
|
|
vals[14] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.IsDronePilot.IsValue() {
|
|
vals[15] = psql.Arg(s.IsDronePilot.MustGet())
|
|
} else {
|
|
vals[15] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
if s.IsWarrant.IsValue() {
|
|
vals[16] = psql.Arg(s.IsWarrant.MustGet())
|
|
} else {
|
|
vals[16] = psql.Raw("DEFAULT")
|
|
}
|
|
|
|
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
|
}))
|
|
}
|
|
|
|
func (s UserSetter) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
return um.Set(s.Expressions()...)
|
|
}
|
|
|
|
func (s UserSetter) Expressions(prefix ...string) []bob.Expression {
|
|
exprs := make([]bob.Expression, 0, 17)
|
|
|
|
if s.ID.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "id")...),
|
|
psql.Arg(s.ID),
|
|
}})
|
|
}
|
|
|
|
if !s.ArcgisAccessToken.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "arcgis_access_token")...),
|
|
psql.Arg(s.ArcgisAccessToken),
|
|
}})
|
|
}
|
|
|
|
if !s.ArcgisLicense.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "arcgis_license")...),
|
|
psql.Arg(s.ArcgisLicense),
|
|
}})
|
|
}
|
|
|
|
if !s.ArcgisRefreshToken.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "arcgis_refresh_token")...),
|
|
psql.Arg(s.ArcgisRefreshToken),
|
|
}})
|
|
}
|
|
|
|
if !s.ArcgisRefreshTokenExpires.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "arcgis_refresh_token_expires")...),
|
|
psql.Arg(s.ArcgisRefreshTokenExpires),
|
|
}})
|
|
}
|
|
|
|
if !s.ArcgisRole.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "arcgis_role")...),
|
|
psql.Arg(s.ArcgisRole),
|
|
}})
|
|
}
|
|
|
|
if s.DisplayName.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "display_name")...),
|
|
psql.Arg(s.DisplayName),
|
|
}})
|
|
}
|
|
|
|
if !s.Email.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "email")...),
|
|
psql.Arg(s.Email),
|
|
}})
|
|
}
|
|
|
|
if s.OrganizationID.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "organization_id")...),
|
|
psql.Arg(s.OrganizationID),
|
|
}})
|
|
}
|
|
|
|
if s.Username.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "username")...),
|
|
psql.Arg(s.Username),
|
|
}})
|
|
}
|
|
|
|
if s.PasswordHashType.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "password_hash_type")...),
|
|
psql.Arg(s.PasswordHashType),
|
|
}})
|
|
}
|
|
|
|
if s.PasswordHash.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "password_hash")...),
|
|
psql.Arg(s.PasswordHash),
|
|
}})
|
|
}
|
|
|
|
if s.Role.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "role")...),
|
|
psql.Arg(s.Role),
|
|
}})
|
|
}
|
|
|
|
if !s.Avatar.IsUnset() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "avatar")...),
|
|
psql.Arg(s.Avatar),
|
|
}})
|
|
}
|
|
|
|
if s.IsActive.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "is_active")...),
|
|
psql.Arg(s.IsActive),
|
|
}})
|
|
}
|
|
|
|
if s.IsDronePilot.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "is_drone_pilot")...),
|
|
psql.Arg(s.IsDronePilot),
|
|
}})
|
|
}
|
|
|
|
if s.IsWarrant.IsValue() {
|
|
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
|
psql.Quote(append(prefix, "is_warrant")...),
|
|
psql.Arg(s.IsWarrant),
|
|
}})
|
|
}
|
|
|
|
return exprs
|
|
}
|
|
|
|
// FindUser retrieves a single record by primary key
|
|
// If cols is empty Find will return all columns.
|
|
func FindUser(ctx context.Context, exec bob.Executor, IDPK int32, cols ...string) (*User, error) {
|
|
if len(cols) == 0 {
|
|
return Users.Query(
|
|
sm.Where(Users.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
).One(ctx, exec)
|
|
}
|
|
|
|
return Users.Query(
|
|
sm.Where(Users.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
sm.Columns(Users.Columns.Only(cols...)),
|
|
).One(ctx, exec)
|
|
}
|
|
|
|
// UserExists checks the presence of a single record by primary key
|
|
func UserExists(ctx context.Context, exec bob.Executor, IDPK int32) (bool, error) {
|
|
return Users.Query(
|
|
sm.Where(Users.Columns.ID.EQ(psql.Arg(IDPK))),
|
|
).Exists(ctx, exec)
|
|
}
|
|
|
|
// AfterQueryHook is called after User is retrieved from the database
|
|
func (o *User) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
var err error
|
|
|
|
switch queryType {
|
|
case bob.QueryTypeSelect:
|
|
ctx, err = Users.AfterSelectHooks.RunHooks(ctx, exec, UserSlice{o})
|
|
case bob.QueryTypeInsert:
|
|
ctx, err = Users.AfterInsertHooks.RunHooks(ctx, exec, UserSlice{o})
|
|
case bob.QueryTypeUpdate:
|
|
ctx, err = Users.AfterUpdateHooks.RunHooks(ctx, exec, UserSlice{o})
|
|
case bob.QueryTypeDelete:
|
|
ctx, err = Users.AfterDeleteHooks.RunHooks(ctx, exec, UserSlice{o})
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// primaryKeyVals returns the primary key values of the User
|
|
func (o *User) primaryKeyVals() bob.Expression {
|
|
return psql.Arg(o.ID)
|
|
}
|
|
|
|
func (o *User) pkEQ() dialect.Expression {
|
|
return psql.Quote("user_", "id").EQ(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
return o.primaryKeyVals().WriteSQL(ctx, w, d, start)
|
|
}))
|
|
}
|
|
|
|
// Update uses an executor to update the User
|
|
func (o *User) Update(ctx context.Context, exec bob.Executor, s *UserSetter) error {
|
|
v, err := Users.Update(s.UpdateMod(), um.Where(o.pkEQ())).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
o.R = v.R
|
|
*o = *v
|
|
|
|
return nil
|
|
}
|
|
|
|
// Delete deletes a single User record with an executor
|
|
func (o *User) Delete(ctx context.Context, exec bob.Executor) error {
|
|
_, err := Users.Delete(dm.Where(o.pkEQ())).Exec(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
// Reload refreshes the User using the executor
|
|
func (o *User) Reload(ctx context.Context, exec bob.Executor) error {
|
|
o2, err := Users.Query(
|
|
sm.Where(Users.Columns.ID.EQ(psql.Arg(o.ID))),
|
|
).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
o2.R = o.R
|
|
*o = *o2
|
|
|
|
return nil
|
|
}
|
|
|
|
// AfterQueryHook is called after UserSlice is retrieved from the database
|
|
func (o UserSlice) AfterQueryHook(ctx context.Context, exec bob.Executor, queryType bob.QueryType) error {
|
|
var err error
|
|
|
|
switch queryType {
|
|
case bob.QueryTypeSelect:
|
|
ctx, err = Users.AfterSelectHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeInsert:
|
|
ctx, err = Users.AfterInsertHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeUpdate:
|
|
ctx, err = Users.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
case bob.QueryTypeDelete:
|
|
ctx, err = Users.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
func (o UserSlice) pkIN() dialect.Expression {
|
|
if len(o) == 0 {
|
|
return psql.Raw("NULL")
|
|
}
|
|
|
|
return psql.Quote("user_", "id").In(bob.ExpressionFunc(func(ctx context.Context, w io.StringWriter, d bob.Dialect, start int) ([]any, error) {
|
|
pkPairs := make([]bob.Expression, len(o))
|
|
for i, row := range o {
|
|
pkPairs[i] = row.primaryKeyVals()
|
|
}
|
|
return bob.ExpressSlice(ctx, w, d, start, pkPairs, "", ", ", "")
|
|
}))
|
|
}
|
|
|
|
// copyMatchingRows finds models in the given slice that have the same primary key
|
|
// then it first copies the existing relationships from the old model to the new model
|
|
// and then replaces the old model in the slice with the new model
|
|
func (o UserSlice) copyMatchingRows(from ...*User) {
|
|
for i, old := range o {
|
|
for _, new := range from {
|
|
if new.ID != old.ID {
|
|
continue
|
|
}
|
|
new.R = old.R
|
|
o[i] = new
|
|
break
|
|
}
|
|
}
|
|
}
|
|
|
|
// UpdateMod modifies an update query with "WHERE primary_key IN (o...)"
|
|
func (o UserSlice) UpdateMod() bob.Mod[*dialect.UpdateQuery] {
|
|
return bob.ModFunc[*dialect.UpdateQuery](func(q *dialect.UpdateQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return Users.BeforeUpdateHooks.RunHooks(ctx, exec, o)
|
|
})
|
|
|
|
q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
|
|
var err error
|
|
switch retrieved := retrieved.(type) {
|
|
case *User:
|
|
o.copyMatchingRows(retrieved)
|
|
case []*User:
|
|
o.copyMatchingRows(retrieved...)
|
|
case UserSlice:
|
|
o.copyMatchingRows(retrieved...)
|
|
default:
|
|
// If the retrieved value is not a User or a slice of User
|
|
// then run the AfterUpdateHooks on the slice
|
|
_, err = Users.AfterUpdateHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}))
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
})
|
|
}
|
|
|
|
// DeleteMod modifies an delete query with "WHERE primary_key IN (o...)"
|
|
func (o UserSlice) DeleteMod() bob.Mod[*dialect.DeleteQuery] {
|
|
return bob.ModFunc[*dialect.DeleteQuery](func(q *dialect.DeleteQuery) {
|
|
q.AppendHooks(func(ctx context.Context, exec bob.Executor) (context.Context, error) {
|
|
return Users.BeforeDeleteHooks.RunHooks(ctx, exec, o)
|
|
})
|
|
|
|
q.AppendLoader(bob.LoaderFunc(func(ctx context.Context, exec bob.Executor, retrieved any) error {
|
|
var err error
|
|
switch retrieved := retrieved.(type) {
|
|
case *User:
|
|
o.copyMatchingRows(retrieved)
|
|
case []*User:
|
|
o.copyMatchingRows(retrieved...)
|
|
case UserSlice:
|
|
o.copyMatchingRows(retrieved...)
|
|
default:
|
|
// If the retrieved value is not a User or a slice of User
|
|
// then run the AfterDeleteHooks on the slice
|
|
_, err = Users.AfterDeleteHooks.RunHooks(ctx, exec, o)
|
|
}
|
|
|
|
return err
|
|
}))
|
|
|
|
q.AppendWhere(o.pkIN())
|
|
})
|
|
}
|
|
|
|
func (o UserSlice) UpdateAll(ctx context.Context, exec bob.Executor, vals UserSetter) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
_, err := Users.Update(vals.UpdateMod(), o.UpdateMod()).All(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
func (o UserSlice) DeleteAll(ctx context.Context, exec bob.Executor) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
_, err := Users.Delete(o.DeleteMod()).Exec(ctx, exec)
|
|
return err
|
|
}
|
|
|
|
func (o UserSlice) ReloadAll(ctx context.Context, exec bob.Executor) error {
|
|
if len(o) == 0 {
|
|
return nil
|
|
}
|
|
|
|
o2, err := Users.Query(sm.Where(o.pkIN())).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
o.copyMatchingRows(o2...)
|
|
|
|
return nil
|
|
}
|
|
|
|
// CreatorTextJobs starts a query for related objects on comms.text_job
|
|
func (o *User) CreatorTextJobs(mods ...bob.Mod[*dialect.SelectQuery]) CommsTextJobsQuery {
|
|
return CommsTextJobs.Query(append(mods,
|
|
sm.Where(CommsTextJobs.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorTextJobs(mods ...bob.Mod[*dialect.SelectQuery]) CommsTextJobsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return CommsTextJobs.Query(append(mods,
|
|
sm.Where(psql.Group(CommsTextJobs.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CommunicationLogEntries starts a query for related objects on communication_log_entry
|
|
func (o *User) CommunicationLogEntries(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationLogEntriesQuery {
|
|
return CommunicationLogEntries.Query(append(mods,
|
|
sm.Where(CommunicationLogEntries.Columns.User.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CommunicationLogEntries(mods ...bob.Mod[*dialect.SelectQuery]) CommunicationLogEntriesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return CommunicationLogEntries.Query(append(mods,
|
|
sm.Where(psql.Group(CommunicationLogEntries.Columns.User).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorComplianceReportRequests starts a query for related objects on compliance_report_request
|
|
func (o *User) CreatorComplianceReportRequests(mods ...bob.Mod[*dialect.SelectQuery]) ComplianceReportRequestsQuery {
|
|
return ComplianceReportRequests.Query(append(mods,
|
|
sm.Where(ComplianceReportRequests.Columns.Creator.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorComplianceReportRequests(mods ...bob.Mod[*dialect.SelectQuery]) ComplianceReportRequestsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return ComplianceReportRequests.Query(append(mods,
|
|
sm.Where(psql.Group(ComplianceReportRequests.Columns.Creator).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorFeatures starts a query for related objects on feature
|
|
func (o *User) CreatorFeatures(mods ...bob.Mod[*dialect.SelectQuery]) FeaturesQuery {
|
|
return Features.Query(append(mods,
|
|
sm.Where(Features.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorFeatures(mods ...bob.Mod[*dialect.SelectQuery]) FeaturesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return Features.Query(append(mods,
|
|
sm.Where(psql.Group(Features.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CommitterFiles starts a query for related objects on fileupload.file
|
|
func (o *User) CommitterFiles(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadFilesQuery {
|
|
return FileuploadFiles.Query(append(mods,
|
|
sm.Where(FileuploadFiles.Columns.Committer.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CommitterFiles(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadFilesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return FileuploadFiles.Query(append(mods,
|
|
sm.Where(psql.Group(FileuploadFiles.Columns.Committer).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorFiles starts a query for related objects on fileupload.file
|
|
func (o *User) CreatorFiles(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadFilesQuery {
|
|
return FileuploadFiles.Query(append(mods,
|
|
sm.Where(FileuploadFiles.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorFiles(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadFilesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return FileuploadFiles.Query(append(mods,
|
|
sm.Where(psql.Group(FileuploadFiles.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// FileuploadPool starts a query for related objects on fileupload.pool
|
|
func (o *User) FileuploadPool(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadPoolsQuery {
|
|
return FileuploadPools.Query(append(mods,
|
|
sm.Where(FileuploadPools.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) FileuploadPool(mods ...bob.Mod[*dialect.SelectQuery]) FileuploadPoolsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return FileuploadPools.Query(append(mods,
|
|
sm.Where(psql.Group(FileuploadPools.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorLeads starts a query for related objects on lead
|
|
func (o *User) CreatorLeads(mods ...bob.Mod[*dialect.SelectQuery]) LeadsQuery {
|
|
return Leads.Query(append(mods,
|
|
sm.Where(Leads.Columns.Creator.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorLeads(mods ...bob.Mod[*dialect.SelectQuery]) LeadsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return Leads.Query(append(mods,
|
|
sm.Where(psql.Group(Leads.Columns.Creator).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ImpersonatorLogImpersonations starts a query for related objects on log_impersonation
|
|
func (o *User) ImpersonatorLogImpersonations(mods ...bob.Mod[*dialect.SelectQuery]) LogImpersonationsQuery {
|
|
return LogImpersonations.Query(append(mods,
|
|
sm.Where(LogImpersonations.Columns.ImpersonatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) ImpersonatorLogImpersonations(mods ...bob.Mod[*dialect.SelectQuery]) LogImpersonationsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return LogImpersonations.Query(append(mods,
|
|
sm.Where(psql.Group(LogImpersonations.Columns.ImpersonatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// TargetLogImpersonations starts a query for related objects on log_impersonation
|
|
func (o *User) TargetLogImpersonations(mods ...bob.Mod[*dialect.SelectQuery]) LogImpersonationsQuery {
|
|
return LogImpersonations.Query(append(mods,
|
|
sm.Where(LogImpersonations.Columns.TargetID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) TargetLogImpersonations(mods ...bob.Mod[*dialect.SelectQuery]) LogImpersonationsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return LogImpersonations.Query(append(mods,
|
|
sm.Where(psql.Group(LogImpersonations.Columns.TargetID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorNoteAudios starts a query for related objects on note_audio
|
|
func (o *User) CreatorNoteAudios(mods ...bob.Mod[*dialect.SelectQuery]) NoteAudiosQuery {
|
|
return NoteAudios.Query(append(mods,
|
|
sm.Where(NoteAudios.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorNoteAudios(mods ...bob.Mod[*dialect.SelectQuery]) NoteAudiosQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return NoteAudios.Query(append(mods,
|
|
sm.Where(psql.Group(NoteAudios.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// DeletorNoteAudios starts a query for related objects on note_audio
|
|
func (o *User) DeletorNoteAudios(mods ...bob.Mod[*dialect.SelectQuery]) NoteAudiosQuery {
|
|
return NoteAudios.Query(append(mods,
|
|
sm.Where(NoteAudios.Columns.DeletorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) DeletorNoteAudios(mods ...bob.Mod[*dialect.SelectQuery]) NoteAudiosQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return NoteAudios.Query(append(mods,
|
|
sm.Where(psql.Group(NoteAudios.Columns.DeletorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorNoteImages starts a query for related objects on note_image
|
|
func (o *User) CreatorNoteImages(mods ...bob.Mod[*dialect.SelectQuery]) NoteImagesQuery {
|
|
return NoteImages.Query(append(mods,
|
|
sm.Where(NoteImages.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorNoteImages(mods ...bob.Mod[*dialect.SelectQuery]) NoteImagesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return NoteImages.Query(append(mods,
|
|
sm.Where(psql.Group(NoteImages.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// DeletorNoteImages starts a query for related objects on note_image
|
|
func (o *User) DeletorNoteImages(mods ...bob.Mod[*dialect.SelectQuery]) NoteImagesQuery {
|
|
return NoteImages.Query(append(mods,
|
|
sm.Where(NoteImages.Columns.DeletorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) DeletorNoteImages(mods ...bob.Mod[*dialect.SelectQuery]) NoteImagesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return NoteImages.Query(append(mods,
|
|
sm.Where(psql.Group(NoteImages.Columns.DeletorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// UserNotifications starts a query for related objects on notification
|
|
func (o *User) UserNotifications(mods ...bob.Mod[*dialect.SelectQuery]) NotificationsQuery {
|
|
return Notifications.Query(append(mods,
|
|
sm.Where(Notifications.Columns.UserID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) UserNotifications(mods ...bob.Mod[*dialect.SelectQuery]) NotificationsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return Notifications.Query(append(mods,
|
|
sm.Where(psql.Group(Notifications.Columns.UserID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ReviewerNuisanceOlds starts a query for related objects on publicreport.nuisance_old
|
|
func (o *User) ReviewerNuisanceOlds(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNuisanceOldsQuery {
|
|
return PublicreportNuisanceOlds.Query(append(mods,
|
|
sm.Where(PublicreportNuisanceOlds.Columns.ReviewerID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) ReviewerNuisanceOlds(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportNuisanceOldsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportNuisanceOlds.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportNuisanceOlds.Columns.ReviewerID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ReviewerReports starts a query for related objects on publicreport.report
|
|
func (o *User) ReviewerReports(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportsQuery {
|
|
return PublicreportReports.Query(append(mods,
|
|
sm.Where(PublicreportReports.Columns.ReviewerID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) ReviewerReports(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportReports.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportReports.Columns.ReviewerID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// UserReportLogs starts a query for related objects on publicreport.report_log
|
|
func (o *User) UserReportLogs(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportLogsQuery {
|
|
return PublicreportReportLogs.Query(append(mods,
|
|
sm.Where(PublicreportReportLogs.Columns.UserID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) UserReportLogs(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportReportLogsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportReportLogs.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportReportLogs.Columns.UserID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ReviewerWaterOlds starts a query for related objects on publicreport.water_old
|
|
func (o *User) ReviewerWaterOlds(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportWaterOldsQuery {
|
|
return PublicreportWaterOlds.Query(append(mods,
|
|
sm.Where(PublicreportWaterOlds.Columns.ReviewerID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) ReviewerWaterOlds(mods ...bob.Mod[*dialect.SelectQuery]) PublicreportWaterOldsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return PublicreportWaterOlds.Query(append(mods,
|
|
sm.Where(psql.Group(PublicreportWaterOlds.Columns.ReviewerID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorReportTexts starts a query for related objects on report_text
|
|
func (o *User) CreatorReportTexts(mods ...bob.Mod[*dialect.SelectQuery]) ReportTextsQuery {
|
|
return ReportTexts.Query(append(mods,
|
|
sm.Where(ReportTexts.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorReportTexts(mods ...bob.Mod[*dialect.SelectQuery]) ReportTextsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return ReportTexts.Query(append(mods,
|
|
sm.Where(psql.Group(ReportTexts.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorResidents starts a query for related objects on resident
|
|
func (o *User) CreatorResidents(mods ...bob.Mod[*dialect.SelectQuery]) ResidentsQuery {
|
|
return Residents.Query(append(mods,
|
|
sm.Where(Residents.Columns.Creator.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorResidents(mods ...bob.Mod[*dialect.SelectQuery]) ResidentsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return Residents.Query(append(mods,
|
|
sm.Where(psql.Group(Residents.Columns.Creator).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorReviewTasks starts a query for related objects on review_task
|
|
func (o *User) CreatorReviewTasks(mods ...bob.Mod[*dialect.SelectQuery]) ReviewTasksQuery {
|
|
return ReviewTasks.Query(append(mods,
|
|
sm.Where(ReviewTasks.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorReviewTasks(mods ...bob.Mod[*dialect.SelectQuery]) ReviewTasksQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return ReviewTasks.Query(append(mods,
|
|
sm.Where(psql.Group(ReviewTasks.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// ReviewerReviewTasks starts a query for related objects on review_task
|
|
func (o *User) ReviewerReviewTasks(mods ...bob.Mod[*dialect.SelectQuery]) ReviewTasksQuery {
|
|
return ReviewTasks.Query(append(mods,
|
|
sm.Where(ReviewTasks.Columns.ReviewerID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) ReviewerReviewTasks(mods ...bob.Mod[*dialect.SelectQuery]) ReviewTasksQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return ReviewTasks.Query(append(mods,
|
|
sm.Where(psql.Group(ReviewTasks.Columns.ReviewerID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// AddressorSignals starts a query for related objects on signal
|
|
func (o *User) AddressorSignals(mods ...bob.Mod[*dialect.SelectQuery]) SignalsQuery {
|
|
return Signals.Query(append(mods,
|
|
sm.Where(Signals.Columns.Addressor.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) AddressorSignals(mods ...bob.Mod[*dialect.SelectQuery]) SignalsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return Signals.Query(append(mods,
|
|
sm.Where(psql.Group(Signals.Columns.Addressor).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorSignals starts a query for related objects on signal
|
|
func (o *User) CreatorSignals(mods ...bob.Mod[*dialect.SelectQuery]) SignalsQuery {
|
|
return Signals.Query(append(mods,
|
|
sm.Where(Signals.Columns.Creator.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorSignals(mods ...bob.Mod[*dialect.SelectQuery]) SignalsQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return Signals.Query(append(mods,
|
|
sm.Where(psql.Group(Signals.Columns.Creator).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// CreatorSites starts a query for related objects on site
|
|
func (o *User) CreatorSites(mods ...bob.Mod[*dialect.SelectQuery]) SitesQuery {
|
|
return Sites.Query(append(mods,
|
|
sm.Where(Sites.Columns.CreatorID.EQ(psql.Arg(o.ID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) CreatorSites(mods ...bob.Mod[*dialect.SelectQuery]) SitesQuery {
|
|
pkID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkID = append(pkID, o.ID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkID), "integer[]")),
|
|
))
|
|
|
|
return Sites.Query(append(mods,
|
|
sm.Where(psql.Group(Sites.Columns.CreatorID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
// Organization starts a query for related objects on organization
|
|
func (o *User) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
return Organizations.Query(append(mods,
|
|
sm.Where(Organizations.Columns.ID.EQ(psql.Arg(o.OrganizationID))),
|
|
)...)
|
|
}
|
|
|
|
func (os UserSlice) Organization(mods ...bob.Mod[*dialect.SelectQuery]) OrganizationsQuery {
|
|
pkOrganizationID := make(pgtypes.Array[int32], 0, len(os))
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
pkOrganizationID = append(pkOrganizationID, o.OrganizationID)
|
|
}
|
|
PKArgExpr := psql.Select(sm.Columns(
|
|
psql.F("unnest", psql.Cast(psql.Arg(pkOrganizationID), "integer[]")),
|
|
))
|
|
|
|
return Organizations.Query(append(mods,
|
|
sm.Where(psql.Group(Organizations.Columns.ID).OP("IN", PKArgExpr)),
|
|
)...)
|
|
}
|
|
|
|
func insertUserCreatorTextJobs0(ctx context.Context, exec bob.Executor, commsTextJobs1 []*CommsTextJobSetter, user0 *User) (CommsTextJobSlice, error) {
|
|
for i := range commsTextJobs1 {
|
|
commsTextJobs1[i].CreatorID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := CommsTextJobs.Insert(bob.ToMods(commsTextJobs1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorTextJobs0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorTextJobs0(ctx context.Context, exec bob.Executor, count int, commsTextJobs1 CommsTextJobSlice, user0 *User) (CommsTextJobSlice, error) {
|
|
setter := &CommsTextJobSetter{
|
|
CreatorID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := commsTextJobs1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorTextJobs0: %w", err)
|
|
}
|
|
|
|
return commsTextJobs1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorTextJobs(ctx context.Context, exec bob.Executor, related ...*CommsTextJobSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
commsTextJobs1, err := insertUserCreatorTextJobs0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorTextJobs = append(user0.R.CreatorTextJobs, commsTextJobs1...)
|
|
|
|
for _, rel := range commsTextJobs1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorTextJobs(ctx context.Context, exec bob.Executor, related ...*CommsTextJob) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
commsTextJobs1 := CommsTextJobSlice(related)
|
|
|
|
_, err = attachUserCreatorTextJobs0(ctx, exec, len(related), commsTextJobs1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorTextJobs = append(user0.R.CreatorTextJobs, commsTextJobs1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCommunicationLogEntries0(ctx context.Context, exec bob.Executor, communicationLogEntries1 []*CommunicationLogEntrySetter, user0 *User) (CommunicationLogEntrySlice, error) {
|
|
for i := range communicationLogEntries1 {
|
|
communicationLogEntries1[i].User = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := CommunicationLogEntries.Insert(bob.ToMods(communicationLogEntries1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCommunicationLogEntries0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCommunicationLogEntries0(ctx context.Context, exec bob.Executor, count int, communicationLogEntries1 CommunicationLogEntrySlice, user0 *User) (CommunicationLogEntrySlice, error) {
|
|
setter := &CommunicationLogEntrySetter{
|
|
User: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := communicationLogEntries1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCommunicationLogEntries0: %w", err)
|
|
}
|
|
|
|
return communicationLogEntries1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCommunicationLogEntries(ctx context.Context, exec bob.Executor, related ...*CommunicationLogEntrySetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
communicationLogEntries1, err := insertUserCommunicationLogEntries0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CommunicationLogEntries = append(user0.R.CommunicationLogEntries, communicationLogEntries1...)
|
|
|
|
for _, rel := range communicationLogEntries1 {
|
|
rel.R.User = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCommunicationLogEntries(ctx context.Context, exec bob.Executor, related ...*CommunicationLogEntry) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
communicationLogEntries1 := CommunicationLogEntrySlice(related)
|
|
|
|
_, err = attachUserCommunicationLogEntries0(ctx, exec, len(related), communicationLogEntries1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CommunicationLogEntries = append(user0.R.CommunicationLogEntries, communicationLogEntries1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.User = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorComplianceReportRequests0(ctx context.Context, exec bob.Executor, complianceReportRequests1 []*ComplianceReportRequestSetter, user0 *User) (ComplianceReportRequestSlice, error) {
|
|
for i := range complianceReportRequests1 {
|
|
complianceReportRequests1[i].Creator = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := ComplianceReportRequests.Insert(bob.ToMods(complianceReportRequests1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorComplianceReportRequests0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorComplianceReportRequests0(ctx context.Context, exec bob.Executor, count int, complianceReportRequests1 ComplianceReportRequestSlice, user0 *User) (ComplianceReportRequestSlice, error) {
|
|
setter := &ComplianceReportRequestSetter{
|
|
Creator: omit.From(user0.ID),
|
|
}
|
|
|
|
err := complianceReportRequests1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorComplianceReportRequests0: %w", err)
|
|
}
|
|
|
|
return complianceReportRequests1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorComplianceReportRequests(ctx context.Context, exec bob.Executor, related ...*ComplianceReportRequestSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
complianceReportRequests1, err := insertUserCreatorComplianceReportRequests0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorComplianceReportRequests = append(user0.R.CreatorComplianceReportRequests, complianceReportRequests1...)
|
|
|
|
for _, rel := range complianceReportRequests1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorComplianceReportRequests(ctx context.Context, exec bob.Executor, related ...*ComplianceReportRequest) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
complianceReportRequests1 := ComplianceReportRequestSlice(related)
|
|
|
|
_, err = attachUserCreatorComplianceReportRequests0(ctx, exec, len(related), complianceReportRequests1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorComplianceReportRequests = append(user0.R.CreatorComplianceReportRequests, complianceReportRequests1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorFeatures0(ctx context.Context, exec bob.Executor, features1 []*FeatureSetter, user0 *User) (FeatureSlice, error) {
|
|
for i := range features1 {
|
|
features1[i].CreatorID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := Features.Insert(bob.ToMods(features1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorFeatures0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorFeatures0(ctx context.Context, exec bob.Executor, count int, features1 FeatureSlice, user0 *User) (FeatureSlice, error) {
|
|
setter := &FeatureSetter{
|
|
CreatorID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := features1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorFeatures0: %w", err)
|
|
}
|
|
|
|
return features1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorFeatures(ctx context.Context, exec bob.Executor, related ...*FeatureSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
features1, err := insertUserCreatorFeatures0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorFeatures = append(user0.R.CreatorFeatures, features1...)
|
|
|
|
for _, rel := range features1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorFeatures(ctx context.Context, exec bob.Executor, related ...*Feature) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
features1 := FeatureSlice(related)
|
|
|
|
_, err = attachUserCreatorFeatures0(ctx, exec, len(related), features1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorFeatures = append(user0.R.CreatorFeatures, features1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCommitterFiles0(ctx context.Context, exec bob.Executor, fileuploadFiles1 []*FileuploadFileSetter, user0 *User) (FileuploadFileSlice, error) {
|
|
for i := range fileuploadFiles1 {
|
|
fileuploadFiles1[i].Committer = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := FileuploadFiles.Insert(bob.ToMods(fileuploadFiles1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCommitterFiles0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCommitterFiles0(ctx context.Context, exec bob.Executor, count int, fileuploadFiles1 FileuploadFileSlice, user0 *User) (FileuploadFileSlice, error) {
|
|
setter := &FileuploadFileSetter{
|
|
Committer: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := fileuploadFiles1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCommitterFiles0: %w", err)
|
|
}
|
|
|
|
return fileuploadFiles1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCommitterFiles(ctx context.Context, exec bob.Executor, related ...*FileuploadFileSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
fileuploadFiles1, err := insertUserCommitterFiles0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CommitterFiles = append(user0.R.CommitterFiles, fileuploadFiles1...)
|
|
|
|
for _, rel := range fileuploadFiles1 {
|
|
rel.R.CommitterUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCommitterFiles(ctx context.Context, exec bob.Executor, related ...*FileuploadFile) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
fileuploadFiles1 := FileuploadFileSlice(related)
|
|
|
|
_, err = attachUserCommitterFiles0(ctx, exec, len(related), fileuploadFiles1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CommitterFiles = append(user0.R.CommitterFiles, fileuploadFiles1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CommitterUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorFiles0(ctx context.Context, exec bob.Executor, fileuploadFiles1 []*FileuploadFileSetter, user0 *User) (FileuploadFileSlice, error) {
|
|
for i := range fileuploadFiles1 {
|
|
fileuploadFiles1[i].CreatorID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := FileuploadFiles.Insert(bob.ToMods(fileuploadFiles1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorFiles0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorFiles0(ctx context.Context, exec bob.Executor, count int, fileuploadFiles1 FileuploadFileSlice, user0 *User) (FileuploadFileSlice, error) {
|
|
setter := &FileuploadFileSetter{
|
|
CreatorID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := fileuploadFiles1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorFiles0: %w", err)
|
|
}
|
|
|
|
return fileuploadFiles1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorFiles(ctx context.Context, exec bob.Executor, related ...*FileuploadFileSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
fileuploadFiles1, err := insertUserCreatorFiles0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorFiles = append(user0.R.CreatorFiles, fileuploadFiles1...)
|
|
|
|
for _, rel := range fileuploadFiles1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorFiles(ctx context.Context, exec bob.Executor, related ...*FileuploadFile) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
fileuploadFiles1 := FileuploadFileSlice(related)
|
|
|
|
_, err = attachUserCreatorFiles0(ctx, exec, len(related), fileuploadFiles1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorFiles = append(user0.R.CreatorFiles, fileuploadFiles1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserFileuploadPool0(ctx context.Context, exec bob.Executor, fileuploadPools1 []*FileuploadPoolSetter, user0 *User) (FileuploadPoolSlice, error) {
|
|
for i := range fileuploadPools1 {
|
|
fileuploadPools1[i].CreatorID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := FileuploadPools.Insert(bob.ToMods(fileuploadPools1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserFileuploadPool0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserFileuploadPool0(ctx context.Context, exec bob.Executor, count int, fileuploadPools1 FileuploadPoolSlice, user0 *User) (FileuploadPoolSlice, error) {
|
|
setter := &FileuploadPoolSetter{
|
|
CreatorID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := fileuploadPools1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserFileuploadPool0: %w", err)
|
|
}
|
|
|
|
return fileuploadPools1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertFileuploadPool(ctx context.Context, exec bob.Executor, related ...*FileuploadPoolSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
fileuploadPools1, err := insertUserFileuploadPool0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.FileuploadPool = append(user0.R.FileuploadPool, fileuploadPools1...)
|
|
|
|
for _, rel := range fileuploadPools1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachFileuploadPool(ctx context.Context, exec bob.Executor, related ...*FileuploadPool) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
fileuploadPools1 := FileuploadPoolSlice(related)
|
|
|
|
_, err = attachUserFileuploadPool0(ctx, exec, len(related), fileuploadPools1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.FileuploadPool = append(user0.R.FileuploadPool, fileuploadPools1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorLeads0(ctx context.Context, exec bob.Executor, leads1 []*LeadSetter, user0 *User) (LeadSlice, error) {
|
|
for i := range leads1 {
|
|
leads1[i].Creator = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := Leads.Insert(bob.ToMods(leads1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorLeads0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorLeads0(ctx context.Context, exec bob.Executor, count int, leads1 LeadSlice, user0 *User) (LeadSlice, error) {
|
|
setter := &LeadSetter{
|
|
Creator: omit.From(user0.ID),
|
|
}
|
|
|
|
err := leads1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorLeads0: %w", err)
|
|
}
|
|
|
|
return leads1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorLeads(ctx context.Context, exec bob.Executor, related ...*LeadSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
leads1, err := insertUserCreatorLeads0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorLeads = append(user0.R.CreatorLeads, leads1...)
|
|
|
|
for _, rel := range leads1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorLeads(ctx context.Context, exec bob.Executor, related ...*Lead) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
leads1 := LeadSlice(related)
|
|
|
|
_, err = attachUserCreatorLeads0(ctx, exec, len(related), leads1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorLeads = append(user0.R.CreatorLeads, leads1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserImpersonatorLogImpersonations0(ctx context.Context, exec bob.Executor, logImpersonations1 []*LogImpersonationSetter, user0 *User) (LogImpersonationSlice, error) {
|
|
for i := range logImpersonations1 {
|
|
logImpersonations1[i].ImpersonatorID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := LogImpersonations.Insert(bob.ToMods(logImpersonations1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserImpersonatorLogImpersonations0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserImpersonatorLogImpersonations0(ctx context.Context, exec bob.Executor, count int, logImpersonations1 LogImpersonationSlice, user0 *User) (LogImpersonationSlice, error) {
|
|
setter := &LogImpersonationSetter{
|
|
ImpersonatorID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := logImpersonations1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserImpersonatorLogImpersonations0: %w", err)
|
|
}
|
|
|
|
return logImpersonations1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertImpersonatorLogImpersonations(ctx context.Context, exec bob.Executor, related ...*LogImpersonationSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
logImpersonations1, err := insertUserImpersonatorLogImpersonations0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ImpersonatorLogImpersonations = append(user0.R.ImpersonatorLogImpersonations, logImpersonations1...)
|
|
|
|
for _, rel := range logImpersonations1 {
|
|
rel.R.ImpersonatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachImpersonatorLogImpersonations(ctx context.Context, exec bob.Executor, related ...*LogImpersonation) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
logImpersonations1 := LogImpersonationSlice(related)
|
|
|
|
_, err = attachUserImpersonatorLogImpersonations0(ctx, exec, len(related), logImpersonations1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ImpersonatorLogImpersonations = append(user0.R.ImpersonatorLogImpersonations, logImpersonations1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.ImpersonatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserTargetLogImpersonations0(ctx context.Context, exec bob.Executor, logImpersonations1 []*LogImpersonationSetter, user0 *User) (LogImpersonationSlice, error) {
|
|
for i := range logImpersonations1 {
|
|
logImpersonations1[i].TargetID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := LogImpersonations.Insert(bob.ToMods(logImpersonations1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserTargetLogImpersonations0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserTargetLogImpersonations0(ctx context.Context, exec bob.Executor, count int, logImpersonations1 LogImpersonationSlice, user0 *User) (LogImpersonationSlice, error) {
|
|
setter := &LogImpersonationSetter{
|
|
TargetID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := logImpersonations1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserTargetLogImpersonations0: %w", err)
|
|
}
|
|
|
|
return logImpersonations1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertTargetLogImpersonations(ctx context.Context, exec bob.Executor, related ...*LogImpersonationSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
logImpersonations1, err := insertUserTargetLogImpersonations0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.TargetLogImpersonations = append(user0.R.TargetLogImpersonations, logImpersonations1...)
|
|
|
|
for _, rel := range logImpersonations1 {
|
|
rel.R.TargetUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachTargetLogImpersonations(ctx context.Context, exec bob.Executor, related ...*LogImpersonation) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
logImpersonations1 := LogImpersonationSlice(related)
|
|
|
|
_, err = attachUserTargetLogImpersonations0(ctx, exec, len(related), logImpersonations1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.TargetLogImpersonations = append(user0.R.TargetLogImpersonations, logImpersonations1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.TargetUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorNoteAudios0(ctx context.Context, exec bob.Executor, noteAudios1 []*NoteAudioSetter, user0 *User) (NoteAudioSlice, error) {
|
|
for i := range noteAudios1 {
|
|
noteAudios1[i].CreatorID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := NoteAudios.Insert(bob.ToMods(noteAudios1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorNoteAudios0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorNoteAudios0(ctx context.Context, exec bob.Executor, count int, noteAudios1 NoteAudioSlice, user0 *User) (NoteAudioSlice, error) {
|
|
setter := &NoteAudioSetter{
|
|
CreatorID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := noteAudios1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorNoteAudios0: %w", err)
|
|
}
|
|
|
|
return noteAudios1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorNoteAudios(ctx context.Context, exec bob.Executor, related ...*NoteAudioSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
noteAudios1, err := insertUserCreatorNoteAudios0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorNoteAudios = append(user0.R.CreatorNoteAudios, noteAudios1...)
|
|
|
|
for _, rel := range noteAudios1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorNoteAudios(ctx context.Context, exec bob.Executor, related ...*NoteAudio) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
noteAudios1 := NoteAudioSlice(related)
|
|
|
|
_, err = attachUserCreatorNoteAudios0(ctx, exec, len(related), noteAudios1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorNoteAudios = append(user0.R.CreatorNoteAudios, noteAudios1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserDeletorNoteAudios0(ctx context.Context, exec bob.Executor, noteAudios1 []*NoteAudioSetter, user0 *User) (NoteAudioSlice, error) {
|
|
for i := range noteAudios1 {
|
|
noteAudios1[i].DeletorID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := NoteAudios.Insert(bob.ToMods(noteAudios1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserDeletorNoteAudios0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserDeletorNoteAudios0(ctx context.Context, exec bob.Executor, count int, noteAudios1 NoteAudioSlice, user0 *User) (NoteAudioSlice, error) {
|
|
setter := &NoteAudioSetter{
|
|
DeletorID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := noteAudios1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserDeletorNoteAudios0: %w", err)
|
|
}
|
|
|
|
return noteAudios1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertDeletorNoteAudios(ctx context.Context, exec bob.Executor, related ...*NoteAudioSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
noteAudios1, err := insertUserDeletorNoteAudios0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.DeletorNoteAudios = append(user0.R.DeletorNoteAudios, noteAudios1...)
|
|
|
|
for _, rel := range noteAudios1 {
|
|
rel.R.DeletorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachDeletorNoteAudios(ctx context.Context, exec bob.Executor, related ...*NoteAudio) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
noteAudios1 := NoteAudioSlice(related)
|
|
|
|
_, err = attachUserDeletorNoteAudios0(ctx, exec, len(related), noteAudios1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.DeletorNoteAudios = append(user0.R.DeletorNoteAudios, noteAudios1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.DeletorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorNoteImages0(ctx context.Context, exec bob.Executor, noteImages1 []*NoteImageSetter, user0 *User) (NoteImageSlice, error) {
|
|
for i := range noteImages1 {
|
|
noteImages1[i].CreatorID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := NoteImages.Insert(bob.ToMods(noteImages1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorNoteImages0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorNoteImages0(ctx context.Context, exec bob.Executor, count int, noteImages1 NoteImageSlice, user0 *User) (NoteImageSlice, error) {
|
|
setter := &NoteImageSetter{
|
|
CreatorID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := noteImages1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorNoteImages0: %w", err)
|
|
}
|
|
|
|
return noteImages1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorNoteImages(ctx context.Context, exec bob.Executor, related ...*NoteImageSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
noteImages1, err := insertUserCreatorNoteImages0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorNoteImages = append(user0.R.CreatorNoteImages, noteImages1...)
|
|
|
|
for _, rel := range noteImages1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorNoteImages(ctx context.Context, exec bob.Executor, related ...*NoteImage) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
noteImages1 := NoteImageSlice(related)
|
|
|
|
_, err = attachUserCreatorNoteImages0(ctx, exec, len(related), noteImages1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorNoteImages = append(user0.R.CreatorNoteImages, noteImages1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserDeletorNoteImages0(ctx context.Context, exec bob.Executor, noteImages1 []*NoteImageSetter, user0 *User) (NoteImageSlice, error) {
|
|
for i := range noteImages1 {
|
|
noteImages1[i].DeletorID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := NoteImages.Insert(bob.ToMods(noteImages1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserDeletorNoteImages0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserDeletorNoteImages0(ctx context.Context, exec bob.Executor, count int, noteImages1 NoteImageSlice, user0 *User) (NoteImageSlice, error) {
|
|
setter := &NoteImageSetter{
|
|
DeletorID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := noteImages1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserDeletorNoteImages0: %w", err)
|
|
}
|
|
|
|
return noteImages1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertDeletorNoteImages(ctx context.Context, exec bob.Executor, related ...*NoteImageSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
noteImages1, err := insertUserDeletorNoteImages0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.DeletorNoteImages = append(user0.R.DeletorNoteImages, noteImages1...)
|
|
|
|
for _, rel := range noteImages1 {
|
|
rel.R.DeletorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachDeletorNoteImages(ctx context.Context, exec bob.Executor, related ...*NoteImage) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
noteImages1 := NoteImageSlice(related)
|
|
|
|
_, err = attachUserDeletorNoteImages0(ctx, exec, len(related), noteImages1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.DeletorNoteImages = append(user0.R.DeletorNoteImages, noteImages1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.DeletorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserUserNotifications0(ctx context.Context, exec bob.Executor, notifications1 []*NotificationSetter, user0 *User) (NotificationSlice, error) {
|
|
for i := range notifications1 {
|
|
notifications1[i].UserID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := Notifications.Insert(bob.ToMods(notifications1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserUserNotifications0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserUserNotifications0(ctx context.Context, exec bob.Executor, count int, notifications1 NotificationSlice, user0 *User) (NotificationSlice, error) {
|
|
setter := &NotificationSetter{
|
|
UserID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := notifications1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserUserNotifications0: %w", err)
|
|
}
|
|
|
|
return notifications1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertUserNotifications(ctx context.Context, exec bob.Executor, related ...*NotificationSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
notifications1, err := insertUserUserNotifications0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.UserNotifications = append(user0.R.UserNotifications, notifications1...)
|
|
|
|
for _, rel := range notifications1 {
|
|
rel.R.UserUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachUserNotifications(ctx context.Context, exec bob.Executor, related ...*Notification) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
notifications1 := NotificationSlice(related)
|
|
|
|
_, err = attachUserUserNotifications0(ctx, exec, len(related), notifications1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.UserNotifications = append(user0.R.UserNotifications, notifications1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.UserUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserReviewerNuisanceOlds0(ctx context.Context, exec bob.Executor, publicreportNuisanceOlds1 []*PublicreportNuisanceOldSetter, user0 *User) (PublicreportNuisanceOldSlice, error) {
|
|
for i := range publicreportNuisanceOlds1 {
|
|
publicreportNuisanceOlds1[i].ReviewerID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportNuisanceOlds.Insert(bob.ToMods(publicreportNuisanceOlds1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserReviewerNuisanceOlds0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserReviewerNuisanceOlds0(ctx context.Context, exec bob.Executor, count int, publicreportNuisanceOlds1 PublicreportNuisanceOldSlice, user0 *User) (PublicreportNuisanceOldSlice, error) {
|
|
setter := &PublicreportNuisanceOldSetter{
|
|
ReviewerID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := publicreportNuisanceOlds1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserReviewerNuisanceOlds0: %w", err)
|
|
}
|
|
|
|
return publicreportNuisanceOlds1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertReviewerNuisanceOlds(ctx context.Context, exec bob.Executor, related ...*PublicreportNuisanceOldSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportNuisanceOlds1, err := insertUserReviewerNuisanceOlds0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ReviewerNuisanceOlds = append(user0.R.ReviewerNuisanceOlds, publicreportNuisanceOlds1...)
|
|
|
|
for _, rel := range publicreportNuisanceOlds1 {
|
|
rel.R.ReviewerUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachReviewerNuisanceOlds(ctx context.Context, exec bob.Executor, related ...*PublicreportNuisanceOld) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportNuisanceOlds1 := PublicreportNuisanceOldSlice(related)
|
|
|
|
_, err = attachUserReviewerNuisanceOlds0(ctx, exec, len(related), publicreportNuisanceOlds1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ReviewerNuisanceOlds = append(user0.R.ReviewerNuisanceOlds, publicreportNuisanceOlds1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.ReviewerUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserReviewerReports0(ctx context.Context, exec bob.Executor, publicreportReports1 []*PublicreportReportSetter, user0 *User) (PublicreportReportSlice, error) {
|
|
for i := range publicreportReports1 {
|
|
publicreportReports1[i].ReviewerID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportReports.Insert(bob.ToMods(publicreportReports1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserReviewerReports0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserReviewerReports0(ctx context.Context, exec bob.Executor, count int, publicreportReports1 PublicreportReportSlice, user0 *User) (PublicreportReportSlice, error) {
|
|
setter := &PublicreportReportSetter{
|
|
ReviewerID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := publicreportReports1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserReviewerReports0: %w", err)
|
|
}
|
|
|
|
return publicreportReports1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertReviewerReports(ctx context.Context, exec bob.Executor, related ...*PublicreportReportSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportReports1, err := insertUserReviewerReports0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ReviewerReports = append(user0.R.ReviewerReports, publicreportReports1...)
|
|
|
|
for _, rel := range publicreportReports1 {
|
|
rel.R.ReviewerUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachReviewerReports(ctx context.Context, exec bob.Executor, related ...*PublicreportReport) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportReports1 := PublicreportReportSlice(related)
|
|
|
|
_, err = attachUserReviewerReports0(ctx, exec, len(related), publicreportReports1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ReviewerReports = append(user0.R.ReviewerReports, publicreportReports1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.ReviewerUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserUserReportLogs0(ctx context.Context, exec bob.Executor, publicreportReportLogs1 []*PublicreportReportLogSetter, user0 *User) (PublicreportReportLogSlice, error) {
|
|
for i := range publicreportReportLogs1 {
|
|
publicreportReportLogs1[i].UserID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportReportLogs.Insert(bob.ToMods(publicreportReportLogs1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserUserReportLogs0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserUserReportLogs0(ctx context.Context, exec bob.Executor, count int, publicreportReportLogs1 PublicreportReportLogSlice, user0 *User) (PublicreportReportLogSlice, error) {
|
|
setter := &PublicreportReportLogSetter{
|
|
UserID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := publicreportReportLogs1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserUserReportLogs0: %w", err)
|
|
}
|
|
|
|
return publicreportReportLogs1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertUserReportLogs(ctx context.Context, exec bob.Executor, related ...*PublicreportReportLogSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportReportLogs1, err := insertUserUserReportLogs0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.UserReportLogs = append(user0.R.UserReportLogs, publicreportReportLogs1...)
|
|
|
|
for _, rel := range publicreportReportLogs1 {
|
|
rel.R.UserUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachUserReportLogs(ctx context.Context, exec bob.Executor, related ...*PublicreportReportLog) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportReportLogs1 := PublicreportReportLogSlice(related)
|
|
|
|
_, err = attachUserUserReportLogs0(ctx, exec, len(related), publicreportReportLogs1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.UserReportLogs = append(user0.R.UserReportLogs, publicreportReportLogs1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.UserUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserReviewerWaterOlds0(ctx context.Context, exec bob.Executor, publicreportWaterOlds1 []*PublicreportWaterOldSetter, user0 *User) (PublicreportWaterOldSlice, error) {
|
|
for i := range publicreportWaterOlds1 {
|
|
publicreportWaterOlds1[i].ReviewerID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := PublicreportWaterOlds.Insert(bob.ToMods(publicreportWaterOlds1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserReviewerWaterOlds0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserReviewerWaterOlds0(ctx context.Context, exec bob.Executor, count int, publicreportWaterOlds1 PublicreportWaterOldSlice, user0 *User) (PublicreportWaterOldSlice, error) {
|
|
setter := &PublicreportWaterOldSetter{
|
|
ReviewerID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := publicreportWaterOlds1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserReviewerWaterOlds0: %w", err)
|
|
}
|
|
|
|
return publicreportWaterOlds1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertReviewerWaterOlds(ctx context.Context, exec bob.Executor, related ...*PublicreportWaterOldSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
publicreportWaterOlds1, err := insertUserReviewerWaterOlds0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ReviewerWaterOlds = append(user0.R.ReviewerWaterOlds, publicreportWaterOlds1...)
|
|
|
|
for _, rel := range publicreportWaterOlds1 {
|
|
rel.R.ReviewerUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachReviewerWaterOlds(ctx context.Context, exec bob.Executor, related ...*PublicreportWaterOld) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
publicreportWaterOlds1 := PublicreportWaterOldSlice(related)
|
|
|
|
_, err = attachUserReviewerWaterOlds0(ctx, exec, len(related), publicreportWaterOlds1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ReviewerWaterOlds = append(user0.R.ReviewerWaterOlds, publicreportWaterOlds1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.ReviewerUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorReportTexts0(ctx context.Context, exec bob.Executor, reportTexts1 []*ReportTextSetter, user0 *User) (ReportTextSlice, error) {
|
|
for i := range reportTexts1 {
|
|
reportTexts1[i].CreatorID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := ReportTexts.Insert(bob.ToMods(reportTexts1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorReportTexts0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorReportTexts0(ctx context.Context, exec bob.Executor, count int, reportTexts1 ReportTextSlice, user0 *User) (ReportTextSlice, error) {
|
|
setter := &ReportTextSetter{
|
|
CreatorID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := reportTexts1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorReportTexts0: %w", err)
|
|
}
|
|
|
|
return reportTexts1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorReportTexts(ctx context.Context, exec bob.Executor, related ...*ReportTextSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
reportTexts1, err := insertUserCreatorReportTexts0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorReportTexts = append(user0.R.CreatorReportTexts, reportTexts1...)
|
|
|
|
for _, rel := range reportTexts1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorReportTexts(ctx context.Context, exec bob.Executor, related ...*ReportText) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
reportTexts1 := ReportTextSlice(related)
|
|
|
|
_, err = attachUserCreatorReportTexts0(ctx, exec, len(related), reportTexts1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorReportTexts = append(user0.R.CreatorReportTexts, reportTexts1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorResidents0(ctx context.Context, exec bob.Executor, residents1 []*ResidentSetter, user0 *User) (ResidentSlice, error) {
|
|
for i := range residents1 {
|
|
residents1[i].Creator = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := Residents.Insert(bob.ToMods(residents1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorResidents0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorResidents0(ctx context.Context, exec bob.Executor, count int, residents1 ResidentSlice, user0 *User) (ResidentSlice, error) {
|
|
setter := &ResidentSetter{
|
|
Creator: omit.From(user0.ID),
|
|
}
|
|
|
|
err := residents1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorResidents0: %w", err)
|
|
}
|
|
|
|
return residents1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorResidents(ctx context.Context, exec bob.Executor, related ...*ResidentSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
residents1, err := insertUserCreatorResidents0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorResidents = append(user0.R.CreatorResidents, residents1...)
|
|
|
|
for _, rel := range residents1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorResidents(ctx context.Context, exec bob.Executor, related ...*Resident) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
residents1 := ResidentSlice(related)
|
|
|
|
_, err = attachUserCreatorResidents0(ctx, exec, len(related), residents1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorResidents = append(user0.R.CreatorResidents, residents1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorReviewTasks0(ctx context.Context, exec bob.Executor, reviewTasks1 []*ReviewTaskSetter, user0 *User) (ReviewTaskSlice, error) {
|
|
for i := range reviewTasks1 {
|
|
reviewTasks1[i].CreatorID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := ReviewTasks.Insert(bob.ToMods(reviewTasks1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorReviewTasks0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorReviewTasks0(ctx context.Context, exec bob.Executor, count int, reviewTasks1 ReviewTaskSlice, user0 *User) (ReviewTaskSlice, error) {
|
|
setter := &ReviewTaskSetter{
|
|
CreatorID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := reviewTasks1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorReviewTasks0: %w", err)
|
|
}
|
|
|
|
return reviewTasks1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorReviewTasks(ctx context.Context, exec bob.Executor, related ...*ReviewTaskSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
reviewTasks1, err := insertUserCreatorReviewTasks0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorReviewTasks = append(user0.R.CreatorReviewTasks, reviewTasks1...)
|
|
|
|
for _, rel := range reviewTasks1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorReviewTasks(ctx context.Context, exec bob.Executor, related ...*ReviewTask) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
reviewTasks1 := ReviewTaskSlice(related)
|
|
|
|
_, err = attachUserCreatorReviewTasks0(ctx, exec, len(related), reviewTasks1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorReviewTasks = append(user0.R.CreatorReviewTasks, reviewTasks1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserReviewerReviewTasks0(ctx context.Context, exec bob.Executor, reviewTasks1 []*ReviewTaskSetter, user0 *User) (ReviewTaskSlice, error) {
|
|
for i := range reviewTasks1 {
|
|
reviewTasks1[i].ReviewerID = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := ReviewTasks.Insert(bob.ToMods(reviewTasks1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserReviewerReviewTasks0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserReviewerReviewTasks0(ctx context.Context, exec bob.Executor, count int, reviewTasks1 ReviewTaskSlice, user0 *User) (ReviewTaskSlice, error) {
|
|
setter := &ReviewTaskSetter{
|
|
ReviewerID: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := reviewTasks1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserReviewerReviewTasks0: %w", err)
|
|
}
|
|
|
|
return reviewTasks1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertReviewerReviewTasks(ctx context.Context, exec bob.Executor, related ...*ReviewTaskSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
reviewTasks1, err := insertUserReviewerReviewTasks0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ReviewerReviewTasks = append(user0.R.ReviewerReviewTasks, reviewTasks1...)
|
|
|
|
for _, rel := range reviewTasks1 {
|
|
rel.R.ReviewerUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachReviewerReviewTasks(ctx context.Context, exec bob.Executor, related ...*ReviewTask) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
reviewTasks1 := ReviewTaskSlice(related)
|
|
|
|
_, err = attachUserReviewerReviewTasks0(ctx, exec, len(related), reviewTasks1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.ReviewerReviewTasks = append(user0.R.ReviewerReviewTasks, reviewTasks1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.ReviewerUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserAddressorSignals0(ctx context.Context, exec bob.Executor, signals1 []*SignalSetter, user0 *User) (SignalSlice, error) {
|
|
for i := range signals1 {
|
|
signals1[i].Addressor = omitnull.From(user0.ID)
|
|
}
|
|
|
|
ret, err := Signals.Insert(bob.ToMods(signals1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserAddressorSignals0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserAddressorSignals0(ctx context.Context, exec bob.Executor, count int, signals1 SignalSlice, user0 *User) (SignalSlice, error) {
|
|
setter := &SignalSetter{
|
|
Addressor: omitnull.From(user0.ID),
|
|
}
|
|
|
|
err := signals1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserAddressorSignals0: %w", err)
|
|
}
|
|
|
|
return signals1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertAddressorSignals(ctx context.Context, exec bob.Executor, related ...*SignalSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
signals1, err := insertUserAddressorSignals0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.AddressorSignals = append(user0.R.AddressorSignals, signals1...)
|
|
|
|
for _, rel := range signals1 {
|
|
rel.R.AddressorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachAddressorSignals(ctx context.Context, exec bob.Executor, related ...*Signal) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
signals1 := SignalSlice(related)
|
|
|
|
_, err = attachUserAddressorSignals0(ctx, exec, len(related), signals1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.AddressorSignals = append(user0.R.AddressorSignals, signals1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.AddressorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorSignals0(ctx context.Context, exec bob.Executor, signals1 []*SignalSetter, user0 *User) (SignalSlice, error) {
|
|
for i := range signals1 {
|
|
signals1[i].Creator = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := Signals.Insert(bob.ToMods(signals1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorSignals0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorSignals0(ctx context.Context, exec bob.Executor, count int, signals1 SignalSlice, user0 *User) (SignalSlice, error) {
|
|
setter := &SignalSetter{
|
|
Creator: omit.From(user0.ID),
|
|
}
|
|
|
|
err := signals1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorSignals0: %w", err)
|
|
}
|
|
|
|
return signals1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorSignals(ctx context.Context, exec bob.Executor, related ...*SignalSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
signals1, err := insertUserCreatorSignals0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorSignals = append(user0.R.CreatorSignals, signals1...)
|
|
|
|
for _, rel := range signals1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorSignals(ctx context.Context, exec bob.Executor, related ...*Signal) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
signals1 := SignalSlice(related)
|
|
|
|
_, err = attachUserCreatorSignals0(ctx, exec, len(related), signals1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorSignals = append(user0.R.CreatorSignals, signals1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func insertUserCreatorSites0(ctx context.Context, exec bob.Executor, sites1 []*SiteSetter, user0 *User) (SiteSlice, error) {
|
|
for i := range sites1 {
|
|
sites1[i].CreatorID = omit.From(user0.ID)
|
|
}
|
|
|
|
ret, err := Sites.Insert(bob.ToMods(sites1...)).All(ctx, exec)
|
|
if err != nil {
|
|
return ret, fmt.Errorf("insertUserCreatorSites0: %w", err)
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func attachUserCreatorSites0(ctx context.Context, exec bob.Executor, count int, sites1 SiteSlice, user0 *User) (SiteSlice, error) {
|
|
setter := &SiteSetter{
|
|
CreatorID: omit.From(user0.ID),
|
|
}
|
|
|
|
err := sites1.UpdateAll(ctx, exec, *setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserCreatorSites0: %w", err)
|
|
}
|
|
|
|
return sites1, nil
|
|
}
|
|
|
|
func (user0 *User) InsertCreatorSites(ctx context.Context, exec bob.Executor, related ...*SiteSetter) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
|
|
sites1, err := insertUserCreatorSites0(ctx, exec, related, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorSites = append(user0.R.CreatorSites, sites1...)
|
|
|
|
for _, rel := range sites1 {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachCreatorSites(ctx context.Context, exec bob.Executor, related ...*Site) error {
|
|
if len(related) == 0 {
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
sites1 := SiteSlice(related)
|
|
|
|
_, err = attachUserCreatorSites0(ctx, exec, len(related), sites1, user0)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.CreatorSites = append(user0.R.CreatorSites, sites1...)
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = user0
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func attachUserOrganization0(ctx context.Context, exec bob.Executor, count int, user0 *User, organization1 *Organization) (*User, error) {
|
|
setter := &UserSetter{
|
|
OrganizationID: omit.From(organization1.ID),
|
|
}
|
|
|
|
err := user0.Update(ctx, exec, setter)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("attachUserOrganization0: %w", err)
|
|
}
|
|
|
|
return user0, nil
|
|
}
|
|
|
|
func (user0 *User) InsertOrganization(ctx context.Context, exec bob.Executor, related *OrganizationSetter) error {
|
|
var err error
|
|
|
|
organization1, err := Organizations.Insert(related).One(ctx, exec)
|
|
if err != nil {
|
|
return fmt.Errorf("inserting related objects: %w", err)
|
|
}
|
|
|
|
_, err = attachUserOrganization0(ctx, exec, 1, user0, organization1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.Organization = organization1
|
|
|
|
organization1.R.User = append(organization1.R.User, user0)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (user0 *User) AttachOrganization(ctx context.Context, exec bob.Executor, organization1 *Organization) error {
|
|
var err error
|
|
|
|
_, err = attachUserOrganization0(ctx, exec, 1, user0, organization1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
user0.R.Organization = organization1
|
|
|
|
organization1.R.User = append(organization1.R.User, user0)
|
|
|
|
return nil
|
|
}
|
|
|
|
type userWhere[Q psql.Filterable] struct {
|
|
ID psql.WhereMod[Q, int32]
|
|
ArcgisAccessToken psql.WhereNullMod[Q, string]
|
|
ArcgisLicense psql.WhereNullMod[Q, enums.Arcgislicensetype]
|
|
ArcgisRefreshToken psql.WhereNullMod[Q, string]
|
|
ArcgisRefreshTokenExpires psql.WhereNullMod[Q, time.Time]
|
|
ArcgisRole psql.WhereNullMod[Q, string]
|
|
DisplayName psql.WhereMod[Q, string]
|
|
Email psql.WhereNullMod[Q, string]
|
|
OrganizationID psql.WhereMod[Q, int32]
|
|
Username psql.WhereMod[Q, string]
|
|
PasswordHashType psql.WhereMod[Q, enums.Hashtype]
|
|
PasswordHash psql.WhereMod[Q, string]
|
|
Role psql.WhereMod[Q, enums.Userrole]
|
|
Avatar psql.WhereNullMod[Q, uuid.UUID]
|
|
IsActive psql.WhereMod[Q, bool]
|
|
IsDronePilot psql.WhereMod[Q, bool]
|
|
IsWarrant psql.WhereMod[Q, bool]
|
|
}
|
|
|
|
func (userWhere[Q]) AliasedAs(alias string) userWhere[Q] {
|
|
return buildUserWhere[Q](buildUserColumns(alias))
|
|
}
|
|
|
|
func buildUserWhere[Q psql.Filterable](cols userColumns) userWhere[Q] {
|
|
return userWhere[Q]{
|
|
ID: psql.Where[Q, int32](cols.ID),
|
|
ArcgisAccessToken: psql.WhereNull[Q, string](cols.ArcgisAccessToken),
|
|
ArcgisLicense: psql.WhereNull[Q, enums.Arcgislicensetype](cols.ArcgisLicense),
|
|
ArcgisRefreshToken: psql.WhereNull[Q, string](cols.ArcgisRefreshToken),
|
|
ArcgisRefreshTokenExpires: psql.WhereNull[Q, time.Time](cols.ArcgisRefreshTokenExpires),
|
|
ArcgisRole: psql.WhereNull[Q, string](cols.ArcgisRole),
|
|
DisplayName: psql.Where[Q, string](cols.DisplayName),
|
|
Email: psql.WhereNull[Q, string](cols.Email),
|
|
OrganizationID: psql.Where[Q, int32](cols.OrganizationID),
|
|
Username: psql.Where[Q, string](cols.Username),
|
|
PasswordHashType: psql.Where[Q, enums.Hashtype](cols.PasswordHashType),
|
|
PasswordHash: psql.Where[Q, string](cols.PasswordHash),
|
|
Role: psql.Where[Q, enums.Userrole](cols.Role),
|
|
Avatar: psql.WhereNull[Q, uuid.UUID](cols.Avatar),
|
|
IsActive: psql.Where[Q, bool](cols.IsActive),
|
|
IsDronePilot: psql.Where[Q, bool](cols.IsDronePilot),
|
|
IsWarrant: psql.Where[Q, bool](cols.IsWarrant),
|
|
}
|
|
}
|
|
|
|
func (o *User) Preload(name string, retrieved any) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
switch name {
|
|
case "CreatorTextJobs":
|
|
rels, ok := retrieved.(CommsTextJobSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorTextJobs = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CommunicationLogEntries":
|
|
rels, ok := retrieved.(CommunicationLogEntrySlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CommunicationLogEntries = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.User = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorComplianceReportRequests":
|
|
rels, ok := retrieved.(ComplianceReportRequestSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorComplianceReportRequests = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorFeatures":
|
|
rels, ok := retrieved.(FeatureSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorFeatures = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CommitterFiles":
|
|
rels, ok := retrieved.(FileuploadFileSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CommitterFiles = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CommitterUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorFiles":
|
|
rels, ok := retrieved.(FileuploadFileSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorFiles = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "FileuploadPool":
|
|
rels, ok := retrieved.(FileuploadPoolSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.FileuploadPool = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorLeads":
|
|
rels, ok := retrieved.(LeadSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorLeads = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "ImpersonatorLogImpersonations":
|
|
rels, ok := retrieved.(LogImpersonationSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ImpersonatorLogImpersonations = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.ImpersonatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "TargetLogImpersonations":
|
|
rels, ok := retrieved.(LogImpersonationSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.TargetLogImpersonations = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.TargetUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorNoteAudios":
|
|
rels, ok := retrieved.(NoteAudioSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorNoteAudios = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "DeletorNoteAudios":
|
|
rels, ok := retrieved.(NoteAudioSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.DeletorNoteAudios = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.DeletorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorNoteImages":
|
|
rels, ok := retrieved.(NoteImageSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorNoteImages = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "DeletorNoteImages":
|
|
rels, ok := retrieved.(NoteImageSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.DeletorNoteImages = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.DeletorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "UserNotifications":
|
|
rels, ok := retrieved.(NotificationSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.UserNotifications = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.UserUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "ReviewerNuisanceOlds":
|
|
rels, ok := retrieved.(PublicreportNuisanceOldSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ReviewerNuisanceOlds = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.ReviewerUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "ReviewerReports":
|
|
rels, ok := retrieved.(PublicreportReportSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ReviewerReports = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.ReviewerUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "UserReportLogs":
|
|
rels, ok := retrieved.(PublicreportReportLogSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.UserReportLogs = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.UserUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "ReviewerWaterOlds":
|
|
rels, ok := retrieved.(PublicreportWaterOldSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ReviewerWaterOlds = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.ReviewerUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorReportTexts":
|
|
rels, ok := retrieved.(ReportTextSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorReportTexts = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorResidents":
|
|
rels, ok := retrieved.(ResidentSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorResidents = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorReviewTasks":
|
|
rels, ok := retrieved.(ReviewTaskSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorReviewTasks = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "ReviewerReviewTasks":
|
|
rels, ok := retrieved.(ReviewTaskSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.ReviewerReviewTasks = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.ReviewerUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "AddressorSignals":
|
|
rels, ok := retrieved.(SignalSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.AddressorSignals = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.AddressorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorSignals":
|
|
rels, ok := retrieved.(SignalSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorSignals = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "CreatorSites":
|
|
rels, ok := retrieved.(SiteSlice)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.CreatorSites = rels
|
|
|
|
for _, rel := range rels {
|
|
if rel != nil {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
}
|
|
return nil
|
|
case "Organization":
|
|
rel, ok := retrieved.(*Organization)
|
|
if !ok {
|
|
return fmt.Errorf("user cannot load %T as %q", retrieved, name)
|
|
}
|
|
|
|
o.R.Organization = rel
|
|
|
|
if rel != nil {
|
|
rel.R.User = UserSlice{o}
|
|
}
|
|
return nil
|
|
default:
|
|
return fmt.Errorf("user has no relationship %q", name)
|
|
}
|
|
}
|
|
|
|
type userPreloader struct {
|
|
Organization func(...psql.PreloadOption) psql.Preloader
|
|
}
|
|
|
|
func buildUserPreloader() userPreloader {
|
|
return userPreloader{
|
|
Organization: func(opts ...psql.PreloadOption) psql.Preloader {
|
|
return psql.Preload[*Organization, OrganizationSlice](psql.PreloadRel{
|
|
Name: "Organization",
|
|
Sides: []psql.PreloadSide{
|
|
{
|
|
From: Users,
|
|
To: Organizations,
|
|
FromColumns: []string{"organization_id"},
|
|
ToColumns: []string{"id"},
|
|
},
|
|
},
|
|
}, Organizations.Columns.Names(), opts...)
|
|
},
|
|
}
|
|
}
|
|
|
|
type userThenLoader[Q orm.Loadable] struct {
|
|
CreatorTextJobs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CommunicationLogEntries func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorComplianceReportRequests func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorFeatures func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CommitterFiles func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorFiles func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
FileuploadPool func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorLeads func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ImpersonatorLogImpersonations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
TargetLogImpersonations func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
DeletorNoteAudios func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
DeletorNoteImages func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
UserNotifications func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ReviewerNuisanceOlds func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ReviewerReports func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
UserReportLogs func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ReviewerWaterOlds func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorReportTexts func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorResidents func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorReviewTasks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
ReviewerReviewTasks func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
AddressorSignals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorSignals func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
CreatorSites func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
Organization func(...bob.Mod[*dialect.SelectQuery]) orm.Loader[Q]
|
|
}
|
|
|
|
func buildUserThenLoader[Q orm.Loadable]() userThenLoader[Q] {
|
|
type CreatorTextJobsLoadInterface interface {
|
|
LoadCreatorTextJobs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CommunicationLogEntriesLoadInterface interface {
|
|
LoadCommunicationLogEntries(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorComplianceReportRequestsLoadInterface interface {
|
|
LoadCreatorComplianceReportRequests(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorFeaturesLoadInterface interface {
|
|
LoadCreatorFeatures(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CommitterFilesLoadInterface interface {
|
|
LoadCommitterFiles(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorFilesLoadInterface interface {
|
|
LoadCreatorFiles(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type FileuploadPoolLoadInterface interface {
|
|
LoadFileuploadPool(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorLeadsLoadInterface interface {
|
|
LoadCreatorLeads(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ImpersonatorLogImpersonationsLoadInterface interface {
|
|
LoadImpersonatorLogImpersonations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type TargetLogImpersonationsLoadInterface interface {
|
|
LoadTargetLogImpersonations(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorNoteAudiosLoadInterface interface {
|
|
LoadCreatorNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type DeletorNoteAudiosLoadInterface interface {
|
|
LoadDeletorNoteAudios(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorNoteImagesLoadInterface interface {
|
|
LoadCreatorNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type DeletorNoteImagesLoadInterface interface {
|
|
LoadDeletorNoteImages(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type UserNotificationsLoadInterface interface {
|
|
LoadUserNotifications(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ReviewerNuisanceOldsLoadInterface interface {
|
|
LoadReviewerNuisanceOlds(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ReviewerReportsLoadInterface interface {
|
|
LoadReviewerReports(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type UserReportLogsLoadInterface interface {
|
|
LoadUserReportLogs(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ReviewerWaterOldsLoadInterface interface {
|
|
LoadReviewerWaterOlds(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorReportTextsLoadInterface interface {
|
|
LoadCreatorReportTexts(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorResidentsLoadInterface interface {
|
|
LoadCreatorResidents(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorReviewTasksLoadInterface interface {
|
|
LoadCreatorReviewTasks(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type ReviewerReviewTasksLoadInterface interface {
|
|
LoadReviewerReviewTasks(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type AddressorSignalsLoadInterface interface {
|
|
LoadAddressorSignals(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorSignalsLoadInterface interface {
|
|
LoadCreatorSignals(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type CreatorSitesLoadInterface interface {
|
|
LoadCreatorSites(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
type OrganizationLoadInterface interface {
|
|
LoadOrganization(context.Context, bob.Executor, ...bob.Mod[*dialect.SelectQuery]) error
|
|
}
|
|
|
|
return userThenLoader[Q]{
|
|
CreatorTextJobs: thenLoadBuilder[Q](
|
|
"CreatorTextJobs",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorTextJobsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorTextJobs(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CommunicationLogEntries: thenLoadBuilder[Q](
|
|
"CommunicationLogEntries",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CommunicationLogEntriesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCommunicationLogEntries(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorComplianceReportRequests: thenLoadBuilder[Q](
|
|
"CreatorComplianceReportRequests",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorComplianceReportRequestsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorComplianceReportRequests(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorFeatures: thenLoadBuilder[Q](
|
|
"CreatorFeatures",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorFeaturesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorFeatures(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CommitterFiles: thenLoadBuilder[Q](
|
|
"CommitterFiles",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CommitterFilesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCommitterFiles(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorFiles: thenLoadBuilder[Q](
|
|
"CreatorFiles",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorFilesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorFiles(ctx, exec, mods...)
|
|
},
|
|
),
|
|
FileuploadPool: thenLoadBuilder[Q](
|
|
"FileuploadPool",
|
|
func(ctx context.Context, exec bob.Executor, retrieved FileuploadPoolLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadFileuploadPool(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorLeads: thenLoadBuilder[Q](
|
|
"CreatorLeads",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorLeadsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorLeads(ctx, exec, mods...)
|
|
},
|
|
),
|
|
ImpersonatorLogImpersonations: thenLoadBuilder[Q](
|
|
"ImpersonatorLogImpersonations",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ImpersonatorLogImpersonationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadImpersonatorLogImpersonations(ctx, exec, mods...)
|
|
},
|
|
),
|
|
TargetLogImpersonations: thenLoadBuilder[Q](
|
|
"TargetLogImpersonations",
|
|
func(ctx context.Context, exec bob.Executor, retrieved TargetLogImpersonationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadTargetLogImpersonations(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorNoteAudios: thenLoadBuilder[Q](
|
|
"CreatorNoteAudios",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorNoteAudiosLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorNoteAudios(ctx, exec, mods...)
|
|
},
|
|
),
|
|
DeletorNoteAudios: thenLoadBuilder[Q](
|
|
"DeletorNoteAudios",
|
|
func(ctx context.Context, exec bob.Executor, retrieved DeletorNoteAudiosLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadDeletorNoteAudios(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorNoteImages: thenLoadBuilder[Q](
|
|
"CreatorNoteImages",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorNoteImagesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorNoteImages(ctx, exec, mods...)
|
|
},
|
|
),
|
|
DeletorNoteImages: thenLoadBuilder[Q](
|
|
"DeletorNoteImages",
|
|
func(ctx context.Context, exec bob.Executor, retrieved DeletorNoteImagesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadDeletorNoteImages(ctx, exec, mods...)
|
|
},
|
|
),
|
|
UserNotifications: thenLoadBuilder[Q](
|
|
"UserNotifications",
|
|
func(ctx context.Context, exec bob.Executor, retrieved UserNotificationsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadUserNotifications(ctx, exec, mods...)
|
|
},
|
|
),
|
|
ReviewerNuisanceOlds: thenLoadBuilder[Q](
|
|
"ReviewerNuisanceOlds",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ReviewerNuisanceOldsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadReviewerNuisanceOlds(ctx, exec, mods...)
|
|
},
|
|
),
|
|
ReviewerReports: thenLoadBuilder[Q](
|
|
"ReviewerReports",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ReviewerReportsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadReviewerReports(ctx, exec, mods...)
|
|
},
|
|
),
|
|
UserReportLogs: thenLoadBuilder[Q](
|
|
"UserReportLogs",
|
|
func(ctx context.Context, exec bob.Executor, retrieved UserReportLogsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadUserReportLogs(ctx, exec, mods...)
|
|
},
|
|
),
|
|
ReviewerWaterOlds: thenLoadBuilder[Q](
|
|
"ReviewerWaterOlds",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ReviewerWaterOldsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadReviewerWaterOlds(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorReportTexts: thenLoadBuilder[Q](
|
|
"CreatorReportTexts",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorReportTextsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorReportTexts(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorResidents: thenLoadBuilder[Q](
|
|
"CreatorResidents",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorResidentsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorResidents(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorReviewTasks: thenLoadBuilder[Q](
|
|
"CreatorReviewTasks",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorReviewTasksLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorReviewTasks(ctx, exec, mods...)
|
|
},
|
|
),
|
|
ReviewerReviewTasks: thenLoadBuilder[Q](
|
|
"ReviewerReviewTasks",
|
|
func(ctx context.Context, exec bob.Executor, retrieved ReviewerReviewTasksLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadReviewerReviewTasks(ctx, exec, mods...)
|
|
},
|
|
),
|
|
AddressorSignals: thenLoadBuilder[Q](
|
|
"AddressorSignals",
|
|
func(ctx context.Context, exec bob.Executor, retrieved AddressorSignalsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadAddressorSignals(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorSignals: thenLoadBuilder[Q](
|
|
"CreatorSignals",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorSignalsLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorSignals(ctx, exec, mods...)
|
|
},
|
|
),
|
|
CreatorSites: thenLoadBuilder[Q](
|
|
"CreatorSites",
|
|
func(ctx context.Context, exec bob.Executor, retrieved CreatorSitesLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadCreatorSites(ctx, exec, mods...)
|
|
},
|
|
),
|
|
Organization: thenLoadBuilder[Q](
|
|
"Organization",
|
|
func(ctx context.Context, exec bob.Executor, retrieved OrganizationLoadInterface, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
return retrieved.LoadOrganization(ctx, exec, mods...)
|
|
},
|
|
),
|
|
}
|
|
}
|
|
|
|
// LoadCreatorTextJobs loads the user's CreatorTextJobs into the .R struct
|
|
func (o *User) LoadCreatorTextJobs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorTextJobs = nil
|
|
|
|
related, err := o.CreatorTextJobs(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorTextJobs = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorTextJobs loads the user's CreatorTextJobs into the .R struct
|
|
func (os UserSlice) LoadCreatorTextJobs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
commsTextJobs, err := os.CreatorTextJobs(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorTextJobs = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range commsTextJobs {
|
|
|
|
if !rel.CreatorID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.CreatorID.IsValue() && o.ID == rel.CreatorID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorTextJobs = append(o.R.CreatorTextJobs, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCommunicationLogEntries loads the user's CommunicationLogEntries into the .R struct
|
|
func (o *User) LoadCommunicationLogEntries(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CommunicationLogEntries = nil
|
|
|
|
related, err := o.CommunicationLogEntries(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.User = o
|
|
}
|
|
|
|
o.R.CommunicationLogEntries = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCommunicationLogEntries loads the user's CommunicationLogEntries into the .R struct
|
|
func (os UserSlice) LoadCommunicationLogEntries(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
communicationLogEntries, err := os.CommunicationLogEntries(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CommunicationLogEntries = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range communicationLogEntries {
|
|
|
|
if !rel.User.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.User.IsValue() && o.ID == rel.User.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.User = o
|
|
|
|
o.R.CommunicationLogEntries = append(o.R.CommunicationLogEntries, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorComplianceReportRequests loads the user's CreatorComplianceReportRequests into the .R struct
|
|
func (o *User) LoadCreatorComplianceReportRequests(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorComplianceReportRequests = nil
|
|
|
|
related, err := o.CreatorComplianceReportRequests(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorComplianceReportRequests = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorComplianceReportRequests loads the user's CreatorComplianceReportRequests into the .R struct
|
|
func (os UserSlice) LoadCreatorComplianceReportRequests(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
complianceReportRequests, err := os.CreatorComplianceReportRequests(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorComplianceReportRequests = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range complianceReportRequests {
|
|
|
|
if !(o.ID == rel.Creator) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorComplianceReportRequests = append(o.R.CreatorComplianceReportRequests, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorFeatures loads the user's CreatorFeatures into the .R struct
|
|
func (o *User) LoadCreatorFeatures(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorFeatures = nil
|
|
|
|
related, err := o.CreatorFeatures(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorFeatures = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorFeatures loads the user's CreatorFeatures into the .R struct
|
|
func (os UserSlice) LoadCreatorFeatures(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
features, err := os.CreatorFeatures(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorFeatures = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range features {
|
|
|
|
if !(o.ID == rel.CreatorID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorFeatures = append(o.R.CreatorFeatures, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCommitterFiles loads the user's CommitterFiles into the .R struct
|
|
func (o *User) LoadCommitterFiles(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CommitterFiles = nil
|
|
|
|
related, err := o.CommitterFiles(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CommitterUser = o
|
|
}
|
|
|
|
o.R.CommitterFiles = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCommitterFiles loads the user's CommitterFiles into the .R struct
|
|
func (os UserSlice) LoadCommitterFiles(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
fileuploadFiles, err := os.CommitterFiles(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CommitterFiles = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range fileuploadFiles {
|
|
|
|
if !rel.Committer.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.Committer.IsValue() && o.ID == rel.Committer.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CommitterUser = o
|
|
|
|
o.R.CommitterFiles = append(o.R.CommitterFiles, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorFiles loads the user's CreatorFiles into the .R struct
|
|
func (o *User) LoadCreatorFiles(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorFiles = nil
|
|
|
|
related, err := o.CreatorFiles(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorFiles = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorFiles loads the user's CreatorFiles into the .R struct
|
|
func (os UserSlice) LoadCreatorFiles(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
fileuploadFiles, err := os.CreatorFiles(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorFiles = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range fileuploadFiles {
|
|
|
|
if !(o.ID == rel.CreatorID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorFiles = append(o.R.CreatorFiles, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadFileuploadPool loads the user's FileuploadPool into the .R struct
|
|
func (o *User) LoadFileuploadPool(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.FileuploadPool = nil
|
|
|
|
related, err := o.FileuploadPool(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.FileuploadPool = related
|
|
return nil
|
|
}
|
|
|
|
// LoadFileuploadPool loads the user's FileuploadPool into the .R struct
|
|
func (os UserSlice) LoadFileuploadPool(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
fileuploadPools, err := os.FileuploadPool(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.FileuploadPool = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range fileuploadPools {
|
|
|
|
if !(o.ID == rel.CreatorID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.FileuploadPool = append(o.R.FileuploadPool, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorLeads loads the user's CreatorLeads into the .R struct
|
|
func (o *User) LoadCreatorLeads(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorLeads = nil
|
|
|
|
related, err := o.CreatorLeads(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorLeads = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorLeads loads the user's CreatorLeads into the .R struct
|
|
func (os UserSlice) LoadCreatorLeads(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
leads, err := os.CreatorLeads(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorLeads = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range leads {
|
|
|
|
if !(o.ID == rel.Creator) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorLeads = append(o.R.CreatorLeads, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadImpersonatorLogImpersonations loads the user's ImpersonatorLogImpersonations into the .R struct
|
|
func (o *User) LoadImpersonatorLogImpersonations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ImpersonatorLogImpersonations = nil
|
|
|
|
related, err := o.ImpersonatorLogImpersonations(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.ImpersonatorUser = o
|
|
}
|
|
|
|
o.R.ImpersonatorLogImpersonations = related
|
|
return nil
|
|
}
|
|
|
|
// LoadImpersonatorLogImpersonations loads the user's ImpersonatorLogImpersonations into the .R struct
|
|
func (os UserSlice) LoadImpersonatorLogImpersonations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
logImpersonations, err := os.ImpersonatorLogImpersonations(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.ImpersonatorLogImpersonations = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range logImpersonations {
|
|
|
|
if !(o.ID == rel.ImpersonatorID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.ImpersonatorUser = o
|
|
|
|
o.R.ImpersonatorLogImpersonations = append(o.R.ImpersonatorLogImpersonations, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadTargetLogImpersonations loads the user's TargetLogImpersonations into the .R struct
|
|
func (o *User) LoadTargetLogImpersonations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.TargetLogImpersonations = nil
|
|
|
|
related, err := o.TargetLogImpersonations(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.TargetUser = o
|
|
}
|
|
|
|
o.R.TargetLogImpersonations = related
|
|
return nil
|
|
}
|
|
|
|
// LoadTargetLogImpersonations loads the user's TargetLogImpersonations into the .R struct
|
|
func (os UserSlice) LoadTargetLogImpersonations(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
logImpersonations, err := os.TargetLogImpersonations(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.TargetLogImpersonations = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range logImpersonations {
|
|
|
|
if !(o.ID == rel.TargetID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.TargetUser = o
|
|
|
|
o.R.TargetLogImpersonations = append(o.R.TargetLogImpersonations, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorNoteAudios loads the user's CreatorNoteAudios into the .R struct
|
|
func (o *User) LoadCreatorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorNoteAudios = nil
|
|
|
|
related, err := o.CreatorNoteAudios(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorNoteAudios = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorNoteAudios loads the user's CreatorNoteAudios into the .R struct
|
|
func (os UserSlice) LoadCreatorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
noteAudios, err := os.CreatorNoteAudios(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorNoteAudios = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range noteAudios {
|
|
|
|
if !(o.ID == rel.CreatorID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorNoteAudios = append(o.R.CreatorNoteAudios, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadDeletorNoteAudios loads the user's DeletorNoteAudios into the .R struct
|
|
func (o *User) LoadDeletorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.DeletorNoteAudios = nil
|
|
|
|
related, err := o.DeletorNoteAudios(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.DeletorUser = o
|
|
}
|
|
|
|
o.R.DeletorNoteAudios = related
|
|
return nil
|
|
}
|
|
|
|
// LoadDeletorNoteAudios loads the user's DeletorNoteAudios into the .R struct
|
|
func (os UserSlice) LoadDeletorNoteAudios(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
noteAudios, err := os.DeletorNoteAudios(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.DeletorNoteAudios = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range noteAudios {
|
|
|
|
if !rel.DeletorID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.DeletorID.IsValue() && o.ID == rel.DeletorID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.DeletorUser = o
|
|
|
|
o.R.DeletorNoteAudios = append(o.R.DeletorNoteAudios, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorNoteImages loads the user's CreatorNoteImages into the .R struct
|
|
func (o *User) LoadCreatorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorNoteImages = nil
|
|
|
|
related, err := o.CreatorNoteImages(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorNoteImages = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorNoteImages loads the user's CreatorNoteImages into the .R struct
|
|
func (os UserSlice) LoadCreatorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
noteImages, err := os.CreatorNoteImages(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorNoteImages = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range noteImages {
|
|
|
|
if !(o.ID == rel.CreatorID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorNoteImages = append(o.R.CreatorNoteImages, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadDeletorNoteImages loads the user's DeletorNoteImages into the .R struct
|
|
func (o *User) LoadDeletorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.DeletorNoteImages = nil
|
|
|
|
related, err := o.DeletorNoteImages(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.DeletorUser = o
|
|
}
|
|
|
|
o.R.DeletorNoteImages = related
|
|
return nil
|
|
}
|
|
|
|
// LoadDeletorNoteImages loads the user's DeletorNoteImages into the .R struct
|
|
func (os UserSlice) LoadDeletorNoteImages(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
noteImages, err := os.DeletorNoteImages(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.DeletorNoteImages = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range noteImages {
|
|
|
|
if !rel.DeletorID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.DeletorID.IsValue() && o.ID == rel.DeletorID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.DeletorUser = o
|
|
|
|
o.R.DeletorNoteImages = append(o.R.DeletorNoteImages, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadUserNotifications loads the user's UserNotifications into the .R struct
|
|
func (o *User) LoadUserNotifications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.UserNotifications = nil
|
|
|
|
related, err := o.UserNotifications(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.UserUser = o
|
|
}
|
|
|
|
o.R.UserNotifications = related
|
|
return nil
|
|
}
|
|
|
|
// LoadUserNotifications loads the user's UserNotifications into the .R struct
|
|
func (os UserSlice) LoadUserNotifications(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
notifications, err := os.UserNotifications(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.UserNotifications = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range notifications {
|
|
|
|
if !(o.ID == rel.UserID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.UserUser = o
|
|
|
|
o.R.UserNotifications = append(o.R.UserNotifications, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerNuisanceOlds loads the user's ReviewerNuisanceOlds into the .R struct
|
|
func (o *User) LoadReviewerNuisanceOlds(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ReviewerNuisanceOlds = nil
|
|
|
|
related, err := o.ReviewerNuisanceOlds(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.ReviewerUser = o
|
|
}
|
|
|
|
o.R.ReviewerNuisanceOlds = related
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerNuisanceOlds loads the user's ReviewerNuisanceOlds into the .R struct
|
|
func (os UserSlice) LoadReviewerNuisanceOlds(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportNuisanceOlds, err := os.ReviewerNuisanceOlds(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.ReviewerNuisanceOlds = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportNuisanceOlds {
|
|
|
|
if !rel.ReviewerID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.ReviewerID.IsValue() && o.ID == rel.ReviewerID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.ReviewerUser = o
|
|
|
|
o.R.ReviewerNuisanceOlds = append(o.R.ReviewerNuisanceOlds, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerReports loads the user's ReviewerReports into the .R struct
|
|
func (o *User) LoadReviewerReports(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ReviewerReports = nil
|
|
|
|
related, err := o.ReviewerReports(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.ReviewerUser = o
|
|
}
|
|
|
|
o.R.ReviewerReports = related
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerReports loads the user's ReviewerReports into the .R struct
|
|
func (os UserSlice) LoadReviewerReports(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportReports, err := os.ReviewerReports(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.ReviewerReports = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportReports {
|
|
|
|
if !rel.ReviewerID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.ReviewerID.IsValue() && o.ID == rel.ReviewerID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.ReviewerUser = o
|
|
|
|
o.R.ReviewerReports = append(o.R.ReviewerReports, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadUserReportLogs loads the user's UserReportLogs into the .R struct
|
|
func (o *User) LoadUserReportLogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.UserReportLogs = nil
|
|
|
|
related, err := o.UserReportLogs(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.UserUser = o
|
|
}
|
|
|
|
o.R.UserReportLogs = related
|
|
return nil
|
|
}
|
|
|
|
// LoadUserReportLogs loads the user's UserReportLogs into the .R struct
|
|
func (os UserSlice) LoadUserReportLogs(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportReportLogs, err := os.UserReportLogs(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.UserReportLogs = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportReportLogs {
|
|
|
|
if !rel.UserID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.UserID.IsValue() && o.ID == rel.UserID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.UserUser = o
|
|
|
|
o.R.UserReportLogs = append(o.R.UserReportLogs, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerWaterOlds loads the user's ReviewerWaterOlds into the .R struct
|
|
func (o *User) LoadReviewerWaterOlds(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ReviewerWaterOlds = nil
|
|
|
|
related, err := o.ReviewerWaterOlds(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.ReviewerUser = o
|
|
}
|
|
|
|
o.R.ReviewerWaterOlds = related
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerWaterOlds loads the user's ReviewerWaterOlds into the .R struct
|
|
func (os UserSlice) LoadReviewerWaterOlds(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
publicreportWaterOlds, err := os.ReviewerWaterOlds(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.ReviewerWaterOlds = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range publicreportWaterOlds {
|
|
|
|
if !rel.ReviewerID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.ReviewerID.IsValue() && o.ID == rel.ReviewerID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.ReviewerUser = o
|
|
|
|
o.R.ReviewerWaterOlds = append(o.R.ReviewerWaterOlds, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorReportTexts loads the user's CreatorReportTexts into the .R struct
|
|
func (o *User) LoadCreatorReportTexts(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorReportTexts = nil
|
|
|
|
related, err := o.CreatorReportTexts(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorReportTexts = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorReportTexts loads the user's CreatorReportTexts into the .R struct
|
|
func (os UserSlice) LoadCreatorReportTexts(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
reportTexts, err := os.CreatorReportTexts(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorReportTexts = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range reportTexts {
|
|
|
|
if !(o.ID == rel.CreatorID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorReportTexts = append(o.R.CreatorReportTexts, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorResidents loads the user's CreatorResidents into the .R struct
|
|
func (o *User) LoadCreatorResidents(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorResidents = nil
|
|
|
|
related, err := o.CreatorResidents(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorResidents = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorResidents loads the user's CreatorResidents into the .R struct
|
|
func (os UserSlice) LoadCreatorResidents(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
residents, err := os.CreatorResidents(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorResidents = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range residents {
|
|
|
|
if !(o.ID == rel.Creator) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorResidents = append(o.R.CreatorResidents, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorReviewTasks loads the user's CreatorReviewTasks into the .R struct
|
|
func (o *User) LoadCreatorReviewTasks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorReviewTasks = nil
|
|
|
|
related, err := o.CreatorReviewTasks(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorReviewTasks = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorReviewTasks loads the user's CreatorReviewTasks into the .R struct
|
|
func (os UserSlice) LoadCreatorReviewTasks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
reviewTasks, err := os.CreatorReviewTasks(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorReviewTasks = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range reviewTasks {
|
|
|
|
if !rel.CreatorID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.CreatorID.IsValue() && o.ID == rel.CreatorID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorReviewTasks = append(o.R.CreatorReviewTasks, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerReviewTasks loads the user's ReviewerReviewTasks into the .R struct
|
|
func (o *User) LoadReviewerReviewTasks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.ReviewerReviewTasks = nil
|
|
|
|
related, err := o.ReviewerReviewTasks(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.ReviewerUser = o
|
|
}
|
|
|
|
o.R.ReviewerReviewTasks = related
|
|
return nil
|
|
}
|
|
|
|
// LoadReviewerReviewTasks loads the user's ReviewerReviewTasks into the .R struct
|
|
func (os UserSlice) LoadReviewerReviewTasks(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
reviewTasks, err := os.ReviewerReviewTasks(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.ReviewerReviewTasks = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range reviewTasks {
|
|
|
|
if !rel.ReviewerID.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.ReviewerID.IsValue() && o.ID == rel.ReviewerID.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.ReviewerUser = o
|
|
|
|
o.R.ReviewerReviewTasks = append(o.R.ReviewerReviewTasks, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadAddressorSignals loads the user's AddressorSignals into the .R struct
|
|
func (o *User) LoadAddressorSignals(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.AddressorSignals = nil
|
|
|
|
related, err := o.AddressorSignals(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.AddressorUser = o
|
|
}
|
|
|
|
o.R.AddressorSignals = related
|
|
return nil
|
|
}
|
|
|
|
// LoadAddressorSignals loads the user's AddressorSignals into the .R struct
|
|
func (os UserSlice) LoadAddressorSignals(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
signals, err := os.AddressorSignals(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.AddressorSignals = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range signals {
|
|
|
|
if !rel.Addressor.IsValue() {
|
|
continue
|
|
}
|
|
if !(rel.Addressor.IsValue() && o.ID == rel.Addressor.MustGet()) {
|
|
continue
|
|
}
|
|
|
|
rel.R.AddressorUser = o
|
|
|
|
o.R.AddressorSignals = append(o.R.AddressorSignals, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorSignals loads the user's CreatorSignals into the .R struct
|
|
func (o *User) LoadCreatorSignals(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorSignals = nil
|
|
|
|
related, err := o.CreatorSignals(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorSignals = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorSignals loads the user's CreatorSignals into the .R struct
|
|
func (os UserSlice) LoadCreatorSignals(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
signals, err := os.CreatorSignals(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorSignals = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range signals {
|
|
|
|
if !(o.ID == rel.Creator) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorSignals = append(o.R.CreatorSignals, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorSites loads the user's CreatorSites into the .R struct
|
|
func (o *User) LoadCreatorSites(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.CreatorSites = nil
|
|
|
|
related, err := o.CreatorSites(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, rel := range related {
|
|
rel.R.CreatorUser = o
|
|
}
|
|
|
|
o.R.CreatorSites = related
|
|
return nil
|
|
}
|
|
|
|
// LoadCreatorSites loads the user's CreatorSites into the .R struct
|
|
func (os UserSlice) LoadCreatorSites(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
sites, err := os.CreatorSites(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
o.R.CreatorSites = nil
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range sites {
|
|
|
|
if !(o.ID == rel.CreatorID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.CreatorUser = o
|
|
|
|
o.R.CreatorSites = append(o.R.CreatorSites, rel)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// LoadOrganization loads the user's Organization into the .R struct
|
|
func (o *User) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if o == nil {
|
|
return nil
|
|
}
|
|
|
|
// Reset the relationship
|
|
o.R.Organization = nil
|
|
|
|
related, err := o.Organization(mods...).One(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
related.R.User = UserSlice{o}
|
|
|
|
o.R.Organization = related
|
|
return nil
|
|
}
|
|
|
|
// LoadOrganization loads the user's Organization into the .R struct
|
|
func (os UserSlice) LoadOrganization(ctx context.Context, exec bob.Executor, mods ...bob.Mod[*dialect.SelectQuery]) error {
|
|
if len(os) == 0 {
|
|
return nil
|
|
}
|
|
|
|
organizations, err := os.Organization(mods...).All(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, o := range os {
|
|
if o == nil {
|
|
continue
|
|
}
|
|
|
|
for _, rel := range organizations {
|
|
|
|
if !(o.OrganizationID == rel.ID) {
|
|
continue
|
|
}
|
|
|
|
rel.R.User = append(rel.R.User, o)
|
|
|
|
o.R.Organization = rel
|
|
break
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|