Documentation
¶
Index ¶
- Variables
- func Convert[T Production](c *Connection, col string, v []bson.M) ([]*T, error)
- type Connection
- func (c *Connection) Close(ctx context.Context)
- func (c *Connection) CollectionExists(ctx context.Context, name string) (bool, error)
- func (c *Connection) Delete(ctx context.Context, name string, query any) error
- func (c *Connection) Drop(ctx context.Context, name string)
- func (c *Connection) DropAll(ctx context.Context)
- func (c *Connection) Exists(ctx context.Context, name string, query any) (bool, error)
- func (c *Connection) Filter(ctx context.Context, name string, query any, allowCollisions bool) ([]bson.M, error)
- func (c *Connection) Get(col string) *mongo.Collection
- func (c *Connection) NewCollection(col string) *mongo.Collection
- func (c *Connection) Read(ctx context.Context, name string, v *[]bson.M) error
- func (c *Connection) Update(ctx context.Context, name string, query, data any) error
- func (c *Connection) Write(ctx context.Context, name string, w any) error
- type Production
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ConnectionURI = "mongodb://localhost:27017" DatabaseName = "PaymentProcessor" ConnectionTimeout = time.Second * 90 )
Functions ¶
func Convert ¶
func Convert[T Production](c *Connection, col string, v []bson.M) ([]*T, error)
Convert converts []bson.M into a []*T
Types ¶
type Connection ¶
type Connection struct {
Client *mongo.Client
Collections map[string]*mongo.Collection
}
func NewConn ¶
func NewConn(ctx context.Context) *Connection
func (*Connection) Close ¶
func (c *Connection) Close(ctx context.Context)
Close closes the mongo connection
func (*Connection) CollectionExists ¶
CollectionExists checks if a collection exists
func (*Connection) Drop ¶
func (c *Connection) Drop(ctx context.Context, name string)
Drop drops the collection
func (*Connection) DropAll ¶
func (c *Connection) DropAll(ctx context.Context)
DropAll drops all the collection
func (*Connection) Filter ¶
func (c *Connection) Filter(ctx context.Context, name string, query any, allowCollisions bool) ([]bson.M, error)
Filter looks for a match with the given search query
func (*Connection) Get ¶
func (c *Connection) Get(col string) *mongo.Collection
Get gets a collection in the database
func (*Connection) NewCollection ¶
func (c *Connection) NewCollection(col string) *mongo.Collection
type Production ¶
type Production interface {
}
Click to show internal directories.
Click to hide internal directories.