package
1.12.6
Repository: https://github.com/go-dev-frame/sponge.git
Documentation: pkg.go.dev

# README

mgo

mgo is a library wrapped on the official library mongo-go-driver, with added features paging queries.


Example of use

    import "github.com/go-dev-frame/sponge/pkg/mgo"

    // dsn document: https://www.mongodb.com/docs/manual/reference/connection-string/

    // case 1: specify options in dsn
    db, err := mgo.Init("mongodb://root:[email protected]:27017/account?socketTimeoutMS=30000&maxPoolSize=100&minPoolSize=1&maxConnIdleTimeMS=300000")

    // case 2: specify options in code
    db, err := mgo.Init("mongodb://root:[email protected]:27017/account",
        mgo.WithOption().SetMaxPoolSize(100),
        mgo.WithOption().SetMinPoolSize(1),
        mgo.WithOption().SetMaxConnIdleTime(5*time.Minute),
        mgo.WithOption().SetSocketTimeout(30*time.Second),
    )

    // close mongodb
    defer mgo.Close(db)

# Packages

Package query is a library of custom condition queries, support for complex conditional paging queries.

# Functions

Close mongodb.
ConvertToObjectIDs convert ids to objectIDs.
EmbedDeletedAt embed deleted_at datetime column.
EmbedUpdatedAt embed updated_at datetime column.
ExcludeDeleted exclude soft deleted records.
Init connecting to mongo.
Init2 connecting to mongo using uri.
NewCustomLogger create a custom logger for mongodb, debug level is used by default.
WithOption set option for mongodb.

# Constants

DBDriverName mongodb driver.

# Variables

No description provided by the author

# Structs

Model embedded structs, add `bson: ",inline"` when defining table structs.

# Type aliases

No description provided by the author