model

package
v0.0.0-...-ec85eee Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package model contains the types for schema 'go_echo_api_boilerplate_development'.

Package model contains the types for schema 'go_echo_api_boilerplate_development'.

Package model contains the types for schema 'go_echo_api_boilerplate_development'.

Package model contains the types for schema 'go_echo_api_boilerplate_development'.

Index

Constants

View Source
const (
	// Exec operation for like sql.DB.Exec()
	Exec operation = 1
	// Query operation for sql.DB.Query()
	Query operation = 2
)

Variables

View Source
var XOLog = func(context.Context, string, ...interface{}) {}

XOLog provides the log func used by generated queries.

Functions

func Ping

func Ping(db Queryer) error

Ping checks if db connection is valid

Types

type Execer

type Execer interface {
	sqlx.Execer
	sqlx.ExecerContext
}

type Executor

type Executor interface {
	Queryer
	Execer
}

Executor is the common interface for database operations that can be used with types from schema 'go_echo_api_boilerplate_development'.

This should work with database/sql.DB and database/sql.Tx.

type Gender

type Gender int

Gender represents user's gender

const (
	GenderUnknown Gender = iota
	GenderMale
	GenderFemale
)

func Int64ToGender

func Int64ToGender(i int64) Gender

Int64ToGender converts int64 to gender

func StringToGender

func StringToGender(s string) Gender

StringToGender converts string to gender

func (Gender) String

func (g Gender) String() string

type Queryer

type Queryer interface {
	sqlx.Queryer
	sqlx.QueryerContext
	Ping() error
}

type ScannerValuer

type ScannerValuer interface {
	sql.Scanner
	driver.Valuer
}

ScannerValuer is the common interface for types that implement both the database/sql.Scanner and sql/driver.Valuer interfaces.

type Slice

type Slice []ScannerValuer

Slice is a slice of ScannerValuers.

type SmsReconfirmation

