Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 606 Bytes

README.md

File metadata and controls

38 lines (28 loc) · 606 Bytes

Proxy Middleware for Gin Framework

实现对官方 mongodb 的golang驱动的单例封装

Usage

Download and install it:

$ go get github.com/igufei/go-mongo

Import it in your code:

import "github.com/igufei/go-mongo"

Example

import (
	"fmt"
	mongo "github.com/igufei/go-mongo"
	"go.mongodb.org/mongo-driver/bson"
)

func init() {
	mongo.MustConnect("mongodb://localhost:27017", "usermanager")
}

func main() {
	value := mongo.Instance.FindOne("agent", bson.M{
		"username": "gufeng",
	})
	fmt.Printf("%v", value)
}