dbconnection

package
v0.0.0-...-54f4621 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connections

type Connections struct {
	// contains filtered or unexported fields
}

Connections is a MongoDB Connection handler

func NewConnection

func NewConnection(l *log.Logger) *Connections

NewConnection creates a connection with the given logger

func (*Connections) Connect

func (conn *Connections) Connect()

Connect creates and checks connection

func (*Connections) CreateConnection

func (conn *Connections) CreateConnection()

CreateConnection gets GetClient, checks connection and returns connection for CRUD Interface.

func (*Connections) DeleteInterface

func (conn *Connections) DeleteInterface()

DeleteInterface is Temp Func for later implementation

func (*Connections) DeleteRecord

func (conn *Connections) DeleteRecord(filter bson.M) int64

DeleteRecord remove one existing Record Returns no. of Record/Document deleted.

func (*Connections) GetClient

func (conn *Connections) GetClient() *mongo.Client

GetClient returns a MongoDB Client

func (*Connections) InsertInterface

func (conn *Connections) InsertInterface()

InsertInterface is Temp Func for later implementation

func (*Connections) InsertRecord

func (conn *Connections) InsertRecord(product Product) interface{}

InsertRecord insert a new record in the Collection Returns ObjectID of each Document/Record inserted.

func (*Connections) ReturnAllRecords

func (conn *Connections) ReturnAllRecords(filter bson.M) []*Product

ReturnAllRecords return all documents from the collection Products

func (*Connections) ReturnRecordInterface

func (conn *Connections) ReturnRecordInterface()

ReturnRecordInterface is Temp Func for later implementation

func (*Connections) UpdateInterface

func (conn *Connections) UpdateInterface()

UpdateInterface is Temp Func for later implementation

func (*Connections) UpdateRecord

func (conn *Connections) UpdateRecord(updatedData interface{}, where bson.M) int64

UpdateRecord updates the value of a record Returns no. of record updated as Int .

type Product

type Product struct {
	Fileid      int    `json:"fileid" bson:"fileid"`
	Position    int    `json:"position" bson:"position"`
	Filename    string `json:"filename" bson:"filename"`
	Description string `json:"description" bson:"description"`
	Filedate    string `json:"filedate" bson:"filedate"`
	Source      string `json:"source" bson:"source"`
}

Product defines the structure for an API product

Jump to

Keyboard shortcuts

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