models

package
v0.0.0-...-2965246 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Active  = "active"
	Pending = "pending"
	Expired = "expired"
)
View Source
const (
	RoleUser  = "user"
	RoleAdmin = "admin"
)

Variables

This section is empty.

Functions

func GenerateSlug

func GenerateSlug(size int) string

func TransformPassword

func TransformPassword(val string) (string, error)

func VerifyPassword

func VerifyPassword(hashedPassword string, val string) error

Types

type Analytics

type Analytics struct {
	State   string `json:"state"`
	Country string `json:"country"`
	Count   int    `json:"count"`
}

type Article

type Article struct {
	Source      Source `json:"source"`
	Author      string `json:"author"`
	Title       string `json:"title"`
	Description string `json:"description"`
	URL         string `json:"url"`
	URLToImage  string `json:"urlToImage"`
	PublishedAt string `json:"publishedAt"`
	Content     string `json:"content"`
}

type Domain

type Domain struct {
	Host       string      `json:"host" db:"host"`
	Blacklist  bool        `json:"blacklist" db:"blacklist"`
	Properties PropertyMap `json:"properties" db:"properties"`
	Created    time.Time   `json:"created" db:"created"`
	Updated    null.Time   `json:"updated" db:"updated"`
}

type PropertyMap

type PropertyMap map[string]interface{}

PropertyMap is the type for our properties field

func (PropertyMap) Merge

func (lhs PropertyMap) Merge(rhs PropertyMap)

Merge trees represented as PropertyMap from rhs into lhs with keys from rhs taking precedent.

func (*PropertyMap) Scan

func (p *PropertyMap) Scan(src interface{}) error

Scan is the second interface (sql.Scanner), which takes the raw data from the database

and transforms it to our type (unmarshal the JSONB([]byte) to PropertyMap type)

func (PropertyMap) Value

func (p PropertyMap) Value() (driver.Value, error)

Value is the interface (driver.Valuer) that transforms our type

to a database driver compatible type (marshall the map to JSONB)

type Source

type Source struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type URL

type URL struct {
	Url      string    `json:"url" db:"url"`
	Slug     string    `json:"slug" db:"slug"`
	IP       string    `json:"ip" db:"ip"`
	Counter  int       `json:"counter" db:"counter"`
	Created  time.Time `json:"created" db:"created"`
	Updated  null.Time `json:"updated" db:"updated"`
	Status   string    `json:"status" db:"status"`
	Password string    `json:"-" db:"password"`
	Expired  null.Time `json:"expired" db:"expired"`
	Mindful  bool      `json:"mindful" db:"mindful"`
	Username string    `json:"username" db:"username"`
}

type URLStat

type URLStat struct {
	Slug       string      `json:"slug" db:"slug"`
	Country    string      `json:"country" db:"country"`
	State      string      `json:"state" db:"state"`
	Counter    int         `json:"counter" db:"counter"`
	Properties PropertyMap `json:"properties" db:"properties"`
	Created    time.Time   `json:"created" db:"created"`
	Updated    null.Time   `json:"updated" db:"updated"`
}

type User

type User struct {
	Username   string      `json:"username" db:"username"`
	Role       string      `json:"role" db:"role"`
	Password   string      `json:"-" db:"password"`
	Status     string      `json:"status" db:"status"`
	Properties PropertyMap `json:"properties" db:"properties"`
	Created    time.Time   `json:"created" db:"created"`
	Updated    null.Time   `json:"updated" db:"updated"`
}

Jump to

Keyboard shortcuts

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