storage

package
v0.0.0-...-bad3c2a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Q = sqload.MustLoadFromString[struct {
	InitDb                      string `query:"InitDb"`
	CreateUser                  string `query:"CreateUser"`
	GetUserById                 string `query:"GetUserById"`
	GetUsers                    string `query:"GetUsers"`
	GetDevicesByMac             string `query:"GetDevicesByMac"`
	GetDeviceById               string `query:"GetDeviceById"`
	GetDevices                  string `query:"GetDevices"`
	GetDevicesByUserId          string `query:"GetDevicesByUserId"`
	UpdateUser                  string `query:"UpdateUser"`
	DeleteUserById              string `query:"DeleteUserById"`
	CreateDevice                string `query:"CreateDevice"`
	UpdateDevice                string `query:"UpdateDevice"`
	DeleteDeviceById            string `query:"DeleteDeviceById"`
	DeleteDeviceByUserId        string `query:"DeleteDeviceByUserId"`
	CreateBandwidthSlot         string `query:"CreateBandwidthSlot"`
	GetBandwidthSlotById        string `query:"GetBandwidthSlotById"`
	GetBandwidthSlots           string `query:"GetBandwidthSlots"`
	GetBandwidthSlotsByUserId   string `query:"GetBandwidthSlotsByUserId"`
	DeleteBandwidthSlotById     string `query:"DeleteBandwidthSlotById"`
	DeleteBandwidthSlotByUserId string `query:"DeleteBandwidthSlotByUserId"`
}](dbScript)

Functions

func ConnectDatabase

func ConnectDatabase(cfg DbConfig) (*sql.DB, error)

Types

type BandwidthSlot

type BandwidthSlot struct {
	Id       int
	UserId   int
	RemoteId int
}

func (BandwidthSlot) GetUser

func (slot BandwidthSlot) GetUser(userStore UserStore) (User, error)

type BandwidthSlotStorage

type BandwidthSlotStorage interface {
	Create(slot *BandwidthSlot) error
	Read(id int) (BandwidthSlot, error)
	ReadMany(pageSize, pageNumber int) ([]BandwidthSlot, error)
	ReadManyByUserId(userId int, pageSize, pageNumber int) ([]BandwidthSlot, error)
	Delete(id int) error
	DeleteByUserId(userId int) error
}

type BandwidthSlotStore

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

func (BandwidthSlotStore) Create

func (s BandwidthSlotStore) Create(slot *BandwidthSlot) error

func (BandwidthSlotStore) Delete

func (s BandwidthSlotStore) Delete(id int) error

func (BandwidthSlotStore) DeleteByUserId

func (s BandwidthSlotStore) DeleteByUserId(userId int) error

func (BandwidthSlotStore) Read

func (s BandwidthSlotStore) Read(id int) (BandwidthSlot, error)

func (BandwidthSlotStore) ReadMany

func (s BandwidthSlotStore) ReadMany(pageSize, pageNumber int) ([]BandwidthSlot, error)

func (BandwidthSlotStore) ReadManyByUserId

func (s BandwidthSlotStore) ReadManyByUserId(userId int, pageSize, pageNumber int) ([]BandwidthSlot, error)

type DbConfig

type DbConfig struct {
	Init bool
	URI  string
}

type Device

type Device struct {
	Id     int
	UserId int
	Alias  string
	Mac    string
	// contains filtered or unexported fields
}

func (Device) GetUser

func (device Device) GetUser(userStore UserStorage) (User, error)

type DeviceStorage

type DeviceStorage interface {
	Create(device *Device) error
	Read(id int) (Device, error)
	ReadMany(pageSize, pageNumber int) ([]Device, error)
	ReadManyByUserId(userId int, pageSize, pageNumber int) ([]Device, error)
	ReadManyByMac(macAddress []string) ([]Device, error)
	Update(device Device) error
	Delete(id int) error
	DeleteByUserId(userId int) error
}

type DeviceStore

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

func (DeviceStore) Create

func (d DeviceStore) Create(device *Device) error

func (DeviceStore) Delete

func (d DeviceStore) Delete(id int) error

func (DeviceStore) DeleteByUserId

func (d DeviceStore) DeleteByUserId(userId int) error

func (DeviceStore) Read

func (d DeviceStore) Read(id int) (Device, error)

func (DeviceStore) ReadMany

func (d DeviceStore) ReadMany(pageSize, pageNumber int) ([]Device, error)

func (DeviceStore) ReadManyByMac

func (d DeviceStore) ReadManyByMac(macAddresses []string) ([]Device, error)

func (DeviceStore) ReadManyByUserId

func (d DeviceStore) ReadManyByUserId(userId int, pageSize, pageNumber int) ([]Device, error)

func (DeviceStore) Update

func (d DeviceStore) Update(device Device) error

type Store

type Store struct {
	UserStore          UserStorage
	DeviceStore        DeviceStorage
	BandwidthSlotStore BandwidthSlotStorage
}

func NewStore

func NewStore(db *sql.DB) *Store

type User

type User struct {
	Id   int
	Name string
}

type UserStorage

type UserStorage interface {
	Create(user *User) error
	Read(id int) (User, error)
	ReadMany(pageSize, pageNumber int) ([]User, error)
	Update(user User) error
	Delete(id int) error
}

type UserStore

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

func (UserStore) Create

func (u UserStore) Create(user *User) error

func (UserStore) Delete

func (u UserStore) Delete(id int) error

func (UserStore) Read

func (u UserStore) Read(id int) (User, error)

func (UserStore) ReadMany

func (u UserStore) ReadMany(pageSize, pageNumber int) ([]User, error)

func (UserStore) Update

func (u UserStore) Update(user User) error

Jump to

Keyboard shortcuts

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