nidus-sync/db/factory/arcgis.oauth_token.bob.go

945 lines
29 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/null"
"github.com/aarondl/opt/omit"
"github.com/aarondl/opt/omitnull"
"github.com/jaswdr/faker/v2"
)
type ArcgisOauthTokenMod interface {
Apply(context.Context, *ArcgisOauthTokenTemplate)
}
type ArcgisOauthTokenModFunc func(context.Context, *ArcgisOauthTokenTemplate)
func (f ArcgisOauthTokenModFunc) Apply(ctx context.Context, n *ArcgisOauthTokenTemplate) {
f(ctx, n)
}
type ArcgisOauthTokenModSlice []ArcgisOauthTokenMod
func (mods ArcgisOauthTokenModSlice) Apply(ctx context.Context, n *ArcgisOauthTokenTemplate) {
for _, f := range mods {
f.Apply(ctx, n)
}
}
// ArcgisOauthTokenTemplate is an object representing the database table.
// all columns are optional and should be set by mods
type ArcgisOauthTokenTemplate struct {
AccessToken func() string
AccessTokenExpires func() time.Time
ArcgisAccountID func() null.Val[string]
ArcgisID func() null.Val[string]
ArcgisLicenseTypeID func() null.Val[string]
Created func() time.Time
ID func() int32
InvalidatedAt func() null.Val[time.Time]
RefreshToken func() string
RefreshTokenExpires func() time.Time
UserID func() int32
Username func() string
r arcgisOauthTokenR
f *Factory
alreadyPersisted bool
}
type arcgisOauthTokenR struct {
ArcgisAccountAccount *arcgisOauthTokenRArcgisAccountAccountR
UserUser *arcgisOauthTokenRUserUserR
}
type arcgisOauthTokenRArcgisAccountAccountR struct {
o *ArcgisAccountTemplate
}
type arcgisOauthTokenRUserUserR struct {
o *UserTemplate
}
// Apply mods to the ArcgisOauthTokenTemplate
func (o *ArcgisOauthTokenTemplate) Apply(ctx context.Context, mods ...ArcgisOauthTokenMod) {
for _, mod := range mods {
mod.Apply(ctx, o)
}
}
// setModelRels creates and sets the relationships on *models.ArcgisOauthToken
// according to the relationships in the template. Nothing is inserted into the db
func (t ArcgisOauthTokenTemplate) setModelRels(o *models.ArcgisOauthToken) {
if t.r.ArcgisAccountAccount != nil {
rel := t.r.ArcgisAccountAccount.o.Build()
rel.R.ArcgisAccountOauthTokens = append(rel.R.ArcgisAccountOauthTokens, o)
o.ArcgisAccountID = null.From(rel.ID) // h2
o.R.ArcgisAccountAccount = rel
}
if t.r.UserUser != nil {
rel := t.r.UserUser.o.Build()
rel.R.UserOauthTokens = append(rel.R.UserOauthTokens, o)
o.UserID = rel.ID // h2
o.R.UserUser = rel
}
}
// BuildSetter returns an *models.ArcgisOauthTokenSetter
// this does nothing with the relationship templates
func (o ArcgisOauthTokenTemplate) BuildSetter() *models.ArcgisOauthTokenSetter {
m := &models.ArcgisOauthTokenSetter{}
if o.AccessToken != nil {
val := o.AccessToken()
m.AccessToken = omit.From(val)
}
if o.AccessTokenExpires != nil {
val := o.AccessTokenExpires()
m.AccessTokenExpires = omit.From(val)
}
if o.ArcgisAccountID != nil {
val := o.ArcgisAccountID()
m.ArcgisAccountID = omitnull.FromNull(val)
}
if o.ArcgisID != nil {
val := o.ArcgisID()
m.ArcgisID = omitnull.FromNull(val)
}
if o.ArcgisLicenseTypeID != nil {
val := o.ArcgisLicenseTypeID()
m.ArcgisLicenseTypeID = omitnull.FromNull(val)
}
if o.Created != nil {
val := o.Created()
m.Created = omit.From(val)
}
if o.ID != nil {
val := o.ID()
m.ID = omit.From(val)
}
if o.InvalidatedAt != nil {
val := o.InvalidatedAt()
m.InvalidatedAt = omitnull.FromNull(val)
}
if o.RefreshToken != nil {
val := o.RefreshToken()
m.RefreshToken = omit.From(val)
}
if o.RefreshTokenExpires != nil {
val := o.RefreshTokenExpires()
m.RefreshTokenExpires = omit.From(val)
}
if o.UserID != nil {
val := o.UserID()
m.UserID = omit.From(val)
}
if o.Username != nil {
val := o.Username()
m.Username = omit.From(val)
}
return m
}
// BuildManySetter returns an []*models.ArcgisOauthTokenSetter
// this does nothing with the relationship templates
func (o ArcgisOauthTokenTemplate) BuildManySetter(number int) []*models.ArcgisOauthTokenSetter {
m := make([]*models.ArcgisOauthTokenSetter, number)
for i := range m {
m[i] = o.BuildSetter()
}
return m
}
// Build returns an *models.ArcgisOauthToken
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use ArcgisOauthTokenTemplate.Create
func (o ArcgisOauthTokenTemplate) Build() *models.ArcgisOauthToken {
m := &models.ArcgisOauthToken{}
if o.AccessToken != nil {
m.AccessToken = o.AccessToken()
}
if o.AccessTokenExpires != nil {
m.AccessTokenExpires = o.AccessTokenExpires()
}
if o.ArcgisAccountID != nil {
m.ArcgisAccountID = o.ArcgisAccountID()
}
if o.ArcgisID != nil {
m.ArcgisID = o.ArcgisID()
}
if o.ArcgisLicenseTypeID != nil {
m.ArcgisLicenseTypeID = o.ArcgisLicenseTypeID()
}
if o.Created != nil {
m.Created = o.Created()
}
if o.ID != nil {
m.ID = o.ID()
}
if o.InvalidatedAt != nil {
m.InvalidatedAt = o.InvalidatedAt()
}
if o.RefreshToken != nil {
m.RefreshToken = o.RefreshToken()
}
if o.RefreshTokenExpires != nil {
m.RefreshTokenExpires = o.RefreshTokenExpires()
}
if o.UserID != nil {
m.UserID = o.UserID()
}
if o.Username != nil {
m.Username = o.Username()
}
o.setModelRels(m)
return m
}
// BuildMany returns an models.ArcgisOauthTokenSlice
// Related objects are also created and placed in the .R field
// NOTE: Objects are not inserted into the database. Use ArcgisOauthTokenTemplate.CreateMany
func (o ArcgisOauthTokenTemplate) BuildMany(number int) models.ArcgisOauthTokenSlice {
m := make(models.ArcgisOauthTokenSlice, number)
for i := range m {
m[i] = o.Build()
}
return m
}
func ensureCreatableArcgisOauthToken(m *models.ArcgisOauthTokenSetter) {
if !(m.AccessToken.IsValue()) {
val := random_string(nil)
m.AccessToken = omit.From(val)
}
if !(m.AccessTokenExpires.IsValue()) {
val := random_time_Time(nil)
m.AccessTokenExpires = omit.From(val)
}
if !(m.Created.IsValue()) {
val := random_time_Time(nil)
m.Created = omit.From(val)
}
if !(m.RefreshToken.IsValue()) {
val := random_string(nil)
m.RefreshToken = omit.From(val)
}
if !(m.RefreshTokenExpires.IsValue()) {
val := random_time_Time(nil)
m.RefreshTokenExpires = omit.From(val)
}
if !(m.UserID.IsValue()) {
val := random_int32(nil)
m.UserID = omit.From(val)
}
if !(m.Username.IsValue()) {
val := random_string(nil)
m.Username = omit.From(val)
}
}
// insertOptRels creates and inserts any optional the relationships on *models.ArcgisOauthToken
// according to the relationships in the template.
// any required relationship should have already exist on the model
func (o *ArcgisOauthTokenTemplate) insertOptRels(ctx context.Context, exec bob.Executor, m *models.ArcgisOauthToken) error {
var err error
isArcgisAccountAccountDone, _ := arcgisOauthTokenRelArcgisAccountAccountCtx.Value(ctx)
if !isArcgisAccountAccountDone && o.r.ArcgisAccountAccount != nil {
ctx = arcgisOauthTokenRelArcgisAccountAccountCtx.WithValue(ctx, true)
if o.r.ArcgisAccountAccount.o.alreadyPersisted {
m.R.ArcgisAccountAccount = o.r.ArcgisAccountAccount.o.Build()
} else {
var rel0 *models.ArcgisAccount
rel0, err = o.r.ArcgisAccountAccount.o.Create(ctx, exec)
if err != nil {
return err
}
err = m.AttachArcgisAccountAccount(ctx, exec, rel0)
if err != nil {
return err
}
}
}
return err
}
// Create builds a arcgisOauthToken and inserts it into the database
// Relations objects are also inserted and placed in the .R field
func (o *ArcgisOauthTokenTemplate) Create(ctx context.Context, exec bob.Executor) (*models.ArcgisOauthToken, error) {
var err error
opt := o.BuildSetter()
ensureCreatableArcgisOauthToken(opt)
if o.r.UserUser == nil {
ArcgisOauthTokenMods.WithNewUserUser().Apply(ctx, o)
}
var rel1 *models.User
if o.r.UserUser.o.alreadyPersisted {
rel1 = o.r.UserUser.o.Build()
} else {
rel1, err = o.r.UserUser.o.Create(ctx, exec)
if err != nil {
return nil, err
}
}
opt.UserID = omit.From(rel1.ID)
m, err := models.ArcgisOauthTokens.Insert(opt).One(ctx, exec)
if err != nil {
return nil, err
}
m.R.UserUser = rel1
if err := o.insertOptRels(ctx, exec, m); err != nil {
return nil, err
}
return m, err
}
// MustCreate builds a arcgisOauthToken and inserts it into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o *ArcgisOauthTokenTemplate) MustCreate(ctx context.Context, exec bob.Executor) *models.ArcgisOauthToken {
m, err := o.Create(ctx, exec)
if err != nil {
panic(err)
}
return m
}
// CreateOrFail builds a arcgisOauthToken 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 *ArcgisOauthTokenTemplate) CreateOrFail(ctx context.Context, tb testing.TB, exec bob.Executor) *models.ArcgisOauthToken {
tb.Helper()
m, err := o.Create(ctx, exec)
if err != nil {
tb.Fatal(err)
return nil
}
return m
}
// CreateMany builds multiple arcgisOauthTokens and inserts them into the database
// Relations objects are also inserted and placed in the .R field
func (o ArcgisOauthTokenTemplate) CreateMany(ctx context.Context, exec bob.Executor, number int) (models.ArcgisOauthTokenSlice, error) {
var err error
m := make(models.ArcgisOauthTokenSlice, number)
for i := range m {
m[i], err = o.Create(ctx, exec)
if err != nil {
return nil, err
}
}
return m, nil
}
// MustCreateMany builds multiple arcgisOauthTokens and inserts them into the database
// Relations objects are also inserted and placed in the .R field
// panics if an error occurs
func (o ArcgisOauthTokenTemplate) MustCreateMany(ctx context.Context, exec bob.Executor, number int) models.ArcgisOauthTokenSlice {
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
panic(err)
}
return m
}
// CreateManyOrFail builds multiple arcgisOauthTokens 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 ArcgisOauthTokenTemplate) CreateManyOrFail(ctx context.Context, tb testing.TB, exec bob.Executor, number int) models.ArcgisOauthTokenSlice {
tb.Helper()
m, err := o.CreateMany(ctx, exec, number)
if err != nil {
tb.Fatal(err)
return nil
}
return m
}
// ArcgisOauthToken has methods that act as mods for the ArcgisOauthTokenTemplate
var ArcgisOauthTokenMods arcgisOauthTokenMods
type arcgisOauthTokenMods struct{}
func (m arcgisOauthTokenMods) RandomizeAllColumns(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModSlice{
ArcgisOauthTokenMods.RandomAccessToken(f),
ArcgisOauthTokenMods.RandomAccessTokenExpires(f),
ArcgisOauthTokenMods.RandomArcgisAccountID(f),
ArcgisOauthTokenMods.RandomArcgisID(f),
ArcgisOauthTokenMods.RandomArcgisLicenseTypeID(f),
ArcgisOauthTokenMods.RandomCreated(f),
ArcgisOauthTokenMods.RandomID(f),
ArcgisOauthTokenMods.RandomInvalidatedAt(f),
ArcgisOauthTokenMods.RandomRefreshToken(f),
ArcgisOauthTokenMods.RandomRefreshTokenExpires(f),
ArcgisOauthTokenMods.RandomUserID(f),
ArcgisOauthTokenMods.RandomUsername(f),
}
}
// Set the model columns to this value
func (m arcgisOauthTokenMods) AccessToken(val string) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.AccessToken = func() string { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) AccessTokenFunc(f func() string) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.AccessToken = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetAccessToken() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.AccessToken = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m arcgisOauthTokenMods) RandomAccessToken(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.AccessToken = func() string {
return random_string(f)
}
})
}
// Set the model columns to this value
func (m arcgisOauthTokenMods) AccessTokenExpires(val time.Time) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.AccessTokenExpires = func() time.Time { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) AccessTokenExpiresFunc(f func() time.Time) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.AccessTokenExpires = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetAccessTokenExpires() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.AccessTokenExpires = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m arcgisOauthTokenMods) RandomAccessTokenExpires(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.AccessTokenExpires = func() time.Time {
return random_time_Time(f)
}
})
}
// Set the model columns to this value
func (m arcgisOauthTokenMods) ArcgisAccountID(val null.Val[string]) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisAccountID = func() null.Val[string] { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) ArcgisAccountIDFunc(f func() null.Val[string]) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisAccountID = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetArcgisAccountID() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisAccountID = 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 arcgisOauthTokenMods) RandomArcgisAccountID(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisAccountID = 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 arcgisOauthTokenMods) RandomArcgisAccountIDNotNull(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisAccountID = 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 arcgisOauthTokenMods) ArcgisID(val null.Val[string]) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisID = func() null.Val[string] { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) ArcgisIDFunc(f func() null.Val[string]) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisID = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetArcgisID() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisID = 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 arcgisOauthTokenMods) RandomArcgisID(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisID = 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 arcgisOauthTokenMods) RandomArcgisIDNotNull(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisID = 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 arcgisOauthTokenMods) ArcgisLicenseTypeID(val null.Val[string]) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisLicenseTypeID = func() null.Val[string] { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) ArcgisLicenseTypeIDFunc(f func() null.Val[string]) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisLicenseTypeID = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetArcgisLicenseTypeID() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisLicenseTypeID = 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 arcgisOauthTokenMods) RandomArcgisLicenseTypeID(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisLicenseTypeID = 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 arcgisOauthTokenMods) RandomArcgisLicenseTypeIDNotNull(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ArcgisLicenseTypeID = 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 arcgisOauthTokenMods) Created(val time.Time) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.Created = func() time.Time { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) CreatedFunc(f func() time.Time) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.Created = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetCreated() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
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 arcgisOauthTokenMods) RandomCreated(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.Created = func() time.Time {
return random_time_Time(f)
}
})
}
// Set the model columns to this value
func (m arcgisOauthTokenMods) ID(val int32) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ID = func() int32 { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) IDFunc(f func() int32) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ID = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetID() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ID = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m arcgisOauthTokenMods) RandomID(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.ID = func() int32 {
return random_int32(f)
}
})
}
// Set the model columns to this value
func (m arcgisOauthTokenMods) InvalidatedAt(val null.Val[time.Time]) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.InvalidatedAt = func() null.Val[time.Time] { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) InvalidatedAtFunc(f func() null.Val[time.Time]) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.InvalidatedAt = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetInvalidatedAt() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.InvalidatedAt = 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 arcgisOauthTokenMods) RandomInvalidatedAt(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.InvalidatedAt = 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 arcgisOauthTokenMods) RandomInvalidatedAtNotNull(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.InvalidatedAt = 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 arcgisOauthTokenMods) RefreshToken(val string) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.RefreshToken = func() string { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) RefreshTokenFunc(f func() string) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.RefreshToken = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetRefreshToken() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.RefreshToken = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m arcgisOauthTokenMods) RandomRefreshToken(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.RefreshToken = func() string {
return random_string(f)
}
})
}
// Set the model columns to this value
func (m arcgisOauthTokenMods) RefreshTokenExpires(val time.Time) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.RefreshTokenExpires = func() time.Time { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) RefreshTokenExpiresFunc(f func() time.Time) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.RefreshTokenExpires = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetRefreshTokenExpires() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.RefreshTokenExpires = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m arcgisOauthTokenMods) RandomRefreshTokenExpires(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.RefreshTokenExpires = func() time.Time {
return random_time_Time(f)
}
})
}
// Set the model columns to this value
func (m arcgisOauthTokenMods) UserID(val int32) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.UserID = func() int32 { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) UserIDFunc(f func() int32) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.UserID = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetUserID() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.UserID = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m arcgisOauthTokenMods) RandomUserID(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.UserID = func() int32 {
return random_int32(f)
}
})
}
// Set the model columns to this value
func (m arcgisOauthTokenMods) Username(val string) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.Username = func() string { return val }
})
}
// Set the Column from the function
func (m arcgisOauthTokenMods) UsernameFunc(f func() string) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.Username = f
})
}
// Clear any values for the column
func (m arcgisOauthTokenMods) UnsetUsername() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.Username = nil
})
}
// Generates a random value for the column using the given faker
// if faker is nil, a default faker is used
func (m arcgisOauthTokenMods) RandomUsername(f *faker.Faker) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(_ context.Context, o *ArcgisOauthTokenTemplate) {
o.Username = func() string {
return random_string(f)
}
})
}
func (m arcgisOauthTokenMods) WithParentsCascading() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
if isDone, _ := arcgisOauthTokenWithParentsCascadingCtx.Value(ctx); isDone {
return
}
ctx = arcgisOauthTokenWithParentsCascadingCtx.WithValue(ctx, true)
{
related := o.f.NewArcgisAccountWithContext(ctx, ArcgisAccountMods.WithParentsCascading())
m.WithArcgisAccountAccount(related).Apply(ctx, o)
}
{
related := o.f.NewUserWithContext(ctx, UserMods.WithParentsCascading())
m.WithUserUser(related).Apply(ctx, o)
}
})
}
func (m arcgisOauthTokenMods) WithArcgisAccountAccount(rel *ArcgisAccountTemplate) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
o.r.ArcgisAccountAccount = &arcgisOauthTokenRArcgisAccountAccountR{
o: rel,
}
})
}
func (m arcgisOauthTokenMods) WithNewArcgisAccountAccount(mods ...ArcgisAccountMod) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
related := o.f.NewArcgisAccountWithContext(ctx, mods...)
m.WithArcgisAccountAccount(related).Apply(ctx, o)
})
}
func (m arcgisOauthTokenMods) WithExistingArcgisAccountAccount(em *models.ArcgisAccount) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
o.r.ArcgisAccountAccount = &arcgisOauthTokenRArcgisAccountAccountR{
o: o.f.FromExistingArcgisAccount(em),
}
})
}
func (m arcgisOauthTokenMods) WithoutArcgisAccountAccount() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
o.r.ArcgisAccountAccount = nil
})
}
func (m arcgisOauthTokenMods) WithUserUser(rel *UserTemplate) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
o.r.UserUser = &arcgisOauthTokenRUserUserR{
o: rel,
}
})
}
func (m arcgisOauthTokenMods) WithNewUserUser(mods ...UserMod) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
related := o.f.NewUserWithContext(ctx, mods...)
m.WithUserUser(related).Apply(ctx, o)
})
}
func (m arcgisOauthTokenMods) WithExistingUserUser(em *models.User) ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
o.r.UserUser = &arcgisOauthTokenRUserUserR{
o: o.f.FromExistingUser(em),
}
})
}
func (m arcgisOauthTokenMods) WithoutUserUser() ArcgisOauthTokenMod {
return ArcgisOauthTokenModFunc(func(ctx context.Context, o *ArcgisOauthTokenTemplate) {
o.r.UserUser = nil
})
}