database

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: CC-BY-4.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormDatabase

type GormDatabase struct {
	DB *gorm.DB
}

GormDatabase is a wrapper for the gorm framework.

func New

func New(dialect, connection, defaultUser, defaultPass string, strength int, createDefaultUserIfNotExist bool) (*GormDatabase, error)

New creates a new wrapper for the gorm database framework.

func (*GormDatabase) Close

func (d *GormDatabase) Close()

Close closes the gorm database connection.

func (*GormDatabase) CountUser

func (d *GormDatabase) CountUser(condition ...interface{}) (int, error)

CountUser returns the user count which satisfies the given condition.

func (*GormDatabase) CreateApplication

func (d *GormDatabase) CreateApplication(application *model.Application) error

CreateApplication creates an application.

func (*GormDatabase) CreateClient

func (d *GormDatabase) CreateClient(client *model.Client) error

CreateClient creates a client.

func (*GormDatabase) CreateMessage

func (d *GormDatabase) CreateMessage(message *model.Message) error

CreateMessage creates a message.

func (*GormDatabase) CreatePluginConf

func (d *GormDatabase) CreatePluginConf(p *model.PluginConf) error

CreatePluginConf creates a new plugin configuration.

func (*GormDatabase) CreateUser

func (d *GormDatabase) CreateUser(user *model.User) error

CreateUser creates a user.

func (*GormDatabase) DeleteApplicationByID

func (d *GormDatabase) DeleteApplicationByID(id uint) error

DeleteApplicationByID deletes an application by its id.

func (*GormDatabase) DeleteClientByID

func (d *GormDatabase) DeleteClientByID(id uint) error

DeleteClientByID deletes a client by its id.

func (*GormDatabase) DeleteMessageByID

func (d *GormDatabase) DeleteMessageByID(id uint) error

DeleteMessageByID deletes a message by its id.

func (*GormDatabase) DeleteMessagesByApplication

func (d *GormDatabase) DeleteMessagesByApplication(applicationID uint) error

DeleteMessagesByApplication deletes all messages from an application.

func (*GormDatabase) DeleteMessagesByUser

func (d *GormDatabase) DeleteMessagesByUser(userID uint) error

DeleteMessagesByUser deletes all messages from a user.

func (*GormDatabase) DeletePluginConfByID

func (d *GormDatabase) DeletePluginConfByID(id uint) error

DeletePluginConfByID deletes a plugin configuration by its id.

func (*GormDatabase) DeleteUserByID

func (d *GormDatabase) DeleteUserByID(id uint) error

DeleteUserByID deletes a user by its id.

func (*GormDatabase) GetApplicationByID

func (d *GormDatabase) GetApplicationByID(id uint) (*model.Application, error)

GetApplicationByID returns the application for the given id or nil.

func (*GormDatabase) GetApplicationByToken

func (d *GormDatabase) GetApplicationByToken(token string) (*model.Application, error)

GetApplicationByToken returns the application for the given token or nil.

func (*GormDatabase) GetApplicationsByUser

func (d *GormDatabase) GetApplicationsByUser(userID uint) ([]*model.Application, error)

GetApplicationsByUser returns all applications from a user.

func (*GormDatabase) GetClientByID

func (d *GormDatabase) GetClientByID(id uint) (*model.Client, error)

GetClientByID returns the client for the given id or nil.

func (*GormDatabase) GetClientByToken

func (d *GormDatabase) GetClientByToken(token string) (*model.Client, error)

GetClientByToken returns the client for the given token or nil.

func (*GormDatabase) GetClientsByUser

func (d *GormDatabase) GetClientsByUser(userID uint) ([]*model.Client, error)

GetClientsByUser returns all clients from a user.

func (*GormDatabase) GetMessageByID

func (d *GormDatabase) GetMessageByID(id uint) (*model.Message, error)

GetMessageByID returns the messages for the given id or nil.

func (*GormDatabase) GetMessagesByApplication

func (d *GormDatabase) GetMessagesByApplication(tokenID uint) ([]*model.Message, error)

GetMessagesByApplication returns all messages from an application.

func (*GormDatabase) GetMessagesByApplicationSince

func (d *GormDatabase) GetMessagesByApplicationSince(appID uint, limit int, since uint) ([]*model.Message, error)

GetMessagesByApplicationSince returns limited messages from an application. If since is 0 it will be ignored.

func (*GormDatabase) GetMessagesByUser

func (d *GormDatabase) GetMessagesByUser(userID uint) ([]*model.Message, error)

GetMessagesByUser returns all messages from a user.

func (*GormDatabase) GetMessagesByUserSince

func (d *GormDatabase) GetMessagesByUserSince(userID uint, limit int, since uint) ([]*model.Message, error)

GetMessagesByUserSince returns limited messages from a user. If since is 0 it will be ignored.

func (*GormDatabase) GetPluginConfByApplicationID

func (d *GormDatabase) GetPluginConfByApplicationID(appid uint) (*model.PluginConf, error)

GetPluginConfByApplicationID gets plugin configuration by its internal appid.

func (*GormDatabase) GetPluginConfByID

func (d *GormDatabase) GetPluginConfByID(id uint) (*model.PluginConf, error)

GetPluginConfByID gets plugin configuration by plugin ID.

func (*GormDatabase) GetPluginConfByToken

func (d *GormDatabase) GetPluginConfByToken(token string) (*model.PluginConf, error)

GetPluginConfByToken gets plugin configuration by plugin token.

func (*GormDatabase) GetPluginConfByUser

func (d *GormDatabase) GetPluginConfByUser(userid uint) ([]*model.PluginConf, error)

GetPluginConfByUser gets plugin configurations from a user.

func (*GormDatabase) GetPluginConfByUserAndPath

func (d *GormDatabase) GetPluginConfByUserAndPath(userid uint, path string) (*model.PluginConf, error)

GetPluginConfByUserAndPath gets plugin configuration by user and file name.

func (*GormDatabase) GetUserByID

func (d *GormDatabase) GetUserByID(id uint) (*model.User, error)

GetUserByID returns the user by the given id or nil.

func (*GormDatabase) GetUserByName

func (d *GormDatabase) GetUserByName(name string) (*model.User, error)

GetUserByName returns the user by the given name or nil.

func (*GormDatabase) GetUsers

func (d *GormDatabase) GetUsers() ([]*model.User, error)

GetUsers returns all users.

func (*GormDatabase) Ping

func (d *GormDatabase) Ping() error

Ping pings the database to verify the connection.

func (*GormDatabase) UpdateApplication

func (d *GormDatabase) UpdateApplication(app *model.Application) error

UpdateApplication updates an application.

func (*GormDatabase) UpdateApplicationTokenLastUsed added in v2.4.0

func (d *GormDatabase) UpdateApplicationTokenLastUsed(token string, t *time.Time) error

UpdateApplicationTokenLastUsed updates the last used time of the application token.

func (*GormDatabase) UpdateClient

func (d *GormDatabase) UpdateClient(client *model.Client) error

UpdateClient updates a client.

func (*GormDatabase) UpdateClientTokensLastUsed added in v2.4.0

func (d *GormDatabase) UpdateClientTokensLastUsed(tokens []string, t *time.Time) error

UpdateClientTokensLastUsed updates the last used timestamp of clients.

func (*GormDatabase) UpdatePluginConf

func (d *GormDatabase) UpdatePluginConf(p *model.PluginConf) error

UpdatePluginConf updates plugin configuration.

func (*GormDatabase) UpdateUser

func (d *GormDatabase) UpdateUser(user *model.User) error

UpdateUser updates a user.

Jump to

Keyboard shortcuts

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