mongo

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address    string // mongo address, like: mongodb://127.0.0.1:27017
	Username   string // username
	Password   string
	Database   string
	AuthSource string        // default is admin
	Timeout    time.Duration // default is 30 seconds
}

Config represents the configuration of a MongoDB connection

type Instance

type Instance struct {
	*mongo.Client
	// contains filtered or unexported fields
}

func New

func New() *Instance

func (*Instance) Close

func (m *Instance) Close() error

Close closes the connection to the

func (*Instance) Collection

func (m *Instance) Collection(name string, opts ...*options.CollectionOptions) *mongo.Collection

Collection use current database for the provide collection

func (*Instance) Connect

func (m *Instance) Connect(config *Config, timeout time.Duration) error

Connect connects to the server

func (*Instance) Database

func (m *Instance) Database(database string, opts ...*options.DatabaseOptions) *mongo.Database

Database use the other database

Jump to

Keyboard shortcuts

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