database

package
v0.0.0-...-68c97d4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB(path string) *DB

func (*DB) CreateChirp

func (db *DB) CreateChirp(chirp models.Chirp) (models.Chirp, error)

func (*DB) CreateUser

func (db *DB) CreateUser(signupReq models.SignUpRequest) (models.User, error)

func (*DB) DeleteChirp

func (db *DB) DeleteChirp(id string) error

func (*DB) DeleteOldDBFileIfExists

func (db *DB) DeleteOldDBFileIfExists(filepath string) error

func (*DB) GetChirp

func (db *DB) GetChirp(id string) (models.Chirp, error)

func (*DB) GetChirps

func (db *DB) GetChirps(sortOrder string) ([]models.Chirp, error)

func (*DB) GetChirpsByAuthorID

func (db *DB) GetChirpsByAuthorID(id string) ([]models.Chirp, error)

func (*DB) GetUserByEmail

func (db *DB) GetUserByEmail(email string) (models.User, error)

func (*DB) GetUserByID

func (db *DB) GetUserByID(id int) (models.User, error)

func (*DB) InvalidateRefreshToken

func (db *DB) InvalidateRefreshToken(token string) error

func (*DB) RefreshTokenIsInvalid

func (db *DB) RefreshTokenIsInvalid(token string) bool

func (*DB) UpdateUser

func (db *DB) UpdateUser(user models.User) error

type DBStructure

type DBStructure struct {
	Chirps               map[int]models.Chirp `json:"chirps"`
	Users                map[int]models.User  `json:"users"`
	InvalidRefreshTokens map[string]time.Time `json:"invalid_refresh_tokens"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