db

package
v0.0.0-...-8bdfbef Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationToken

type AuthenticationToken struct {
	UserID                int64  `json:"userId"`
	AccessToken           string `json:"accessToken"`
	AccessTokenExpiresAt  string `json:"accessTokenExpiresAt"`
	RefreshToken          string `json:"refreshToken"`
	RefreshTokenExpiresAt string `json:"refreshTokenExpiresAt"`
	CreatedAt             string `json:"createdAt"`
}

type CreateAuthenticationTokenParams

type CreateAuthenticationTokenParams struct {
	UserID                int64  `json:"userId"`
	AccessToken           string `json:"accessToken"`
	AccessTokenExpiresAt  string `json:"accessTokenExpiresAt"`
	RefreshToken          string `json:"refreshToken"`
	RefreshTokenExpiresAt string `json:"refreshTokenExpiresAt"`
	CreatedAt             string `json:"createdAt"`
}

type CreateOauthUserParams

type CreateOauthUserParams struct {
	OauthProviderID int64       `json:"oauthProviderId"`
	UserID          int64       `json:"userId"`
	ExternalUserID  string      `json:"externalUserId"`
	Email           interface{} `json:"email"`
}

type CreateResetPasswordTokenParams

type CreateResetPasswordTokenParams struct {
	UserID    int64          `json:"userId"`
	Token     string         `json:"token"`
	ExpiresAt string         `json:"expiresAt"`
	CreatedAt string         `json:"createdAt"`
	UpdatedAt sql.NullString `json:"updatedAt"`
}

type CreateUserCredentialsParams

type CreateUserCredentialsParams struct {
	UserID          interface{} `json:"userId"`
	Password        string      `json:"password"`
	Email           string      `json:"email"`
	IsEmailVerified int64       `json:"isEmailVerified"`
}

type CreateUserParams

type CreateUserParams struct {
	Uuid      string         `json:"uuid"`
	Name      string         `json:"name"`
	IsActive  int64          `json:"isActive"`
	ImageID   sql.NullString `json:"imageId"`
	ImageUrl  sql.NullString `json:"imageUrl"`
	CreatedAt string         `json:"createdAt"`
	UpdatedAt sql.NullString `json:"updatedAt"`
	RoleID    int64          `json:"roleId"`
}

type CreateVerifyEmailTokenParams

