models

package
v0.0.0-...-5c8e363 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AccInfo

func AccInfo(ctx context.Context) map[string]interface{}

AccInfo get details about an existing account

func DeleteAccount

func DeleteAccount(ctx context.Context) map[string]interface{}

DeleteAccount delete an existing account

func DeleteAllNotes

func DeleteAllNotes(ctx context.Context) map[string]interface{}

DeleteAllNotes Deletes all notes belonging to a user

func DeleteNote

func DeleteNote(ctx context.Context, noteID uint) map[string]interface{}

DeleteNote Delete a single note belonging to a user

func GetDB

func GetDB() *gorm.DB

GetDB returns a handle to the DB object

func ListNotes

func ListNotes(ctx context.Context) map[string]interface{}

ListNotes List all notes belonging to a user

func Login

func Login(email, pass string) map[string]interface{}

Login in to an existing account

func LoginUsername

func LoginUsername(username, pass string) map[string]interface{}

LoginUsername login with a username instead of an email address

func ModifyPassword

func ModifyPassword(ctx context.Context, password string) map[string]interface{}

ModifyPassword modify the password for an already existing account

func ModifyUsername

func ModifyUsername(ctx context.Context, username string) map[string]interface{}

ModifyUsername modify the username for an already existing account

func SaveAccImage

func SaveAccImage(ctx context.Context, imageURL string) map[string]interface{}

SaveAccImage save the image url for the account profile picture

func Stats

func Stats() map[string]interface{}

Types

type Account

type Account struct {
	gorm.Model
	Email    string  `json:"email"`
	Username string  `json:"username"`
	Password string  `json:"password"`
	Token    string  `gorm:"-" json:"token"`
	ImageURL string  `json:"image_url"`
	Notes    []Notes `gorm:"foreignkey:AccountID" json:"-"`
}

Account Represents a user account

func GetUser

func GetUser(u uint) *Account

GetUser get an existing user account

func (*Account) Create

func (acc *Account) Create() map[string]interface{}

Create a new user account

func (*Account) Validate

func (acc *Account) Validate() (map[string]interface{}, bool)

Validate incoming user details

type Notes

type Notes struct {
	NoteID          uint      `gorm:"primary_key" json:"note_id"`
	AccountID       uint      `gorm:"column:account_id" json:"id"`
	Title           string    `json:"title"`
	Content         string    `json:"content"`
	ImageURL        string    `json:"image_url"`
	ListParseString string    `json:"list_parse_string"`
	Reminders       string    `json:"reminders"`
	Date            time.Time `json:"date"`
	Color           int       `json:"color"`
	HideContent     bool      `json:"hide_content"`
	IsDeleted       bool      `json:"is_deleted"`
	IsArchived      bool      `json:"is_archived"`
	IsList          bool      `json:"is_list"`
	IsStarred       bool      `json:"is_starred"`
	Pin             string    `json:"pin"`
	Password        string    `json:"password"`
}

Notes Represents a note in the database

func (*Notes) SaveNote

func (note *Notes) SaveNote(ctx context.Context) map[string]interface{}

SaveNote Create or update a note

type Token

type Token struct {
	UserID uint
	jwt.StandardClaims
}

Token represents a JWT token

Jump to

Keyboard shortcuts

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