mongoc

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MongoCli *mongo.Client
	DbName   string

	CtxExpireTime = 5 * time.Second

	DefaultLimit    int64 = 10
	DefaultMaxLimit int64 = 1000
)

Functions

func Close

func Close() error

func CountDocuments

func CountDocuments(coll string, filter interface{}) (int64, error)

func CountDocumentsByModel

func CountDocumentsByModel(doc, filter interface{}) (int64, error)

func CreateMany

func CreateMany(coll string, indexes [][]string) ([]string, error)

func CreateManyByModel

func CreateManyByModel(doc interface{}, indexes [][]string) ([]string, error)

func CreateOne

func CreateOne(coll string, indexes []string) (string, error)

func CreateOneByModel

func CreateOneByModel(doc interface{}, indexes []string) (string, error)

func DeleteMany

func DeleteMany(coll string, filter interface{}) error

func DeleteManyByModel

func DeleteManyByModel(doc, filter interface{}) error

func DeleteOne

func DeleteOne(coll string, filter interface{}) error

func DeleteOneByModel

func DeleteOneByModel(doc, filter interface{}) error

func FiledMethodValue

func FiledMethodValue(methodName string, dataModel interface{}) (string, error)

func FindFindOneAndDeleteOne

func FindFindOneAndDeleteOne(coll string, filter, result interface{}) error

func FindFindOneAndDeleteOneByModel

func FindFindOneAndDeleteOneByModel(filter, result interface{}) error

func FindMany

func FindMany(pageSize, pageNo int64, coll string, filter, sort, result, projects interface{}) error

func FindManyByModel

func FindManyByModel(pageSize, pageNo int64, coll string, filter, sort, result, projects interface{}) error

func FindManyCount

func FindManyCount(pageSize, pageNo int64, coll string, filter, sort, result, projects interface{}) (int64, error)

func FindManyCountByModel

func FindManyCountByModel(pageSize, pageNo int64, coll string, filter, sort, result, projects interface{}) (int64, error)

func FindManyRange

func FindManyRange(pageSize, lastId int64, coll string, filter, sort, result, projects interface{}) error

func FindManyRangeByModel

func FindManyRangeByModel(pageSize, lastId int64, coll string, filter, sort, result, projects interface{}) error

func FindManyRangeCount

func FindManyRangeCount(pageSize, lastId int64, coll string, filter, sort, result, projects interface{}) (int64, error)

func FindManyRangeCountByModel

func FindManyRangeCountByModel(pageSize, lastId int64, coll string, filter, sort, result, projects interface{}) (int64, error)

func FindOne

func FindOne(coll string, filter, result interface{}) error

func FindOneAndReplace

func FindOneAndReplace(coll string, filter, replace, result interface{}) error

func FindOneAndReplaceByModel

func FindOneAndReplaceByModel(filter, replace, result interface{}) error

func FindOneAndUpdate

func FindOneAndUpdate(coll string, filter, update, result interface{}) error

func FindOneAndUpdateByModel

func FindOneAndUpdateByModel(filter, update, result interface{}) error

func FindOneByModel

func FindOneByModel(filter, result interface{}) error

func InitDefaultData

func InitDefaultData(basePath string)

func InitMongo

func InitMongo(username, password, host string, port uint64, dbName string, minPoolSize, maxPoolSize uint64) error

func InsertMany

func InsertMany(coll string, docs []interface{}) error

func InsertManyByModel

func InsertManyByModel(docs []interface{}) error

func InsertOne

func InsertOne(coll string, doc interface{}) error

func InsertOneByModel

func InsertOneByModel(doc interface{}) error

func Transaction

func Transaction(fn func(mongo.SessionContext) error) error

func TransactionWithOptions

func TransactionWithOptions(opts *options.SessionOptions, fn func(mongo.SessionContext) error) error

func UpdateById

func UpdateById(coll string, id, doc interface{}) error

func UpdateByIdByModel

func UpdateByIdByModel(id, doc interface{}) error

func UpdateMany

func UpdateMany(coll string, filter, docs []interface{}) error

func UpdateManyByModel

func UpdateManyByModel(filter, docs []interface{}) error

func UpdateOne

func UpdateOne(coll string, filter, doc interface{}) error

func UpdateOneByModel

func UpdateOneByModel(filter, doc interface{}) error

Types

type BaseModel

type BaseModel struct {
	CreatedAt time.Time  `json:"created_at" bson:"created_at"`
	UpdatedAt time.Time  `json:"updated_at" bson:"updated_at"`
	DeletedAt *time.Time `json:"-" bson:"deleted_at"`
	Remark    string     `json:"remark" bson:"remark"`
}

func (*BaseModel) CollectionName

func (c *BaseModel) CollectionName() string

type UpdateModel

type UpdateModel struct {
	BaseModel
	FileName    string    `json:"file_name" bson:"file_name"`
	ExecuteTime time.Time `json:"execute_time" bson:"execute_time"`
}

func (*UpdateModel) CollectionName

func (c *UpdateModel) CollectionName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL