storage

package
v0.0.0-...-b4e23d6 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMongoDB

func NewMongoDB(connUrl string) (*mongoDB, error)

Types

type Message

type Message struct {
	Id       string `json:"id" bson:"_id"`
	OwnerId  string `json:"owner_id" bson:"owner_id"`
	IsPublic bool   `json:"is_public" bson:"is_public"`
	Content  string `json:"content" bson:"content"`
	Password string `json:"password" bson:"password"`
}

func (Message) IsEmpty

func (m Message) IsEmpty() bool

type MessageReq

type MessageReq struct {
	OwnerId  primitive.ObjectID `json:"owner_id" bson:"owner_id"`
	IsPublic *bool              `json:"is_public" bson:"is_public"`
	Content  *string            `json:"content" bson:"content"`
}

type MessageStorager

type MessageStorager interface {
	AddMessage(m *Message) (string, error)
	ReadMessage(id string) (*Message, error)
	ReadAllMessages(owner_id string) ([]*Message, error)
	DeleteMessage(id string) error
	DeleteAllMessages(owner_id string) error
	Disconnect(ctx context.Context) error
}

type Storager

type Storager interface {
	MessageStorager
	UserStorager
}

type User

type User struct {
	Id       string `json:"id" bson:"_id"`
	Username string `json:"username" bson:"username"`
	Password string `json:"password" bson:"password"`
}

type UserReq

type UserReq struct {
	Username string `json:"username" bson:"username"`
	Password string `json:"password" bson:"password"`
}

type UserStorager

type UserStorager interface {
	AddUser(u *UserReq) error
	ReadUser(u *UserReq) (User, error)
	ReadUserByUsername(username string) (*User, error)
	ReadUserById(id string) (*User, error)
	DeleteUser(id string) error
}

Jump to

Keyboard shortcuts

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