models

package
v0.0.0-...-41d384d Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNotification

func CreateNotification(notification Notification) error

func CreateUser

func CreateUser(user User) error

func DeleteComment

func DeleteComment(commentID primitive.ObjectID) error

func DeletePost

func DeletePost(postID primitive.ObjectID) error

func GetUnreadNotifications

func GetUnreadNotifications(userID primitive.ObjectID) (int64, error)

func UpdateNotification

func UpdateNotification(notificationID primitive.ObjectID, read bool) error

Types

type Comment

type Comment struct {
	ID        primitive.ObjectID   `bson:"_id" json:"id"`
	CreatedAt primitive.Timestamp  `bson:"created_at" json:"created_at"`
	UpdatedAt primitive.Timestamp  `bson:"updated_at" json:"updated_at"`
	Post      primitive.ObjectID   `bson:"post" json:"post"`
	Author    primitive.ObjectID   `bson:"author" json:"author"`
	Content   string               `bson:"content" json:"content"`
	Likes     []primitive.ObjectID `bson:"likes" json:"likes"`
}

func CreateComment

func CreateComment(comment Comment) (Comment, error)

func GetCommentByID

func GetCommentByID(commentID primitive.ObjectID) (Comment, error)

func GetCommentsByPostID

func GetCommentsByPostID(postID primitive.ObjectID, limit, offset int64) ([]Comment, error)

func UpdateComment

func UpdateComment(commentID primitive.ObjectID, update bson.M) (Comment, error)

type CommentResponse

type CommentResponse struct {
	Message string                 `json:"message"`
	Comment CommentResponseContent `json:"comment"`
}

type CommentResponseAuthor

type CommentResponseAuthor struct {
	ID          primitive.ObjectID  `json:"id"`
	CreatedAt   primitive.Timestamp `json:"created_at"`
	Role        string              `json:"role"`
	DisplayName string              `json:"display_name"`
	Username    string              `json:"username"`
	About       string              `json:"about,omitempty"`
	Points      uint                `json:"points"`
}

type CommentResponseContent

type CommentResponseContent struct {
	ID        primitive.ObjectID    `json:"id"`
	CreatedAt primitive.Timestamp   `json:"created_at"`
	UpdatedAt primitive.Timestamp   `json:"updated_at"`
	Post      primitive.ObjectID    `json:"post"`
	Author    CommentResponseAuthor `json:"author"`
	Content   string                `json:"content"`
	Likes     []primitive.ObjectID  `json:"likes"`
}

type Notification

type Notification struct {
	ID           primitive.ObjectID  `bson:"_id" json:"id"`
	CreatedAt    primitive.Timestamp `bson:"created_at" json:"created_at"`
	TargetUserID primitive.ObjectID  `bson:"target_user_id" json:"target_user_id"`
	SourceUserID primitive.ObjectID  `bson:"source_user_id" json:"source_user_id"`
	Type         string              `bson:"type" json:"type"`
	TypeContent  string              `bson:"type_content" json:"type_content"`
	Read         bool                `bson:"read" json:"read"`
}

func GetNotificationByID

func GetNotificationByID(notificationID primitive.ObjectID) (notification Notification, err error)

func GetNotifications

func GetNotifications(limit, offset int64, userID primitive.ObjectID) ([]Notification, error)

type Post

type Post struct {
	ID        primitive.ObjectID   `bson:"_id" json:"id"`
	CreatedAt primitive.Timestamp  `bson:"created_at" json:"created_at"`
	UpdatedAt primitive.Timestamp  `bson:"updated_at" json:"updated_at"`
	Author    primitive.ObjectID   `bson:"author" json:"author"`
	Content   string               `bson:"content" json:"content"`
	Likes     []primitive.ObjectID `bson:"likes" json:"likes"`
	Comments  uint                 `bson:"comments" json:"comments"`
}

func CreatePost

func CreatePost(post Post) (Post, error)

func GetPostByID

func GetPostByID(postID primitive.ObjectID) (post Post, err error)

func GetPosts

func GetPosts(limit, offset int64, filter, sort bson.M) ([]Post, error)

func UpdatePost

func UpdatePost(postID primitive.ObjectID, update bson.M) (Post, error)

type PostResponse

type PostResponse struct {
	Message string              `json:"message"`
	Post    PostResponseContent `json:"post"`
}

type PostResponseAuthor

type PostResponseAuthor struct {
	ID          primitive.ObjectID  `json:"id"`
	CreatedAt   primitive.Timestamp `json:"created_at"`
	Role        string              `json:"role"`
	DisplayName string              `json:"display_name"`
	Username    string              `json:"username"`
	About       string              `json:"about,omitempty"`
	Points      uint                `json:"points"`
}

type PostResponseContent

type PostResponseContent struct {
	ID        primitive.ObjectID   `json:"id"`
	CreatedAt primitive.Timestamp  `json:"created_at"`
	UpdatedAt primitive.Timestamp  `json:"updated_at"`
	Author    PostResponseAuthor   `json:"author"`
	Content   string               `json:"content"`
	Likes     []primitive.ObjectID `json:"likes"`
	Comments  uint                 `json:"comments"`
}

type User

type User struct {
	ID          primitive.ObjectID   `bson:"_id" json:"id"`
	CreatedAt   primitive.Timestamp  `bson:"created_at" json:"created_at"`
	IsBanned    bool                 `bson:"is_banned" json:"is_banned,omitempty"`
	Role        string               `bson:"role" json:"role,omitempty"`
	Email       string               `bson:"email" json:"email,omitempty"`
	DisplayName string               `bson:"display_name" json:"display_name"`
	Username    string               `bson:"username" json:"username"`
	Password    string               `bson:"password" json:"password,omitempty"`
	About       string               `bson:"about" json:"about"`
	Points      uint                 `bson:"points" json:"points"`
	Followers   []primitive.ObjectID `bson:"followers" json:"followers"`
	Following   []primitive.ObjectID `bson:"following" json:"following"`
}

func GetUserByEmail

func GetUserByEmail(email string) (user User, err error)

func GetUserByID

func GetUserByID(id primitive.ObjectID) (user User, err error)

func GetUserByUsername

func GetUserByUsername(username string) (user User, err error)

func GetUsers

func GetUsers(limit, offset int64, filter bson.M, sort bson.M) ([]User, error)

func UpdateUser

func UpdateUser(userID primitive.ObjectID, update bson.M) (User, error)

Jump to

Keyboard shortcuts

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