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.
20 lines
544 B
20 lines
544 B
package dorm
|
|
|
|
import (
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
)
|
|
|
|
type MongoSessionDatabaseOptions struct {
|
|
session mongo.SessionContext // 会话
|
|
dbDatabase *mongo.Database // 数据库
|
|
}
|
|
|
|
// Database 选择数据库
|
|
func (cs *MongoSessionOptions) Database(name string, opts ...*options.DatabaseOptions) *MongoSessionDatabaseOptions {
|
|
return &MongoSessionDatabaseOptions{
|
|
session: cs.Session, // 会话
|
|
dbDatabase: cs.Db.Database(name, opts...), // 数据库
|
|
}
|
|
}
|