dbkit_tests

package
v0.0.0-...-9e9b37c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch interface {
	String() string
	Execute(ctx context.Context) error

	UpsertUser(birthdate time.Time, anotherID uuid.UUID, gender int64, created time.Time, lastSeen time.Time, interest int64, displayName string, avatar string, email *string, keywords []string, facebookUserID *string, arbData json.RawMessage)

	InsertUser(birthdate time.Time, anotherID uuid.UUID, gender int64, created time.Time, lastSeen time.Time, interest int64, displayName string, avatar string, email *string, keywords []string, facebookUserID *string, arbData json.RawMessage)
	DeleteUserByID(id int64)
	DeleteUserByAnotherID(anotherID uuid.UUID)
	DeleteUserByAnotherIDAndGender(anotherID uuid.UUID, gender int64)
	DeleteUserByEmail(email *string)
	DeleteUserByFacebookUserID(facebookUserID *string)
	DeleteUserByFacebookUserIDAndAvatar(facebookUserID *string, avatar string)
	DeleteUserByAvatar(avatar string)
	DeleteUserByCreated(created time.Time)
	DeleteUserByCreatedAndGender(created time.Time, gender int64)
	DeleteUserByCreatedAndGenderAndBirthdate(created time.Time, gender int64, birthdate time.Time)
	SaveUser(user *User)
}

type DB

type DB struct {
	Connection interface{}

	Users *UsersTable
	// contains filtered or unexported fields
}

DB is the main access point to the database

var Main *DB

func NewDB

func NewDB(driverName, dataSourceName string) (*DB, error)

NewDB creates a new DB pointer to access a database

func (*DB) NewBatch

func (db *DB) NewBatch() Batch

func (*DB) NewLoader

func (db *DB) NewLoader() *Loader

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader makes it easy to load multiple values from multiple tables in one go

func (*Loader) AddUser

func (l *Loader) AddUser(user *User)

func (*Loader) GetUser

func (l *Loader) GetUser(id int64) *User

func (*Loader) Load

func (l *Loader) Load(ctx context.Context) error

func (*Loader) LoadP

func (l *Loader) LoadP(ctx context.Context)

func (*Loader) MarkUserForLoad

func (l *Loader) MarkUserForLoad(id int64)

type User

type User struct {
	ID             int64
	Birthdate      time.Time
	AnotherID      uuid.UUID
	Gender         int64
	Created        time.Time
	LastSeen       time.Time
	Interest       int64
	DisplayName    string
	Avatar         string
	Email          *string
	Keywords       []string
	FacebookUserID *string
	ArbData        json.RawMessage
	// contains filtered or unexported fields
}

User represents a row in the Users table

func (*User) IsDirty

func (i *User) IsDirty() bool

IsDirty returns true if any of the values the originally loaded values

func (*User) IsDirtyAnotherID

func (i *User) IsDirtyAnotherID() bool

IsDirtyAnotherID returns true if the AnotherID value differs from the originally loaded value

func (*User) IsDirtyArbData

func (i *User) IsDirtyArbData() bool

IsDirtyArbData returns true if the ArbData value differs from the originally loaded value

func (*User) IsDirtyAvatar

func (i *User) IsDirtyAvatar() bool

IsDirtyAvatar returns true if the Avatar value differs from the originally loaded value

func (*User) IsDirtyBirthdate

func (i *User) IsDirtyBirthdate() bool

IsDirtyBirthdate returns true if the Birthdate value differs from the originally loaded value

func (*User) IsDirtyCreated

func (i *User) IsDirtyCreated() bool

IsDirtyCreated returns true if the Created value differs from the originally loaded value

func (*User) IsDirtyDisplayName

func (i *User) IsDirtyDisplayName() bool

IsDirtyDisplayName returns true if the DisplayName value differs from the originally loaded value

func (*User) IsDirtyEmail

func (i *User) IsDirtyEmail() bool

IsDirtyEmail returns true if the Email value differs from the originally loaded value

