// 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"
	"encoding/json"
	"testing"
	"time"

	"github.com/Gleipnir-Technology/bob"
	"github.com/Gleipnir-Technology/bob/types"
	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 FieldseekerZones2Mod interface {
	Apply(context.Context, *FieldseekerZones2Template)
}

type FieldseekerZones2ModFunc func(context.Context, *FieldseekerZones2Template)

func (f FieldseekerZones2ModFunc) Apply(ctx context.Context, n *FieldseekerZones2Template) {
	f(ctx, n)
}

type FieldseekerZones2ModSlice []FieldseekerZones2Mod

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

// FieldseekerZones2Template is an object representing the database table.
// all columns are optional and should be set by mods
type FieldseekerZones2Template struct {
	Objectid       func() int64
	Name           func() null.Val[string]
	Globalid       func() uuid.UUID
	CreatedUser    func() null.Val[string]
	CreatedDate    func() null.Val[time.Time]
	LastEditedUser func() null.Val[string]
	LastEditedDate func() null.Val[time.Time]
	Creationdate   func() null.Val[time.Time]
	Creator        func() null.Val[string]
	Editdate       func() null.Val[time.Time]
	Editor         func() null.Val[string]
	ShapeArea      func() null.Val[float64]
	ShapeLength    func() null.Val[float64]
	Geometry       func() types.JSON[json.RawMessage]
	Geospatial     func() null.Val[string]
	Version        func() int32
	OrganizationID func() int32

	r fieldseekerZones2R
	f *Factory

	alreadyPersisted bool
}

type fieldseekerZones2R struct {
	Organization *fieldseekerZones2ROrganizationR
}

type fieldseekerZones2ROrganizationR struct {
	o *OrganizationTemplate
}

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

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

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

	if o.Objectid != nil {
		val := o.Objectid()
		m.Objectid = omit.From(val)
	}
	if o.Name != nil {
		val := o.Name()
		m.Name = omitnull.FromNull(val)
	}
	if o.Globalid != nil {
		val := o.Globalid()
		m.Globalid = omit.From(val)
	}
	if o.CreatedUser != nil {
		val := o.CreatedUser()
		m.CreatedUser = omitnull.FromNull(val)
	}
	if o.CreatedDate != nil {
		val := o.CreatedDate()
		m.CreatedDate = omitnull.FromNull(val)
	}
	if o.LastEditedUser != nil {
		val := o.LastEditedUser()
		m.LastEditedUser = omitnull.FromNull(val)
	}
	if o.LastEditedDate != nil {
		val := o.LastEditedDate()
		m.LastEditedDate = omitnull.FromNull(val)
	}
	if o.Creationdate != nil {
		val := o.Creationdate()
		m.Creationdate = omitnull.FromNull(val)
	}
	if o.Creator != nil {
		val := o.Creator()
		m.Creator = omitnull.FromNull(val)
	}
	if o.Editdate != nil {
		val := o.Editdate()
		m.Editdate = omitnull.FromNull(val)
	}
	if o.Editor != nil {
		val := o.Editor()
		m.Editor = omitnull.FromNull(val)
	}
	if o.ShapeArea != nil {
		val := o.ShapeArea()
		m.ShapeArea = omitnull.FromNull(val)
	}
	if o.ShapeLength != nil {
		val := o.ShapeLength()
		m.ShapeLength = omitnull.FromNull(val)
	}
	if o.Geometry != nil {
		val := o.Geometry()
		m.Geometry = omit.From(val)
	}
	if o.Geospatial != nil {
		val := o.Geospatial()
		m.Geospatial = omitnull.FromNull(val)
	}
	if o.Version != nil {
		val := o.Version()
		m.Version = omit.From(val)
	}
	if o.OrganizationID != nil {
		val := o.OrganizationID()
		m.OrganizationID = omit.From(val)
	}

	return m
}

