userdb

package
v0.0.0-...-4109721 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package userdb contains user related CRUD functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store manages the set of APIs for user database access.

func NewStore

func NewStore(logger *slog.Logger, db *sqlx.DB) *Store

NewStore constructs the api for data access.

func (*Store) APIKeyValidation

func (s *Store) APIKeyValidation(ctx context.Context, apiKeyHash string) (bool, error)

APIKeyValidation validate a given API Key Hash.

func (*Store) Create

func (s *Store) Create(ctx context.Context, usrDB UserDB) error

Create create a user to the database.

func (*Store) DeleteAll

func (s *Store) DeleteAll(ctx context.Context) error

DeleteAll deletes all users.

func (*Store) IsUsersEmpty

func (s *Store) IsUsersEmpty(ctx context.Context) (bool, error)

IsUsersEmpty checks if the table users is empty.

type UserDB

type UserDB struct {
	ID          uuid.UUID `db:"user_id"`
	Name        string    `db:"name"`
	APIKeyHash  string    `db:"api_key_hash"`
	DateCreated time.Time `db:"date_created"`
}

UserDB represents individual user of the database layer.

Jump to

Keyboard shortcuts

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