Documentation
¶
Overview ¶
Package mgo provides a MongoDB client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collecter ¶ added in v1.1.0
type Collecter[T any] interface { // InsertOne insert one document InsertOne(ctx context.Context, model T) error // InsertMany insert many documents InsertMany(ctx context.Context, models []T) error // FindOne find one document FindOne(ctx context.Context, options ...SetOption) (*T, error) // FindMany find many documents FindMany(ctx context.Context, options ...SetOption) ([]T, error) // UpdateOne update one document UpdateOne(ctx context.Context, options ...SetOption) error // UpdateMany update many documents UpdateMany(ctx context.Context, options ...SetOption) error // DeleteOne delete one document DeleteOne(ctx context.Context, options ...SetOption) error // DeleteMany delete many documents DeleteMany(ctx context.Context, options ...SetOption) error // Count count documents Count(ctx context.Context, options ...SetOption) (int64, error) // Aggregate aggregate documents Aggregate(ctx context.Context, options ...SetOption) ([]T, error) }
Collecter is a interface for mongo collection
func NewCollection ¶ added in v1.1.0
func NewCollection[T any](c *mongo.Collection) Collecter[T]
NewCollection is a function to create a new collection
type Option ¶ added in v1.1.0
type Option struct {
// Filter is a filter to find
Filter bson.M
// Update is a update to update
Update bson.M
// Sort is a sort to sort
Sort bson.M
// Projection is a projection to projection
Projection bson.M
// Pipeline is a pipeline to aggregate
Pipeline []bson.M
// Skip is a skip to skip
Skip *int64
// Limit is a limit to limit
Limit *int64
}
Filter is a function to set filter
Click to show internal directories.
Click to hide internal directories.