mongoabstraction

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MIT Imports: 6 Imported by: 0

README

mongoabstraction

A attempt to abstract mongodb connectivity in golang

Documentation

Index

Constants

View Source
const (
	DatabaseName   string = "testdb"
	CollectionName string = "movies"
)

Variables

View Source
var (
	DBError error
)

Functions

This section is empty.

Types

type ClientHelper

type ClientHelper interface {
	Database(string) DatabaseHelper
	Connect(context.Context) error
	StartSession() (mongo.Session, error)
	CheckConnection(context.Context) error
}

func NewClient

func NewClient() (ClientHelper, error)

type CollectionHelper

type CollectionHelper interface {
	FindOne(context.Context, interface{}) SingleResultHelper
	FindMany(ctx context.Context, filter interface{}) (MongoResults, error)
	InsertOne(context.Context, interface{}) (interface{}, error)
	DeleteOne(ctx context.Context, filter interface{}) (int64, error)
}

type DatabaseHelper

type DatabaseHelper interface {
	Collection(name string) CollectionHelper
	Client() ClientHelper
}

type MongoResults added in v1.2.0

type MongoResults struct {
	RS []bson.M
}

type SingleResultHelper

type SingleResultHelper interface {
	Decode(v interface{}) error
}

Jump to

Keyboard shortcuts

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