1 Star 1 Fork 0

kade/library

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
interface.go 675 Bytes
Copy Edit Raw Blame History
kadegolang authored 2024-03-05 16:25 . 补充go-restful
package mongo
import (
"gitee.com/go-kade/library/ioc"
"go.mongodb.org/mongo-driver/mongo"
)
const (
AppName = "mongodb"
)
func DB() *mongo.Database {
return ioc.Config().Get(AppName).(*mongoDB).GetDB()
}
func Client() *mongo.Client {
return ioc.Config().Get(AppName).(*mongoDB).Client()
}
// 需要依赖 mongodb, 通过Ioc的依赖注入 来通过配置文件自动注入该对象
// //i.col = ioc_mongo.Client().Database(resource.AppName).Collection(resource.AppName)
// s, _ := ioc_mongo.Client().StartSession()
// s.StartTransaction()
// s.Client().Database(resource.AppName).Collection(resource.AppName)
// i.col = ioc_mongo.DB().Collection(resource.AppName)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/go-kade/library.git
git@gitee.com:go-kade/library.git
go-kade
library
library
v1.2.9

Search