Documentation
¶
Overview ¶
Package data provides the data access layer for the application. It is responsible for interacting with the database layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmailOrUsernameExists = fmt.Errorf("user with this email or username already exists")
ErrEmailOrUsernameExists is an error returned when a user with the given email already exists.
Functions ¶
This section is empty.
Types ¶
type Datalayer ¶
type Datalayer struct {
// contains filtered or unexported fields
}
Datalayer is a struct that helps us to interact with the data.
func New ¶
func New(db UserCredentials, saltLength int, tokenExpirationTime time.Duration, signKey []byte) *Datalayer
New returns a new Datalayer struct.
func (*Datalayer) CreateUser ¶
CreateUser is a function to create a new user.
func (*Datalayer) GetUserById ¶
type UserCredentials ¶
type UserCredentials interface { HasEmailOrUsername(ctx context.Context, username, email string) (bool, error) GetSaltAndHash(ctx context.Context, username string) (salt, hash string, err error) InsertUser(ctx context.Context, username, salt, hash, email string) (int, error) GetUserInfo(ctx context.Context, userId int) (username, email string, err error) GetUserID(ctx context.Context, username string) (int64, error) ImportGoldenWords(ctx context.Context, userId int) error ImportGoldenWordsForOld(ctx context.Context) error }
UserCredentials is an interface that represents database.
Click to show internal directories.
Click to hide internal directories.