代码拉取完成,页面将自动刷新
package abstr
import (
"context"
"reflect"
"time"
"go.mongodb.org/mongo-driver/mongo"
)
// 数据库操作默认超时时间(5 秒)
const DefaultTimeout = 5 * time.Second
type DBHelper interface {
Aggregate(ctx context.Context, collname string, pipeline []map[string]interface{}, value interface{}) error
CountDocuments(ctx context.Context, collname string, filter map[string]interface{}) (int64, error)
CreateOne(ctx context.Context, collname string, rec interface{}) error
CreateMany(ctx context.Context, collname string, recs ...interface{}) error
FindOne(ctx context.Context, collname string, value interface{}, options ...FindOption) error
FindOneAndDelete(ctx context.Context, collname string, filter map[string]interface{}, value interface{}, options ...FindOption) error
List(ctx context.Context, collname string, value interface{}, options ...FindOption) (*Page, error)
// $pull
Pull(ctx context.Context, collname string, filter map[string]interface{}, value interface{}) error
RemoveMany(ctx context.Context, collname string, filter map[string]interface{}) error
// $unset
Unmark(ctx context.Context, collname string, filter map[string]interface{}, value interface{}) error
UpdateMany(ctx context.Context, collname string, filter interface{}, update interface{}) (*mongo.UpdateResult, error)
UpdateOne(ctx context.Context, collname string, filter map[string]interface{}, value interface{}, options ...FindOption) error
// 对 UpdateOne 的扩展,允许使用 $set 之外的操作符
UpdateOneMore(ctx context.Context, collname string, filter map[string]interface{}, value interface{}, options ...FindOption) error
}
//Init init db session
// t 要注册的类型
type Init func(dbc DBConfig, t ...reflect.Type) error
//Decrypt decrypt db config
type Decrypt func(src string) string
type DBConfig struct {
URI string `yaml:"uri"`
PoolSize int `yaml:"poolSize"`
SSLEnabled bool `yaml:"sslEnabled"`
RootCA string `yaml:"rootCAFile"`
Timeout string `yaml:"timeout"`
VerifyPeer bool `yaml:"verifyPeer"`
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。