// 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 FieldseekerHabitatrelateMod interface {
	Apply(context.Context, *FieldseekerHabitatrelateTemplate)
}

type FieldseekerHabitatrelateModFunc func(context.Context, *FieldseekerHabitatrelateTemplate)

func (f FieldseekerHabitatrelateModFunc) Apply(ctx context.Context, n *FieldseekerHabitatrelateTemplate) {
	f(ctx, n)
}

type FieldseekerHabitatrelateModSlice []FieldseekerHabitatrelateMod

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

// FieldseekerHabitatrelateTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type FieldseekerHabitatrelateTemplate struct {
	Objectid       func() int64
	ForeignID      func() null.Val[uuid.UUID]
	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]
	Habitattype    func() null.Val[string]
	Creationdate   func() null.Val[time.Time]
	Creator        func() null.Val[string]
	Editdate       func() null.Val[time.Time]
	Editor         func() null.Val[string]
	Geometry       func() types.JSON[json.RawMessage]
	Geospatial     func() null.Val[string]
	Version        func() int32
	OrganizationID func() int32

	r fieldseekerHabitatrelateR
	f *Factory

	alreadyPersisted bool
}

type fieldseekerHabitatrelateR struct {
	Organization *fieldseekerHabitatrelateROrganizationR
}

type fieldseekerHabitatrelateROrganizationR struct {
	o *OrganizationTemplate
}

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

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

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

	if o.Objectid != nil {
		val := o.Objectid()
		m.Objectid = omit.From(val)
	}
	if o.ForeignID != nil {
		val := o.ForeignID()
		m.ForeignID = 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.Habitattype != nil {
		val := o.Habitattype()
		m.Habitattype = 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.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.FieldseekerHabitatrelateSetter
// this does nothing with the relationship templates
func (o FieldseekerHabitatrelateTemplate) BuildManySetter(number int) []*models.FieldseekerHabitatrelateSetter {
	m := make([]*models.FieldseekerHabitatrelateSetter, number)

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

	return m
}

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

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

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

	return m
}

func ensureCreatableFieldseekerHabitatrelate(m *models.FieldseekerHabitatrelateSetter) {
	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.FieldseekerHabitatrelate
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *FieldseekerHabitatrelateTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.FieldseekerHabitatrelate) error {
	var err error

	return err
}

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

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

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

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

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

	return m, nil
}

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

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

// FieldseekerHabitatrelate has methods that act as mods for the FieldseekerHabitatrelateTemplate
var FieldseekerHabitatrelateMods fieldseekerHabitatrelateMods

type fieldseekerHabitatrelateMods struct{}

func (m fieldseekerHabitatrelateMods) RandomizeAllColumns(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModSlice{
		FieldseekerHabitatrelateMods.RandomObjectid(f),
		FieldseekerHabitatrelateMods.RandomForeignID(f),
		FieldseekerHabitatrelateMods.RandomGlobalid(f),
		FieldseekerHabitatrelateMods.RandomCreatedUser(f),
		FieldseekerHabitatrelateMods.RandomCreatedDate(f),
		FieldseekerHabitatrelateMods.RandomLastEditedUser(f),
		FieldseekerHabitatrelateMods.RandomLastEditedDate(f),
		FieldseekerHabitatrelateMods.RandomHabitattype(f),
		FieldseekerHabitatrelateMods.RandomCreationdate(f),
		FieldseekerHabitatrelateMods.RandomCreator(f),
		FieldseekerHabitatrelateMods.RandomEditdate(f),
		FieldseekerHabitatrelateMods.RandomEditor(f),
		FieldseekerHabitatrelateMods.RandomGeometry(f),
		FieldseekerHabitatrelateMods.RandomGeospatial(f),
		FieldseekerHabitatrelateMods.RandomVersion(f),
		FieldseekerHabitatrelateMods.RandomOrganizationID(f),
	}
}

