mongodb

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 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 uint64 `json:"pool_size" yaml:"pool_size"`
	Timeout  uint64 `json:"timeout" yaml:"timeout"`
}

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 NewDatabaseDsn added in v1.6.6

func NewDatabaseDsn(dsn string) (*Database, error)

func (*Database) Close

func (d *Database) Close() error

disconnect mongodb

func (*Database) Database

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

get default database

func (*Database) ListDatabase

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

func (*Database) ListDatabaseNames

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

func (*Database) Open

func (d *Database) Open() error

connect to mongodb

func (*Database) Ping

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