mongo

package
v0.0.0-...-e6dd299 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDBDriver

type MongoDBDriver struct {
	// External data
	DbHost string
	DbPort int
	DbUser string
	DbPass string
	DbName string

	// Internal data
	Db *mongo.Client
}

MongoDBDriver represents the MongoDB database driver

func NewMongoDBDriver

func NewMongoDBDriver(host string, port int, user string, pass string, dbName string, logger zerolog.Logger) *MongoDBDriver

NewMongoDBDriver creates a new instance of MongoDBDriver

func (*MongoDBDriver) Close

func (m *MongoDBDriver) Close() error

Close closes the connection to the database

func (*MongoDBDriver) Connect

func (m *MongoDBDriver) Connect() error

Connect establishes a connection to the database

func (*MongoDBDriver) DeleteUserData

func (m *MongoDBDriver) DeleteUserData(accountID string) error

DeleteUserData deletes a user data record from the database

func (*MongoDBDriver) GetUserData

func (m *MongoDBDriver) GetUserData(accountID string) (string, time.Time, error)

GetUserData retrieves a user data record from the database

func (*MongoDBDriver) InsertUserData

func (m *MongoDBDriver) InsertUserData(accountID string, data string) error

InsertUserData inserts a new user data record into the database

func (*MongoDBDriver) Migrate

func (m *MongoDBDriver) Migrate() error

Migrate the schema to the database

type UserData

type UserData struct {
	ID        uint      `bson:"_id,omitempty"`
	AccountID string    `bson:"account_id"`
	Timestamp time.Time `bson:"timestamp"`
	Data      string    `bson:"data"`
}

UserData model

Jump to

Keyboard shortcuts

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