sqlite

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Devices

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

Devices storage implements storage.Devices interface for sqlite database.

func (*Devices) All

func (d *Devices) All(ctx context.Context) ([]models.Device, error)

All returns slice with all devices from storage.

func (*Devices) New

func (d *Devices) New(ctx context.Context, userID string, m models.Device) (string, error)

New stores given devices data in database and returns id of new device (given with input model).

func (*Devices) OfUser

func (d *Devices) OfUser(ctx context.Context, userID string) ([]models.Device, error)

OfUser returns list of models owned by user with given id.

func (*Devices) Read

func (d *Devices) Read(ctx context.Context, id string) (*models.Device, error)

Read returns single device data with given ID.

func (*Devices) Remove

func (d *Devices) Remove(ctx context.Context, id string) error

Remove deletes device with given id from storage.

type Factory

type Factory struct {
	UsersStorage     *Users
	DevicesStorage   *Devices
	TwoFactorStorage *TwoFactor
}

Factory implements storage factory interface.

func NewFactory

func NewFactory(filename string) (*Factory, func() error, error)

NewFactory returns Factory, database closer for sqlite connection and error if something went wrong.

func (*Factory) Devices

func (f *Factory) Devices() storage.Devices

Devices returns sqlite implementation of storage Devices interface.

func (*Factory) TwoFactor

func (f *Factory) TwoFactor() storage.TwoFactor

TwoFactor returns sqlite implementation of storage TwoFactor interface.

func (*Factory) Users

func (f *Factory) Users() storage.Users

Users returns sqlite implementation of storage Users interface.

type TwoFactor

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

TwoFactor storage implements storage.TwoFactor interface for sqlite database.

func (*TwoFactor) Get

func (tf *TwoFactor) Get(ctx context.Context, userID string) (*models.TwoFactor, error)

Get returns two factor methods for user with given user ID.

func (*TwoFactor) Remove

func (tf *TwoFactor) Remove(ctx context.Context, userID string) error

Remove deletes all two factor methods of user with given user ID. You can still use Update method after all to start adding more methods.

func (*TwoFactor) Update

func (tf *TwoFactor) Update(ctx context.Context, userID string, f func(*models.TwoFactor) error) error

Updates apply given function to two factor methods of user with given user ID.

type Users

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

Users storage implements storage.Users interface for sqlite database.

func (*Users) All

func (s *Users) All(ctx context.Context) ([]storage.UserEntry, error)

All returns slice with all users from storage.

func (*Users) New

func (s *Users) New(ctx context.Context, u storage.UserEntry) (string, error)

New stores given user data in database and returns assigned (given) id.

func (*Users) Read

func (s *Users) Read(ctx context.Context, id string) (*storage.UserEntry, error)

Read returns single user data with given ID.

func (*Users) Remove

func (s *Users) Remove(ctx context.Context, id string) error

Remove deletes user with given id from storage.

func (*Users) Update

func (s *Users) Update(ctx context.Context, id string, f func(*storage.UserEntry) error) error

Update overwrites existing user data.

Jump to

Keyboard shortcuts

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