models

package
v0.0.0-...-f48d556 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountAnime

func CountAnime() (int64, error)

CountAnime returns a total amount of titles in the database

func SearchAnime

func SearchAnime(params url.Values) (*[]AnimeModel, int64, error)

SearchAnime searches titles with given parameters. Query is not required. Retuns an AnimeModel array, total results count, and an error if any. If no anime was found returns an empty array.

Types

type AnimeModel

type AnimeModel struct {
	ID          int64     `json:"_id" bson:"_id"`
	Title       string    `json:"title" bson:"title"`
	Summary     string    `json:"summary" bson:"summary"`
	Description string    `json:"description" bson:"description"`
	Image       string    `json:"image_url" bson:"image_url"`
	Scores      []Score   `json:"scores" bson:"scores"`
	CreatedAt   time.Time `json:"created_at" bson:"created_at"`
}

AnimeModel is a database model of an anime.

func AddAnime

func AddAnime(model AnimeModel) (*AnimeModel, error)

AddAnime inserts an anime to the database

func DeleteAnime

func DeleteAnime(id int64) (*AnimeModel, error)

DeleteAnime deletes an anime from the database and returns a deleted document if any.

func GetAnimeByTitle

func GetAnimeByTitle(title string) (*AnimeModel, error)

GetAnimeByTitle finds an anime by title, if not present returns ErrNoDocuments.

type Comment

type Comment struct {
	Author    string    `json:"author"`
	Content   string    `json:"content"`
	CreatedAt time.Time `json:"created_at"`
}

Comment is a comment model

type Score

type Score struct {
	UserID int64 `json:"user_id" bson:"user_id"`
	Score  int   `json:"score" bson:"score"`
}

Score is a database model of a score.

type SearchAnimeSettings

type SearchAnimeSettings struct {
	Query string
	Page  int
	Limit int64
	Skips int64
}

SearchAnimeSettings is ... TODO

func NewSearchSettings

func NewSearchSettings(params url.Values) (*SearchAnimeSettings, error)

NewSearchSettings TODO

func (*SearchAnimeSettings) GetFilter

func (s *SearchAnimeSettings) GetFilter() *bson.M

type User

type User struct {
	ID       int64  `json:"_id"`
	Email    string `json:"email"`
	Password string `json:"password"`
	IsAdmin  bool   `json:"admin"`
}

User is a user model

Jump to

Keyboard shortcuts

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