932 lines
26 KiB
Go
932 lines
26 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/google/uuid"
|
|
"github.com/jaswdr/faker/v2"
|
|
"github.com/stephenafamo/bob"
|
|
)
|
|
|
|
type NoteImageMod interface {
|
|
Apply(context.Context, *NoteImageTemplate)
|
|
}
|
|
|
|
type NoteImageModFunc func(context.Context, *NoteImageTemplate)
|
|
|
|
func (f NoteImageModFunc) Apply(ctx context.Context, n *NoteImageTemplate) {
|
|
f(ctx, n)
|
|
}
|
|
|
|
type NoteImageModSlice []NoteImageMod
|
|
|
|
func (mods NoteImageModSlice) Apply(ctx context.Context, n *NoteImageTemplate) {
|
|
for _, f := range mods {
|
|
f.Apply(ctx, n)
|
|
}
|
|
}
|
|
|
|
// NoteImageTemplate is an object representing the database table.
|
|
// all columns are optional and should be set by mods
|
|
type NoteImageTemplate struct {
|
|
Created func() time.Time
|
|
CreatorID func() int32
|
|
Deleted func() null.Val[time.Time]
|
|
DeletorID func() null.Val[int32]
|
|
OrganizationID func() int32
|
|
Version func() int32
|
|
UUID func() uuid.UUID
|
|
|
|
r noteImageR
|
|
f *Factory
|
|
|
|
alreadyPersisted bool
|
|
}
|
|
|
|
type noteImageR struct {
|
|
CreatorUser *noteImageRCreatorUserR
|
|
DeletorUser *noteImageRDeletorUserR
|
|
Organization *noteImageROrganizationR
|
|
NoteImageBreadcrumbs []*noteImageRNoteImageBreadcrumbsR
|
|
NoteImageData []*noteImageRNoteImageDataR
|
|
}
|
|
|
|
type noteImageRCreatorUserR struct {
|
|
o *UserTemplate
|
|
}
|
|
type noteImageRDeletorUserR struct {
|
|
o *UserTemplate
|
|
}
|
|
type noteImageROrganizationR struct {
|
|
o *OrganizationTemplate
|
|
}
|
|
type noteImageRNoteImageBreadcrumbsR struct {
|
|
number int
|
|
o *NoteImageBreadcrumbTemplate
|
|
}
|
|
type noteImageRNoteImageDataR struct {
|
|
number int
|
|
o *NoteImageDatumTemplate
|
|
}
|
|
|
|
// Apply mods to the NoteImageTemplate
|
|
func (o *NoteImageTemplate) Apply(ctx context.Context, mods ...NoteImageMod) {
|
|
for _, mod := range mods {
|
|
mod.Apply(ctx, o)
|
|
}
|
|
}
|
|
|
|
// setModelRels creates and sets the relationships on *models.NoteImage
|
|
// according to the relationships in the template. Nothing is inserted into the db
|
|
func (t NoteImageTemplate) setModelRels(o *models.NoteImage) {
|
|
if t.r.CreatorUser != nil {
|
|
rel := t.r.CreatorUser.o.Build()
|
|
rel.R.CreatorNoteImages = append(rel.R.CreatorNoteImages, o)
|
|
o.CreatorID = rel.ID // h2
|
|
o.R.CreatorUser = rel
|
|
}
|
|
|
|
if t.r.DeletorUser != nil {
|
|
rel := t.r.DeletorUser.o.Build()
|
|
rel.R.DeletorNoteImages = append(rel.R.DeletorNoteImages, o)
|
|
o.DeletorID = null.From(rel.ID) // h2
|
|
o.R.DeletorUser = rel
|
|
}
|
|
|
|
if t.r.Organization != nil {
|
|
rel := t.r.Organization.o.Build()
|
|
rel.R.NoteImages = append(rel.R.NoteImages, o)
|
|
o.OrganizationID = rel.ID // h2
|
|
o.R.Organization = rel
|
|
}
|
|
|
|
if t.r.NoteImageBreadcrumbs != nil {
|
|
rel := models.NoteImageBreadcrumbSlice{}
|
|
for _, r := range t.r.NoteImageBreadcrumbs {
|
|
related := r.o.BuildMany(r.number)
|
|
for _, rel := range related {
|
|
rel.NoteImageVersion = o.Version // h2
|
|
rel.NoteImageUUID = o.UUID // h2
|
|
rel.R.NoteImage = o
|
|
}
|
|
rel = append(rel, related...)
|
|
}
|
|
o.R.NoteImageBreadcrumbs = rel
|
|
}
|
|
|
|
if t.r.NoteImageData != nil {
|
|
rel := models.NoteImageDatumSlice{}
|
|
for _, r := range t.r.NoteImageData {
|
|
related := r.o.BuildMany(r.number)
|
|
for _, rel := range related {
|
|
rel.NoteImageVersion = o.Version // h2
|
|
rel.NoteImageUUID = o.UUID // h2
|
|
rel.R.NoteImage = o
|
|
}
|
|
rel = append(rel, related...)
|
|
}
|
|
o.R.NoteImageData = rel
|
|
}
|
|
}
|
|
|
|
// BuildSetter returns an *models.NoteImageSetter
|
|
// this does nothing with the relationship templates
|
|
func (o NoteImageTemplate) BuildSetter() *models.NoteImageSetter {
|
|
m := &models.NoteImageSetter{}
|
|
|
|
if o.Created != nil {
|
|
val := o.Created()
|
|
m.Created = omit.From(val)
|
|
}
|
|
if o.CreatorID != nil {
|
|
val := o.CreatorID()
|
|
m.CreatorID = omit.From(val)
|
|
}
|
|
if o.Deleted != nil {
|
|
val := o.Deleted()
|
|
m.Deleted = omitnull.FromNull(val)
|
|
}
|
|
if o.DeletorID != nil {
|
|
val := o.DeletorID()
|
|
m.DeletorID = omitnull.FromNull(val)
|
|
}
|
|
if o.OrganizationID != nil {
|
|
val := o.OrganizationID()
|
|
m.OrganizationID = omit.From(val)
|
|
}
|
|
if o.Version != nil {
|
|
val := o.Version()
|
|
m.Version = omit.From(val)
|
|
}
|
|
if o.UUID != nil {
|
|
val := o.UUID()
|
|
m.UUID = omit.From(val)
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildManySetter returns an []*models.NoteImageSetter
|
|
// this does nothing with the relationship templates
|
|
func (o NoteImageTemplate) BuildManySetter(number int) []*models.NoteImageSetter {
|
|
m := make([]*models.NoteImageSetter, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.BuildSetter()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
// Build returns an *models.NoteImage
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use NoteImageTemplate.Create
|
|
func (o NoteImageTemplate) Build() *models.NoteImage {
|
|
m := &models.NoteImage{}
|
|
|
|
if o.Created != nil {
|
|
m.Created = o.Created()
|
|
}
|
|
if o.CreatorID != nil {
|
|
m.CreatorID = o.CreatorID()
|
|
}
|
|
if o.Deleted != nil {
|
|
m.Deleted = o.Deleted()
|
|
}
|
|
if o.DeletorID != nil {
|
|
m.DeletorID = o.DeletorID()
|
|
}
|
|
if o.OrganizationID != nil {
|
|
m.OrganizationID = o.OrganizationID()
|
|
}
|
|
if o.Version != nil {
|
|
m.Version = o.Version()
|
|
}
|
|
if o.UUID != nil {
|
|
m.UUID = o.UUID()
|
|
}
|
|
|
|
o.setModelRels(m)
|
|
|
|
return m
|
|
}
|
|
|
|
// BuildMany returns an models.NoteImageSlice
|
|
// Related objects are also created and placed in the .R field
|
|
// NOTE: Objects are not inserted into the database. Use NoteImageTemplate.CreateMany
|
|
func (o NoteImageTemplate) BuildMany(number int) models.NoteImageSlice {
|
|
m := make(models.NoteImageSlice, number)
|
|
|
|
for i := range m {
|
|
m[i] = o.Build()
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func ensureCreatableNoteImage(m *models.NoteImageSetter) {
|
|
if !(m.Created.IsValue()) {
|
|
val := random_time_Time(nil)
|
|
m.Created = omit.From(val)
|
|
}
|
|
if !(m.CreatorID.IsValue()) {
|
|
val := random_int32(nil)
|
|
m.CreatorID = omit.From(val)
|
|
}
|
|
if !(m.OrganizationID.IsValue()) {
|
|
val := random_int32(nil)
|
|
m.OrganizationID = omit.From(val)
|
|
}
|
|
if !(m.Version.IsValue()) {
|
|
val := random_int32(nil)
|
|
m.Version = omit.From(val)
|
|
}
|
|
if !(m.UUID.IsValue()) {
|
|
val := random_uuid_UUID(nil)
|
|
m.UUID = omit.From(val)
|
|
}
|
|
}
|
|
|
|
// insertOptRels creates and inserts any optional the relationships on *models.NoteImage
|
|
// according to the relationships in the template.
|
|
// any required relationship should have already exist on the model
|
|
func (o *NoteImageTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.NoteImage) error {
|
|
var err error
|
|
|
|
isDeletorUserDone, _ := noteImageRelDeletorUserCtx.Value(ctx)
|
|
if !isDeletorUserDone && o.r.DeletorUser != nil {
|
|
ctx = noteImageRelDeletorUserCtx.WithValue(ctx, true)
|
|
if o.r.DeletorUser.o.alreadyPersisted {
|
|
m.R.DeletorUser = o.r.DeletorUser.o.Build()
|
|
} else {
|
|
var rel1 *models.User
|
|
rel1, err = o.r.DeletorUser.o.Create(ctx, exec)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = m.AttachDeletorUser(ctx, exec, rel1)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
isNoteImageBreadcrumbsDone, _ := noteImageRelNoteImageBreadcrumbsCtx.Value(ctx)
|
|
if !isNoteImageBreadcrumbsDone && o.r.NoteImageBreadcrumbs != nil {
|
|
ctx = noteImageRelNoteImageBreadcrumbsCtx.WithValue(ctx, true)
|
|
for _, r := range o.r.NoteImageBreadcrumbs {
|
|
if r.o.alreadyPersisted {
|
|
m.R.NoteImageBreadcrumbs = append(m.R.NoteImageBreadcrumbs, r.o.Build())
|
|
} else {
|
|
rel3, err := r.o.CreateMany(ctx, exec, r.number)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = m.AttachNoteImageBreadcrumbs(ctx, exec, rel3...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
isNoteImageDataDone, _ := noteImageRelNoteImageDataCtx.Value(ctx)
|
|
if !isNoteImageDataDone && o.r.NoteImageData != nil {
|
|
ctx = noteImageRelNoteImageDataCtx.WithValue(ctx, true)
|
|
for _, r := range o.r.NoteImageData {
|
|
if r.o.alreadyPersisted {
|
|
m.R.NoteImageData = append(m.R.NoteImageData, r.o.Build())
|
|
} else {
|
|
rel4, err := r.o.CreateMany(ctx, exec, r.number)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = m.AttachNoteImageData(ctx, exec, rel4...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return err
|
|
}
|
|
|
|
// Create builds a noteImage and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o *NoteImageTemplate) Create(ctx context.Context, exec bob.Executor) (*models.NoteImage, error) {
|
|
var err error
|
|
opt := o.BuildSetter()
|
|
ensureCreatableNoteImage(opt)
|
|
|
|
if o.r.CreatorUser == nil {
|
|
NoteImageMods.WithNewCreatorUser().Apply(ctx, o)
|
|
}
|
|
|
|
var rel0 *models.User
|
|
|
|
if o.r.CreatorUser.o.alreadyPersisted {
|
|
rel0 = o.r.CreatorUser.o.Build()
|
|
} else {
|
|
rel0, err = o.r.CreatorUser.o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
opt.CreatorID = omit.From(rel0.ID)
|
|
|
|
if o.r.Organization == nil {
|
|
NoteImageMods.WithNewOrganization().Apply(ctx, o)
|
|
}
|
|
|
|
var rel2 *models.Organization
|
|
|
|
if o.r.Organization.o.alreadyPersisted {
|
|
rel2 = o.r.Organization.o.Build()
|
|
} else {
|
|
rel2, err = o.r.Organization.o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
opt.OrganizationID = omit.From(rel2.ID)
|
|
|
|
m, err := models.NoteImages.Insert(opt).One(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
m.R.CreatorUser = rel0
|
|
m.R.Organization = rel2
|
|
|
|
if err := o.insertOptRels(ctx, exec, m); err != nil {
|
|
return nil, err
|
|
}
|
|
return m, err
|
|
}
|
|
|
|
// MustCreate builds a noteImage and inserts it into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o *NoteImageTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.NoteImage {
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateOrFail builds a noteImage 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 *NoteImageTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.NoteImage {
|
|
tb.Helper()
|
|
m, err := o.Create(ctx, exec)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateMany builds multiple noteImages and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
func (o NoteImageTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.NoteImageSlice, error) {
|
|
var err error
|
|
m := make(models.NoteImageSlice, number)
|
|
|
|
for i := range m {
|
|
m[i], err = o.Create(ctx, exec)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return m, nil
|
|
}
|
|
|
|
// MustCreateMany builds multiple noteImages and inserts them into the database
|
|
// Relations objects are also inserted and placed in the .R field
|
|
// panics if an error occurs
|
|
func (o NoteImageTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.NoteImageSlice {
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return m
|
|
}
|
|
|
|
// CreateManyOrFail builds multiple noteImages 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 NoteImageTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.NoteImageSlice {
|
|
tb.Helper()
|
|
m, err := o.CreateMany(ctx, exec, number)
|
|
if err != nil {
|
|
tb.Fatal(err)
|
|
return nil
|
|
}
|
|
return m
|
|
}
|
|
|
|
// NoteImage has methods that act as mods for the NoteImageTemplate
|
|
var NoteImageMods noteImageMods
|
|
|
|
type noteImageMods struct{}
|
|
|
|
func (m noteImageMods) RandomizeAllColumns(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModSlice{
|
|
NoteImageMods.RandomCreated(f),
|
|
NoteImageMods.RandomCreatorID(f),
|
|
NoteImageMods.RandomDeleted(f),
|
|
NoteImageMods.RandomDeletorID(f),
|
|
NoteImageMods.RandomOrganizationID(f),
|
|
NoteImageMods.RandomVersion(f),
|
|
NoteImageMods.RandomUUID(f),
|
|
}
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m noteImageMods) Created(val time.Time) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Created = func() time.Time { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m noteImageMods) CreatedFunc(f func() time.Time) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Created = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m noteImageMods) UnsetCreated() NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
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 noteImageMods) RandomCreated(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Created = func() time.Time {
|
|
return random_time_Time(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m noteImageMods) CreatorID(val int32) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.CreatorID = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m noteImageMods) CreatorIDFunc(f func() int32) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.CreatorID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m noteImageMods) UnsetCreatorID() NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.CreatorID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m noteImageMods) RandomCreatorID(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.CreatorID = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m noteImageMods) Deleted(val null.Val[time.Time]) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Deleted = func() null.Val[time.Time] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m noteImageMods) DeletedFunc(f func() null.Val[time.Time]) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Deleted = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m noteImageMods) UnsetDeleted() NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Deleted = 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 noteImageMods) RandomDeleted(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Deleted = 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 noteImageMods) RandomDeletedNotNull(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Deleted = 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 noteImageMods) DeletorID(val null.Val[int32]) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.DeletorID = func() null.Val[int32] { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m noteImageMods) DeletorIDFunc(f func() null.Val[int32]) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.DeletorID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m noteImageMods) UnsetDeletorID() NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.DeletorID = 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 noteImageMods) RandomDeletorID(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.DeletorID = func() null.Val[int32] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_int32(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 noteImageMods) RandomDeletorIDNotNull(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.DeletorID = func() null.Val[int32] {
|
|
if f == nil {
|
|
f = &defaultFaker
|
|
}
|
|
|
|
val := random_int32(f)
|
|
return null.From(val)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m noteImageMods) OrganizationID(val int32) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.OrganizationID = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m noteImageMods) OrganizationIDFunc(f func() int32) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.OrganizationID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m noteImageMods) UnsetOrganizationID() NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.OrganizationID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m noteImageMods) RandomOrganizationID(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.OrganizationID = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m noteImageMods) Version(val int32) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Version = func() int32 { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m noteImageMods) VersionFunc(f func() int32) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Version = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m noteImageMods) UnsetVersion() NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Version = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m noteImageMods) RandomVersion(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.Version = func() int32 {
|
|
return random_int32(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
// Set the model columns to this value
|
|
func (m noteImageMods) UUID(val uuid.UUID) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.UUID = func() uuid.UUID { return val }
|
|
})
|
|
}
|
|
|
|
// Set the Column from the function
|
|
func (m noteImageMods) UUIDFunc(f func() uuid.UUID) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.UUID = f
|
|
})
|
|
}
|
|
|
|
// Clear any values for the column
|
|
func (m noteImageMods) UnsetUUID() NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.UUID = nil
|
|
})
|
|
}
|
|
|
|
// Generates a random value for the column using the given faker
|
|
// if faker is nil, a default faker is used
|
|
func (m noteImageMods) RandomUUID(f *faker.Faker) NoteImageMod {
|
|
return NoteImageModFunc(func(_ context.Context, o *NoteImageTemplate) {
|
|
o.UUID = func() uuid.UUID {
|
|
return random_uuid_UUID(f)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithParentsCascading() NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
if isDone, _ := noteImageWithParentsCascadingCtx.Value(ctx); isDone {
|
|
return
|
|
}
|
|
ctx = noteImageWithParentsCascadingCtx.WithValue(ctx, true)
|
|
{
|
|
|
|
related := o.f.NewUserWithContext(ctx, UserMods.WithParentsCascading())
|
|
m.WithCreatorUser(related).Apply(ctx, o)
|
|
}
|
|
{
|
|
|
|
related := o.f.NewUserWithContext(ctx, UserMods.WithParentsCascading())
|
|
m.WithDeletorUser(related).Apply(ctx, o)
|
|
}
|
|
{
|
|
|
|
related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading())
|
|
m.WithOrganization(related).Apply(ctx, o)
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithCreatorUser(rel *UserTemplate) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.CreatorUser = ¬eImageRCreatorUserR{
|
|
o: rel,
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithNewCreatorUser(mods ...UserMod) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
related := o.f.NewUserWithContext(ctx, mods...)
|
|
|
|
m.WithCreatorUser(related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithExistingCreatorUser(em *models.User) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.CreatorUser = ¬eImageRCreatorUserR{
|
|
o: o.f.FromExistingUser(em),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithoutCreatorUser() NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.CreatorUser = nil
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithDeletorUser(rel *UserTemplate) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.DeletorUser = ¬eImageRDeletorUserR{
|
|
o: rel,
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithNewDeletorUser(mods ...UserMod) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
related := o.f.NewUserWithContext(ctx, mods...)
|
|
|
|
m.WithDeletorUser(related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithExistingDeletorUser(em *models.User) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.DeletorUser = ¬eImageRDeletorUserR{
|
|
o: o.f.FromExistingUser(em),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithoutDeletorUser() NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.DeletorUser = nil
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithOrganization(rel *OrganizationTemplate) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.Organization = ¬eImageROrganizationR{
|
|
o: rel,
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithNewOrganization(mods ...OrganizationMod) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
related := o.f.NewOrganizationWithContext(ctx, mods...)
|
|
|
|
m.WithOrganization(related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithExistingOrganization(em *models.Organization) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.Organization = ¬eImageROrganizationR{
|
|
o: o.f.FromExistingOrganization(em),
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithoutOrganization() NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.Organization = nil
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithNoteImageBreadcrumbs(number int, related *NoteImageBreadcrumbTemplate) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.NoteImageBreadcrumbs = []*noteImageRNoteImageBreadcrumbsR{{
|
|
number: number,
|
|
o: related,
|
|
}}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithNewNoteImageBreadcrumbs(number int, mods ...NoteImageBreadcrumbMod) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
related := o.f.NewNoteImageBreadcrumbWithContext(ctx, mods...)
|
|
m.WithNoteImageBreadcrumbs(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) AddNoteImageBreadcrumbs(number int, related *NoteImageBreadcrumbTemplate) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.NoteImageBreadcrumbs = append(o.r.NoteImageBreadcrumbs, ¬eImageRNoteImageBreadcrumbsR{
|
|
number: number,
|
|
o: related,
|
|
})
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) AddNewNoteImageBreadcrumbs(number int, mods ...NoteImageBreadcrumbMod) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
related := o.f.NewNoteImageBreadcrumbWithContext(ctx, mods...)
|
|
m.AddNoteImageBreadcrumbs(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) AddExistingNoteImageBreadcrumbs(existingModels ...*models.NoteImageBreadcrumb) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
for _, em := range existingModels {
|
|
o.r.NoteImageBreadcrumbs = append(o.r.NoteImageBreadcrumbs, ¬eImageRNoteImageBreadcrumbsR{
|
|
o: o.f.FromExistingNoteImageBreadcrumb(em),
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithoutNoteImageBreadcrumbs() NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.NoteImageBreadcrumbs = nil
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithNoteImageData(number int, related *NoteImageDatumTemplate) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.NoteImageData = []*noteImageRNoteImageDataR{{
|
|
number: number,
|
|
o: related,
|
|
}}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithNewNoteImageData(number int, mods ...NoteImageDatumMod) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
related := o.f.NewNoteImageDatumWithContext(ctx, mods...)
|
|
m.WithNoteImageData(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) AddNoteImageData(number int, related *NoteImageDatumTemplate) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.NoteImageData = append(o.r.NoteImageData, ¬eImageRNoteImageDataR{
|
|
number: number,
|
|
o: related,
|
|
})
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) AddNewNoteImageData(number int, mods ...NoteImageDatumMod) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
related := o.f.NewNoteImageDatumWithContext(ctx, mods...)
|
|
m.AddNoteImageData(number, related).Apply(ctx, o)
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) AddExistingNoteImageData(existingModels ...*models.NoteImageDatum) NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
for _, em := range existingModels {
|
|
o.r.NoteImageData = append(o.r.NoteImageData, ¬eImageRNoteImageDataR{
|
|
o: o.f.FromExistingNoteImageDatum(em),
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
func (m noteImageMods) WithoutNoteImageData() NoteImageMod {
|
|
return NoteImageModFunc(func(ctx context.Context, o *NoteImageTemplate) {
|
|
o.r.NoteImageData = nil
|
|
})
|
|
}
|