helpers

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 12 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

func Create2dsphere

func Create2dsphere(mconn models.DBInfo) (db *mongo.Database)

func Decode

func Decode(publickey, tokenstr string) (payload models.Payload, err error)

func DecodeGetName

func DecodeGetName(publickey string, tokenstring string) string

func DecodeGetRole

func DecodeGetRole(publickey string, tokenstring string) string

func DecodeGetUsername

func DecodeGetUsername(publickey string, tokenstring string) string

func DeleteDoc

func DeleteDoc(db *mongo.Database, collection string, filter bson.M) (result *mongo.DeleteResult)

func DeleteOneDoc

func DeleteOneDoc(db *mongo.Database, collection string, filter bson.M) (result *mongo.DeleteResult)

func DocExists

func DocExists[T any](db *mongo.Database, collname string, filter bson.M, doc T) (result bool)

func Encode

func Encode(name, username, role, privatekey string) (string, error)

func GenerateKey

func GenerateKey() (privatekey, publickey string)

func GetAllDistinctDoc

func GetAllDistinctDoc(db *mongo.Database, filter bson.M, fieldname, collection string) (doc []any)

func GetAllDoc

func GetAllDoc[T any](db *mongo.Database, collection string) (doc []T, err error)

func GetAllDocByFilter

func GetAllDocByFilter[T any](db *mongo.Database, collection string, filter bson.M) (doc []T, err error)

func GetBoxDoc

func GetBoxDoc[T any](db *mongo.Database, collname, locfield string, geospatial models.Geospatial) (result []T, err error)

func GetCenterDoc added in v1.0.8

func GetCenterDoc[T any](db *mongo.Database, collname, locfield string, geospatial models.Geospatial) (result []T, err error)

func GetCenterSphereDoc added in v1.0.8

func GetCenterSphereDoc[T any](db *mongo.Database, collname, locfield string, geospatial models.Geospatial) (result []T, err error)

func GetGeoIntersectsDoc

func GetGeoIntersectsDoc[T any](db *mongo.Database, collname, locfield string, geospatial models.Geospatial) (result []T, err error)

func GetGeoWithinDoc

func GetGeoWithinDoc[T any](db *mongo.Database, collname, locfield string, geospatial models.Geospatial) (result []T, err error)

func GetNearDoc

func GetNearDoc[T any](db *mongo.Database, collname, locfield string, geospatial models.Geospatial) (result []T, err error)

func GetNearSphereDoc

func GetNearSphereDoc[T any](db *mongo.Database, collname, locfield string, geospatial models.Geospatial) (result []T, err error)

func GetOneDoc

func GetOneDoc[T any](db *mongo.Database, collection string, filter bson.M) (doc T)

func GetOneLatestDoc

func GetOneLatestDoc[T any](db *mongo.Database, collection string, filter bson.M) (doc T, err error)

func GetRandomDoc

func GetRandomDoc[T any](db *mongo.Database, collection string, size uint) (result []T, err error)

func HashPassword

func HashPassword(password string) (string, error)

func InsertOneDoc

func InsertOneDoc(db *mongo.Database, collection string, doc interface{}) (insertedID interface{}, err error)

func MongoConnect

func MongoConnect(mconn models.DBInfo) (db *mongo.Database)

func PostgresConnect added in v1.2.1

func PostgresConnect(pconn models.PostgresInfo) *sql.DB

func ReplaceOneDoc

func ReplaceOneDoc(db *mongo.Database, collection string, filter bson.M, doc interface{}) (updatereseult *mongo.UpdateResult)

Types

This section is empty.

Jump to

Keyboard shortcuts

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