mongodb

package
v0.0.0-...-4440d16 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserModel

type UserModel struct {
	C *mongo.Collection
}

UserModel wraps a mongo collection and provides methods to query it

func (*UserModel) All

func (m *UserModel) All() ([]models.User, error)

All returns all users

func (*UserModel) FindByEmail

func (m *UserModel) FindByEmail(email string) (*models.User, error)

FindByEmail finds a user by email

func (*UserModel) FindById

func (m *UserModel) FindById(id string) (*models.User, error)

FindByID finds a user by id

func (*UserModel) FindByUsername

func (m *UserModel) FindByUsername(username string) (*models.User, error)

FindByUsername finds a user by username

func (*UserModel) InsertUser

func (m *UserModel) InsertUser(user *models.User) (*mongo.InsertOneResult, error)

InsertUser inserts a new user to the database

func (*UserModel) UpdateUser

func (m *UserModel) UpdateUser(user *models.User) (*mongo.UpdateResult, error)

UpdateUser updates the user with the given id when posts, comments or subscribes are added/removed/updated

Jump to

Keyboard shortcuts

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