memory

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package memory implements storage interfaces for bolt key-value store database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DevicesStorage

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

DevicesStorage implements storage.Devices interface for bolt database.

func (*DevicesStorage) All

func (s *DevicesStorage) All(ctx context.Context) ([]models.Device, error)

All returns slice with all devices from storage.

func (*DevicesStorage) New

func (d *DevicesStorage) New(ctx context.Context, userID int, newDevice models.Device) (int, error)

New stores given devices data in database and returns assigned id.

func (*DevicesStorage) OfUser

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

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

func (*DevicesStorage) Read

func (s *DevicesStorage) Read(ctx context.Context, id int) (*models.Device, error)

Read returns single device data with given ID.

func (*DevicesStorage) Remove

func (s *DevicesStorage) Remove(ctx context.Context, id int) error

Remove deletes device with given id from storage.

func (*DevicesStorage) Update

func (s *DevicesStorage) Update(ctx context.Context, d models.Device) error

Update overwrites existing device data.

type Factory

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

Factory implements storage.Factory interface for bolt database.

func New

func New(db *bolt.DB) (*Factory, error)

New returns pointer to new memory storage Factory.

func (Factory) Devices

func (f Factory) Devices() *DevicesStorage

func (Factory) Users

func (f Factory) Users() *UsersStorage

Users returns storage interface for manipulating users data.

type UsersStorage

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

UsersStorage implements storage.Users interface for bolt database.

func (*UsersStorage) All

func (s *UsersStorage) All(ctx context.Context) ([]models.User, error)

All returns slice with all users from storage.

func (*UsersStorage) New

func (s *UsersStorage) New(ctx context.Context, newUser models.User) (int, error)

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

func (*UsersStorage) Read

func (s *UsersStorage) Read(ctx context.Context, id int) (*models.User, error)

Read returns single user data with given ID.

func (*UsersStorage) Remove

func (s *UsersStorage) Remove(ctx context.Context, id int) error

Remove deletes user with given id from storage.

func (*UsersStorage) Update

func (s *UsersStorage) Update(ctx context.Context, u models.User) error

Update overwrites existing user data.

func (*UsersStorage) UpdateMany

func (s *UsersStorage) UpdateMany(ctx context.Context, u []models.User) error

UpdateMany overwrites data of all users in given slice.

Jump to

Keyboard shortcuts

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