func (*User) IsDirtyFacebookUserID

func (i *User) IsDirtyFacebookUserID() bool

IsDirtyFacebookUserID returns true if the FacebookUserID value differs from the originally loaded value

func (*User) IsDirtyGender

func (i *User) IsDirtyGender() bool

IsDirtyGender returns true if the Gender value differs from the originally loaded value

func (*User) IsDirtyID

func (i *User) IsDirtyID() bool

IsDirtyID returns true if the ID value differs from the originally loaded value

func (*User) IsDirtyInterest

func (i *User) IsDirtyInterest() bool

IsDirtyInterest returns true if the Interest value differs from the originally loaded value

func (*User) IsDirtyKeywords

func (i *User) IsDirtyKeywords() bool

IsDirtyKeywords returns true if the Keywords value differs from the originally loaded value

func (*User) IsDirtyLastSeen

func (i *User) IsDirtyLastSeen() bool

IsDirtyLastSeen returns true if the LastSeen value differs from the originally loaded value

func (*User) Save

func (i *User) Save(ctx context.Context) error

Save saves any changes to the row

func (*User) SaveP

func (i *User) SaveP(ctx context.Context)

SaveP saves any changes to the row and panics on error

type UserQuery

type UserQuery struct {
	// contains filtered or unexported fields
}

UserQuery is a modifiable query against the Users table

func (*UserQuery) Count

func (q *UserQuery) Count(ctx context.Context) (int64, error)

Count returns a the count of matched item

func (*UserQuery) CountP

func (q *UserQuery) CountP(ctx context.Context) int64

CountP returns a the count of matched item and panics on error

func (*UserQuery) Each

func (q *UserQuery) Each(ctx context.Context, reuseItem bool, action func(*User) error) error

Each returns a slice with all the matched item (warning: can use lots of memory)

func (*UserQuery) EachP

func (q *UserQuery) EachP(ctx context.Context, reuseItem bool, action func(*User) error)

EachP returns a slice with all the matched item (warning: can use lots of memory) and panics on error

func (*UserQuery) First

func (q *UserQuery) First(ctx context.Context) (*User, error)

First returns the first item found by the query

func (*UserQuery) FirstP

func (q *UserQuery) FirstP(ctx context.Context) *User

FirstP returns the first item found by the query and panics on error

func (*UserQuery) Limit

func (q *UserQuery) Limit(limit int) *UserQuery

Limit changes the limit of the UserQuery query to the given value

func (*UserQuery) Offset

func (q *UserQuery) Offset(offset int) *UserQuery

Offset changes the offset of the UserQuery query to the given value

func (*UserQuery) Slice

func (q *UserQuery) Slice(ctx context.Context, expectedSliceSize int) ([]*User, error)

Slice returns a slice with all the matched item (warning: can use lots of memory)

func (*UserQuery) SliceP

func (q *UserQuery) SliceP(ctx context.Context, expectedSliceSize int) []*User

SliceP returns a slice with all the matched item (warning: can use lots of memory) and panics on error

func (*UserQuery) SortAscendingBy

func (q *UserQuery) SortAscendingBy(column string) *UserQuery

SortAscendingBy adds an ascending sort column to the query

func (*UserQuery) SortDescendingBy

func (q *UserQuery) SortDescendingBy(column string) *UserQuery

SortDescendingBy adds an descending sort column to the query

func (*UserQuery) Where

func (q *UserQuery) Where(where string, args ...interface{}) *UserQuery

Where changes the where clause of the query

type UsersTable

type UsersTable struct {
	BeforeUpdate func(context.Context, *User) error
	AfterUpdate  func(context.Context, *User)
	BeforeInsert func(context.Context, *User) error
	AfterInsert  func(context.Context, *User)
	// contains filtered or unexported fields
}

UsersTable is generated by dbkit

func (UsersTable) Delete

func (t UsersTable) Delete(ctx context.Context, query string, args ...interface{}) error

Delete deletes records from the Users table based on the given query

func (UsersTable) DeleteByAnotherID