// Set the model columns to this value
func (m fieldseekerHabitatrelateMods) Objectid(val int64) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Objectid = func() int64 { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) ObjectidFunc(f func() int64) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Objectid = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetObjectid() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomObjectid(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Objectid = func() int64 {
			return random_int64(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerHabitatrelateMods) ForeignID(val null.Val[uuid.UUID]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.ForeignID = func() null.Val[uuid.UUID] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) ForeignIDFunc(f func() null.Val[uuid.UUID]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.ForeignID = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetForeignID() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.ForeignID = 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 fieldseekerHabitatrelateMods) RandomForeignID(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.ForeignID = func() null.Val[uuid.UUID] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_uuid_UUID(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 fieldseekerHabitatrelateMods) RandomForeignIDNotNull(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.ForeignID = func() null.Val[uuid.UUID] {
			if f == nil {
				f = &defaultFaker
			}

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

// Set the model columns to this value
func (m fieldseekerHabitatrelateMods) Globalid(val uuid.UUID) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Globalid = func() uuid.UUID { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) GlobalidFunc(f func() uuid.UUID) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Globalid = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetGlobalid() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomGlobalid(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Globalid = func() uuid.UUID {
			return random_uuid_UUID(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerHabitatrelateMods) CreatedUser(val null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.CreatedUser = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) CreatedUserFunc(f func() null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.CreatedUser = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetCreatedUser() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomCreatedUser(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomCreatedUserNotNull(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) CreatedDate(val null.Val[time.Time]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.CreatedDate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) CreatedDateFunc(f func() null.Val[time.Time]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.CreatedDate = f
	})
}

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

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) LastEditedUserFunc(f func() null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.LastEditedUser = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetLastEditedUser() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomLastEditedUser(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomLastEditedUserNotNull(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) LastEditedDate(val null.Val[time.Time]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.LastEditedDate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) LastEditedDateFunc(f func() null.Val[time.Time]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.LastEditedDate = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetLastEditedDate() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomLastEditedDate(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomLastEditedDateNotNull(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) Habitattype(val null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Habitattype = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) HabitattypeFunc(f func() null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Habitattype = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetHabitattype() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Habitattype = 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 fieldseekerHabitatrelateMods) RandomHabitattype(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Habitattype = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

			val := random_string(f, "250")
			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 fieldseekerHabitatrelateMods) RandomHabitattypeNotNull(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Habitattype = func() null.Val[string] {
			if f == nil {
				f = &defaultFaker
			}

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

// Set the model columns to this value
func (m fieldseekerHabitatrelateMods) Creationdate(val null.Val[time.Time]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Creationdate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) CreationdateFunc(f func() null.Val[time.Time]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Creationdate = f
	})
}

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

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) CreatorFunc(f func() null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Creator = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetCreator() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomCreator(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomCreatorNotNull(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) Editdate(val null.Val[time.Time]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Editdate = func() null.Val[time.Time] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) EditdateFunc(f func() null.Val[time.Time]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Editdate = f
	})
}

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

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) EditorFunc(f func() null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Editor = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetEditor() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomEditor(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomEditorNotNull(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) Geometry(val types.JSON[json.RawMessage]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Geometry = func() types.JSON[json.RawMessage] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) GeometryFunc(f func() types.JSON[json.RawMessage]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Geometry = f
	})
}

// Clear any values for the column
func (m fieldseekerHabitatrelateMods) UnsetGeometry() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		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 fieldseekerHabitatrelateMods) RandomGeometry(f *faker.Faker) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Geometry = func() types.JSON[json.RawMessage] {
			return random_types_JSON_json_RawMessage_(f)
		}
	})
}

// Set the model columns to this value
func (m fieldseekerHabitatrelateMods) Geospatial(val null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Geospatial = func() null.Val[string] { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) GeospatialFunc(f func() null.Val[string]) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Geospatial = f
	})
}

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

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) VersionFunc(f func() int32) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.Version = f
	})
}

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

// Set the model columns to this value
func (m fieldseekerHabitatrelateMods) OrganizationID(val int32) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.OrganizationID = func() int32 { return val }
	})
}

// Set the Column from the function
func (m fieldseekerHabitatrelateMods) OrganizationIDFunc(f func() int32) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(_ context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.OrganizationID = f
	})
}

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

func (m fieldseekerHabitatrelateMods) WithParentsCascading() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(ctx context.Context, o *FieldseekerHabitatrelateTemplate) {
		if isDone, _ := fieldseekerHabitatrelateWithParentsCascadingCtx.Value(ctx); isDone {
			return
		}
		ctx = fieldseekerHabitatrelateWithParentsCascadingCtx.WithValue(ctx, true)
		{

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

func (m fieldseekerHabitatrelateMods) WithOrganization(rel *OrganizationTemplate) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(ctx context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.r.Organization = &fieldseekerHabitatrelateROrganizationR{
			o: rel,
		}
	})
}

func (m fieldseekerHabitatrelateMods) WithNewOrganization(mods ...OrganizationMod) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(ctx context.Context, o *FieldseekerHabitatrelateTemplate) {
		related := o.f.NewOrganizationWithContext(ctx, mods...)

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

func (m fieldseekerHabitatrelateMods) WithExistingOrganization(em *models.Organization) FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(ctx context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.r.Organization = &fieldseekerHabitatrelateROrganizationR{
			o: o.f.FromExistingOrganization(em),
		}
	})
}

func (m fieldseekerHabitatrelateMods) WithoutOrganization() FieldseekerHabitatrelateMod {
	return FieldseekerHabitatrelateModFunc(func(ctx context.Context, o *FieldseekerHabitatrelateTemplate) {
		o.r.Organization = nil
	})
}
