848 lines
25 KiB
Go
848 lines
25 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 factory
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/Gleipnir-Technology/bob"
|
|
"github.com/Gleipnir-Technology/bob/types/pgtypes"
|
|
enums "github.com/Gleipnir-Technology/nidus-sync/db/enums"
|
|
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
|
"github.com/aarondl/opt/null"
|
|
"github.com/aarondl/opt/omit"
|
|
"github.com/aarondl/opt/omitnull"
|
|
"github.com/jaswdr/faker/v2"
|
|
)
|
|
|
|
type CommsEmailLogMod interface {
|
|
Apply(context.Context, *CommsEmailLogTemplate)
|
|
}
|
|
|
|
type CommsEmailLogModFunc func(context.Context, *CommsEmailLogTemplate)
|
|
|
|
func (f CommsEmailLogModFunc) Apply(ctx context.Context, n *CommsEmailLogTemplate) {
|
|
f(ctx, n)
|
|
}
|
|
|
|
type CommsEmailLogModSlice []CommsEmailLogMod
|
|
|
|
func (mods CommsEmailLogModSlice) Apply(ctx context.Context, n *CommsEmailLogTemplate) {
|
|
for _, f := range mods {
|
|
f.Apply(ctx, n)
|
|
}
|
|
}
|
|
|
|
// CommsEmailLogTemplate is an object representing the database table.
|
|
// all columns are optional and should be set by mods
|
|
type CommsEmailLogTemplate struct {
|
|
ID func() int32
|
|
Created func() time.Time
|
|
DeliveryStatus func() string
|
|
Destination func() string
|
|
PublicID func() string
|
|
SentAt func() null.Val[time.Time]
|
|
Source func() string
|
|
Subject func() string
|
|
TemplateID func() int32
|
|
TemplateData func() pgtypes.HStore
|
|
Type func() enums.CommsMessagetypeemail
|
|
|
|
r commsEmailLogR
|
|
f *Factory
|
|
|
|
alreadyPersisted bool
|
|
}
|
|
|
|
type commsEmailLogR struct {
|
|
DestinationEmailContact *commsEmailLogRDestinationEmailContactR
|
|
TemplateEmailTemplate *commsEmailLogRTemplateEmailTemplateR
|
|
}
|
|
|
|
type commsEmailLogRDestinationEmailContactR struct {
|
|
o *CommsEmailContactTemplate
|
|
}
|
|
type commsEmailLogRTemplateEmailTemplateR struct {
|
|
o *CommsEmailTemplateTemplate
|
|
}
|
|
|
|
// Apply mods to the CommsEmailLogTemplate
|
|
func (o *CommsEmailLogTemplate) Apply(ctx context.Context, mods ...CommsEmailLogMod) {
|
|
for _, mod := range mods {
|
|
mod.Apply(ctx, o)
|
|
}
|
|
}
|
|
|
|
// setModelRels creates and sets the relationships on *models.CommsEmailLog
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
func (t CommsEmailLogTemplate) setModelRels(o *models.CommsEmailLog) {
|
|
if t.r.DestinationEmailContact != nil {
|
|
rel := t.r.DestinationEmailContact.o.Build()
|
|
rel.R.DestinationEmailLogs = append(rel.R.DestinationEmailLogs, o)
|
|
o.Destination = rel.Address // h2
|
|
o.R.DestinationEmailContact = rel
|
|
}
|
|
|
|
if t.r.TemplateEmailTemplate != nil {
|
|
rel := t.r.TemplateEmailTemplate.o.Build()
|
|
rel.R.TemplateEmailLogs = append(rel.R.TemplateEmailLogs, o)
|
|
o.TemplateID = rel.ID // h2
|
|
o.R.TemplateEmailTemplate = rel
|
|
}
|
|
}
|
|
|
|
// BuildSetter returns an *models.CommsEmailLogSetter
|
|
// this does nothing with the relationship templates
|
|
func (o CommsEmailLogTemplate) BuildSetter() *models.CommsEmailLogSetter {
|
|
m := &models.CommsEmailLogSetter{}
|
|
|
|
if o.ID != nil {
|
|
val := o.ID()
|
|
m.ID = omit.From(val)
|
|
}
|
|
if o.Created != nil {
|
|
val := o.Created()
|
|
m.Created = omit.From(val)
|
|
}
|
|
if o.DeliveryStatus != nil {
|
|
val := o.DeliveryStatus()
|
|
m.DeliveryStatus = omit.From(val)
|
|
}
|
|
if o.Destination != nil {
|
|
val := o.Destination()
|
|
m.Destination = omit.From(val)
|
|
}
|
|
if o.PublicID != nil {
|
|
val := o.PublicID()
|
|
m.PublicID = omit.From(val)
|
|
}
|
|
if o.SentAt != nil {
|
|
val := o.SentAt()
|
|
m.SentAt = omitnull.FromNull(val)
|
|
}
|
|
if o.Source != nil {
|
|
val := o.Source()
|
|
m.Source = omit.From(val)
|
|
}
|
|
if o.Subject != nil {
|
|
val := o.Subject()
|
|
m.Subject = omit.From(val)
|
|
}
|
|
if o.TemplateID != nil {
|
|
val := o.TemplateID()
|
|
m.TemplateID = omit.From(val)
|
|
}
|
|
if o.TemplateData != nil {
|
|
val := o.TemplateData()
|
|
m.TemplateData = omit.From(val)
|
|
}
|
|
if o.Type != nil {
|
|
val := o.Type()
|
|
m.Type = omit.From(val)
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildManySetter returns an []*models.CommsEmailLogSetter
|
|
// this does nothing with the relationship templates
|
|
func (o CommsEmailLogTemplate) BuildManySetter(number int) []*models.CommsEmailLogSetter {
|
|
m := make([]*models.CommsEmailLogSetter, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.BuildSetter()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// Build returns an *models.CommsEmailLog
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use CommsEmailLogTemplate.Create
|
|
func (o CommsEmailLogTemplate) Build() *models.CommsEmailLog {
|
|
m := &models.CommsEmailLog{}
|
|
|
|
if o.ID != nil {
|
|
m.ID = o.ID()
|
|
}
|
|
if o.Created != nil {
|
|
m.Created = o.Created()
|
|
}
|
|
if o.DeliveryStatus != nil {
|
|
m.DeliveryStatus = o.DeliveryStatus()
|
|
}
|
|
if o.Destination != nil {
|
|
m.Destination = o.Destination()
|
|
}
|
|
if o.PublicID != nil {
|
|
m.PublicID = o.PublicID()
|
|
}
|
|
if o.SentAt != nil {
|
|
m.SentAt = o.SentAt()
|
|
}
|
|
if o.Source != nil {
|
|
m.Source = o.Source()
|
|
}
|
|
if o.Subject != nil {
|
|
m.Subject = o.Subject()
|
|
}
|
|
if o.TemplateID != nil {
|
|
m.TemplateID = o.TemplateID()
|
|
}
|
|
if o.TemplateData != nil {
|
|
m.TemplateData = o.TemplateData()
|
|
}
|
|
if o.Type != nil {
|
|
m.Type = o.Type()
|
|
}
|
|
|
|
o.setModelRels(m)
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildMany returns an models.CommsEmailLogSlice
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use CommsEmailLogTemplate.CreateMany
|
|
func (o CommsEmailLogTemplate) BuildMany(number int) models.CommsEmailLogSlice {
|
|
m := make(models.CommsEmailLogSlice, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.Build()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func ensureCreatableCommsEmailLog(m *models.CommsEmailLogSetter) {
|
|
if !(m.Created.IsValue()) {
|
|
val := random_time_Time(nil)
|
|
m.Created = omit.From(val)
|
|
}
|
|
if !(m.DeliveryStatus.IsValue()) {
|
|
val := random_string(nil, "16")
|
|
m.DeliveryStatus = omit.From(val)
|
|
}
|
|
if !(m.Destination.IsValue()) {
|
|
val := random_string(nil)
|
|
m.Destination = omit.From(val)
|
|
}
|
|
if !(m.PublicID.IsValue()) {
|
|
val := random_string(nil, "64")
|
|
m.PublicID = omit.From(val)
|
|
}
|
|
if !(m.Source.IsValue()) {
|
|
val := random_string(nil)
|
|
m.Source = omit.From(val)
|
|
}
|
|
if !(m.Subject.IsValue()) {
|
|
val := random_string(nil, "255")
|
|
m.Subject = omit.From(val)
|
|
}
|
|
if !(m.TemplateID.IsValue()) {
|
|
val := random_int32(nil)
|
|
m.TemplateID = omit.From(val)
|
|
}
|
|
if !(m.TemplateData.IsValue()) {
|
|
val := random_pgtypes_HStore(nil)
|
|
m.TemplateData = omit.From(val)
|
|
}
|
|
if !(m.Type.IsValue()) {
|
|
val := random_enums_CommsMessagetypeemail(nil)
|
|
m.Type = omit.From(val)
|
|
}
|
|
}
|
|
|
|
// insertOptRels creates and inserts any optional the relationships on *models.CommsEmailLog
|
|
// according to the relationships in the template.
|
|
// any required relationship should have already exist on the model
|
|
func (o *CommsEmailLogTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.CommsEmailLog) error {
|
|
var err error
|
|
|
|
return err
|
|
}
|
|
|
|
// Create builds a commsEmailLog and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o *CommsEmailLogTemplate) Create(ctx context.Context, exec bob.Executor) (*models.CommsEmailLog, error) {
|
|
var err error
|
|
opt := o.BuildSetter()
|
|
ensureCreatableCommsEmailLog(opt)
|
|
|
|
if o.r.DestinationEmailContact == nil {
|
|
CommsEmailLogMods.WithNewDestinationEmailContact().Apply(ctx, o)
|
|
}
|
|
|
|
var rel0 *models.CommsEmailContact
|
|
|
|
if o.r.DestinationEmailContact.o.alreadyPersisted {
|
|
rel0 = o.r.DestinationEmailContact.o.Build()
|
|
} else {
|
|
rel0, err = o.r.DestinationEmailContact.o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
opt.Destination = omit.From(rel0.Address)
|
|
|
|
if o.r.TemplateEmailTemplate == nil {
|
|
CommsEmailLogMods.WithNewTemplateEmailTemplate().Apply(ctx, o)
|
|
}
|
|
|
|
var rel1 *models.CommsEmailTemplate
|
|
|
|
if o.r.TemplateEmailTemplate.o.alreadyPersisted {
|
|
rel1 = o.r.TemplateEmailTemplate.o.Build()
|
|
} else {
|
|
rel1, err = o.r.TemplateEmailTemplate.o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
opt.TemplateID = omit.From(rel1.ID)
|
|
|
|
m, err := models.CommsEmailLogs.Insert(opt).One(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
m.R.DestinationEmailContact = rel0
|
|
m.R.TemplateEmailTemplate = rel1
|
|
|
|
if err := o.insertOptRels(ctx, exec, m); err != nil {
|
|
return nil, err
|
|
}
|
|
return m, err
|
|
}
|
|
|
|
// MustCreate builds a commsEmailLog and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o *CommsEmailLogTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.CommsEmailLog {
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateOrFail builds a commsEmailLog and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
|
|
func (o *CommsEmailLogTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.CommsEmailLog {
|
|
tb.Helper()
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateMany builds multiple commsEmailLogs and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o CommsEmailLogTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.CommsEmailLogSlice, error) {
|
|
var err error
|
|
m := make(models.CommsEmailLogSlice, number)
|
|
|
|
for i := range m {
|
|
m[i], err = o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return m, nil
|
|
}
|
|
|
|
// MustCreateMany builds multiple commsEmailLogs and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o CommsEmailLogTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.CommsEmailLogSlice {
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateManyOrFail builds multiple commsEmailLogs and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// It calls `tb.Fatal(err)` on the test/benchmark if an error occurs
|
|
func (o CommsEmailLogTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.CommsEmailLogSlice {
|
|
tb.Helper()
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CommsEmailLog has methods that act as mods for the CommsEmailLogTemplate
|
|
var CommsEmailLogMods commsEmailLogMods
|
|
|
|
type commsEmailLogMods struct{}
|
|
|
|
func (m commsEmailLogMods) RandomizeAllColumns(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModSlice{
|
|
CommsEmailLogMods.RandomID(f),
|
|
CommsEmailLogMods.RandomCreated(f),
|
|
CommsEmailLogMods.RandomDeliveryStatus(f),
|
|
CommsEmailLogMods.RandomDestination(f),
|
|
CommsEmailLogMods.RandomPublicID(f),
|
|
CommsEmailLogMods.RandomSentAt(f),
|
|
CommsEmailLogMods.RandomSource(f),
|
|
CommsEmailLogMods.RandomSubject(f),
|
|
CommsEmailLogMods.RandomTemplateID(f),
|
|
CommsEmailLogMods.RandomTemplateData(f),
|
|
CommsEmailLogMods.RandomType(f),
|
|
}
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) ID(val int32) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.ID = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) IDFunc(f func() int32) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.ID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetID() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.ID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomID(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.ID = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) Created(val time.Time) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Created = func() time.Time { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) CreatedFunc(f func() time.Time) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Created = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetCreated() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Created = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomCreated(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Created = func() time.Time {
|
|
return random_time_Time(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) DeliveryStatus(val string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.DeliveryStatus = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) DeliveryStatusFunc(f func() string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.DeliveryStatus = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetDeliveryStatus() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.DeliveryStatus = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomDeliveryStatus(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.DeliveryStatus = func() string {
|
|
return random_string(f, "16")
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) Destination(val string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Destination = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) DestinationFunc(f func() string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Destination = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetDestination() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Destination = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomDestination(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Destination = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) PublicID(val string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.PublicID = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) PublicIDFunc(f func() string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.PublicID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetPublicID() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.PublicID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomPublicID(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.PublicID = func() string {
|
|
return random_string(f, "64")
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) SentAt(val null.Val[time.Time]) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.SentAt = func() null.Val[time.Time] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) SentAtFunc(f func() null.Val[time.Time]) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.SentAt = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetSentAt() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.SentAt = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
// The generated value is sometimes null
|
|
func (m commsEmailLogMods) RandomSentAt(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.SentAt = func() null.Val[time.Time] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_time_Time(f)
|
|
return null.From(val)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
// The generated value is never null
|
|
func (m commsEmailLogMods) RandomSentAtNotNull(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.SentAt = func() null.Val[time.Time] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_time_Time(f)
|
|
return null.From(val)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) Source(val string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Source = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) SourceFunc(f func() string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Source = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetSource() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Source = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomSource(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Source = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) Subject(val string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Subject = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) SubjectFunc(f func() string) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Subject = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetSubject() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Subject = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomSubject(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Subject = func() string {
|
|
return random_string(f, "255")
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) TemplateID(val int32) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.TemplateID = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) TemplateIDFunc(f func() int32) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.TemplateID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetTemplateID() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.TemplateID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomTemplateID(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.TemplateID = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) TemplateData(val pgtypes.HStore) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.TemplateData = func() pgtypes.HStore { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) TemplateDataFunc(f func() pgtypes.HStore) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.TemplateData = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetTemplateData() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.TemplateData = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomTemplateData(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.TemplateData = func() pgtypes.HStore {
|
|
return random_pgtypes_HStore(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailLogMods) Type(val enums.CommsMessagetypeemail) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Type = func() enums.CommsMessagetypeemail { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailLogMods) TypeFunc(f func() enums.CommsMessagetypeemail) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Type = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailLogMods) UnsetType() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Type = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailLogMods) RandomType(f *faker.Faker) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(_ context.Context, o *CommsEmailLogTemplate) {
|
|
o.Type = func() enums.CommsMessagetypeemail {
|
|
return random_enums_CommsMessagetypeemail(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithParentsCascading() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
if isDone, _ := commsEmailLogWithParentsCascadingCtx.Value(ctx); isDone {
|
|
return
|
|
}
|
|
ctx = commsEmailLogWithParentsCascadingCtx.WithValue(ctx, true)
|
|
{
|
|
|
|
related := o.f.NewCommsEmailContactWithContext(ctx, CommsEmailContactMods.WithParentsCascading())
|
|
m.WithDestinationEmailContact(related).Apply(ctx, o)
|
|
}
|
|
{
|
|
|
|
related := o.f.NewCommsEmailTemplateWithContext(ctx, CommsEmailTemplateMods.WithParentsCascading())
|
|
m.WithTemplateEmailTemplate(related).Apply(ctx, o)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithDestinationEmailContact(rel *CommsEmailContactTemplate) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
o.r.DestinationEmailContact = &commsEmailLogRDestinationEmailContactR{
|
|
o: rel,
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithNewDestinationEmailContact(mods ...CommsEmailContactMod) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
related := o.f.NewCommsEmailContactWithContext(ctx, mods...)
|
|
|
|
m.WithDestinationEmailContact(related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithExistingDestinationEmailContact(em *models.CommsEmailContact) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
o.r.DestinationEmailContact = &commsEmailLogRDestinationEmailContactR{
|
|
o: o.f.FromExistingCommsEmailContact(em),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithoutDestinationEmailContact() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
o.r.DestinationEmailContact = nil
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithTemplateEmailTemplate(rel *CommsEmailTemplateTemplate) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
o.r.TemplateEmailTemplate = &commsEmailLogRTemplateEmailTemplateR{
|
|
o: rel,
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithNewTemplateEmailTemplate(mods ...CommsEmailTemplateMod) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
related := o.f.NewCommsEmailTemplateWithContext(ctx, mods...)
|
|
|
|
m.WithTemplateEmailTemplate(related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithExistingTemplateEmailTemplate(em *models.CommsEmailTemplate) CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
o.r.TemplateEmailTemplate = &commsEmailLogRTemplateEmailTemplateR{
|
|
o: o.f.FromExistingCommsEmailTemplate(em),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailLogMods) WithoutTemplateEmailTemplate() CommsEmailLogMod {
|
|
return CommsEmailLogModFunc(func(ctx context.Context, o *CommsEmailLogTemplate) {
|
|
o.r.TemplateEmailTemplate = nil
|
|
})
|
|
}
|