db

package
v0.0.0-...-772c6e4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Adds an item to the List
	AddListItem(ctx context.Context, i ListItem) error

	// Deletes and item from the List
	DeleteListItem(ctx context.Context, i ListItem) (int64, error)

	// Retrieve all items on the List
	GetList(ctx context.Context) ([]ListItem, error)
}

DB is an interface to store and retrieve stateful data

type ListItem

type ListItem struct {
	Name    string `bson:"name"`
	Creator string `bson:"creator"`
}

ListItem contains information necessary for adding and deleting items from 'The List'

type Mongo

type Mongo struct {
	C *mongo.Client
	// contains filtered or unexported fields
}

Mongo implements the DB interface

func NewMongo

func NewMongo(connString string, dbName string) (*Mongo, error)

NewMongo creates a new Mongo object to be used by the bot

func (*Mongo) AddListItem

func (m *Mongo) AddListItem(ctx context.Context, i ListItem) error

AddListItem takes in a context and ListItem and returns an error if the item is not added to the list

func (*Mongo) DeleteListItem

func (m *Mongo) DeleteListItem(ctx context.Context, i ListItem) (int64, error)

DeleteListItem takes in a context and ListItem, returns the number of items deleted and an error

func (*Mongo) GetList

func (m *Mongo) GetList(ctx context.Context) ([]ListItem, error)

GetList takes a context and returns slice of all ListItems and an error

Jump to

Keyboard shortcuts

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