storagesql

package
v0.0.0-...-bc28a72 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

This package holds a default implementation of the storage interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSQLStorageDatabase

func NewSQLStorageDatabase() core.DatabaseStorage

NewSQLStorageDatabase - Create new SQLStorageDatabase instance

func SetConnectionParams

func SetConnectionParams(dbUser string, dbPassword string, dbHost string, dbPort string, db string)

Types

type AppRepository

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

AppRepository - SQL repository for table App

func NewSQLAppRepository

func NewSQLAppRepository(db *DatabaseStorage) *AppRepository

NewSQLAppRepository - Create a new instance of SQLAppRepository

func (*AppRepository) AppExists

func (storage *AppRepository) AppExists(id string) (bool, error)

AppExists - Check if App already exists

func (*AppRepository) CreateApp

func (storage *AppRepository) CreateApp(id string, name string) error

CreateApp - Create a new App row in the database

func (*AppRepository) DeleteApp

func (storage *AppRepository) DeleteApp(id string) error

DeleteApp - Delete App Row in the database

func (*AppRepository) GetApp

func (storage *AppRepository) GetApp(id string) (*core.App, error)

func (*AppRepository) GetApps

func (storage *AppRepository) GetApps() ([]*core.App, error)

GetApps - Get all stored apps in the database

func (*AppRepository) UpdateApp

func (storage *AppRepository) UpdateApp(id string, name string) error

UpdateApp - Update App Row in the database

type ChannelRepository

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

ChannelRepository - SQL repository for tables Channel, Channel_Client and Channel_Event

func NewSQLChannelRepository

func NewSQLChannelRepository(db *DatabaseStorage) *ChannelRepository

NewSQLChannelRepository - Create a new instance of SQLChannelRepository

func (*ChannelRepository) AddChannelEvent

func (repo *ChannelRepository) AddChannelEvent(appID string, channelID string, event *core.ChannelEvent) error

AddChannelEvent - Add event to given channel

func (*ChannelRepository) AddChannelEvents

func (repo *ChannelRepository) AddChannelEvents(items []core.InsertItem) error

AddChannelEvents - UNSUPPORTED

func (*ChannelRepository) CreateChannel

func (repo *ChannelRepository) CreateChannel(id string, appID string, name string, createdAt int64, isClosed bool, extra string, persistent bool, private bool, presence bool, push bool) error

CreateChannel - Insert new channel row

func (*ChannelRepository) DeleteAppChannels

func (repo *ChannelRepository) DeleteAppChannels(appID string) error

DeleteAppChannels - Remove channel row

func (*ChannelRepository) DeleteChannel

func (repo *ChannelRepository) DeleteChannel(appID string, id string) error

DeleteChannel - Remove channel row

func (*ChannelRepository) ExistsAppChannel

func (repo *ChannelRepository) ExistsAppChannel(appID string, channelID string) (bool, error)

ExistsAppChannel - Check if app channel exists

func (*ChannelRepository) GetAllChannels

func (repo *ChannelRepository) GetAllChannels() ([]*core.Channel, error)

GetAllChannels - Get all channels without joined users

func (*ChannelRepository) GetAllChannelsCount

func (repo *ChannelRepository) GetAllChannelsCount() (uint64, error)

GetAllChannelsCount - Get how much clients an App has

func (*ChannelRepository) GetAllPrivateChannels

func (repo *ChannelRepository) GetAllPrivateChannels() ([]*core.Channel, error)

GetAllPrivateChannels - Get all private channels without joined users

func (*ChannelRepository) GetAllPublicChannels

func (repo *ChannelRepository) GetAllPublicChannels() ([]*core.Channel, error)

GetAllPublicChannels - Get all public channels without joined users

func (*ChannelRepository) GetAppChannel

func (repo *ChannelRepository) GetAppChannel(appID string, channelID string) (*core.Channel, error)

GetAppChannel - Get channel with given AppID and ChannelID

func (*ChannelRepository) GetAppChannels

func (repo *ChannelRepository) GetAppChannels(appID string) ([]*core.Channel, error)

GetAppChannels - Get all app channels without joined users

func (*ChannelRepository) GetAppChannelsCount

