connector

package
v0.0.0-...-b1be036 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// InsertDeviceSQL adds a devics)
	InsertDeviceSQL = `` /* 202-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type DbPool

type DbPool struct {
	Db *sqlx.DB
}

DbPool struct wraps the db instance

func SqlxNewInstance

func SqlxNewInstance() (*DbPool, error)

SqlxNewInstance create DbPool instance

func (*DbPool) CloseConnection

func (p *DbPool) CloseConnection() error

CloseConnection closes connetion

func (*DbPool) CreateAllTables

func (p *DbPool) CreateAllTables() error

CreateAllTables initializes the

func (*DbPool) DropAllTables

func (p *DbPool) DropAllTables() error

DropAllTables initializes the

func (*DbPool) InsertDevice

func (p *DbPool) InsertDevice(d *Device) error

InsertDevice a record into device table

func (*DbPool) InsertUser

func (p *DbPool) InsertUser(users *NewUser) error

InsertUser inserts a single user to the database

func (*DbPool) ListAllDevices

func (p *DbPool) ListAllDevices() ([]Device, error)

ListAllDevices list all devices

func (*DbPool) ListAllUsers

func (p *DbPool) ListAllUsers() ([]User, error)

ListAllUsers list all users

type Device

type Device struct {
	ID         string `json:"id"`
	CreatedAt  string `json:"created_at"`
	UpdatedAt  string `json:"updated_at"`
	DeletedAt  string `json:"deleted_at"`
	PhoneBrand string `json:"phone_brand"`
	PhoneModel string `json:"phone_model"`
	PushID     string `json:"push_id"`
	DeviceID   string `json:"device_id"`
}

Device model for storing device table rows

type NewUser

type NewUser struct {
	Name     string `json:"Name" valid:"required"`
	Email    string `json:"Email" valid:"required,email"`
	Mobile   string `json:"Mobile" valid:"required,numeric"`
	Password string `json:"Password" valid:"required,minstringlength(8)"`
	DeviceID string `json:"DeviceID" valid:"optional"`
}

NewUser to check input

type PgxPool

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

PgxPool is the Pgx connection pool

func PgxNewConnection

func PgxNewConnection(ctx context.Context) (*PgxPool, error)

PgxNewConnection initialize connection pol

func (*PgxPool) CreateAllTables

func (p *PgxPool) CreateAllTables(ctx context.Context) ([]Device, error)

CreateAllTables queries for a user name

func (*PgxPool) FindUserName

func (p *PgxPool) FindUserName(ctx context.Context, users *NewUser) error

FindUserName queries for a user name

func (*PgxPool) InsertArticle

func (p *PgxPool) InsertArticle(ctx context.Context, users *NewUser) error

InsertArticle inserts a single user to the database

func (*PgxPool) InsertDevice

func (p *PgxPool) InsertDevice(ctx context.Context, users *NewUser) error

InsertDevice inserts a single user to the database

func (*PgxPool) InsertUser

func (p *PgxPool) InsertUser(ctx context.Context, users *NewUser) error

InsertUser inserts a single user to the database

func (*PgxPool) ListAllArticles

func (p *PgxPool) ListAllArticles(ctx context.Context) error

ListAllArticles queries for a user name

func (*PgxPool) ListAllDevices

func (p *PgxPool) ListAllDevices(ctx context.Context) ([]Device, error)

ListAllDevices queries for a user name

func (*PgxPool) ListAllUsers

func (p *PgxPool) ListAllUsers(ctx context.Context) ([]User, error)

ListAllUsers queries for a user name

func (*PgxPool) PgxCloseConnection

func (p *PgxPool) PgxCloseConnection(ctx context.Context) error

PgxCloseConnection close

type User

type User struct {
	ID        string `json:"id"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"update_at"`
	DeletedAt string `json:"deleted_at"`
	Username  string `json:"username"`
	Phone     string `json:"phone"`
	Email     string `json:"email"`
	Password  string `json:"password"`
	Pin       int    `json:"pin"`
	Device    string `json:"device"`
	Role      string `json:"role"`
}

User model for storing user table rows

Jump to

Keyboard shortcuts

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