Documentation ¶
Index ¶
- Constants
- Variables
- func CollFactory(collectionName string) func() *mongo.Collection
- func ExtractValue(v reflect.Value) interface{}
- func GetClient() *mongo.Client
- func GetDatabase() *mongo.Database
- func GetUpdate(ty reflect.Type, fieldName string, v1 reflect.Value, v2 reflect.Value) *bson.E
- func Initialize(cfgPath string, pDatabaseName string)
- func MakeUpdateStatements[A any](o A, n A) bson.D
- func MkUpdateSetStatement[A any](o A, n A) bson.D
- func Shutdown()
- func ToOID(id string) *primitive.ObjectID
- type Entity
- type Initializable
- type MongoCRUD
- type MongoCRUDRepo
- func (m MongoCRUDRepo[A]) Create(b A) (*mongo.InsertOneResult, error)
- func (m MongoCRUDRepo[A]) DeleteById(id string) int64
- func (it *MongoCRUDRepo[A]) Init(collectionName string) *MongoCRUDRepo[A]
- func (m MongoCRUDRepo[A]) RetrieveByFilter(filter *bson.D) ([]A, error)
- func (m MongoCRUDRepo[A]) RetrieveById(oid primitive.ObjectID) *A
- func (m MongoCRUDRepo[A]) RetrieveWithLimit(filter *bson.D, limit int) ([]A, error)
- func (m MongoCRUDRepo[A]) UpdateById(id *primitive.ObjectID) UpdateFn
- type ReflectiveGet
- type UpdateFn
Constants ¶
View Source
const ( SET = "$set" BSON = "bson" OID = "_id" )
Variables ¶
View Source
var ( RegexEnvFile *regexp.Regexp RegexDatabase *regexp.Regexp )
View Source
var HexRegex *regexp.Regexp
Functions ¶
func CollFactory ¶
func CollFactory(collectionName string) func() *mongo.Collection
func ExtractValue ¶
func GetDatabase ¶
func Initialize ¶
func MakeUpdateStatements ¶
func MkUpdateSetStatement ¶
Types ¶
type Initializable ¶
type Initializable[A any] interface { Init() Initializable[A] }
type MongoCRUDRepo ¶
type MongoCRUDRepo[A any] struct { Coll *mongo.Collection // contains filtered or unexported fields }
func (MongoCRUDRepo[A]) Create ¶
func (m MongoCRUDRepo[A]) Create(b A) (*mongo.InsertOneResult, error)
func (MongoCRUDRepo[A]) DeleteById ¶
func (m MongoCRUDRepo[A]) DeleteById(id string) int64
func (*MongoCRUDRepo[A]) Init ¶
func (it *MongoCRUDRepo[A]) Init(collectionName string) *MongoCRUDRepo[A]
func (MongoCRUDRepo[A]) RetrieveByFilter ¶
func (m MongoCRUDRepo[A]) RetrieveByFilter(filter *bson.D) ([]A, error)
func (MongoCRUDRepo[A]) RetrieveById ¶
func (m MongoCRUDRepo[A]) RetrieveById(oid primitive.ObjectID) *A
func (MongoCRUDRepo[A]) RetrieveWithLimit ¶
func (m MongoCRUDRepo[A]) RetrieveWithLimit(filter *bson.D, limit int) ([]A, error)
func (MongoCRUDRepo[A]) UpdateById ¶
func (m MongoCRUDRepo[A]) UpdateById(id *primitive.ObjectID) UpdateFn
type ReflectiveGet ¶
type ReflectiveGet[C comparable] func(v reflect.Value) C
Click to show internal directories.
Click to hide internal directories.