func (repo *ChannelRepository) GetAppChannelsCount(appID string) (uint64, error)

GetAppChannelsCount - Get how much clients an App has

func (*ChannelRepository) GetAppPrivateChannels

func (repo *ChannelRepository) GetAppPrivateChannels(appID string) ([]*core.Channel, error)

GetAppPrivateChannels - Get all app private channels without joined users

func (*ChannelRepository) GetAppPublicChannels

func (repo *ChannelRepository) GetAppPublicChannels(appID string) ([]*core.Channel, error)

GetAppPublicChannels - Get all app public channels without joined users

func (*ChannelRepository) GetChannelClients

func (repo *ChannelRepository) GetChannelClients(appID string, channelID string) ([]string, error)

GetChannelClients - Get channel clients

func (*ChannelRepository) GetChannelEventsAfter

func (repo *ChannelRepository) GetChannelEventsAfter(appID string, channelID string, timestamp int64) ([]*core.ChannelEvent, error)

GetChannelEventsAfter - Get all events after given timestamp

func (*ChannelRepository) GetChannelEventsAfterAndBefore

func (repo *ChannelRepository) GetChannelEventsAfterAndBefore(appID string, channelID string, timestampAfter int64, timestampBefore int64) ([]*core.ChannelEvent, error)

GetChannelEventsAfterAndBefore - Get all events between given timestamps

func (*ChannelRepository) GetChannelLastEvents

func (repo *ChannelRepository) GetChannelLastEvents(appID string, channelID string, amount int64) ([]*core.ChannelEvent, error)

GetChannelLastEvents - Get last events

func (*ChannelRepository) GetChannelLastEventsAfter

func (repo *ChannelRepository) GetChannelLastEventsAfter(appID string, channelID string, amount int64, timestamp int64) ([]*core.ChannelEvent, error)

GetChannelLastEventsAfter - Get an given amount events after given timestamp

func (*ChannelRepository) GetChannelLastEventsBefore

func (repo *ChannelRepository) GetChannelLastEventsBefore(appID string, channelID string, amount int64, timestamp int64) ([]*core.ChannelEvent, error)

GetChannelLastEventsAfter - Get an given amount events after given timestamp

func (*ChannelRepository) GetClientAllowedChannels

func (repo *ChannelRepository) GetClientAllowedChannels(clientID string) ([]string, error)

GetClientAllowedChannels - Get all allowed channels for the given client, including public and private

func (*ChannelRepository) GetClientPrivateChannels

func (repo *ChannelRepository) GetClientPrivateChannels(clientID string) ([]*core.Channel, error)

GetClientPrivateChannels - Get all client private channels

func (*ChannelRepository) GetClientPublicChannels

func (repo *ChannelRepository) GetClientPublicChannels(clientID string) ([]*core.Channel, error)

GetClientPublicChannels - Get all client public channels

func (*ChannelRepository) JoinClient

func (repo *ChannelRepository) JoinClient(appID string, channelID string, clientID string) error

JoinClient - Add client to channel

func (*ChannelRepository) LeaveClient

func (repo *ChannelRepository) LeaveClient(appID string, channelID string, clientID string) error

LeaveClient - Remove client to channel

func (*ChannelRepository) SetChannelCloseStatus

func (repo *ChannelRepository) SetChannelCloseStatus(appID string, channelID string, isClosed bool) error

SetChannelCloseStatus - Set channel closed or open

type ClientRepository

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

ClientRepository - SQL implementation of client repository

func NewSQLClientRepository

func NewSQLClientRepository(db *DatabaseStorage) *ClientRepository

NewSQLClientRepository - Create a new instance of SQLClientRepository

func (*ClientRepository) CreateClient

func (repo *ClientRepository) CreateClient(id string, username string, appID string, extra string) error

CreateClient - Insert new client row

func (*ClientRepository) DeleteAppClients

func (repo *ClientRepository) DeleteAppClients(appID string) error

DeleteAppClients - Remove all clients that belong to the given appID

func (*ClientRepository) DeleteClient

func (repo *ClientRepository) DeleteClient(id string) error

DeleteClient - Remove client row with given id

func (*ClientRepository) ExistsAppClient

func (repo *ClientRepository) ExistsAppClient(AppID string, ClientID string) (bool, error)

