userProviderMysql

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: MIT Imports: 8 Imported by: 0

README

Mysql User Provider

Example GoTuna UserProvider for Mysql

Create mysql table

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `phone` varchar(255) NOT NULL,
  `password_hash` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email_UNIQUE` (`email`)
)

Insert sample records

INSERT INTO `users` (`email`, `name`, `phone`, `password_hash`) VALUES
('john@example.com', 'John', '555-0001', '$2a$10$M8YHTRKueW4DEV2/Wc4SF.DZ98NxP37eF5.XeEY1u3JWu8UWcqUNm');

INSERT INTO `users` (`email`, `name`, `phone`, `password_hash`) VALUES
('bob@example.com', 'Bob', '555-2555', '$2a$10$ibd7hES316n1XhuAWJuzv.7EfqZzcBAgtQ.k4loS6fL4EihEJMKxS');

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMysqlUserRepository

func NewMysqlUserRepository(db *sql.DB) gotuna.UserRepository

NewMysqlUserRepository returns a new mysql implementation of gotuna.UserRepository

Types

type DBUser

type DBUser struct {
	ID           string
	Email        string
	Name         string
	Phone        string
	PasswordHash string
}

DBUser is a sample gotuna.User implementation used with mysql

func (DBUser) GetID

func (u DBUser) GetID() string

GetID should return auto-incremented, unique "id" field from mysql database for this user

Jump to

Keyboard shortcuts

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