Documentation ¶ Index ¶ func Collection(client *mongo.Client, cname string) (*mongo.Collection, error) func CollectionMulti(client *mongo.Client, cname string) (*mongo.Collection, error) func Init(conf *Config) func New() (*mongo.Client, error) func Ping() error type Config Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ func Collection ¶ func Collection(client *mongo.Client, cname string) (*mongo.Collection, error) Collection 获取集合 func CollectionMulti ¶ func CollectionMulti(client *mongo.Client, cname string) (*mongo.Collection, error) CollectionMulti 支持多数据库直接获取collection func Init ¶ func Init(conf *Config) func New ¶ func New() (*mongo.Client, error) New 获取mongo客户端 // "mongodb://user:password@localhost:27017" func Ping ¶ func Ping() error Types ¶ type Config ¶ type Config struct { Uri string Username string Password string Database string Timeout int } Source Files ¶ View all Source files mongo.go Click to show internal directories. Click to hide internal directories.