672 lines
21 KiB
Go
672 lines
21 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"
|
|
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 CommsEmailTemplateMod interface {
|
|
Apply(context.Context, *CommsEmailTemplateTemplate)
|
|
}
|
|
|
|
type CommsEmailTemplateModFunc func(context.Context, *CommsEmailTemplateTemplate)
|
|
|
|
func (f CommsEmailTemplateModFunc) Apply(ctx context.Context, n *CommsEmailTemplateTemplate) {
|
|
f(ctx, n)
|
|
}
|
|
|
|
type CommsEmailTemplateModSlice []CommsEmailTemplateMod
|
|
|
|
func (mods CommsEmailTemplateModSlice) Apply(ctx context.Context, n *CommsEmailTemplateTemplate) {
|
|
for _, f := range mods {
|
|
f.Apply(ctx, n)
|
|
}
|
|
}
|
|
|
|
// CommsEmailTemplateTemplate is an object representing the database table.
|
|
// all columns are optional and should be set by mods
|
|
type CommsEmailTemplateTemplate struct {
|
|
ContentHTML func() string
|
|
ContentTXT func() string
|
|
ContentHashHTML func() string
|
|
ContentHashTXT func() string
|
|
Created func() time.Time
|
|
ID func() int32
|
|
Superceded func() null.Val[time.Time]
|
|
MessageType func() enums.CommsMessagetypeemail
|
|
|
|
r commsEmailTemplateR
|
|
f *Factory
|
|
|
|
alreadyPersisted bool
|
|
}
|
|
|
|
type commsEmailTemplateR struct {
|
|
TemplateEmailLogs []*commsEmailTemplateRTemplateEmailLogsR
|
|
}
|
|
|
|
type commsEmailTemplateRTemplateEmailLogsR struct {
|
|
number int
|
|
o *CommsEmailLogTemplate
|
|
}
|
|
|
|
// Apply mods to the CommsEmailTemplateTemplate
|
|
func (o *CommsEmailTemplateTemplate) Apply(ctx context.Context, mods ...CommsEmailTemplateMod) {
|
|
for _, mod := range mods {
|
|
mod.Apply(ctx, o)
|
|
}
|
|
}
|
|
|
|
// setModelRels creates and sets the relationships on *models.CommsEmailTemplate
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
func (t CommsEmailTemplateTemplate) setModelRels(o *models.CommsEmailTemplate) {
|
|
if t.r.TemplateEmailLogs != nil {
|
|
rel := models.CommsEmailLogSlice{}
|
|
for _, r := range t.r.TemplateEmailLogs {
|
|
related := r.o.BuildMany(r.number)
|
|
for _, rel := range related {
|
|
rel.TemplateID = o.ID // h2
|
|
rel.R.TemplateEmailTemplate = o
|
|
}
|
|
rel = append(rel, related...)
|
|
}
|
|
o.R.TemplateEmailLogs = rel
|
|
}
|
|
}
|
|
|
|
// BuildSetter returns an *models.CommsEmailTemplateSetter
|
|
// this does nothing with the relationship templates
|
|
func (o CommsEmailTemplateTemplate) BuildSetter() *models.CommsEmailTemplateSetter {
|
|
m := &models.CommsEmailTemplateSetter{}
|
|
|
|
if o.ContentHTML != nil {
|
|
val := o.ContentHTML()
|
|
m.ContentHTML = omit.From(val)
|
|
}
|
|
if o.ContentTXT != nil {
|
|
val := o.ContentTXT()
|
|
m.ContentTXT = omit.From(val)
|
|
}
|
|
if o.ContentHashHTML != nil {
|
|
val := o.ContentHashHTML()
|
|
m.ContentHashHTML = omit.From(val)
|
|
}
|
|
if o.ContentHashTXT != nil {
|
|
val := o.ContentHashTXT()
|
|
m.ContentHashTXT = omit.From(val)
|
|
}
|
|
if o.Created != nil {
|
|
val := o.Created()
|
|
m.Created = omit.From(val)
|
|
}
|
|
if o.ID != nil {
|
|
val := o.ID()
|
|
m.ID = omit.From(val)
|
|
}
|
|
if o.Superceded != nil {
|
|
val := o.Superceded()
|
|
m.Superceded = omitnull.FromNull(val)
|
|
}
|
|
if o.MessageType != nil {
|
|
val := o.MessageType()
|
|
m.MessageType = omit.From(val)
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildManySetter returns an []*models.CommsEmailTemplateSetter
|
|
// this does nothing with the relationship templates
|
|
func (o CommsEmailTemplateTemplate) BuildManySetter(number int) []*models.CommsEmailTemplateSetter {
|
|
m := make([]*models.CommsEmailTemplateSetter, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.BuildSetter()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// Build returns an *models.CommsEmailTemplate
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use CommsEmailTemplateTemplate.Create
|
|
func (o CommsEmailTemplateTemplate) Build() *models.CommsEmailTemplate {
|
|
m := &models.CommsEmailTemplate{}
|
|
|
|
if o.ContentHTML != nil {
|
|
m.ContentHTML = o.ContentHTML()
|
|
}
|
|
if o.ContentTXT != nil {
|
|
m.ContentTXT = o.ContentTXT()
|
|
}
|
|
if o.ContentHashHTML != nil {
|
|
m.ContentHashHTML = o.ContentHashHTML()
|
|
}
|
|
if o.ContentHashTXT != nil {
|
|
m.ContentHashTXT = o.ContentHashTXT()
|
|
}
|
|
if o.Created != nil {
|
|
m.Created = o.Created()
|
|
}
|
|
if o.ID != nil {
|
|
m.ID = o.ID()
|
|
}
|
|
if o.Superceded != nil {
|
|
m.Superceded = o.Superceded()
|
|
}
|
|
if o.MessageType != nil {
|
|
m.MessageType = o.MessageType()
|
|
}
|
|
|
|
o.setModelRels(m)
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildMany returns an models.CommsEmailTemplateSlice
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use CommsEmailTemplateTemplate.CreateMany
|
|
func (o CommsEmailTemplateTemplate) BuildMany(number int) models.CommsEmailTemplateSlice {
|
|
m := make(models.CommsEmailTemplateSlice, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.Build()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func ensureCreatableCommsEmailTemplate(m *models.CommsEmailTemplateSetter) {
|
|
if !(m.ContentHTML.IsValue()) {
|
|
val := random_string(nil)
|
|
m.ContentHTML = omit.From(val)
|
|
}
|
|
if !(m.ContentTXT.IsValue()) {
|
|
val := random_string(nil)
|
|
m.ContentTXT = omit.From(val)
|
|
}
|
|
if !(m.ContentHashHTML.IsValue()) {
|
|
val := random_string(nil, "64")
|
|
m.ContentHashHTML = omit.From(val)
|
|
}
|
|
if !(m.ContentHashTXT.IsValue()) {
|
|
val := random_string(nil, "64")
|
|
m.ContentHashTXT = omit.From(val)
|
|
}
|
|
if !(m.Created.IsValue()) {
|
|
val := random_time_Time(nil)
|
|
m.Created = omit.From(val)
|
|
}
|
|
if !(m.MessageType.IsValue()) {
|
|
val := random_enums_CommsMessagetypeemail(nil)
|
|
m.MessageType = omit.From(val)
|
|
}
|
|
}
|
|
|
|
// insertOptRels creates and inserts any optional the relationships on *models.CommsEmailTemplate
|
|
// according to the relationships in the template.
|
|
// any required relationship should have already exist on the model
|
|
func (o *CommsEmailTemplateTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.CommsEmailTemplate) error {
|
|
var err error
|
|
|
|
isTemplateEmailLogsDone, _ := commsEmailTemplateRelTemplateEmailLogsCtx.Value(ctx)
|
|
if !isTemplateEmailLogsDone && o.r.TemplateEmailLogs != nil {
|
|
ctx = commsEmailTemplateRelTemplateEmailLogsCtx.WithValue(ctx, true)
|
|
for _, r := range o.r.TemplateEmailLogs {
|
|
if r.o.alreadyPersisted {
|
|
m.R.TemplateEmailLogs = append(m.R.TemplateEmailLogs, r.o.Build())
|
|
} else {
|
|
rel0, err := r.o.CreateMany(ctx, exec, r.number)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = m.AttachTemplateEmailLogs(ctx, exec, rel0...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// Create builds a commsEmailTemplate and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o *CommsEmailTemplateTemplate) Create(ctx context.Context, exec bob.Executor) (*models.CommsEmailTemplate, error) {
|
|
var err error
|
|
opt := o.BuildSetter()
|
|
ensureCreatableCommsEmailTemplate(opt)
|
|
|
|
m, err := models.CommsEmailTemplates.Insert(opt).One(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if err := o.insertOptRels(ctx, exec, m); err != nil {
|
|
return nil, err
|
|
}
|
|
return m, err
|
|
}
|
|
|
|
// MustCreate builds a commsEmailTemplate and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o *CommsEmailTemplateTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.CommsEmailTemplate {
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateOrFail builds a commsEmailTemplate 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 *CommsEmailTemplateTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.CommsEmailTemplate {
|
|
tb.Helper()
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateMany builds multiple commsEmailTemplates and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o CommsEmailTemplateTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.CommsEmailTemplateSlice, error) {
|
|
var err error
|
|
m := make(models.CommsEmailTemplateSlice, number)
|
|
|
|
for i := range m {
|
|
m[i], err = o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return m, nil
|
|
}
|
|
|
|
// MustCreateMany builds multiple commsEmailTemplates and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o CommsEmailTemplateTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.CommsEmailTemplateSlice {
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateManyOrFail builds multiple commsEmailTemplates 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 CommsEmailTemplateTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.CommsEmailTemplateSlice {
|
|
tb.Helper()
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CommsEmailTemplate has methods that act as mods for the CommsEmailTemplateTemplate
|
|
var CommsEmailTemplateMods commsEmailTemplateMods
|
|
|
|
type commsEmailTemplateMods struct{}
|
|
|
|
func (m commsEmailTemplateMods) RandomizeAllColumns(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModSlice{
|
|
CommsEmailTemplateMods.RandomContentHTML(f),
|
|
CommsEmailTemplateMods.RandomContentTXT(f),
|
|
CommsEmailTemplateMods.RandomContentHashHTML(f),
|
|
CommsEmailTemplateMods.RandomContentHashTXT(f),
|
|
CommsEmailTemplateMods.RandomCreated(f),
|
|
CommsEmailTemplateMods.RandomID(f),
|
|
CommsEmailTemplateMods.RandomSuperceded(f),
|
|
CommsEmailTemplateMods.RandomMessageType(f),
|
|
}
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailTemplateMods) ContentHTML(val string) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHTML = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailTemplateMods) ContentHTMLFunc(f func() string) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHTML = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailTemplateMods) UnsetContentHTML() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHTML = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailTemplateMods) RandomContentHTML(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHTML = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailTemplateMods) ContentTXT(val string) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentTXT = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailTemplateMods) ContentTXTFunc(f func() string) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentTXT = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailTemplateMods) UnsetContentTXT() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentTXT = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailTemplateMods) RandomContentTXT(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentTXT = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailTemplateMods) ContentHashHTML(val string) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHashHTML = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailTemplateMods) ContentHashHTMLFunc(f func() string) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHashHTML = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailTemplateMods) UnsetContentHashHTML() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHashHTML = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailTemplateMods) RandomContentHashHTML(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHashHTML = func() string {
|
|
return random_string(f, "64")
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailTemplateMods) ContentHashTXT(val string) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHashTXT = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailTemplateMods) ContentHashTXTFunc(f func() string) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHashTXT = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailTemplateMods) UnsetContentHashTXT() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHashTXT = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailTemplateMods) RandomContentHashTXT(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ContentHashTXT = func() string {
|
|
return random_string(f, "64")
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailTemplateMods) Created(val time.Time) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.Created = func() time.Time { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailTemplateMods) CreatedFunc(f func() time.Time) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.Created = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailTemplateMods) UnsetCreated() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
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 commsEmailTemplateMods) RandomCreated(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.Created = func() time.Time {
|
|
return random_time_Time(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailTemplateMods) ID(val int32) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ID = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailTemplateMods) IDFunc(f func() int32) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailTemplateMods) UnsetID() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
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 commsEmailTemplateMods) RandomID(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.ID = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m commsEmailTemplateMods) Superceded(val null.Val[time.Time]) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.Superceded = func() null.Val[time.Time] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailTemplateMods) SupercededFunc(f func() null.Val[time.Time]) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.Superceded = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailTemplateMods) UnsetSuperceded() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.Superceded = 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 commsEmailTemplateMods) RandomSuperceded(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.Superceded = 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 commsEmailTemplateMods) RandomSupercededNotNull(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.Superceded = 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 commsEmailTemplateMods) MessageType(val enums.CommsMessagetypeemail) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.MessageType = func() enums.CommsMessagetypeemail { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m commsEmailTemplateMods) MessageTypeFunc(f func() enums.CommsMessagetypeemail) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.MessageType = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m commsEmailTemplateMods) UnsetMessageType() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.MessageType = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m commsEmailTemplateMods) RandomMessageType(f *faker.Faker) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(_ context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.MessageType = func() enums.CommsMessagetypeemail {
|
|
return random_enums_CommsMessagetypeemail(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailTemplateMods) WithParentsCascading() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(ctx context.Context, o *CommsEmailTemplateTemplate) {
|
|
if isDone, _ := commsEmailTemplateWithParentsCascadingCtx.Value(ctx); isDone {
|
|
return
|
|
}
|
|
ctx = commsEmailTemplateWithParentsCascadingCtx.WithValue(ctx, true)
|
|
})
|
|
}
|
|
|
|
func (m commsEmailTemplateMods) WithTemplateEmailLogs(number int, related *CommsEmailLogTemplate) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(ctx context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.r.TemplateEmailLogs = []*commsEmailTemplateRTemplateEmailLogsR{{
|
|
number: number,
|
|
o: related,
|
|
}}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailTemplateMods) WithNewTemplateEmailLogs(number int, mods ...CommsEmailLogMod) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(ctx context.Context, o *CommsEmailTemplateTemplate) {
|
|
related := o.f.NewCommsEmailLogWithContext(ctx, mods...)
|
|
m.WithTemplateEmailLogs(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m commsEmailTemplateMods) AddTemplateEmailLogs(number int, related *CommsEmailLogTemplate) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(ctx context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.r.TemplateEmailLogs = append(o.r.TemplateEmailLogs, &commsEmailTemplateRTemplateEmailLogsR{
|
|
number: number,
|
|
o: related,
|
|
})
|
|
})
|
|
}
|
|
|
|
func (m commsEmailTemplateMods) AddNewTemplateEmailLogs(number int, mods ...CommsEmailLogMod) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(ctx context.Context, o *CommsEmailTemplateTemplate) {
|
|
related := o.f.NewCommsEmailLogWithContext(ctx, mods...)
|
|
m.AddTemplateEmailLogs(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m commsEmailTemplateMods) AddExistingTemplateEmailLogs(existingModels ...*models.CommsEmailLog) CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(ctx context.Context, o *CommsEmailTemplateTemplate) {
|
|
for _, em := range existingModels {
|
|
o.r.TemplateEmailLogs = append(o.r.TemplateEmailLogs, &commsEmailTemplateRTemplateEmailLogsR{
|
|
o: o.f.FromExistingCommsEmailLog(em),
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m commsEmailTemplateMods) WithoutTemplateEmailLogs() CommsEmailTemplateMod {
|
|
return CommsEmailTemplateModFunc(func(ctx context.Context, o *CommsEmailTemplateTemplate) {
|
|
o.r.TemplateEmailLogs = nil
|
|
})
|
|
}
|