You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
374 B
24 lines
374 B
2 years ago
|
package dorm
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
"github.com/upper/db/v4/adapter/mongo"
|
||
|
)
|
||
|
|
||
|
func NewUpperMongodbClient(settings mongo.ConnectionURL) (*UpperClient, error) {
|
||
|
|
||
|
var err error
|
||
|
c := &UpperClient{}
|
||
|
|
||
|
sess, err := mongo.Open(settings)
|
||
|
if err != nil {
|
||
|
return nil, errors.New(fmt.Sprintf("连接失败:%v", err))
|
||
|
}
|
||
|
defer sess.Close()
|
||
|
|
||
|
c.Db = &sess
|
||
|
|
||
|
return c, nil
|
||
|
}
|