mock

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Snippet

type Snippet struct{}

Snippet manages the set of API's for snippet access

func NewSnippet

func NewSnippet() Snippet

NewSnippet constructs a Snippet for api access.

func (Snippet) Create

Create inserts a new snippet record into the database.

func (Snippet) Delete

func (s Snippet) Delete(context.Context, string) error

Delete removes a snippet record from the database.

func (Snippet) Latest

func (s Snippet) Latest(context.Context) ([]snippet.Info, error)

Latest gets the latest snippets from the database.

func (Snippet) Retrieve

func (s Snippet) Retrieve(ctx context.Context, id string) (*snippet.Info, error)

Retrieve gets the specified snippet from the database.

func (Snippet) Update

func (s Snippet) Update(ctx context.Context, id string, us snippet.UpdateSnippet, t time.Time) error

Update updates a snippet record in the database.

type User

type User struct {
}

User manages the set of API's for user access. It wraps a sql.DB connection pool.

func NewUser

func NewUser() User

NewUser constructs a User for api access.

func (User) Authenticate

func (u User) Authenticate(ctx context.Context, now time.Time, email, password string) (auth.Claims, error)

Authenticate finds a user by their email and verifies their password.

func (User) ChangePassword

func (u User) ChangePassword(ctx context.Context, id, currentPassword, newPassword string) error

ChangePassword generates a hash based on the new password and saves it to the db.

func (User) Create

func (u User) Create(ctx context.Context, nu user.NewUser, now time.Time) (*user.Info, error)

Create inserts a new user into the database.

func (User) Delete

func (u User) Delete(ctx context.Context, id string) error

Delete removes a user from the database.

func (User) List

func (u User) List(ctx context.Context) ([]user.Info, error)

List retrieves a list of existing users from the database.

func (User) QueryByID

func (u User) QueryByID(ctx context.Context, id string) (*user.Info, error)

QueryByID gets the specified user from the database.

func (User) Update

Update replaces a user document in the database.

Jump to

Keyboard shortcuts

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