database

package
v0.0.0-...-dbe288e Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chirp

type Chirp struct {
	Id       int    `json:"id"`
	Body     string `json:"body"`
	AuthorId int    `json:"author_id"`
}

func (Chirp) GetId

func (c Chirp) GetId() int

type DB

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

func NewDB

func NewDB(path string) (*DB, error)

func (*DB) CreateChirp

func (db *DB) CreateChirp(body string, authorId int) (Chirp, error)

func (*DB) CreateUser

func (db *DB) CreateUser(email string, password string) (User, error)

func (*DB) GetChirp

func (db *DB) GetChirp(id int) (Chirp, error)

func (*DB) GetChirps

func (db *DB) GetChirps() ([]Chirp, error)

func (*DB) GetUser

func (db *DB) GetUser(id int) (User, error)

func (*DB) GetUserByEmail

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

func (*DB) GetUsers

func (db *DB) GetUsers() ([]User, error)

func (*DB) IsTokenRevoked

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

func (*DB) PrintUsers

func (db *DB) PrintUsers()

func (*DB) RevokeToken

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

func (*DB) UpdateUser

func (db *DB) UpdateUser(user User) (User, error)

type DBStructure

type DBStructure struct {
	Chirps  []Chirp              `json:"chirps"`
	Users   []User               `json:"users"`
	Revokes map[string]time.Time `json:"revokes"`
}

type HasId

type HasId interface {
	GetId() int
}

type User

type User struct {
	Id       int    `json:"id"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

func (User) GetId

func (u User) GetId() int

Jump to

Keyboard shortcuts

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