database

package
v0.0.0-...-a4ed614 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHATS_COLLECTION    = "chats"
	PROJECTS_COLLECTION = "projects"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, uri string, dbName string) (*DB, error)

func (*DB) Client

func (db *DB) Client() *mongo.Client

func (*DB) HaveAccess

func (db *DB) HaveAccess(ctx context.Context, userId uint64, projectId uint64) bool

func (*DB) Read

func (db *DB) Read(ctx context.Context, projectId uint64) ([]*Message, error)

func (*DB) Save

func (db *DB) Save(ctx context.Context, message *Message) error

type Message

type Message struct {
	ID        primitive.ObjectID `bson:"_id"`
	ProjectID uint64             `bson:"project_id"`
	UserID    uint64             `bson:"user_id"`
	Message   string             `bson:"message"`
	SendTime  time.Time          `bson:"send_time"`
}

type Project

type Project struct {
	ID    uint64   `bson:"id"`
	Users []uint64 `bson:"users"`
}

type ProjectChatDB

type ProjectChatDB interface {
	Save(ctx context.Context, message *Message) error
	Read(ctx context.Context, projectId uint64) ([]*Message, error)
}

type ProjectManager

type ProjectManager interface {
	Client() *mongo.Client
	ProjectChatDB
	ProjectsDB
}

type ProjectsDB

type ProjectsDB interface {
	HaveAccess(ctx context.Context, userId uint64, projectId uint64) bool
}

Directories

Path Synopsis
Package mock_database is a generated GoMock package.
Package mock_database is a generated GoMock package.

Jump to

Keyboard shortcuts

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