mongolib

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package mongolib is for encapsulating go.mongodb.org/mongo-driver any operations

As a quick start:

	ctx := context.Background()
	mgo, err := mongolib.NewMongoDriver(ctx, mongolib.Config{
		AppName: "test",
		URL:         "mongodb://localhost:27017",
		Database:    "golang",
	}, nil)
	if err != nil {
		panic(err)
	}
	collection := mgo.Database.Collection("example")
 collection.find(...)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AppName     string
	URL         string
	Database    string
	MaxPoolSize uint64
}

type MongoDriver

type MongoDriver struct {
	Client   *mongo.Client
	Database *mongo.Database
}

func NewMongoDriver

func NewMongoDriver(ctx context.Context, cfg Config, opts ...*options.ClientOptions) (*MongoDriver, error)

func (*MongoDriver) Close

func (m *MongoDriver) Close(ctx context.Context) error

Jump to

Keyboard shortcuts

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