db

package
v0.0.0-...-35669d6 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckChat

func CheckChat(user string, chat string) (string, bool)

Checks whether User has access to Chat

func CreateChat

func CreateChat(chat *Chat) error

func GetChatCol

func GetChatCol() *mongo.Collection

func GetCurrUser

func GetCurrUser(claims *jwt.RegisteredClaims, user *User) error

func GetDatabase

func GetDatabase() *mongo.Database

func GetMessageCol

func GetMessageCol() *mongo.Collection

func GetUserByEmail

func GetUserByEmail(email string, user *User) error

func GetUserById

func GetUserById(id primitive.ObjectID, user *User) error

func GetUserChats

func GetUserChats(id primitive.ObjectID, chats *[]Chat) error

func GetUserCol

func GetUserCol() *mongo.Collection

func UpdateChat

func UpdateChat(chat *Chat) error

Types

type Chat

type Chat struct {
	ID     primitive.ObjectID   `bson:"_id" json:"id,"`
	Name   string               `bson:"name,omitempty" json:"name"`
	Users  []primitive.ObjectID `bson:"users,omitempty" json:"users"`
	Public bool                 `bson:"public,omitempty" json:"public" default:"false"`
}

type Message

type Message struct {
	ID         primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	ChatID     primitive.ObjectID `bson:"chat_id,omitempty" json:"chat_id"`
	FromUserID primitive.ObjectID `bson:"from_user_id,omitempty" json:"from_user_id"`
	Message    string             `bson:"message,omitempty" json:"message"`
	Time       primitive.DateTime `bson:"time,omitempty" json:"time"`
}

type User

type User struct {
	ID       primitive.ObjectID `bson:"_id,omitempty" json:"id"`
	Name     string             `bson:"name,omitempty" json:"name"`
	Email    string             `bson:"email,omitempty" json:"email"`
	Password string             `bson:"password,omitempty" json:"password,omitempty"`
}

Jump to

Keyboard shortcuts

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