models

package
v0.0.0-...-a683649 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataAccessLayer

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

func InitDataAccessLayer

func InitDataAccessLayer(dbHost, dbPort, dbUser, dbPassword, dbName string) *DataAccessLayer

*

  • Function initializes our connection with the `postgres` database for this
  • web-application and saves the db connection instance in a global variable.

func (*DataAccessLayer) CreateUser

func (dal *DataAccessLayer) CreateUser(email string, firstName string, lastName string, password string, tenantId int64, tenantSchema string, roleId int64) (*User, error)

*

  • Function will create a user, if validation passess, and reutrns the `user`
  • struct else returns the error.

func (*DataAccessLayer) CreateUserTable

func (dal *DataAccessLayer) CreateUserTable(dropExistingTable bool)

*

  • Function will create the `users` table in the database.

func (*DataAccessLayer) FindUserByEmail

func (dal *DataAccessLayer) FindUserByEmail(email string) (*User, error)

*

  • Function will return the `user` struct if it exists in the database or
  • return an error.

func (*DataAccessLayer) Shutdown

func (dal *DataAccessLayer) Shutdown()

type User

type User struct {
	TenantId     int64          `db:"tenant_id"`
	TenantSchema sql.NullString `db:"tenant_schema"`
	Id           int64          `db:"id"`
	FirstName    sql.NullString `db:"first_name"`
	LastName     sql.NullString `db:"last_name"`
	PasswordHash sql.NullString `db:"password_hash"`
	Email        sql.NullString `db:"email"`
	RoleId       uint8          `db:"role_id"`
}

Jump to

Keyboard shortcuts

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