func (t UsersTable) DeleteByAnotherID(ctx context.Context, anotherID uuid.UUID) error

DeleteByAnotherIDP deletes records the Users table based on the given values

func (UsersTable) DeleteByAnotherIDAndGender

func (t UsersTable) DeleteByAnotherIDAndGender(ctx context.Context, anotherID uuid.UUID, gender int64) error

DeleteByAnotherIDAndGenderP deletes records the Users table based on the given values

func (UsersTable) DeleteByAnotherIDAndGenderP

func (t UsersTable) DeleteByAnotherIDAndGenderP(ctx context.Context, anotherID uuid.UUID, gender int64)

DeleteByAnotherIDAndGender deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByAnotherIDP

func (t UsersTable) DeleteByAnotherIDP(ctx context.Context, anotherID uuid.UUID)

DeleteByAnotherID deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByAvatar

func (t UsersTable) DeleteByAvatar(ctx context.Context, avatar string) error

DeleteByAvatarP deletes records the Users table based on the given values

func (UsersTable) DeleteByAvatarP

func (t UsersTable) DeleteByAvatarP(ctx context.Context, avatar string)

DeleteByAvatar deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByCreated

func (t UsersTable) DeleteByCreated(ctx context.Context, created time.Time) error

DeleteByCreatedP deletes records the Users table based on the given values

func (UsersTable) DeleteByCreatedAndGender

func (t UsersTable) DeleteByCreatedAndGender(ctx context.Context, created time.Time, gender int64) error

DeleteByCreatedAndGenderP deletes records the Users table based on the given values

func (UsersTable) DeleteByCreatedAndGenderAndBirthdate

func (t UsersTable) DeleteByCreatedAndGenderAndBirthdate(ctx context.Context, created time.Time, gender int64, birthdate time.Time) error

DeleteByCreatedAndGenderAndBirthdateP deletes records the Users table based on the given values

func (UsersTable) DeleteByCreatedAndGenderAndBirthdateP

func (t UsersTable) DeleteByCreatedAndGenderAndBirthdateP(ctx context.Context, created time.Time, gender int64, birthdate time.Time)

DeleteByCreatedAndGenderAndBirthdate deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByCreatedAndGenderP

func (t UsersTable) DeleteByCreatedAndGenderP(ctx context.Context, created time.Time, gender int64)

DeleteByCreatedAndGender deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByCreatedP

func (t UsersTable) DeleteByCreatedP(ctx context.Context, created time.Time)

DeleteByCreated deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByEmail

func (t UsersTable) DeleteByEmail(ctx context.Context, email *string) error

DeleteByEmailP deletes records the Users table based on the given values

func (UsersTable) DeleteByEmailP

func (t UsersTable) DeleteByEmailP(ctx context.Context, email *string)

DeleteByEmail deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByFacebookUserID

func (t UsersTable) DeleteByFacebookUserID(ctx context.Context, facebookUserID *string) error

DeleteByFacebookUserIDP deletes records the Users table based on the given values

func (UsersTable) DeleteByFacebookUserIDAndAvatar

func (t UsersTable) DeleteByFacebookUserIDAndAvatar(ctx context.Context, facebookUserID *string, avatar string) error

DeleteByFacebookUserIDAndAvatarP deletes records the Users table based on the given values

func (UsersTable) DeleteByFacebookUserIDAndAvatarP

func (t UsersTable) DeleteByFacebookUserIDAndAvatarP(ctx context.Context, facebookUserID *string, avatar string)

DeleteByFacebookUserIDAndAvatar deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByFacebookUserIDP

func (t UsersTable) DeleteByFacebookUserIDP(ctx context.Context, facebookUserID *string)

DeleteByFacebookUserID deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteByID

func (t UsersTable) DeleteByID(ctx context.Context, id int64) error

DeleteByIDP deletes records the Users table based on the given values

func (UsersTable) DeleteByIDP

func (t UsersTable) DeleteByIDP(ctx context.Context, id int64)

