database

package
v0.4.0 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

View Source
const ARTICLE_COLLECTION = "articles_cache"
View Source
const GUILD_COLLECTION = "discord_guilds"

Variables

View Source
var Client *mongo.Client

Functions

func Connect

func Connect(mongodbConfig MongodbConfig) (err error)

func InsertArticle added in v0.3.0

func InsertArticle(ctx context.Context, article Article) error

Types

type Article added in v0.3.0

type Article struct {
	ID        string `json:"id,omitempty" bson:"_id,omitempty"`
	ArticleID string `json:"article_id,omitempty" bson:"article_id,omitempty"`
	Link      string `json:"link,omitempty" bson:"link,omitempty"`
	ChangedAt int64  `json:"changed_at" bson:"changed_at"`
}
func FindArticleByLink(link string) (*Article, error)

type ChannelSubjects added in v0.3.0

type ChannelSubjects struct {
	ChannelID string   `json:"channelId" bson:"channelId,omitempty"`
	Subjects  []string `json:"subjects" bson:"subjects,omitempty"`
}

type Guild

type Guild struct {
	ID              string            `json:"id,omitempty" bson:"_id,omitempty"`
	GuildID         string            `json:"guildId,omitempty" bson:"guildId,omitempty"`
	Name            string            `json:"name" bson:"name,omitempty"`
	Settings        Settings          `json:"Settings" bson:"Settings,omitempty"`
	ChannelSubjects []ChannelSubjects `json:"channelSubjects" bson:"channelSubjects,omitempty"`
	ChangedAt       int64             `json:"changed_at" bson:"changed_at"`
}

func FindGuildByGuildID added in v0.3.0

func FindGuildByGuildID(guildID string) (Guild, error)

func GetAllGuilds

func GetAllGuilds() (guilds []Guild, err error)

func InsertGuild

func InsertGuild(g Guild) (Guild, error)

func NewGuild

func NewGuild(guildID, name string) Guild

func (*Guild) AddChannelSubject added in v0.3.0

func (g *Guild) AddChannelSubject(channelID string, subject string)

func (*Guild) RemoveChannelSubject added in v0.4.0

func (g *Guild) RemoveChannelSubject(channelID string, subject string)

func (Guild) Save added in v0.3.0

func (g Guild) Save() error

type MongoCollections

type MongoCollections struct {
	Guild   *mongo.Collection
	Article *mongo.Collection
}

type MongodbConfig

type MongodbConfig struct {
	Uri    string
	DbName string
}

type Settings added in v0.3.0

type Settings struct {
	Active bool `json:"active" bson:"active"`
}

Jump to

Keyboard shortcuts

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