// BuildManySetter returns an []*models.FieldseekerZones2Setter
// this does nothing with the relationship templates
func (o FieldseekerZones2Template) BuildManySetter(number int) []*models.FieldseekerZones2Setter {
	m := make([]*models.FieldseekerZones2Setter, number)

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

	return m
}

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

	if o.Objectid != nil {
		m.Objectid = o.Objectid()
	}
	if o.Name != nil {
		m.Name = o.Name()
	}
	if o.Globalid != nil {
		m.Globalid = o.Globalid()
	}
	if o.CreatedUser != nil {
		m.CreatedUser = o.CreatedUser()
	}
	if o.CreatedDate != nil {
		m.CreatedDate = o.CreatedDate()
	}
	if o.LastEditedUser != nil {
		m.LastEditedUser = o.LastEditedUser()
	}
	if o.LastEditedDate != nil {
		m.LastEditedDate = o.LastEditedDate()
	}
	if o.Creationdate != nil {
		m.Creationdate = o.Creationdate()
	}
	if o.Creator != nil {
		m.Creator = o.Creator()
	}
	if o.Editdate != nil {
		m.Editdate = o.Editdate()
	}
	if o.Editor != nil {
		m.Editor = o.Editor()
	}
	if o.ShapeArea != nil {
		m.ShapeArea = o.ShapeArea()
	}
	if o.ShapeLength != nil {
		m.ShapeLength = o.ShapeLength()
	}
	if o.Geometry != nil {
		m.Geometry = o.Geometry()
	}
	if o.Geospatial != nil {
		m.Geospatial = o.Geospatial()
	}
	if o.Version != nil {
		m.Version = o.Version()
	}
	if o.OrganizationID != nil {
		m.OrganizationID = o.OrganizationID()
	}

	o.setModelRels(m)

	return m
}

// BuildMany returns an models.FieldseekerZones2Slice
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use FieldseekerZones2Template.CreateMany
func (o FieldseekerZones2Template) BuildMany(number int) models.FieldseekerZones2Slice {
	m := make(models.FieldseekerZones2Slice, number)

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

	return m
}

func ensureCreatableFieldseekerZones2(m *models.FieldseekerZones2Setter) {
	if !(m.Objectid.IsValue()) {
		val := random_int64(nil)
		m.Objectid = omit.From(val)
	}
	if !(m.Globalid.IsValue()) {
		val := random_uuid_UUID(nil)
		m.Globalid = omit.From(val)
	}
	if !(m.Geometry.IsValue()) {
		val := random_types_JSON_json_RawMessage_(nil)
		m.Geometry = omit.From(val)
	}
	if !(m.OrganizationID.IsValue()) {
		val := random_int32(nil)
		m.OrganizationID = omit.From(val)
	}
}

// insertOptRels creates and inserts any optional the relationships on *models.FieldseekerZones2
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *FieldseekerZones2Template) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FieldseekerZones2) error {
	var err error

	return err
}

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

	if o.r.Organization == nil {
		FieldseekerZones2Mods.WithNewOrganization().Apply(ctx, o)
	}

	var rel0 *models.Organization

	if o.r.Organization.o.alreadyPersisted {
		rel0 = o.r.Organization.o.Build()
	} else {
		rel0, err = o.r.Organization.o.Create(ctx, exec)
		if err != nil {
			return nil, err
		}
	}

	opt.OrganizationID = omit.From(rel0.ID)

	m, err := models.FieldseekerZones2s.Insert(opt).One(ctx, exec)
	if err != nil {
		return nil, err
	}

	m.R.Organization = rel0

	if err := o.insertOptRels(ctx, exec, m); err != nil {
		return nil, err
	}
	return m, err
}

// MustCreate builds a fieldseekerZones2 and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *FieldseekerZones2Template) MustCreate(ctx context.Context, exec bob.Executor) *models.FieldseekerZones2 {
	m, err := o.Create(ctx, exec)
	if err != nil {
		panic(err)
	}
	return m
}

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

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

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

	return m, nil
}

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

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

// FieldseekerZones2 has methods that act as mods for the FieldseekerZones2Template
var FieldseekerZones2Mods fieldseekerZones2Mods

type fieldseekerZones2Mods struct{}