DeleteByID deletes records the Users table based on the given values and panics on error

func (UsersTable) DeleteP

func (t UsersTable) DeleteP(ctx context.Context, query string, args ...interface{})

DeleteP deletes records from the Users table based on the given query and panics on error

func (UsersTable) Execute

func (t UsersTable) Execute(ctx context.Context, command string, args ...interface{}) error

Execute runs a raw comand against the database

func (UsersTable) ExecuteP

func (t UsersTable) ExecuteP(ctx context.Context, command string, args ...interface{})

ExecuteP runs a raw comand against the database and panics on errors

func (UsersTable) FindByAnotherID

func (t UsersTable) FindByAnotherID(anotherID uuid.UUID) *UserQuery

FindByAnotherID finds records the Users table based on the given values

func (UsersTable) FindByAnotherIDAndGender

func (t UsersTable) FindByAnotherIDAndGender(anotherID uuid.UUID, gender int64) *UserQuery

FindByAnotherIDAndGender finds records the Users table based on the given values

func (UsersTable) FindByAvatar

func (t UsersTable) FindByAvatar(avatar string) *UserQuery

FindByAvatar finds records the Users table based on the given values

func (UsersTable) FindByCreated

func (t UsersTable) FindByCreated(created time.Time) *UserQuery

FindByCreated finds records the Users table based on the given values

func (UsersTable) FindByCreatedAndGender

func (t UsersTable) FindByCreatedAndGender(created time.Time, gender int64) *UserQuery

FindByCreatedAndGender finds records the Users table based on the given values

func (UsersTable) FindByCreatedAndGenderAndBirthdate

func (t UsersTable) FindByCreatedAndGenderAndBirthdate(created time.Time, gender int64, birthdate time.Time) *UserQuery

FindByCreatedAndGenderAndBirthdate finds records the Users table based on the given values

func (UsersTable) FindByEmail

func (t UsersTable) FindByEmail(email *string) *UserQuery

FindByEmail finds records the Users table based on the given values

func (UsersTable) FindByFacebookUserID

func (t UsersTable) FindByFacebookUserID(facebookUserID *string) *UserQuery

FindByFacebookUserID finds records the Users table based on the given values

func (UsersTable) FindByFacebookUserIDAndAvatar

func (t UsersTable) FindByFacebookUserIDAndAvatar(facebookUserID *string, avatar string) *UserQuery

FindByFacebookUserIDAndAvatar finds records the Users table based on the given values

func (UsersTable) FindByID

func (t UsersTable) FindByID(id int64) *UserQuery

FindByID finds records the Users table based on the given values

func (UsersTable) Insert

func (t UsersTable) Insert(ctx context.Context, birthdate time.Time, anotherID uuid.UUID, gender int64, created time.Time, lastSeen time.Time, interest int64, displayName string, avatar string, email *string, keywords []string, facebookUserID *string, arbData json.RawMessage) (*User, error)

Insert creates a record in the Users table

func (UsersTable) InsertP

func (t UsersTable) InsertP(ctx context.Context, birthdate time.Time, anotherID uuid.UUID, gender int64, created time.Time, lastSeen time.Time, interest int64, displayName string, avatar string, email *string, keywords []string, facebookUserID *string, arbData json.RawMessage) *User

InsertP creates a record in the Users table and panics on errors

func (UsersTable) Load

func (t UsersTable) Load(ctx context.Context, query string, args ...interface{}) (*User, error)

Load a single record from the Users table based on the given query

func (UsersTable) LoadByAnotherID

func (t UsersTable) LoadByAnotherID(ctx context.Context, anotherID uuid.UUID) (*User, error)

LoadByAnotherID loads a single record from the Users table based on the given values

func (UsersTable) LoadByAnotherIDAndGender

func (t UsersTable) LoadByAnotherIDAndGender(ctx context.Context, anotherID uuid.UUID, gender int64) (*User, error)

LoadByAnotherIDAndGender loads a single record from the Users table based on the given values

