// 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"
	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"
)

type NoteAudioMod interface {
	Apply(context.Context, *NoteAudioTemplate)
}

type NoteAudioModFunc func(context.Context, *NoteAudioTemplate)

func (f NoteAudioModFunc) Apply(ctx context.Context, n *NoteAudioTemplate) {
	f(ctx, n)
}

type NoteAudioModSlice []NoteAudioMod

func (mods NoteAudioModSlice) Apply(ctx context.Context, n *NoteAudioTemplate) {
	for _, f := range mods {
		f.Apply(ctx, n)
	}
}

// NoteAudioTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type NoteAudioTemplate struct {
	Created                 func() time.Time
	CreatorID               func() int32
	Deleted                 func() null.Val[time.Time]
	DeletorID               func() null.Val[int32]
	Duration                func() float32
	OrganizationID          func() int32
	Transcription           func() null.Val[string]
	TranscriptionUserEdited func() bool
	Version                 func() int32
	UUID                    func() uuid.UUID

	r noteAudioR
	f *Factory

	alreadyPersisted bool
}

type noteAudioR struct {
	CreatorUser          *noteAudioRCreatorUserR
	DeletorUser          *noteAudioRDeletorUserR
	Organization         *noteAudioROrganizationR
	NoteAudioBreadcrumbs []*noteAudioRNoteAudioBreadcrumbsR
	NoteAudioData        []*noteAudioRNoteAudioDataR
}

type noteAudioRCreatorUserR struct {
	o *UserTemplate
}
type noteAudioRDeletorUserR struct {
	o *UserTemplate
}
type noteAudioROrganizationR struct {
	o *OrganizationTemplate
}
type noteAudioRNoteAudioBreadcrumbsR struct {
	number int
	o      *NoteAudioBreadcrumbTemplate
}
type noteAudioRNoteAudioDataR struct {
	number int
	o      *NoteAudioDatumTemplate
}

// Apply mods to the NoteAudioTemplate
func (o *NoteAudioTemplate) Apply(ctx context.Context, mods ...NoteAudioMod) {
	for _, mod := range mods {
		mod.Apply(ctx, o)
	}
}

