utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JwtKey = []byte("your_secret_key")

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func GCFReturnStruct

func GCFReturnStruct(DataStuct any) string

func GenerateJWT

func GenerateJWT(email, role, secretKey string) (string, error)

func GetAllDocs

func GetAllDocs[T any](db *mongo.Database, col string, filter bson.M) (docs T, err error)

func GetUserFromEmail

func GetUserFromEmail(email string, db *mongo.Database) (doc models.User, err error)

func GetUserFromID

func GetUserFromID(_id primitive.ObjectID, db *mongo.Database) (doc models.User, err error)

func InsertOneDoc

func InsertOneDoc(db *mongo.Database, col string, doc any) (insertedID primitive.ObjectID, err error)

func MongoConnect

func MongoConnect(mconn DBInfo) (db *mongo.Database, err error)

func SetConnection

func SetConnection(MONGOCONNSTRINGENV, dbname string) *mongo.Database

Types

type Claims

type Claims struct {
	Email string `json:"email"`
	Role  string `json:"role"`
	jwt.StandardClaims
}

type DBInfo

type DBInfo struct {
	DBString string
	DBName   string
}

Jump to

Keyboard shortcuts

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