mongo

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 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 Config

type Config struct {
	Host     string `json:"host" yaml:"host"`
	Port     string `json:"port" yaml:"port"`
	User     string `json:"user" yaml:"user"`
	Password string `json:"password" yaml:"password"`
	Auth     string `json:"auth" yaml:"auth"`
	DBName   string `json:"db_name" yaml:"db_name"`
	PoolSize int    `json:"pool_size" yaml:"pool_size"`
}

dsn mongodb://root:WiaQ82n7B3L5Cz*2#10m@172.18.76.150:27017?authSource=admin

type Database

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

mongodb orm use official driver

func NewDatabase

func NewDatabase(conf *Config) (*Database, error)

func (*Database) Close

func (d *Database) Close() error

disconnect mongodb

func (*Database) Database added in v1.0.5

func (d *Database) Database(dbName ...string) *mongo.Database

get default database

func (*Database) ListDatabase added in v1.0.5

func (d *Database) ListDatabase() (mongo.ListDatabasesResult, error)

func (*Database) ListDatabaseNames added in v1.0.5

func (d *Database) ListDatabaseNames() ([]string, error)

func (*Database) Open

func (d *Database) Open() error

connect to mongodb

func (*Database) Ping added in v1.0.5

func (d *Database) Ping() error

ping mongodb server

func (*Database) SelectDatabase

func (d *Database) SelectDatabase(dbName string)

select database

Jump to

Keyboard shortcuts

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