// setModelRels creates and sets the relationships on *models.NoteAudio
// according to the relationships in the template. Nothing is inserted into the db
func (t NoteAudioTemplate) setModelRels(o *models.NoteAudio) {
	if t.r.CreatorUser != nil {
		rel := t.r.CreatorUser.o.Build()
		rel.R.CreatorNoteAudios = append(rel.R.CreatorNoteAudios, o)
		o.CreatorID = rel.ID // h2
		o.R.CreatorUser = rel
	}

	if t.r.DeletorUser != nil {
		rel := t.r.DeletorUser.o.Build()
		rel.R.DeletorNoteAudios = append(rel.R.DeletorNoteAudios, 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.NoteAudios = append(rel.R.NoteAudios, o)
		o.OrganizationID = rel.ID // h2
		o.R.Organization = rel
	}

	if t.r.NoteAudioBreadcrumbs != nil {
		rel := models.NoteAudioBreadcrumbSlice{}
		for _, r := range t.r.NoteAudioBreadcrumbs {
			related := r.o.BuildMany(r.number)
			for _, rel := range related {
				rel.NoteAudioVersion = o.Version // h2
				rel.NoteAudioUUID = o.UUID       // h2
				rel.R.NoteAudio = o
			}
			rel = append(rel, related...)
		}
		o.R.NoteAudioBreadcrumbs = rel
	}

	if t.r.NoteAudioData != nil {
		rel := models.NoteAudioDatumSlice{}
		for _, r := range t.r.NoteAudioData {
			related := r.o.BuildMany(r.number)
			for _, rel := range related {
				rel.NoteAudioVersion = o.Version // h2
				rel.NoteAudioUUID = o.UUID       // h2
				rel.R.NoteAudio = o
			}
			rel = append(rel, related...)
		}
		o.R.NoteAudioData = rel
	}
}

// BuildSetter returns an *models.NoteAudioSetter
// this does nothing with the relationship templates
func (o NoteAudioTemplate) BuildSetter() *models.NoteAudioSetter {
	m := &models.NoteAudioSetter{}

	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.Duration != nil {
		val := o.Duration()
		m.Duration = omit.From(val)
	}
	if o.OrganizationID != nil {
		val := o.OrganizationID()
		m.OrganizationID = omit.From(val)
	}
	if o.Transcription != nil {
		val := o.Transcription()
		m.Transcription = omitnull.FromNull(val)
	}
	if o.TranscriptionUserEdited != nil {
		val := o.TranscriptionUserEdited()
		m.TranscriptionUserEdited = 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.NoteAudioSetter
// this does nothing with the relationship templates
func (o NoteAudioTemplate) BuildManySetter(number int) []*models.NoteAudioSetter {
	m := make([]*models.NoteAudioSetter, number)

	for i := range m {
		m[i] = o.BuildSetter()
	}

	return m
}

// Build returns an *models.NoteAudio
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use NoteAudioTemplate.Create
func (o NoteAudioTemplate) Build() *models.NoteAudio {
	m := &models.NoteAudio{}

	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.Duration != nil {
		m.Duration = o.Duration()
	}
	if o.OrganizationID != nil {
		m.OrganizationID = o.OrganizationID()
	}
	if o.Transcription != nil {
		m.Transcription = o.Transcription()
	}
	if o.TranscriptionUserEdited != nil {
		m.TranscriptionUserEdited = o.TranscriptionUserEdited()
	}
	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.NoteAudioSlice
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use NoteAudioTemplate.CreateMany
func (o NoteAudioTemplate) BuildMany(number int) models.NoteAudioSlice {
	m := make(models.NoteAudioSlice, number)

	for i := range m {
		m[i] = o.Build()
	}

	return m
}

func ensureCreatableNoteAudio(m *models.NoteAudioSetter) {
	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.Duration.IsValue()) {
		val := random_float32(nil)
		m.Duration = omit.From(val)
	}
	if !(m.OrganizationID.IsValue()) {
		val := random_int32(nil)
		m.OrganizationID = omit.From(val)
	}
	if !(m.TranscriptionUserEdited.IsValue()) {
		val := random_bool(nil)
		m.TranscriptionUserEdited = 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.NoteAudio
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *NoteAudioTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.NoteAudio) error {
	var err error

	isDeletorUserDone, _ := noteAudioRelDeletorUserCtx.Value(ctx)
	if !isDeletorUserDone && o.r.DeletorUser != nil {
		ctx = noteAudioRelDeletorUserCtx.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
			}
		}

	}

	isNoteAudioBreadcrumbsDone, _ := noteAudioRelNoteAudioBreadcrumbsCtx.Value(ctx)
	if !isNoteAudioBreadcrumbsDone && o.r.NoteAudioBreadcrumbs != nil {
		ctx = noteAudioRelNoteAudioBreadcrumbsCtx.WithValue(ctx, true)
		for _, r := range o.r.NoteAudioBreadcrumbs {
			if r.o.alreadyPersisted {
				m.R.NoteAudioBreadcrumbs = append(m.R.NoteAudioBreadcrumbs, r.o.Build())
			} else {
				rel3, err := r.o.CreateMany(ctx, exec, r.number)
				if err != nil {
					return err
				}

				err = m.AttachNoteAudioBreadcrumbs(ctx, exec, rel3...)
				if err != nil {
					return err
				}
			}
		}
	}

	isNoteAudioDataDone, _ := noteAudioRelNoteAudioDataCtx.Value(ctx)
	if !isNoteAudioDataDone && o.r.NoteAudioData != nil {
		ctx = noteAudioRelNoteAudioDataCtx.WithValue(ctx, true)
		for _, r := range o.r.NoteAudioData {
			if r.o.alreadyPersisted {
				m.R.NoteAudioData = append(m.R.NoteAudioData, r.o.Build())
			} else {
				rel4, err := r.o.CreateMany(ctx, exec, r.number)
				if err != nil {
					return err
				}

				err = m.AttachNoteAudioData(ctx, exec, rel4...)
				if err != nil {
					return err
				}
			}
		}
	}

	return err
}

// Create builds a noteAudio and inserts it into the database
// Relations objects are also inserted and placed in the .R field
func (o *NoteAudioTemplate) Create(ctx context.Context, exec bob.Executor) (*models.NoteAudio, error) {
	var err error
	opt := o.BuildSetter()
	ensureCreatableNoteAudio(opt)

	if o.r.CreatorUser == nil {
		NoteAudioMods.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 {
		NoteAudioMods.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.NoteAudios.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 noteAudio and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *NoteAudioTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.NoteAudio {
	m, err := o.Create(ctx, exec)
	if err != nil {
		panic(err)
	}
	return m
}

// CreateOrFail builds a noteAudio 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 *NoteAudioTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.NoteAudio {
	tb.Helper()
	m, err := o.Create(ctx, exec)
	if err != nil {
		tb.Fatal(err)
		return nil
	}
	return m
}

// CreateMany builds multiple noteAudios and inserts them into the database
// Relations objects are also inserted and placed in the .R field
func (o NoteAudioTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.NoteAudioSlice, error) {
	var err error
	m := make(models.NoteAudioSlice, number)

	for i := range m {
		m[i], err = o.Create(ctx, exec)
		if err != nil {
			return nil, err
		}
	}

	return m, nil
}

// MustCreateMany builds multiple noteAudios and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o NoteAudioTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.NoteAudioSlice {
	m, err := o.CreateMany(ctx, exec, number)
	if err != nil {
		panic(err)
	}
	return m
}

// CreateManyOrFail builds multiple noteAudios 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 NoteAudioTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.NoteAudioSlice {
	tb.Helper()
	m, err := o.CreateMany(ctx, exec, number)
	if err != nil {
		tb.Fatal(err)
		return nil
	}
	return m
}

// NoteAudio has methods that act as mods for the NoteAudioTemplate
var NoteAudioMods noteAudioMods

type noteAudioMods struct{}

func (m noteAudioMods) RandomizeAllColumns(f *faker.Faker) NoteAudioMod {
	return NoteAudioModSlice{
		NoteAudioMods.RandomCreated(f),
		NoteAudioMods.RandomCreatorID(f),
		NoteAudioMods.RandomDeleted(f),
		NoteAudioMods.RandomDeletorID(f),
		NoteAudioMods.RandomDuration(f),
		NoteAudioMods.RandomOrganizationID(f),
		NoteAudioMods.RandomTranscription(f),
		NoteAudioMods.RandomTranscriptionUserEdited(f),
		NoteAudioMods.RandomVersion(f),
		NoteAudioMods.RandomUUID(f),
	}
}

// Set the model columns to this value
func (m noteAudioMods) Created(val time.Time) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Created = func() time.Time { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) CreatedFunc(f func() time.Time) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Created = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetCreated() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomCreated(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Created = func() time.Time {
			return random_time_Time(f)
		}
	})
}

// Set the model columns to this value
func (m noteAudioMods) CreatorID(val int32) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.CreatorID = func() int32 { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) CreatorIDFunc(f func() int32) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.CreatorID = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetCreatorID() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomCreatorID(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.CreatorID = func() int32 {
			return random_int32(f)
		}
	})
}

// Set the model columns to this value
func (m noteAudioMods) Deleted(val null.Val[time.Time]) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Deleted = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) DeletedFunc(f func() null.Val[time.Time]) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Deleted = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetDeleted() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomDeleted(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomDeletedNotNull(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) DeletorID(val null.Val[int32]) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.DeletorID = func() null.Val[int32] { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) DeletorIDFunc(f func() null.Val[int32]) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.DeletorID = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetDeletorID() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomDeletorID(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomDeletorIDNotNull(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) Duration(val float32) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Duration = func() float32 { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) DurationFunc(f func() float32) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Duration = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetDuration() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Duration = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m noteAudioMods) RandomDuration(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Duration = func() float32 {
			return random_float32(f)
		}
	})
}

// Set the model columns to this value
func (m noteAudioMods) OrganizationID(val int32) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.OrganizationID = func() int32 { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) OrganizationIDFunc(f func() int32) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.OrganizationID = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetOrganizationID() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomOrganizationID(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.OrganizationID = func() int32 {
			return random_int32(f)
		}
	})
}

