database

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDataNotFound = errors.New("database: row or document data not found")

ErrDataNotFound is a reusable error that can be used by different database implementations to denote that a row or document was not found.

Functions

This section is empty.

Types

type Database

type Database interface {
	Connect() error
	Disconnect() error
	ReadServerSettings(guildId string) (models.ServerSettings, error)
	UpdateServerSettings(settings *models.ServerSettings) error
	DeleteServerSettings(guildId string) error
}

type MemoryDatabase

type MemoryDatabase struct {
	// Aternos discord cookie (ATERNOS_SESSION).
	SessionCookie string

	// Aternos server cookie (ATERNOS_SERVER).
	ServerCookie string
}

MemoryDatabase is a simple in-memory database. Useful if you just want to self-host a bot for one discord server.

func NewInMemory

func NewInMemory(session string, server string) *MemoryDatabase

func (*MemoryDatabase) Connect

func (m *MemoryDatabase) Connect() error

func (*MemoryDatabase) DeleteServerSettings added in v0.2.2

func (m *MemoryDatabase) DeleteServerSettings(guildId string) error

func (*MemoryDatabase) Disconnect

func (m *MemoryDatabase) Disconnect() error

func (*MemoryDatabase) ReadServerSettings added in v0.2.2

func (m *MemoryDatabase) ReadServerSettings(guildId string) (models.ServerSettings, error)

func (*MemoryDatabase) UpdateServerSettings added in v0.2.2

func (m *MemoryDatabase) UpdateServerSettings(settings *models.ServerSettings) error

type MongoDb

type MongoDb struct {
	// MongoDB's connection URI string.
	ConnectionURI string

	// Name of the database to use.
	// Defaults to `aternos-discord-bot`
	DatabaseName string

	// Connection timeout.
	//
	// Defaults to 10 seconds.
	ConnectionTimeout time.Duration
	// contains filtered or unexported fields
}

func NewMongo

func NewMongo(uri string) *MongoDb

func (*MongoDb) Connect

func (db *MongoDb) Connect() error

func (*MongoDb) DeleteServerSettings added in v0.2.2

func (db *MongoDb) DeleteServerSettings(guildId string) error

func (*MongoDb) Disconnect

func (db *MongoDb) Disconnect() error

func (*MongoDb) ReadServerSettings added in v0.2.2

func (db *MongoDb) ReadServerSettings(guildId string) (models.ServerSettings, error)

func (*MongoDb) UpdateServerSettings added in v0.2.2

func (db *MongoDb) UpdateServerSettings(settings *models.ServerSettings) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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