type CreateVerifyEmailTokenParams struct {
	UserID    int64          `json:"userId"`
	Token     string         `json:"token"`
	ExpiresAt string         `json:"expiresAt"`
	CreatedAt string         `json:"createdAt"`
	UpdatedAt sql.NullString `json:"updatedAt"`
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DataStore

type DataStore interface {
	Querier
	Connect() error
	Close() error
	MigrateUp() error
	MigrateDown() error
	ExecTx(ctx context.Context, fn func(*Queries) error) error
}

func NewDataStore

func NewDataStore(config config.Config) DataStore

func NewDataStore(db *sql.DB) DataStore {

type Database

type Database struct {
	*Queries
	// contains filtered or unexported fields
}

func (*Database) Close

func (d *Database) Close() error

func (*Database) Connect

func (d *Database) Connect() error

func (*Database) ExecTx

func (d *Database) ExecTx(ctx context.Context, fn func(*Queries) error) error

func (*Database) MigrateDown

func (d *Database) MigrateDown() error

func (*Database) MigrateUp

func (d *Database) MigrateUp() error

type GetAllUsersRow

type GetAllUsersRow struct {
	User            User            `json:"user"`
	UserCredentials UserCredentials `json:"userCredentials"`
}

type GetUserByEmailRow

type GetUserByEmailRow struct {
	User            User            `json:"user"`
	UserCredentials UserCredentials `json:"userCredentials"`
}

type GetUserByIDRow

type GetUserByIDRow struct {
	User User `json:"user"`
}

type GetUserByOauthProviderParams

type GetUserByOauthProviderParams struct {
	ExternalUserID  string `json:"externalUserId"`
	OauthProviderID int64  `json:"oauthProviderId"`
}

type GetUserByOauthProviderRow

type GetUserByOauthProviderRow struct {
	User      User      `json:"user"`
	OauthUser OauthUser `json:"oauthUser"`
}

type GetUserByResetPasswordTokenRow

type GetUserByResetPasswordTokenRow struct {
	User               User               `json:"user"`
	ResetPasswordToken ResetPasswordToken `json:"resetPasswordToken"`
}

type GetUserByUUIDRow

type GetUserByUUIDRow struct {
	ID              int64          `json:"id"`
	Uuid            string         `json:"uuid"`
	Name            string         `json:"name"`
	IsActive        int64          `json:"isActive"`
	ImageID         sql.NullString `json:"imageId"`
	ImageUrl        sql.NullString `json:"imageUrl"`
	CreatedAt       string         `json:"createdAt"`
	UpdatedAt       sql.NullString `json:"updatedAt"`
	RoleID          int64          `json:"roleId"`
	UserID          sql.NullInt64  `json:"userId"`
	Password        sql.NullString `json:"password"`
	Email           sql.NullString `json:"email"`
	IsEmailVerified sql.NullInt64  `json:"isEmailVerified"`
	OauthProviderID sql.NullInt64  `json:"oauthProviderId"`
	UserID_2        sql.NullInt64  `json:"userId2"`
	ExternalUserID  sql.NullString `json:"externalUserId"`
	Email_2         interface{}    `json:"email2"`
}

type GetUserByVerifyEmailTokenRow

type GetUserByVerifyEmailTokenRow struct {
	User             User             `json:"user"`
	VerifyEmailToken VerifyEmailToken `json:"verifyEmailToken"`
}

type OauthProvider

type OauthProvider struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
}

type OauthUser

type OauthUser struct {
	OauthProviderID int64       `json:"oauthProviderId"`
	UserID          int64       `json:"userId"`
	ExternalUserID  string      `json:"externalUserId"`
	Email           interface{} `json:"email"`
}

type Querier

type Querier interface {
	CreateAuthenticationToken(ctx context.Context, arg CreateAuthenticationTokenParams) (AuthenticationToken, error)
	CreateOauthUser(ctx context.Context, arg CreateOauthUserParams) (OauthUser, error)
	CreateResetPasswordToken(ctx context.Context, arg CreateResetPasswordTokenParams) (ResetPasswordToken, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	CreateUserCredentials(ctx context.Context, arg CreateUserCredentialsParams) (UserCredentials, error)
	CreateVerifyEmailToken(ctx context.Context, arg CreateVerifyEmailTokenParams) (VerifyEmailToken, error)
	DeleteAuthenticationToken(ctx context.Context, userID int64) error
	DeleteResetPasswordToken(ctx context.Context, userID int64) error
	DeleteUser(ctx context.Context, uuid string) error
	DeleteVerifyEmailToken(ctx context.Context, userID int64) error
	// SELECT user.*, user_credentials.*
	GetAllUsers(ctx context.Context) ([]GetAllUsersRow, error)
	GetAuthenticationTokenByAccessToken(ctx context.Context, accessToken string) (AuthenticationToken, error)
	GetAuthenticationTokenByRefreshToken(ctx context.Context, refreshToken string) (AuthenticationToken, error)
	GetOauthProviders(ctx context.Context) ([]OauthProvider, error)
	GetRoles(ctx context.Context) ([]Role, error)
	// SELECT user.*, user_credentials.*
	GetUserByEmail(ctx context.Context, email string) (GetUserByEmailRow, error)
	// SELECT user.*, user_credentials.*
	GetUserByID(ctx context.Context, id int64) (GetUserByIDRow, error)
	GetUserByOauthProvider(ctx context.Context, arg GetUserByOauthProviderParams) (GetUserByOauthProviderRow, error)
	GetUserByResetPasswordToken(ctx context.Context, token string) (GetUserByResetPasswordTokenRow, error)
	// SELECT sqlc.embed(user), sqlc.embed(user_credentials), sqlc.embed(oauth_user)
	GetUserByUUID(ctx context.Context, uuid string) (GetUserByUUIDRow, error)
	GetUserByVerifyEmailToken(ctx context.Context, token string) (GetUserByVerifyEmailTokenRow, error)
	GetVerifyEmailTokenByToken(ctx context.Context, token string) (VerifyEmailToken, error)
	UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
	UpdateUserIsEmailVerified(ctx context.Context, arg UpdateUserIsEmailVerifiedParams) error
	UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateAuthenticationToken

func (q *Queries) CreateAuthenticationToken(ctx context.Context, arg CreateAuthenticationTokenParams) (AuthenticationToken, error)

func (*Queries) CreateOauthUser

func (q *Queries) CreateOauthUser(ctx context.Context, arg CreateOauthUserParams) (OauthUser, error)

func (*Queries) CreateResetPasswordToken

func (q *Queries) CreateResetPasswordToken(ctx context.Context, arg CreateResetPasswordTokenParams) (ResetPasswordToken, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) CreateUserCredentials

func (q *Queries) CreateUserCredentials(ctx context.Context, arg CreateUserCredentialsParams) (UserCredentials, error)

func (*Queries) CreateVerifyEmailToken

func (q *Queries) CreateVerifyEmailToken(ctx context.Context, arg CreateVerifyEmailTokenParams) (VerifyEmailToken, error)

func (*Queries) DeleteAuthenticationToken

func (q *Queries) DeleteAuthenticationToken(ctx context.Context, userID int64) error

func (*Queries) DeleteResetPasswordToken

func (q *Queries) DeleteResetPasswordToken(ctx context.Context, userID int64) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, uuid string) error

func (*Queries) DeleteVerifyEmailToken

func (q *Queries) DeleteVerifyEmailToken(ctx context.Context, userID int64) error

func (*Queries) GetAllUsers

func (q *Queries) GetAllUsers(ctx context.Context) ([]GetAllUsersRow, error)

SELECT user.*, user_credentials.*

func (*Queries) GetAuthenticationTokenByAccessToken

func (q *Queries) GetAuthenticationTokenByAccessToken(ctx context.Context, accessToken string) (AuthenticationToken, error)

func (*Queries) GetAuthenticationTokenByRefreshToken

func (q *Queries) GetAuthenticationTokenByRefreshToken(ctx context.Context, refreshToken string) (AuthenticationToken, error)

func (*Queries) GetOauthProviders

func (q *Queries) GetOauthProviders(ctx context.Context) ([]OauthProvider, error)

func (*Queries) GetRoles

func (q *Queries) GetRoles(ctx context.Context) ([]Role, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (GetUserByEmailRow, error)

SELECT user.*, user_credentials.*

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, id int64) (GetUserByIDRow, error)

SELECT user.*, user_credentials.*

func (*Queries) GetUserByOauthProvider

func (q *Queries) GetUserByOauthProvider(ctx context.Context, arg GetUserByOauthProviderParams) (GetUserByOauthProviderRow, error)

func (*Queries) GetUserByResetPasswordToken

func (q *Queries) GetUserByResetPasswordToken(ctx context.Context, token string) (GetUserByResetPasswordTokenRow, error)

func (*Queries) GetUserByUUID

func (q *Queries) GetUserByUUID(ctx context.Context, uuid string) (GetUserByUUIDRow, error)

SELECT sqlc.embed(user), sqlc.embed(user_credentials), sqlc.embed(oauth_user)

func (*Queries) GetUserByVerifyEmailToken

func (q *Queries) GetUserByVerifyEmailToken(ctx context.Context, token string) (GetUserByVerifyEmailTokenRow, error)

func (*Queries) GetVerifyEmailTokenByToken

func (q *Queries) GetVerifyEmailTokenByToken(ctx context.Context, token string) (VerifyEmailToken, error)

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)

func (*Queries) UpdateUserIsEmailVerified

func (q *Queries) UpdateUserIsEmailVerified(ctx context.Context, arg UpdateUserIsEmailVerifiedParams) error

func (*Queries) UpdateUserPassword

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type ResetPasswordToken

type ResetPasswordToken struct {
	UserID    int64          `json:"userId"`
	Token     string         `json:"token"`
	ExpiresAt string         `json:"expiresAt"`
	CreatedAt string         `json:"createdAt"`
	UpdatedAt sql.NullString `json:"updatedAt"`
}

type Role

type Role struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type UpdateUserIsEmailVerifiedParams

type UpdateUserIsEmailVerifiedParams struct {
	IsEmailVerified int64       `json:"isEmailVerified"`
	UserID          interface{} `json:"userId"`
}

type UpdateUserParams

type UpdateUserParams struct {
	Name      sql.NullString `json:"name"`
	ImageID   sql.NullString `json:"imageId"`
	ImageUrl  sql.NullString `json:"imageUrl"`
	IsActive  sql.NullInt64  `json:"isActive"`
	UpdatedAt sql.NullString `json:"updatedAt"`
	Uuid      string         `json:"uuid"`
}

type UpdateUserPasswordParams

type UpdateUserPasswordParams struct {
	Password string      `json:"password"`
	UserID   interface{} `json:"userId"`
}

type User

type User struct {
	ID        int64          `json:"id"`
	Uuid      string         `json:"uuid"`
	Name      string         `json:"name"`
	IsActive  int64          `json:"isActive"`
	ImageID   sql.NullString `json:"imageId"`
	ImageUrl  sql.NullString `json:"imageUrl"`
	CreatedAt string         `json:"createdAt"`
	UpdatedAt sql.NullString `json:"updatedAt"`
	RoleID    int64          `json:"roleId"`
}

type UserCredentials

type UserCredentials struct {
	UserID          interface{} `json:"userId"`
	Password        string      `json:"password"`
	Email           string      `json:"email"`
	IsEmailVerified int64       `json:"isEmailVerified"`
}

type VerifyEmailToken

type VerifyEmailToken struct {
	UserID    int64          `json:"userId"`
	Token     string         `json:"token"`
	ExpiresAt string         `json:"expiresAt"`
	CreatedAt string         `json:"createdAt"`
	UpdatedAt sql.NullString `json:"updatedAt"`
}

Jump to

Keyboard shortcuts

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