func (m fieldseekerZones2Mods) RandomizeAllColumns(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModSlice{
		FieldseekerZones2Mods.RandomObjectid(f),
		FieldseekerZones2Mods.RandomName(f),
		FieldseekerZones2Mods.RandomGlobalid(f),
		FieldseekerZones2Mods.RandomCreatedUser(f),
		FieldseekerZones2Mods.RandomCreatedDate(f),
		FieldseekerZones2Mods.RandomLastEditedUser(f),
		FieldseekerZones2Mods.RandomLastEditedDate(f),
		FieldseekerZones2Mods.RandomCreationdate(f),
		FieldseekerZones2Mods.RandomCreator(f),
		FieldseekerZones2Mods.RandomEditdate(f),
		FieldseekerZones2Mods.RandomEditor(f),
		FieldseekerZones2Mods.RandomShapeArea(f),
		FieldseekerZones2Mods.RandomShapeLength(f),
		FieldseekerZones2Mods.RandomGeometry(f),
		FieldseekerZones2Mods.RandomGeospatial(f),
		FieldseekerZones2Mods.RandomVersion(f),
		FieldseekerZones2Mods.RandomOrganizationID(f),
	}
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) Objectid(val int64) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Objectid = func() int64 { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) ObjectidFunc(f func() int64) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Objectid = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetObjectid() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Objectid = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerZones2Mods) RandomObjectid(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Objectid = func() int64 {
			return random_int64(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) Name(val null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Name = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) NameFunc(f func() null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Name = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetName() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Name = 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 fieldseekerZones2Mods) RandomName(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Name = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "50")
			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 fieldseekerZones2Mods) RandomNameNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Name = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "50")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) Globalid(val uuid.UUID) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Globalid = func() uuid.UUID { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) GlobalidFunc(f func() uuid.UUID) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Globalid = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetGlobalid() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Globalid = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerZones2Mods) RandomGlobalid(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Globalid = func() uuid.UUID {
			return random_uuid_UUID(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) CreatedUser(val null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedUser = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) CreatedUserFunc(f func() null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedUser = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetCreatedUser() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedUser = 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 fieldseekerZones2Mods) RandomCreatedUser(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedUser = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "255")
			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 fieldseekerZones2Mods) RandomCreatedUserNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedUser = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "255")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) CreatedDate(val null.Val[time.Time]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedDate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) CreatedDateFunc(f func() null.Val[time.Time]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedDate = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetCreatedDate() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedDate = 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 fieldseekerZones2Mods) RandomCreatedDate(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedDate = 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 fieldseekerZones2Mods) RandomCreatedDateNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.CreatedDate = 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 fieldseekerZones2Mods) LastEditedUser(val null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedUser = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) LastEditedUserFunc(f func() null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedUser = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetLastEditedUser() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedUser = 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 fieldseekerZones2Mods) RandomLastEditedUser(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedUser = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "255")
			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 fieldseekerZones2Mods) RandomLastEditedUserNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedUser = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "255")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) LastEditedDate(val null.Val[time.Time]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedDate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) LastEditedDateFunc(f func() null.Val[time.Time]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedDate = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetLastEditedDate() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedDate = 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 fieldseekerZones2Mods) RandomLastEditedDate(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedDate = 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 fieldseekerZones2Mods) RandomLastEditedDateNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.LastEditedDate = 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 fieldseekerZones2Mods) Creationdate(val null.Val[time.Time]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creationdate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) CreationdateFunc(f func() null.Val[time.Time]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creationdate = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetCreationdate() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creationdate = 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 fieldseekerZones2Mods) RandomCreationdate(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creationdate = 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 fieldseekerZones2Mods) RandomCreationdateNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creationdate = 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 fieldseekerZones2Mods) Creator(val null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creator = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) CreatorFunc(f func() null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creator = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetCreator() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creator = 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 fieldseekerZones2Mods) RandomCreator(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creator = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "128")
			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 fieldseekerZones2Mods) RandomCreatorNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Creator = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "128")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) Editdate(val null.Val[time.Time]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editdate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) EditdateFunc(f func() null.Val[time.Time]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editdate = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetEditdate() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editdate = 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 fieldseekerZones2Mods) RandomEditdate(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editdate = 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 fieldseekerZones2Mods) RandomEditdateNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editdate = 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 fieldseekerZones2Mods) Editor(val null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editor = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) EditorFunc(f func() null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editor = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetEditor() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editor = 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 fieldseekerZones2Mods) RandomEditor(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editor = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "128")
			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 fieldseekerZones2Mods) RandomEditorNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Editor = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "128")
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) ShapeArea(val null.Val[float64]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeArea = func() null.Val[float64] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) ShapeAreaFunc(f func() null.Val[float64]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeArea = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetShapeArea() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeArea = 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 fieldseekerZones2Mods) RandomShapeArea(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeArea = func() null.Val[float64] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_float64(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 fieldseekerZones2Mods) RandomShapeAreaNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeArea = func() null.Val[float64] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_float64(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) ShapeLength(val null.Val[float64]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeLength = func() null.Val[float64] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) ShapeLengthFunc(f func() null.Val[float64]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeLength = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetShapeLength() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeLength = 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 fieldseekerZones2Mods) RandomShapeLength(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeLength = func() null.Val[float64] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_float64(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 fieldseekerZones2Mods) RandomShapeLengthNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.ShapeLength = func() null.Val[float64] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_float64(f)
			return null.From(val)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) Geometry(val types.JSON[json.RawMessage]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geometry = func() types.JSON[json.RawMessage] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) GeometryFunc(f func() types.JSON[json.RawMessage]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geometry = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetGeometry() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geometry = nil
	})
}

// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m fieldseekerZones2Mods) RandomGeometry(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geometry = func() types.JSON[json.RawMessage] {
			return random_types_JSON_json_RawMessage_(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerZones2Mods) Geospatial(val null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geospatial = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) GeospatialFunc(f func() null.Val[string]) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geospatial = f
	})
}

// Clear any values for the column
func (m fieldseekerZones2Mods) UnsetGeospatial() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geospatial = 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 fieldseekerZones2Mods) RandomGeospatial(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geospatial = 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 fieldseekerZones2Mods) RandomGeospatialNotNull(f *faker.Faker) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Geospatial = 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 fieldseekerZones2Mods) Version(val int32) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Version = func() int32 { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) VersionFunc(f func() int32) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.Version = f
	})
}

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

// Set the model columns to this value
func (m fieldseekerZones2Mods) OrganizationID(val int32) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.OrganizationID = func() int32 { return val }
	})
}

// Set the Column from the function
func (m fieldseekerZones2Mods) OrganizationIDFunc(f func() int32) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(_ context.Context, o *FieldseekerZones2Template) {
		o.OrganizationID = f
	})
}

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

func (m fieldseekerZones2Mods) WithParentsCascading() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(ctx context.Context, o *FieldseekerZones2Template) {
		if isDone, _ := fieldseekerZones2WithParentsCascadingCtx.Value(ctx); isDone {
			return
		}
		ctx = fieldseekerZones2WithParentsCascadingCtx.WithValue(ctx, true)
		{

			related := o.f.NewOrganizationWithContext(ctx, OrganizationMods.WithParentsCascading())
			m.WithOrganization(related).Apply(ctx, o)
		}
	})
}

func (m fieldseekerZones2Mods) WithOrganization(rel *OrganizationTemplate) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(ctx context.Context, o *FieldseekerZones2Template) {
		o.r.Organization = &fieldseekerZones2ROrganizationR{
			o: rel,
		}
	})
}

func (m fieldseekerZones2Mods) WithNewOrganization(mods ...OrganizationMod) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(ctx context.Context, o *FieldseekerZones2Template) {
		related := o.f.NewOrganizationWithContext(ctx, mods...)

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

func (m fieldseekerZones2Mods) WithExistingOrganization(em *models.Organization) FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(ctx context.Context, o *FieldseekerZones2Template) {
		o.r.Organization = &fieldseekerZones2ROrganizationR{
			o: o.f.FromExistingOrganization(em),
		}
	})
}

func (m fieldseekerZones2Mods) WithoutOrganization() FieldseekerZones2Mod {
	return FieldseekerZones2ModFunc(func(ctx context.Context, o *FieldseekerZones2Template) {
		o.r.Organization = nil
	})
}
