database

package
v0.0.0-...-686de45 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

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

func (c *Connection) CollectionExists(ctx context.Context, name string) (bool, error)

CollectionExists checks if a collection exists

func (*Connection) Delete

func (c *Connection) Delete(ctx context.Context, name string, query any) error

Delete deletes an item from the collection that matches the query

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) Exists

func (c *Connection) Exists(ctx context.Context, name string, query any) (bool, error)

Exists checks if a query matches in a 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

func (*Connection) Read

func (c *Connection) Read(ctx context.Context, name string, v *[]bson.M) error

Read reads the information in a collection

func (*Connection) Update

func (c *Connection) Update(ctx context.Context, name string, query, data any) error

Update updates the collection based on a query

func (*Connection) Write

func (c *Connection) Write(ctx context.Context, name string, w any) error

Write writes information to the collection

type Production

type Production interface {
}

Jump to

Keyboard shortcuts

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