At this point it also appears that I'm correctly capturing the GPS location as both PostGIS data and as an H3 cell.
689 lines
21 KiB
Go
689 lines
21 KiB
Go
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. 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"
|
|
|
|
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"
|
|
"github.com/stephenafamo/bob"
|
|
)
|
|
|
|
type PublicreportQuickMod interface {
|
|
Apply(context.Context, *PublicreportQuickTemplate)
|
|
}
|
|
|
|
type PublicreportQuickModFunc func(context.Context, *PublicreportQuickTemplate)
|
|
|
|
func (f PublicreportQuickModFunc) Apply(ctx context.Context, n *PublicreportQuickTemplate) {
|
|
f(ctx, n)
|
|
}
|
|
|
|
type PublicreportQuickModSlice []PublicreportQuickMod
|
|
|
|
func (mods PublicreportQuickModSlice) Apply(ctx context.Context, n *PublicreportQuickTemplate) {
|
|
for _, f := range mods {
|
|
f.Apply(ctx, n)
|
|
}
|
|
}
|
|
|
|
// PublicreportQuickTemplate is an object representing the database table.
|
|
// all columns are optional and should be set by mods
|
|
type PublicreportQuickTemplate struct {
|
|
ID func() int32
|
|
Created func() time.Time
|
|
Comments func() string
|
|
Location func() null.Val[string]
|
|
H3cell func() null.Val[string]
|
|
PublicID func() string
|
|
ReporterEmail func() string
|
|
ReporterPhone func() string
|
|
|
|
r publicreportQuickR
|
|
f *Factory
|
|
|
|
alreadyPersisted bool
|
|
}
|
|
|
|
type publicreportQuickR struct {
|
|
QuickPhotos []*publicreportQuickRQuickPhotosR
|
|
}
|
|
|
|
type publicreportQuickRQuickPhotosR struct {
|
|
number int
|
|
o *PublicreportQuickPhotoTemplate
|
|
}
|
|
|
|
// Apply mods to the PublicreportQuickTemplate
|
|
func (o *PublicreportQuickTemplate) Apply(ctx context.Context, mods ...PublicreportQuickMod) {
|
|
for _, mod := range mods {
|
|
mod.Apply(ctx, o)
|
|
}
|
|
}
|
|
|
|
// setModelRels creates and sets the relationships on *models.PublicreportQuick
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
func (t PublicreportQuickTemplate) setModelRels(o *models.PublicreportQuick) {
|
|
if t.r.QuickPhotos != nil {
|
|
rel := models.PublicreportQuickPhotoSlice{}
|
|
for _, r := range t.r.QuickPhotos {
|
|
related := r.o.BuildMany(r.number)
|
|
for _, rel := range related {
|
|
rel.QuickID = o.ID // h2
|
|
rel.R.Quick = o
|
|
}
|
|
rel = append(rel, related...)
|
|
}
|
|
o.R.QuickPhotos = rel
|
|
}
|
|
}
|
|
|
|
// BuildSetter returns an *models.PublicreportQuickSetter
|
|
// this does nothing with the relationship templates
|
|
func (o PublicreportQuickTemplate) BuildSetter() *models.PublicreportQuickSetter {
|
|
m := &models.PublicreportQuickSetter{}
|
|
|
|
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.Comments != nil {
|
|
val := o.Comments()
|
|
m.Comments = omit.From(val)
|
|
}
|
|
if o.Location != nil {
|
|
val := o.Location()
|
|
m.Location = omitnull.FromNull(val)
|
|
}
|
|
if o.H3cell != nil {
|
|
val := o.H3cell()
|
|
m.H3cell = omitnull.FromNull(val)
|
|
}
|
|
if o.PublicID != nil {
|
|
val := o.PublicID()
|
|
m.PublicID = omit.From(val)
|
|
}
|
|
if o.ReporterEmail != nil {
|
|
val := o.ReporterEmail()
|
|
m.ReporterEmail = omit.From(val)
|
|
}
|
|
if o.ReporterPhone != nil {
|
|
val := o.ReporterPhone()
|
|
m.ReporterPhone = omit.From(val)
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildManySetter returns an []*models.PublicreportQuickSetter
|
|
// this does nothing with the relationship templates
|
|
func (o PublicreportQuickTemplate) BuildManySetter(number int) []*models.PublicreportQuickSetter {
|
|
m := make([]*models.PublicreportQuickSetter, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.BuildSetter()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// Build returns an *models.PublicreportQuick
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use PublicreportQuickTemplate.Create
|
|
func (o PublicreportQuickTemplate) Build() *models.PublicreportQuick {
|
|
m := &models.PublicreportQuick{}
|
|
|
|
if o.ID != nil {
|
|
m.ID = o.ID()
|
|
}
|
|
if o.Created != nil {
|
|
m.Created = o.Created()
|
|
}
|
|
if o.Comments != nil {
|
|
m.Comments = o.Comments()
|
|
}
|
|
if o.Location != nil {
|
|
m.Location = o.Location()
|
|
}
|
|
if o.H3cell != nil {
|
|
m.H3cell = o.H3cell()
|
|
}
|
|
if o.PublicID != nil {
|
|
m.PublicID = o.PublicID()
|
|
}
|
|
if o.ReporterEmail != nil {
|
|
m.ReporterEmail = o.ReporterEmail()
|
|
}
|
|
if o.ReporterPhone != nil {
|
|
m.ReporterPhone = o.ReporterPhone()
|
|
}
|
|
|
|
o.setModelRels(m)
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildMany returns an models.PublicreportQuickSlice
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use PublicreportQuickTemplate.CreateMany
|
|
func (o PublicreportQuickTemplate) BuildMany(number int) models.PublicreportQuickSlice {
|
|
m := make(models.PublicreportQuickSlice, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.Build()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func ensureCreatablePublicreportQuick(m *models.PublicreportQuickSetter) {
|
|
if !(m.Created.IsValue()) {
|
|
val := random_time_Time(nil)
|
|
m.Created = omit.From(val)
|
|
}
|
|
if !(m.Comments.IsValue()) {
|
|
val := random_string(nil)
|
|
m.Comments = omit.From(val)
|
|
}
|
|
if !(m.PublicID.IsValue()) {
|
|
val := random_string(nil)
|
|
m.PublicID = omit.From(val)
|
|
}
|
|
if !(m.ReporterEmail.IsValue()) {
|
|
val := random_string(nil)
|
|
m.ReporterEmail = omit.From(val)
|
|
}
|
|
if !(m.ReporterPhone.IsValue()) {
|
|
val := random_string(nil)
|
|
m.ReporterPhone = omit.From(val)
|
|
}
|
|
}
|
|
|
|
// insertOptRels creates and inserts any optional the relationships on *models.PublicreportQuick
|
|
// according to the relationships in the template.
|
|
// any required relationship should have already exist on the model
|
|
func (o *PublicreportQuickTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.PublicreportQuick) error {
|
|
var err error
|
|
|
|
isQuickPhotosDone, _ := publicreportQuickRelQuickPhotosCtx.Value(ctx)
|
|
if !isQuickPhotosDone && o.r.QuickPhotos != nil {
|
|
ctx = publicreportQuickRelQuickPhotosCtx.WithValue(ctx, true)
|
|
for _, r := range o.r.QuickPhotos {
|
|
if r.o.alreadyPersisted {
|
|
m.R.QuickPhotos = append(m.R.QuickPhotos, r.o.Build())
|
|
} else {
|
|
rel0, err := r.o.CreateMany(ctx, exec, r.number)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = m.AttachQuickPhotos(ctx, exec, rel0...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// Create builds a publicreportQuick and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o *PublicreportQuickTemplate) Create(ctx context.Context, exec bob.Executor) (*models.PublicreportQuick, error) {
|
|
var err error
|
|
opt := o.BuildSetter()
|
|
ensureCreatablePublicreportQuick(opt)
|
|
|
|
m, err := models.PublicreportQuicks.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 publicreportQuick and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o *PublicreportQuickTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.PublicreportQuick {
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateOrFail builds a publicreportQuick 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 *PublicreportQuickTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.PublicreportQuick {
|
|
tb.Helper()
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateMany builds multiple publicreportQuicks and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o PublicreportQuickTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.PublicreportQuickSlice, error) {
|
|
var err error
|
|
m := make(models.PublicreportQuickSlice, number)
|
|
|
|
for i := range m {
|
|
m[i], err = o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return m, nil
|
|
}
|
|
|
|
// MustCreateMany builds multiple publicreportQuicks and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o PublicreportQuickTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.PublicreportQuickSlice {
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateManyOrFail builds multiple publicreportQuicks 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 PublicreportQuickTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.PublicreportQuickSlice {
|
|
tb.Helper()
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// PublicreportQuick has methods that act as mods for the PublicreportQuickTemplate
|
|
var PublicreportQuickMods publicreportQuickMods
|
|
|
|
type publicreportQuickMods struct{}
|
|
|
|
func (m publicreportQuickMods) RandomizeAllColumns(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModSlice{
|
|
PublicreportQuickMods.RandomID(f),
|
|
PublicreportQuickMods.RandomCreated(f),
|
|
PublicreportQuickMods.RandomComments(f),
|
|
PublicreportQuickMods.RandomLocation(f),
|
|
PublicreportQuickMods.RandomH3cell(f),
|
|
PublicreportQuickMods.RandomPublicID(f),
|
|
PublicreportQuickMods.RandomReporterEmail(f),
|
|
PublicreportQuickMods.RandomReporterPhone(f),
|
|
}
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportQuickMods) ID(val int32) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ID = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportQuickMods) IDFunc(f func() int32) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportQuickMods) UnsetID() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
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 publicreportQuickMods) RandomID(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ID = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportQuickMods) Created(val time.Time) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Created = func() time.Time { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportQuickMods) CreatedFunc(f func() time.Time) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Created = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportQuickMods) UnsetCreated() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
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 publicreportQuickMods) RandomCreated(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Created = func() time.Time {
|
|
return random_time_Time(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportQuickMods) Comments(val string) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Comments = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportQuickMods) CommentsFunc(f func() string) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Comments = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportQuickMods) UnsetComments() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Comments = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m publicreportQuickMods) RandomComments(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Comments = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportQuickMods) Location(val null.Val[string]) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Location = func() null.Val[string] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportQuickMods) LocationFunc(f func() null.Val[string]) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Location = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportQuickMods) UnsetLocation() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Location = 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 publicreportQuickMods) RandomLocation(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Location = func() null.Val[string] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_string(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 publicreportQuickMods) RandomLocationNotNull(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.Location = func() null.Val[string] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_string(f)
|
|
return null.From(val)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportQuickMods) H3cell(val null.Val[string]) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.H3cell = func() null.Val[string] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportQuickMods) H3cellFunc(f func() null.Val[string]) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.H3cell = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportQuickMods) UnsetH3cell() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.H3cell = 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 publicreportQuickMods) RandomH3cell(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.H3cell = func() null.Val[string] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_string(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 publicreportQuickMods) RandomH3cellNotNull(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.H3cell = func() null.Val[string] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_string(f)
|
|
return null.From(val)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportQuickMods) PublicID(val string) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.PublicID = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportQuickMods) PublicIDFunc(f func() string) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.PublicID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportQuickMods) UnsetPublicID() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
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 publicreportQuickMods) RandomPublicID(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.PublicID = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportQuickMods) ReporterEmail(val string) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ReporterEmail = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportQuickMods) ReporterEmailFunc(f func() string) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ReporterEmail = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportQuickMods) UnsetReporterEmail() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ReporterEmail = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m publicreportQuickMods) RandomReporterEmail(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ReporterEmail = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m publicreportQuickMods) ReporterPhone(val string) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ReporterPhone = func() string { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m publicreportQuickMods) ReporterPhoneFunc(f func() string) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ReporterPhone = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m publicreportQuickMods) UnsetReporterPhone() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ReporterPhone = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m publicreportQuickMods) RandomReporterPhone(f *faker.Faker) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(_ context.Context, o *PublicreportQuickTemplate) {
|
|
o.ReporterPhone = func() string {
|
|
return random_string(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m publicreportQuickMods) WithParentsCascading() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
|
|
if isDone, _ := publicreportQuickWithParentsCascadingCtx.Value(ctx); isDone {
|
|
return
|
|
}
|
|
ctx = publicreportQuickWithParentsCascadingCtx.WithValue(ctx, true)
|
|
})
|
|
}
|
|
|
|
func (m publicreportQuickMods) WithQuickPhotos(number int, related *PublicreportQuickPhotoTemplate) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
|
|
o.r.QuickPhotos = []*publicreportQuickRQuickPhotosR{{
|
|
number: number,
|
|
o: related,
|
|
}}
|
|
})
|
|
}
|
|
|
|
func (m publicreportQuickMods) WithNewQuickPhotos(number int, mods ...PublicreportQuickPhotoMod) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
|
|
related := o.f.NewPublicreportQuickPhotoWithContext(ctx, mods...)
|
|
m.WithQuickPhotos(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m publicreportQuickMods) AddQuickPhotos(number int, related *PublicreportQuickPhotoTemplate) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
|
|
o.r.QuickPhotos = append(o.r.QuickPhotos, &publicreportQuickRQuickPhotosR{
|
|
number: number,
|
|
o: related,
|
|
})
|
|
})
|
|
}
|
|
|
|
func (m publicreportQuickMods) AddNewQuickPhotos(number int, mods ...PublicreportQuickPhotoMod) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
|
|
related := o.f.NewPublicreportQuickPhotoWithContext(ctx, mods...)
|
|
m.AddQuickPhotos(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m publicreportQuickMods) AddExistingQuickPhotos(existingModels ...*models.PublicreportQuickPhoto) PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
|
|
for _, em := range existingModels {
|
|
o.r.QuickPhotos = append(o.r.QuickPhotos, &publicreportQuickRQuickPhotosR{
|
|
o: o.f.FromExistingPublicreportQuickPhoto(em),
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m publicreportQuickMods) WithoutQuickPhotos() PublicreportQuickMod {
|
|
return PublicreportQuickModFunc(func(ctx context.Context, o *PublicreportQuickTemplate) {
|
|
o.r.QuickPhotos = nil
|
|
})
|
|
}
|