models

package
v0.0.0-...-07785dc Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Source  string
	LogMode bool
	// contains filtered or unexported fields
}

DB abstraction

func NewPostgresDB

func NewPostgresDB(db *DB) *DB

NewPostgresDB - postgres database

func (*DB) Close

func (d *DB) Close()

type Note

type Note struct {
	gorm.Model
	ProjectID uint
	Name      string `gorm:"not null;unique_index" json:"name"`
	Active    bool   `gorm:"default:true" json:"active"`
}

Note struct

type NoteManager

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

NoteManager struct

type Project

type Project struct {
	gorm.Model
	Notes  []Note
	Name   string         `gorm:"not null;unique_index" json:"name"`
	Active bool           `gorm:"default:true" json:"active"`
	Tags   pq.StringArray `gorm:"type:varchar(64)[]"`
}

Project struct

type ProjectManager

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

ProjectManager struct

func NewProjectManager

func NewProjectManager(db *DB) (*ProjectManager, error)

func (*ProjectManager) AddProject

func (state *ProjectManager) AddProject(name string) *Project

func (*ProjectManager) FindProjects

func (state *ProjectManager) FindProjects() []Project

type User

type User struct {
	gorm.Model
	Username string `gorm:"not null;unique_index" json:"username"`
	Email    string `gorm:"type:varchar(100);unique_index" json:"email"`
	Password string `gorm:"not null" json:"-"`
	APIToken string `gorm:"not null;unique_index" json:"apiToken"`
	UUID     string `gorm:"not null;unique_index" json:"uuid"`
}

User struct

type UserManager

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

UserManager struct

func NewUserManager

func NewUserManager(db *DB) (*UserManager, error)

NewUserManager - Create a new *UserManager that can be used for managing users.

func (*UserManager) AddUser

func (state *UserManager) AddUser(username, password, email string) *User

AddUser - Creates a user and hashes the password

func (*UserManager) CheckPassword

func (state *UserManager) CheckPassword(hashedPassword, password string) bool

CheckPassword - compare a hashed password with a possible plaintext equivalent

func (*UserManager) FindUser

func (state *UserManager) FindUser(username string) *User

FindUser -

func (*UserManager) FindUserByAccessToken

func (state *UserManager) FindUserByAccessToken(token string) (*gorm.DB, *User)

FindUserByAccessToken -

func (*UserManager) FindUserByUUID

func (state *UserManager) FindUserByUUID(uuid string) *User

FindUserByUUID -

func (*UserManager) HasUser

func (state *UserManager) HasUser(username string) bool

HasUser - Check if the given username exists.

func (*UserManager) HasUserWithEmail

func (state *UserManager) HasUserWithEmail(email string) bool

HasUserWithEmail - Check if the given username exists.

func (*UserManager) HashPassword

func (state *UserManager) HashPassword(username, password string) string

HashPassword - Hash the password (takes a username as well, it can be used for salting).

func (*UserManager) UpdateUser

func (state *UserManager) UpdateUser(user *User) *User

UpdateUser - Saves the provided *User

Jump to

Keyboard shortcuts

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