Documentation ¶
Overview ¶
Package mgo is a library wrapped on go.mongodb.org/mongo-driver/mongo, with added features paging queries, etc.
Index ¶
- Constants
- func Close(db *mongo.Database) error
- func ConvertToObjectIDs(ids []string) []primitive.ObjectID
- func EmbedDeletedAt(update bson.M) bson.M
- func EmbedUpdatedAt(update bson.M) bson.M
- func ExcludeDeleted(filter bson.M) bson.M
- func Init(dsn string, opts ...*options.ClientOptions) (*mongo.Database, error)
- func Init2(uri string, dbName string, opts ...*options.ClientOptions) (*mongo.Database, error)
- type Model
Constants ¶
View Source
const (
// DBDriverName mongodb driver
DBDriverName = "mongodb"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertToObjectIDs ¶
ConvertToObjectIDs convert ids to objectIDs
func EmbedDeletedAt ¶
EmbedDeletedAt embed deleted_at datetime column
func EmbedUpdatedAt ¶
EmbedUpdatedAt embed updated_at datetime column
func ExcludeDeleted ¶
ExcludeDeleted exclude soft deleted records
Types ¶
type Model ¶
type Model struct { ID primitive.ObjectID `bson:"_id" json:"id"` CreatedAt time.Time `bson:"created_at" json:"createdAt"` UpdatedAt time.Time `bson:"updated_at" json:"updatedAt"` DeletedAt *time.Time `bson:"deleted_at,omitempty" json:"deletedAt,omitempty"` }
Model embedded structs, add `bson: ",inline"` when defining table structs
Click to show internal directories.
Click to hide internal directories.