database

package
v0.0.0-...-50dfd56 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Films *mgo.Collection
	Users *mgo.Collection
}

func GetDB

func GetDB() *Database

func (*Database) CreateUser

func (database *Database) CreateUser(login, password string) (*User, error)

func (*Database) DeleteFilmByID

func (database *Database) DeleteFilmByID(idStr string) error

func (*Database) DeleteRefreshToken

func (database *Database) DeleteRefreshToken(refreshToken string) error

func (*Database) GetAllFilms

func (database *Database) GetAllFilms() (films []*tmdb.Film, err error)

func (*Database) GetCountFromCollection

func (database *Database) GetCountFromCollection(nameCol string) (count int, err error)

func (*Database) GetFilmByID

func (database *Database) GetFilmByID(idStr string) (film *tmdb.Film, err error)

func (*Database) GetFilmsByQuery

func (database *Database) GetFilmsByQuery(queries ...string) ([]*tmdb.Film, error)

func (*Database) GetUser

func (database *Database) GetUser(login string, password string) (*User, error)

func (*Database) GetUserByUserID

func (database *Database) GetUserByUserID(userID string) (*User, error)

func (*Database) InsertFilm

func (database *Database) InsertFilm(film *tmdb.Film) error

func (*Database) IsExistFilm

func (database *Database) IsExistFilm(idStr string) (bool, error)

func (*Database) IsExistUser

func (database *Database) IsExistUser(login string) (bool, error)

func (*Database) UpdateRefreshTokenForUser

func (database *Database) UpdateRefreshTokenForUser(userID, refreshToken string) error

func (*Database) UpdateUser

func (database *Database) UpdateUser(user *User) error

func (*Database) UpsertFilm

func (database *Database) UpsertFilm(film *tmdb.Film) error

func (*Database) UpsertUser

func (database *Database) UpsertUser(user *User) error

type Overview

type Overview struct {
	Name       string `json:"film_tracker" example:"FilmTracker"`
	FilmsCount int    `json:"films_count" example:"1100"`
	UsersCount int    `json:"users_count" example:"52"`
}

type User

type User struct {
	UserID       string `bson:"user_id" json:"user_id"`
	Login        string `bson:"login" json:"login" validate:"min=3, max=10" example:"login" binding:"required"`
	Password     string `bson:"password" json:"password" validate:"min=2, max=40" example:"password" binding:"required"`
	Role         string `bson:"role" json:"role"`
	RefreshToken string `bson:"refresh_token" json:"refresh_token"`
}

Jump to

Keyboard shortcuts

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