func (UsersTable) LoadByAnotherIDAndGenderP

func (t UsersTable) LoadByAnotherIDAndGenderP(ctx context.Context, anotherID uuid.UUID, gender int64) *User

LoadByAnotherIDAndGenderP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByAnotherIDP

func (t UsersTable) LoadByAnotherIDP(ctx context.Context, anotherID uuid.UUID) *User

LoadByAnotherIDP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByAvatar

func (t UsersTable) LoadByAvatar(ctx context.Context, avatar string) (*User, error)

LoadByAvatar loads a single record from the Users table based on the given values

func (UsersTable) LoadByAvatarP

func (t UsersTable) LoadByAvatarP(ctx context.Context, avatar string) *User

LoadByAvatarP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByCreated

func (t UsersTable) LoadByCreated(ctx context.Context, created time.Time) (*User, error)

LoadByCreated loads a single record from the Users table based on the given values

func (UsersTable) LoadByCreatedAndGender

func (t UsersTable) LoadByCreatedAndGender(ctx context.Context, created time.Time, gender int64) (*User, error)

LoadByCreatedAndGender loads a single record from the Users table based on the given values

func (UsersTable) LoadByCreatedAndGenderAndBirthdate

func (t UsersTable) LoadByCreatedAndGenderAndBirthdate(ctx context.Context, created time.Time, gender int64, birthdate time.Time) (*User, error)

LoadByCreatedAndGenderAndBirthdate loads a single record from the Users table based on the given values

func (UsersTable) LoadByCreatedAndGenderAndBirthdateP

func (t UsersTable) LoadByCreatedAndGenderAndBirthdateP(ctx context.Context, created time.Time, gender int64, birthdate time.Time) *User

LoadByCreatedAndGenderAndBirthdateP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByCreatedAndGenderP

func (t UsersTable) LoadByCreatedAndGenderP(ctx context.Context, created time.Time, gender int64) *User

LoadByCreatedAndGenderP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByCreatedP

func (t UsersTable) LoadByCreatedP(ctx context.Context, created time.Time) *User

LoadByCreatedP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByEmail

func (t UsersTable) LoadByEmail(ctx context.Context, email *string) (*User, error)

LoadByEmail loads a single record from the Users table based on the given values

func (UsersTable) LoadByEmailP

func (t UsersTable) LoadByEmailP(ctx context.Context, email *string) *User

LoadByEmailP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByFacebookUserID

func (t UsersTable) LoadByFacebookUserID(ctx context.Context, facebookUserID *string) (*User, error)

LoadByFacebookUserID loads a single record from the Users table based on the given values

func (UsersTable) LoadByFacebookUserIDAndAvatar

func (t UsersTable) LoadByFacebookUserIDAndAvatar(ctx context.Context, facebookUserID *string, avatar string) (*User, error)

LoadByFacebookUserIDAndAvatar loads a single record from the Users table based on the given values

func (UsersTable) LoadByFacebookUserIDAndAvatarP

func (t UsersTable) LoadByFacebookUserIDAndAvatarP(ctx context.Context, facebookUserID *string, avatar string) *User

LoadByFacebookUserIDAndAvatarP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByFacebookUserIDP

func (t UsersTable) LoadByFacebookUserIDP(ctx context.Context, facebookUserID *string) *User

LoadByFacebookUserIDP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadByID

func (t UsersTable) LoadByID(ctx context.Context, id int64) (*User, error)

LoadByID loads a single record from the Users table based on the given values

func (UsersTable) LoadByIDP

func (t UsersTable) LoadByIDP(ctx context.Context, id int64) *User

LoadByIDP loads a single record from the Users table based on the given values and panics on error

func (UsersTable) LoadP

func (t UsersTable) LoadP(ctx context.Context, query string, args ...interface{}) *User

LoadP a single record from the Users table based on the given query and panics on error

func (UsersTable) Query

func (t UsersTable) Query() *UserQuery

Query creates a query for records in the Users table by id

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL