nidus-sync/db/factory/note_audio_breadcrumb.bob.go
Eli Ribble a68b8781e7
Add ability to make LLM agent forget the conversation history
This is extremely useful for testing.

In order to do this I needed to actually deploy the migration to a bob
fork so I could start to add support for behaviors I really want.
Specifically the ability to search for ids in a slice.
2026-01-27 18:44:02 +00:00

549 lines
17 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"
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
"github.com/aarondl/opt/omit"
"github.com/google/uuid"
"github.com/jaswdr/faker/v2"
)
type NoteAudioBreadcrumbMod interface {
Apply(context.Context, *NoteAudioBreadcrumbTemplate)
}
type NoteAudioBreadcrumbModFunc func(context.Context, *NoteAudioBreadcrumbTemplate)
func (f NoteAudioBreadcrumbModFunc) Apply(ctx context.Context, n *NoteAudioBreadcrumbTemplate) {
f(ctx, n)
}
type NoteAudioBreadcrumbModSlice []NoteAudioBreadcrumbMod
func (mods NoteAudioBreadcrumbModSlice) Apply(ctx context.Context, n *NoteAudioBreadcrumbTemplate) {
for _, f := range mods {
f.Apply(ctx, n)
}
}
// NoteAudioBreadcrumbTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type NoteAudioBreadcrumbTemplate struct {
Cell func() string
Created func() time.Time
ManuallySelected func() bool
NoteAudioVersion func() int32
NoteAudioUUID func() uuid.UUID
Position func() int32
r noteAudioBreadcrumbR
f *Factory
alreadyPersisted bool
}
type noteAudioBreadcrumbR struct {
NoteAudio *noteAudioBreadcrumbRNoteAudioR
}
type noteAudioBreadcrumbRNoteAudioR struct {
o *NoteAudioTemplate
}
// Apply mods to the NoteAudioBreadcrumbTemplate
func (o *NoteAudioBreadcrumbTemplate) Apply(ctx context.Context, mods ...NoteAudioBreadcrumbMod) {
for _, mod := range mods {
mod.Apply(ctx, o)
}
}
// setModelRels creates and sets the relationships on *models.NoteAudioBreadcrumb
// according to the relationships in the template. Nothing is inserted into the db
func (t NoteAudioBreadcrumbTemplate) setModelRels(o *models.NoteAudioBreadcrumb) {
if t.r.NoteAudio != nil {
rel := t.r.NoteAudio.o.Build()
rel.R.NoteAudioBreadcrumbs = append(rel.R.NoteAudioBreadcrumbs, o)
o.NoteAudioVersion = rel.Version // h2
o.NoteAudioUUID = rel.UUID // h2
o.R.NoteAudio = rel
}
}
// BuildSetter returns an *models.NoteAudioBreadcrumbSetter
// this does nothing with the relationship templates
func (o NoteAudioBreadcrumbTemplate) BuildSetter() *models.NoteAudioBreadcrumbSetter {
m := &models.NoteAudioBreadcrumbSetter{}
if o.Cell != nil {
val := o.Cell()
m.Cell = omit.From(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omit.From(val)
}
if o.ManuallySelected != nil {
val := o.ManuallySelected()
m.ManuallySelected = omit.From(val)
}
if o.NoteAudioVersion != nil {
val := o.NoteAudioVersion()
m.NoteAudioVersion = omit.From(val)
}
if o.NoteAudioUUID != nil {
val := o.NoteAudioUUID()
m.NoteAudioUUID = omit.From(val)
}
if o.Position != nil {
val := o.Position()
m.Position = omit.From(val)
}
return m
}
// BuildManySetter returns an []*models.NoteAudioBreadcrumbSetter
// this does nothing with the relationship templates
func (o NoteAudioBreadcrumbTemplate) BuildManySetter(number int) []*models.NoteAudioBreadcrumbSetter {
m := make([]*models.NoteAudioBreadcrumbSetter, number)
for i := range m {
m[i] = o.BuildSetter()
}
return m
}
// Build returns an *models.NoteAudioBreadcrumb
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use NoteAudioBreadcrumbTemplate.Create
func (o NoteAudioBreadcrumbTemplate) Build() *models.NoteAudioBreadcrumb {
m := &models.NoteAudioBreadcrumb{}
if o.Cell != nil {
m.Cell = o.Cell()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.ManuallySelected != nil {
m.ManuallySelected = o.ManuallySelected()
}
if o.NoteAudioVersion != nil {
m.NoteAudioVersion = o.NoteAudioVersion()
}
if o.NoteAudioUUID != nil {
m.NoteAudioUUID = o.NoteAudioUUID()
}
if o.Position != nil {
m.Position = o.Position()
}
o.setModelRels(m)
return m
}
// BuildMany returns an models.NoteAudioBreadcrumbSlice
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use NoteAudioBreadcrumbTemplate.CreateMany
func (o NoteAudioBreadcrumbTemplate) BuildMany(number int) models.NoteAudioBreadcrumbSlice {
m := make(models.NoteAudioBreadcrumbSlice, number)
for i := range m {
m[i] = o.Build()
}
return m
}
func ensureCreatableNoteAudioBreadcrumb(m *models.NoteAudioBreadcrumbSetter) {
if !(m.Cell.IsValue()) {
val := random_string(nil)
m.Cell = omit.From(val)
}
if !(m.Created.IsValue()) {
val := random_time_Time(nil)
m.Created = omit.From(val)
}
if !(m.ManuallySelected.IsValue()) {
val := random_bool(nil)
m.ManuallySelected = omit.From(val)
}
if !(m.NoteAudioVersion.IsValue()) {
val := random_int32(nil)
m.NoteAudioVersion = omit.From(val)
}
if !(m.NoteAudioUUID.IsValue()) {
val := random_uuid_UUID(nil)
m.NoteAudioUUID = omit.From(val)
}
if !(m.Position.IsValue()) {
val := random_int32(nil)
m.Position = omit.From(val)
}
}
// insertOptRels creates and inserts any optional the relationships on *models.NoteAudioBreadcrumb
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *NoteAudioBreadcrumbTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.NoteAudioBreadcrumb) error {
var err error
return err
}
// Create builds a noteAudioBreadcrumb and inserts it into the database
// Relations objects are also inserted and placed in the .R field
func (o *NoteAudioBreadcrumbTemplate) Create(ctx context.Context, exec bob.Executor) (*models.NoteAudioBreadcrumb, error) {
var err error
opt := o.BuildSetter()
ensureCreatableNoteAudioBreadcrumb(opt)
if o.r.NoteAudio == nil {
NoteAudioBreadcrumbMods.WithNewNoteAudio().Apply(ctx, o)
}
var rel0 *models.NoteAudio
if o.r.NoteAudio.o.alreadyPersisted {
rel0 = o.r.NoteAudio.o.Build()
} else {
rel0, err = o.r.NoteAudio.o.Create(ctx, exec)
if err != nil {
return nil, err
}
}
opt.NoteAudioVersion = omit.From(rel0.Version)
opt.NoteAudioUUID = omit.From(rel0.UUID)
m, err := models.NoteAudioBreadcrumbs.Insert(opt).One(ctx, exec)
if err != nil {
return nil, err
}
m.R.NoteAudio = rel0
if err := o.insertOptRels(ctx, exec, m); err != nil {
return nil, err
}
return m, err
}
// MustCreate builds a noteAudioBreadcrumb and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *NoteAudioBreadcrumbTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.NoteAudioBreadcrumb {
m, err := o.Create(ctx, exec)
if err != nil {
panic(err)
}
return m
}
// CreateOrFail builds a noteAudioBreadcrumb 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 *NoteAudioBreadcrumbTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.NoteAudioBreadcrumb {
tb.Helper()
m, err := o.Create(ctx, exec)
if err != nil {
tb.Fatal(err)
return nil
}
return m
}
// CreateMany builds multiple noteAudioBreadcrumbs and inserts them into the database
// Relations objects are also inserted and placed in the .R field
func (o NoteAudioBreadcrumbTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.NoteAudioBreadcrumbSlice, error) {
var err error
m := make(models.NoteAudioBreadcrumbSlice, number)
for i := range m {
m[i], err = o.Create(ctx, exec)
if err != nil {
return nil, err
}
}
return m, nil
}
// MustCreateMany builds multiple noteAudioBreadcrumbs and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o NoteAudioBreadcrumbTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.NoteAudioBreadcrumbSlice {
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
panic(err)
}
return m
}
// CreateManyOrFail builds multiple noteAudioBreadcrumbs 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 NoteAudioBreadcrumbTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.NoteAudioBreadcrumbSlice {
tb.Helper()
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
tb.Fatal(err)
return nil
}
return m
}
// NoteAudioBreadcrumb has methods that act as mods for the NoteAudioBreadcrumbTemplate
var NoteAudioBreadcrumbMods noteAudioBreadcrumbMods
type noteAudioBreadcrumbMods struct{}
func (m noteAudioBreadcrumbMods) RandomizeAllColumns(f *faker.Faker) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModSlice{
NoteAudioBreadcrumbMods.RandomCell(f),
NoteAudioBreadcrumbMods.RandomCreated(f),
NoteAudioBreadcrumbMods.RandomManuallySelected(f),
NoteAudioBreadcrumbMods.RandomNoteAudioVersion(f),
NoteAudioBreadcrumbMods.RandomNoteAudioUUID(f),
NoteAudioBreadcrumbMods.RandomPosition(f),
}
}
// Set the model columns to this value
func (m noteAudioBreadcrumbMods) Cell(val string) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Cell = func() string { return val }
})
}
// Set the Column from the function
func (m noteAudioBreadcrumbMods) CellFunc(f func() string) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Cell = f
})
}
// Clear any values for the column
func (m noteAudioBreadcrumbMods) UnsetCell() NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Cell = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m noteAudioBreadcrumbMods) RandomCell(f *faker.Faker) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Cell = func() string {
return random_string(f)
}
})
}
// Set the model columns to this value
func (m noteAudioBreadcrumbMods) Created(val time.Time) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Created = func() time.Time { return val }
})
}
// Set the Column from the function
func (m noteAudioBreadcrumbMods) CreatedFunc(f func() time.Time) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m noteAudioBreadcrumbMods) UnsetCreated() NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
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 noteAudioBreadcrumbMods) RandomCreated(f *faker.Faker) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Created = func() time.Time {
return random_time_Time(f)
}
})
}
// Set the model columns to this value
func (m noteAudioBreadcrumbMods) ManuallySelected(val bool) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.ManuallySelected = func() bool { return val }
})
}
// Set the Column from the function
func (m noteAudioBreadcrumbMods) ManuallySelectedFunc(f func() bool) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.ManuallySelected = f
})
}
// Clear any values for the column
func (m noteAudioBreadcrumbMods) UnsetManuallySelected() NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.ManuallySelected = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m noteAudioBreadcrumbMods) RandomManuallySelected(f *faker.Faker) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.ManuallySelected = func() bool {
return random_bool(f)
}
})
}
// Set the model columns to this value
func (m noteAudioBreadcrumbMods) NoteAudioVersion(val int32) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.NoteAudioVersion = func() int32 { return val }
})
}
// Set the Column from the function
func (m noteAudioBreadcrumbMods) NoteAudioVersionFunc(f func() int32) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.NoteAudioVersion = f
})
}
// Clear any values for the column
func (m noteAudioBreadcrumbMods) UnsetNoteAudioVersion() NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.NoteAudioVersion = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m noteAudioBreadcrumbMods) RandomNoteAudioVersion(f *faker.Faker) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.NoteAudioVersion = func() int32 {
return random_int32(f)
}
})
}
// Set the model columns to this value
func (m noteAudioBreadcrumbMods) NoteAudioUUID(val uuid.UUID) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.NoteAudioUUID = func() uuid.UUID { return val }
})
}
// Set the Column from the function
func (m noteAudioBreadcrumbMods) NoteAudioUUIDFunc(f func() uuid.UUID) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.NoteAudioUUID = f
})
}
// Clear any values for the column
func (m noteAudioBreadcrumbMods) UnsetNoteAudioUUID() NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.NoteAudioUUID = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m noteAudioBreadcrumbMods) RandomNoteAudioUUID(f *faker.Faker) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.NoteAudioUUID = func() uuid.UUID {
return random_uuid_UUID(f)
}
})
}
// Set the model columns to this value
func (m noteAudioBreadcrumbMods) Position(val int32) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Position = func() int32 { return val }
})
}
// Set the Column from the function
func (m noteAudioBreadcrumbMods) PositionFunc(f func() int32) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Position = f
})
}
// Clear any values for the column
func (m noteAudioBreadcrumbMods) UnsetPosition() NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Position = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m noteAudioBreadcrumbMods) RandomPosition(f *faker.Faker) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(_ context.Context, o *NoteAudioBreadcrumbTemplate) {
o.Position = func() int32 {
return random_int32(f)
}
})
}
func (m noteAudioBreadcrumbMods) WithParentsCascading() NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(ctx context.Context, o *NoteAudioBreadcrumbTemplate) {
if isDone, _ := noteAudioBreadcrumbWithParentsCascadingCtx.Value(ctx); isDone {
return
}
ctx = noteAudioBreadcrumbWithParentsCascadingCtx.WithValue(ctx, true)
{
related := o.f.NewNoteAudioWithContext(ctx, NoteAudioMods.WithParentsCascading())
m.WithNoteAudio(related).Apply(ctx, o)
}
})
}
func (m noteAudioBreadcrumbMods) WithNoteAudio(rel *NoteAudioTemplate) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(ctx context.Context, o *NoteAudioBreadcrumbTemplate) {
o.r.NoteAudio = &noteAudioBreadcrumbRNoteAudioR{
o: rel,
}
})
}
func (m noteAudioBreadcrumbMods) WithNewNoteAudio(mods ...NoteAudioMod) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(ctx context.Context, o *NoteAudioBreadcrumbTemplate) {
related := o.f.NewNoteAudioWithContext(ctx, mods...)
m.WithNoteAudio(related).Apply(ctx, o)
})
}
func (m noteAudioBreadcrumbMods) WithExistingNoteAudio(em *models.NoteAudio) NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(ctx context.Context, o *NoteAudioBreadcrumbTemplate) {
o.r.NoteAudio = &noteAudioBreadcrumbRNoteAudioR{
o: o.f.FromExistingNoteAudio(em),
}
})
}
func (m noteAudioBreadcrumbMods) WithoutNoteAudio() NoteAudioBreadcrumbMod {
return NoteAudioBreadcrumbModFunc(func(ctx context.Context, o *NoteAudioBreadcrumbTemplate) {
o.r.NoteAudio = nil
})
}