// Set the model columns to this value
func (m noteAudioMods) Transcription(val null.Val[string]) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Transcription = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) TranscriptionFunc(f func() null.Val[string]) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Transcription = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetTranscription() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Transcription = 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 noteAudioMods) RandomTranscription(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Transcription = 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 noteAudioMods) RandomTranscriptionNotNull(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Transcription = 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 noteAudioMods) TranscriptionUserEdited(val bool) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.TranscriptionUserEdited = func() bool { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) TranscriptionUserEditedFunc(f func() bool) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.TranscriptionUserEdited = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetTranscriptionUserEdited() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.TranscriptionUserEdited = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m noteAudioMods) RandomTranscriptionUserEdited(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.TranscriptionUserEdited = func() bool {
			return random_bool(f)
		}
	})
}

// Set the model columns to this value
func (m noteAudioMods) Version(val int32) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Version = func() int32 { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) VersionFunc(f func() int32) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Version = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetVersion() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomVersion(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.Version = func() int32 {
			return random_int32(f)
		}
	})
}

// Set the model columns to this value
func (m noteAudioMods) UUID(val uuid.UUID) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.UUID = func() uuid.UUID { return val }
	})
}

// Set the Column from the function
func (m noteAudioMods) UUIDFunc(f func() uuid.UUID) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.UUID = f
	})
}

// Clear any values for the column
func (m noteAudioMods) UnsetUUID() NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		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 noteAudioMods) RandomUUID(f *faker.Faker) NoteAudioMod {
	return NoteAudioModFunc(func(_ context.Context, o *NoteAudioTemplate) {
		o.UUID = func() uuid.UUID {
			return random_uuid_UUID(f)
		}
	})
}

func (m noteAudioMods) WithParentsCascading() NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		if isDone, _ := noteAudioWithParentsCascadingCtx.Value(ctx); isDone {
			return
		}
		ctx = noteAudioWithParentsCascadingCtx.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 noteAudioMods) WithCreatorUser(rel *UserTemplate) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.CreatorUser = &noteAudioRCreatorUserR{
			o: rel,
		}
	})
}

func (m noteAudioMods) WithNewCreatorUser(mods ...UserMod) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		related := o.f.NewUserWithContext(ctx, mods...)

		m.WithCreatorUser(related).Apply(ctx, o)
	})
}

func (m noteAudioMods) WithExistingCreatorUser(em *models.User) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.CreatorUser = &noteAudioRCreatorUserR{
			o: o.f.FromExistingUser(em),
		}
	})
}

func (m noteAudioMods) WithoutCreatorUser() NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.CreatorUser = nil
	})
}

func (m noteAudioMods) WithDeletorUser(rel *UserTemplate) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.DeletorUser = &noteAudioRDeletorUserR{
			o: rel,
		}
	})
}

func (m noteAudioMods) WithNewDeletorUser(mods ...UserMod) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		related := o.f.NewUserWithContext(ctx, mods...)

		m.WithDeletorUser(related).Apply(ctx, o)
	})
}

func (m noteAudioMods) WithExistingDeletorUser(em *models.User) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.DeletorUser = &noteAudioRDeletorUserR{
			o: o.f.FromExistingUser(em),
		}
	})
}

func (m noteAudioMods) WithoutDeletorUser() NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.DeletorUser = nil
	})
}

func (m noteAudioMods) WithOrganization(rel *OrganizationTemplate) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.Organization = &noteAudioROrganizationR{
			o: rel,
		}
	})
}

func (m noteAudioMods) WithNewOrganization(mods ...OrganizationMod) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		related := o.f.NewOrganizationWithContext(ctx, mods...)

		m.WithOrganization(related).Apply(ctx, o)
	})
}

func (m noteAudioMods) WithExistingOrganization(em *models.Organization) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.Organization = &noteAudioROrganizationR{
			o: o.f.FromExistingOrganization(em),
		}
	})
}

func (m noteAudioMods) WithoutOrganization() NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.Organization = nil
	})
}

func (m noteAudioMods) WithNoteAudioBreadcrumbs(number int, related *NoteAudioBreadcrumbTemplate) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.NoteAudioBreadcrumbs = []*noteAudioRNoteAudioBreadcrumbsR{{
			number: number,
			o:      related,
		}}
	})
}

func (m noteAudioMods) WithNewNoteAudioBreadcrumbs(number int, mods ...NoteAudioBreadcrumbMod) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		related := o.f.NewNoteAudioBreadcrumbWithContext(ctx, mods...)
		m.WithNoteAudioBreadcrumbs(number, related).Apply(ctx, o)
	})
}

func (m noteAudioMods) AddNoteAudioBreadcrumbs(number int, related *NoteAudioBreadcrumbTemplate) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.NoteAudioBreadcrumbs = append(o.r.NoteAudioBreadcrumbs, &noteAudioRNoteAudioBreadcrumbsR{
			number: number,
			o:      related,
		})
	})
}

func (m noteAudioMods) AddNewNoteAudioBreadcrumbs(number int, mods ...NoteAudioBreadcrumbMod) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		related := o.f.NewNoteAudioBreadcrumbWithContext(ctx, mods...)
		m.AddNoteAudioBreadcrumbs(number, related).Apply(ctx, o)
	})
}

func (m noteAudioMods) AddExistingNoteAudioBreadcrumbs(existingModels ...*models.NoteAudioBreadcrumb) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		for _, em := range existingModels {
			o.r.NoteAudioBreadcrumbs = append(o.r.NoteAudioBreadcrumbs, &noteAudioRNoteAudioBreadcrumbsR{
				o: o.f.FromExistingNoteAudioBreadcrumb(em),
			})
		}
	})
}

func (m noteAudioMods) WithoutNoteAudioBreadcrumbs() NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.NoteAudioBreadcrumbs = nil
	})
}

func (m noteAudioMods) WithNoteAudioData(number int, related *NoteAudioDatumTemplate) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.NoteAudioData = []*noteAudioRNoteAudioDataR{{
			number: number,
			o:      related,
		}}
	})
}

func (m noteAudioMods) WithNewNoteAudioData(number int, mods ...NoteAudioDatumMod) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		related := o.f.NewNoteAudioDatumWithContext(ctx, mods...)
		m.WithNoteAudioData(number, related).Apply(ctx, o)
	})
}

func (m noteAudioMods) AddNoteAudioData(number int, related *NoteAudioDatumTemplate) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.NoteAudioData = append(o.r.NoteAudioData, &noteAudioRNoteAudioDataR{
			number: number,
			o:      related,
		})
	})
}

func (m noteAudioMods) AddNewNoteAudioData(number int, mods ...NoteAudioDatumMod) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		related := o.f.NewNoteAudioDatumWithContext(ctx, mods...)
		m.AddNoteAudioData(number, related).Apply(ctx, o)
	})
}

func (m noteAudioMods) AddExistingNoteAudioData(existingModels ...*models.NoteAudioDatum) NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		for _, em := range existingModels {
			o.r.NoteAudioData = append(o.r.NoteAudioData, &noteAudioRNoteAudioDataR{
				o: o.f.FromExistingNoteAudioDatum(em),
			})
		}
	})
}

func (m noteAudioMods) WithoutNoteAudioData() NoteAudioMod {
	return NoteAudioModFunc(func(ctx context.Context, o *NoteAudioTemplate) {
		o.r.NoteAudioData = nil
	})
}
