models

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

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

Go to latest
Published: Apr 13, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateKeyword

func CreateKeyword(keyword *Keyword) (int64, error)

CreateKeyword inserts a new Keyword into database and returns last inserted Id on success.

func CreateUser

func CreateUser(user *User) (int64, error)

CreateUser insert a new User into database and returns last inserted Id on success.

func GetKeywordsCount

func GetKeywordsCount(query map[string]interface{}) (int64, error)

GetKeywordsCount returns the number of current user's uploaded keywords

func UpdateKeyword

func UpdateKeyword(keyword *Keyword) error

UpdateKeyword updates a Keyword and returns the error if any

Types

type Base

type Base struct {
	Id        uint
	CreatedAt time.Time `orm:"auto_now_add;type(datetime)"`
	UpdatedAt time.Time `orm:"auto_now;type(datetime)"`
}

type Keyword

type Keyword struct {
	Base

	Keyword string
	Status  KeywordStatus `orm:"type(KeywordStatus);default(pending)"`

	LinksCount           int
	NonAdwordLinks       string `orm:"type(json);null"`
	NonAdwordLinksCount  int
	AdwordLinks          string `orm:"type(json);null"`
	AdwordLinksCount     int
	ShopAdwordLinks      string `orm:"type(json);null"`
	ShopAdwordLinksCount int
	HtmlCode             string

	User *User `orm:"rel(fk)"`
}

func GetKeywordByID

func GetKeywordByID(keywordID int64) (*Keyword, error)

GetKeywordByID returns the Keyword by passing keywordID

func GetKeywordByQuery

func GetKeywordByQuery(query map[string]interface{}) (*Keyword, error)

GetKeyword gets a Keyword by query

func GetKeywords

func GetKeywords(query map[string]interface{}) ([]*Keyword, error)

GetKeywords returns keywords by query

type KeywordStatus

type KeywordStatus string

KeywordStatus is an implementation of a string for the SQL type

const (
	Failed     KeywordStatus = "failed"
	Pending    KeywordStatus = "pending"
	Processed  KeywordStatus = "processed"
	Processing KeywordStatus = "processing"

	InvalidKeywordStatusErr = "invalid keyword status"
)

func (KeywordStatus) Value

func (k KeywordStatus) Value() (driver.Value, error)

Value implements the driver.Valuer interface, and turns the KeywordStatus into a string for SQL storage

type OAuthError

type OAuthError struct {
	Code    string `json:"error"`
	Message string `json:"error_description"`
}

type OAuthToken

type OAuthToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    uint64 `json:"expires_in"`
}

type User

type User struct {
	Base

	Email             string `orm:"unique"`
	EncryptedPassword string

	Keywords []*Keyword `orm:"reverse(many)"`
}

func GetUserByID

func GetUserByID(userID uint) (*User, error)

GetUserByID returns the User by passing userID

Jump to

Keyboard shortcuts

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