type SmsReconfirmation struct {
	ID          uint64    `json:"id" db:"id"`                     // id
	UserID      uint64    `json:"user_id" db:"user_id"`           // user_id
	PhoneNumber string    `json:"phone_number" db:"phone_number"` // phone_number
	AuthCode    string    `json:"auth_code" db:"auth_code"`       // auth_code
	CreatedAt   time.Time `json:"created_at" db:"created_at"`     // created_at
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`     // updated_at
	// contains filtered or unexported fields
}

SmsReconfirmation represents a row from 'sms_reconfirmations'.

func GetSmsReconfirmation

func GetSmsReconfirmation(ctx context.Context, db Queryer, key uint64) (*SmsReconfirmation, error)

GetSmsReconfirmation gets a SmsReconfirmation by primary key

func NewSMSReconfirmation

func NewSMSReconfirmation(userId uint64, phoneNumber string) *SmsReconfirmation

NewSMSConfirmation returns initialized sms reconfirmation

func SmsReconfirmationByID

func SmsReconfirmationByID(ctx context.Context, db Queryer, id uint64) (*SmsReconfirmation, error)

SmsReconfirmationByID retrieves a row from 'sms_reconfirmations' as a SmsReconfirmation.

Generated from index 'sms_reconfirmations_id_pkey'.

func SmsReconfirmationByPhoneNumber

func SmsReconfirmationByPhoneNumber(ctx context.Context, db Queryer, phoneNumber string) (*SmsReconfirmation, error)

SmsReconfirmationByPhoneNumber retrieves a row from 'sms_reconfirmations' as a SmsReconfirmation.

Generated from index 'phone_number'.

func SmsReconfirmationByUserID

func SmsReconfirmationByUserID(ctx context.Context, db Queryer, userID uint64) (*SmsReconfirmation, error)

SmsReconfirmationByUserID retrieves a row from 'sms_reconfirmations' as a SmsReconfirmation.

Generated from index 'user_id'.

func (*SmsReconfirmation) Delete

func (sr *SmsReconfirmation) Delete(ctx context.Context, db Execer) error

Delete deletes the SmsReconfirmation from the database.

func (*SmsReconfirmation) Deleted

func (sr *SmsReconfirmation) Deleted() bool

Deleted provides information if the SmsReconfirmation has been deleted from the database.

func (*SmsReconfirmation) Exists

func (sr *SmsReconfirmation) Exists() bool

Exists determines if the SmsReconfirmation exists in the database.

func (*SmsReconfirmation) Insert

func (sr *SmsReconfirmation) Insert(ctx context.Context, db Execer) error

Insert inserts the SmsReconfirmation to the database.

func (*SmsReconfirmation) IsExpired

func (sr *SmsReconfirmation) IsExpired() bool

IsExpired checks if the sms reconfirmation is expired (specified hours have passed)

func (*SmsReconfirmation) Save

func (sr *SmsReconfirmation) Save(ctx context.Context, db Execer) error

Save saves the SmsReconfirmation to the database.

func (*SmsReconfirmation) Update

func (sr *SmsReconfirmation) Update(ctx context.Context, db Execer) error

Update updates the SmsReconfirmation in the database.

func (*SmsReconfirmation) User

func (sr *SmsReconfirmation) User(ctx context.Context, db Executor) (*User, error)

User returns the User associated with the SmsReconfirmation's UserID (user_id).

Generated from foreign key 'sms_reconfirmations_ibfk_1'.

type StringSlice

type StringSlice []string

StringSlice is a slice of strings.

func (*StringSlice) Scan

func (ss *StringSlice) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface for StringSlice.

func (StringSlice) Value

func (ss StringSlice) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface for StringSlice.

type TempUser

type TempUser struct {
	ID          uint64    `json:"id" db:"id"`                     // id
	PhoneNumber string    `json:"phone_number" db:"phone_number"` // phone_number
	AuthCode    string    `json:"auth_code" db:"auth_code"`       // auth_code
	AuthKey     string    `json:"auth_key" db:"auth_key"`         // auth_key
	CreatedAt   time.Time `json:"created_at" db:"created_at"`     // created_at
	UpdatedAt   time.Time `json:"updated_at" db:"updated_at"`     // updated_at
	// contains filtered or unexported fields
}

TempUser represents a row from 'temp_users'.

func GetTempUser

func GetTempUser(ctx context.Context, db Queryer, key uint64) (*TempUser, error)

GetTempUser gets a TempUser by primary key

func NewTempUser

func NewTempUser(phoneNumber string) *TempUser

NewTempUser returns initialized temp user

func TempUserByAuthCodeAuthKey

func TempUserByAuthCodeAuthKey(ctx context.Context, db Queryer, authCode string, authKey string) (*TempUser, error)

TempUserByAuthCodeAuthKey retrieves a row from 'temp_users' as a TempUser.

Generated from index 'auth_code_auth_key_idx'.

func TempUserByID

func TempUserByID(ctx context.Context, db Queryer, id uint64) (*TempUser, error)

TempUserByID retrieves a row from 'temp_users' as a TempUser.

Generated from index 'temp_users_id_pkey'.

func TempUserByPhoneNumber

func TempUserByPhoneNumber(ctx context.Context, db Queryer, phoneNumber string) (*TempUser, error)

TempUserByPhoneNumber retrieves a row from 'temp_users' as a TempUser.

Generated from index 'phone_number'.

func (*TempUser) Delete

func (tu *TempUser) Delete(ctx context.Context, db Execer) error

Delete deletes the TempUser from the database.

func (*TempUser) Deleted

func (tu *TempUser) Deleted() bool

Deleted provides information if the TempUser has been deleted from the database.

func (*TempUser) Exists

func (tu *TempUser) Exists() bool

Exists determines if the TempUser exists in the database.

func (*TempUser) Insert

func (tu *TempUser) Insert(ctx context.Context, db Execer) error

Insert inserts the TempUser to the database.

func (*TempUser) IsExpired

func (tu *TempUser) IsExpired() bool

IsExpired checks if the temp user confirmation is expired (specified hours have passed)

func (*TempUser) Save

func (tu *TempUser) Save(ctx context.Context, db Execer) error

Save saves the TempUser to the database.

func (*TempUser) Update

func (tu *TempUser) Update(ctx context.Context, db Execer) error

Update updates the TempUser in the database.

func (*TempUser) ValidateAuthInfo

func (tu *TempUser) ValidateAuthInfo(authCode string, authKey string) bool

ValidateAuthInfo validates given pair of authCode and authKey

type User

type User struct {
	ID                     uint64         `json:"id" db:"id"`                                             // id
	FirstName              string         `json:"first_name" db:"first_name"`                             // first_name
	LastName               string         `json:"last_name" db:"last_name"`                               // last_name
	Gender                 int64          `json:"gender" db:"gender"`                                     // gender
	DateOfBirth            mysql.NullTime `json:"date_of_birth" db:"date_of_birth"`                       // date_of_birth
	PhoneNumber            string         `json:"phone_number" db:"phone_number"`                         // phone_number
	UnconfirmedPhoneNumber sql.NullString `json:"unconfirmed_phone_number" db:"unconfirmed_phone_number"` // unconfirmed_phone_number
	Email                  string         `json:"email" db:"email"`                                       // email
	PasswordDigest         []byte         `json:"password_digest" db:"password_digest"`                   // password_digest
	CreatedAt              time.Time      `json:"created_at" db:"created_at"`                             // created_at
	UpdatedAt              time.Time      `json:"updated_at" db:"updated_at"`                             // updated_at
	// contains filtered or unexported fields
}

User represents a row from 'users'.

func GetUser

func GetUser(ctx context.Context, db Queryer, key uint64) (*User, error)

GetUser gets a User by primary key

func NewUser

func NewUser(phoneNumber, email, password, firstName, lastName string, gender Gender, dateOfBirth null.Time) *User

NewUser returns initialized user

func UserByEmail

func UserByEmail(ctx context.Context, db Queryer, email string) (*User, error)

UserByEmail retrieves a row from 'users' as a User.

Generated from index 'email'.

func UserByID

func UserByID(ctx context.Context, db Queryer, id uint64) (*User, error)

UserByID retrieves a row from 'users' as a User.

Generated from index 'users_id_pkey'.

func UserByPhoneNumber

func UserByPhoneNumber(ctx context.Context, db Queryer, phoneNumber string) (*User, error)

UserByPhoneNumber retrieves a row from 'users' as a User.

Generated from index 'phone_number'.

func (*User) ConfirmPhoneNumber

func (u *User) ConfirmPhoneNumber() error

func (*User) Delete

func (u *User) Delete(ctx context.Context, db Execer) error

Delete deletes the User from the database.

func (*User) Deleted

func (u *User) Deleted() bool

Deleted provides information if the User has been deleted from the database.

func (*User) Exists

func (u *User) Exists() bool

Exists determines if the User exists in the database.

func (*User) GenderString

func (u *User) GenderString() string

GenderString returns gender string

func (*User) Insert

func (u *User) Insert(ctx context.Context, db Execer) error

Insert inserts the User to the database.

func (*User) SMSReconfirmation

func (u *User) SMSReconfirmation(ctx context.Context, db Queryer) (*SmsReconfirmation, error)

SMSReconfirmation returns the SMSReconfirmation associated with the User's ID (id).

func (*User) Save

func (u *User) Save(ctx context.Context, db Execer) error

Save saves the User to the database.

func (*User) Update

func (u *User) Update(ctx context.Context, db Execer) error

Update updates the User in the database.

Jump to

Keyboard shortcuts

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