ExistsAppClient - Get app client

func (*ClientRepository) GetAllClients

func (repo *ClientRepository) GetAllClients() ([]*core.Client, error)

GetAllClients - Get all Apps clients

func (*ClientRepository) GetAllClientsCount

func (repo *ClientRepository) GetAllClientsCount() (uint64, error)

GetAllClientsCount - Get how much clients an App has

func (*ClientRepository) GetAppClient

func (repo *ClientRepository) GetAppClient(AppID string, ClientID string) (*core.Client, error)

GetAppClient - Get app client

func (*ClientRepository) GetAppClients

func (repo *ClientRepository) GetAppClients(appID string) ([]*core.Client, error)

GetAppClients - Get all App clients

func (*ClientRepository) GetAppClientsCount

func (repo *ClientRepository) GetAppClientsCount(appID string) (uint64, error)

GetAppClientsCount - Get how much clients an App has

func (*ClientRepository) GetClientExtra

func (repo *ClientRepository) GetClientExtra(id string) (string, error)

GetClientExtra - Get column Extra of the client

func (*ClientRepository) UpdateClient

func (repo *ClientRepository) UpdateClient(id string, username string, extra string) error

UpdateClient - Update Client Username and Extra

func (*ClientRepository) UpdateClientExtra

func (repo *ClientRepository) UpdateClientExtra(id string, extra string) error

UpdateClientExtra - Update Client Extra

func (*ClientRepository) UpdateClientUsername

func (repo *ClientRepository) UpdateClientUsername(id string, username string) error

UpdateClientUsername - Update Client Username

type DatabaseStorage

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

DatabaseStorage - DatabaseStorage implementation using SQL Database

func (*DatabaseStorage) GetAppRepository

func (storage *DatabaseStorage) GetAppRepository() core.AppRepository

GetAppRepository - Get SQL implementation of AppRepository

func (*DatabaseStorage) GetChannelRepository

func (storage *DatabaseStorage) GetChannelRepository() core.ChannelRepository

GetChannelRepository - Get SQL implementation of ChannelRepository

func (*DatabaseStorage) GetClientRepository

func (storage *DatabaseStorage) GetClientRepository() core.ClientRepository

GetClientRepository - Get SQL implementation of ClientRepository

func (*DatabaseStorage) GetDB

func (storage *DatabaseStorage) GetDB() *sql.DB

func (*DatabaseStorage) GetDeviceRepository

func (storage *DatabaseStorage) GetDeviceRepository() core.DeviceRepository

GetDeviceRepository - Get SQL implementation of DeviceRepository

type DeviceRepository

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

DeviceRepository - SQL repository for table Device

func NewSQLDeviceRepository

func NewSQLDeviceRepository(db *DatabaseStorage) *DeviceRepository

NewSQLDeviceRepository - Create a new instance of SQLDeviceRepository

func (*DeviceRepository) CreateDevice

func (repo *DeviceRepository) CreateDevice(id string, token string, clientID string) error

CreateDevice - Insert a new device

func (*DeviceRepository) DeleteClientDevices

func (repo *DeviceRepository) DeleteClientDevices(clientID string) error

DeleteClientDevices - Delete all client devices

func (*DeviceRepository) DeleteDevice

func (repo *DeviceRepository) DeleteDevice(id string) error

DeleteDevice - Delete a device

func (*DeviceRepository) GetClientDeviceTokens

func (repo *DeviceRepository) GetClientDeviceTokens(clientID string) ([]string, error)

GetClientDeviceTokens - Get all client device tokens

func (*DeviceRepository) GetClientDevices

func (repo *DeviceRepository) GetClientDevices(clientID string) ([]*core.Device, error)

GetClientDevices - Get all client devices

func (*DeviceRepository) GetClientsDeviceTokens

func (repo *DeviceRepository) GetClientsDeviceTokens(clientIDs []string, amount int) ([]string, error)

GetClientsDeviceTokens - Get all clients device tokens up to given amount

func (*DeviceRepository) GetDevice

func (repo *DeviceRepository) GetDevice(id string) (*core.Device, error)

GetDevice - Get device

Jump to

Keyboard shortcuts

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