favdb

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 12 Imported by: 1

README

fav

User Favorite DB handle in go (memory, github issue, postgesDB...)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InArray added in v0.2.0

func InArray(val interface{}, array interface{}) (exists bool, index int)

InArray: Check if string item is in array

func NewDB

func NewDB() *firestore.Client

func RemoveStringItem added in v0.2.0

func RemoveStringItem(slice []string, s int) []string

RemoveStringItem: Remove string item from slice

func String

func String(v string) *string

func TruncateString added in v0.2.0

func TruncateString(s string, maxLength int) string

Types

type AllArticles

type AllArticles []ArticleDocument

ArticleDocument for sorting.

func (AllArticles) Len

func (a AllArticles) Len() int

func (AllArticles) Less

func (a AllArticles) Less(i, j int) bool

func (AllArticles) Swap

func (a AllArticles) Swap(i, j int)

type ArticleDocument

type ArticleDocument struct {
	ArticleID    string        `json:"article_id"`
	ArticleTitle string        `json:"article_title"`
	Author       string        `json:"author"`
	Board        string        `json:"board"`
	Content      string        `json:"content"`
	Date         string        `json:"date"`
	IP           string        `json:"ip"`
	MessageCount MessageCount  `bson:"message_count"`
	Messages     []interface{} `json:"messages"`
	Timestamp    int           `json:"timestamp"`
	URL          string        `json:"url"`
	ImageLinks   []string      `json:"image_links"`
}

func (*ArticleDocument) ToString

func (d *ArticleDocument) ToString() (info string)

type GithubDB

type GithubDB struct {
	Name   string
	Repo   string
	Token  string
	Client *github.Client
}

func NewGithubDB

func NewGithubDB(dbStr string) *GithubDB

func (*GithubDB) Add

func (u *GithubDB) Add(user UserFavorite)

func (*GithubDB) Get

func (u *GithubDB) Get(uid string) (result *UserFavorite, err error)

func (*GithubDB) ShowAll

func (u *GithubDB) ShowAll() (result []UserFavorite, err error)

ShowAll: Print all result.

func (*GithubDB) Update

func (u *GithubDB) Update(user *UserFavorite) (err error)

type MemDB

type MemDB struct {
	Db MemStorage
}

func NewMemDB

func NewMemDB() *MemDB

func (*MemDB) Add

func (u *MemDB) Add(user UserFavorite)

func (*MemDB) Get

func (u *MemDB) Get(uid string) (result *UserFavorite, err error)

func (*MemDB) ShowAll

func (u *MemDB) ShowAll() (result []UserFavorite, err error)

ShowAll: Print all result.

func (*MemDB) Update

func (u *MemDB) Update(user *UserFavorite) (err error)

type MemStorage

type MemStorage map[string]UserFavorite

type MessageCount

type MessageCount struct {
	All     int `json:"all"`
	Boo     int `json:"boo"`
	Count   int `json:"count"`
	Neutral int `json:"neutral"`
	Push    int `json:"push"`
}

type Model

type Model struct {
	Db  UserFavData
	Log *log.Logger
}

type PGSql

type PGSql struct {
	Db *pg.DB
	// contains filtered or unexported fields
}

func NewPGSql

func NewPGSql(url string) *PGSql

func (*PGSql) Add

func (u *PGSql) Add(user UserFavorite)

func (*PGSql) Get

func (u *PGSql) Get(uid string) (result *UserFavorite, err error)

func (*PGSql) ShowAll

func (u *PGSql) ShowAll() (result []UserFavorite, err error)

ShowAll: Print all result.

func (*PGSql) Update

func (u *PGSql) Update(user *UserFavorite) (err error)

type UserFavData

type UserFavData interface {
	Add(user UserFavorite)
	Get(uid string) (result *UserFavorite, err error)
	ShowAll() (result []UserFavorite, err error)
	Update(user *UserFavorite) (err error)
}

type UserFavorite

type UserFavorite struct {
	Id        int64    `bson:"_id"`
	UserId    string   `json:"user_id" bson:"user_id"`
	Favorites []string `json:"favorites" bson:"favorites"`
}

Directories

Path Synopsis
example
github-issue command

Jump to

Keyboard shortcuts

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