mongo

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNoDocuments

func IsNoDocuments(err error) bool

func Mongo

func Mongo(ctx context.Context, config *configs.Config) error

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Default

func Default() *Client

func (*Client) Client

func (c *Client) Client() *mongo.Client

func (*Client) Database

func (c *Client) Database(ctx context.Context) *CtxMongoDatabase

type Config

type Config struct {
	URI      string `yaml:"uri"`
	Database string `json:"database"`
}

type CtxCollection

type CtxCollection struct {
	// contains filtered or unexported fields
}

func (*CtxCollection) Aggregate

func (c *CtxCollection) Aggregate(pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)

func (*CtxCollection) BulkWrite

func (c *CtxCollection) BulkWrite(requests []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)

func (*CtxCollection) Clone

func (*CtxCollection) CountDocuments

func (c *CtxCollection) CountDocuments(filter interface{}, opts ...*options.CountOptions) (int64, error)

func (*CtxCollection) DeleteMany

func (c *CtxCollection) DeleteMany(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*CtxCollection) DeleteOne

func (c *CtxCollection) DeleteOne(filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

func (*CtxCollection) Distinct

func (c *CtxCollection) Distinct(fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)

func (*CtxCollection) Drop

func (c *CtxCollection) Drop() error

func (*CtxCollection) EstimatedDocumentCount

func (c *CtxCollection) EstimatedDocumentCount(opts ...*options.EstimatedDocumentCountOptions) (int64, error)

func (*CtxCollection) Find

func (c *CtxCollection) Find(filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)

func (*CtxCollection) FindOne

func (c *CtxCollection) FindOne(filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

func (*CtxCollection) FindOneAndDelete

func (c *CtxCollection) FindOneAndDelete(filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult

func (*CtxCollection) FindOneAndReplace

func (c *CtxCollection) FindOneAndReplace(filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult

func (*CtxCollection) FindOneAndUpdate

func (c *CtxCollection) FindOneAndUpdate(filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult

func (*CtxCollection) Indexes

func (c *CtxCollection) Indexes() *CtxIndex

func (*CtxCollection) InsertMany

func (c *CtxCollection) InsertMany(documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

func (*CtxCollection) InsertOne

func (c *CtxCollection) InsertOne(document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*CtxCollection) Name

func (c *CtxCollection) Name() string

func (*CtxCollection) ReplaceOne

func (c *CtxCollection) ReplaceOne(filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

func (*CtxCollection) UpdateMany

func (c *CtxCollection) UpdateMany(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*CtxCollection) UpdateOne

func (c *CtxCollection) UpdateOne(filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

func (*CtxCollection) Watch

func (c *CtxCollection) Watch(pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)

type CtxIndex

type CtxIndex struct {
	// contains filtered or unexported fields
}

func NewCtxIndex

func NewCtxIndex(ctx context.Context, index mongo.IndexView) *CtxIndex

func (*CtxIndex) CreateMany

func (c *CtxIndex) CreateMany(models []mongo.IndexModel, opts ...*options.CreateIndexesOptions) ([]string, error)

func (*CtxIndex) CreateOne

func (c *CtxIndex) CreateOne(model mongo.IndexModel, opts ...*options.CreateIndexesOptions) (string, error)

func (*CtxIndex) DropAll

func (c *CtxIndex) DropAll(opts ...*options.DropIndexesOptions) (bson.Raw, error)

func (*CtxIndex) DropOne

func (c *CtxIndex) DropOne(name string, opts ...*options.DropIndexesOptions) (bson.Raw, error)

func (*CtxIndex) List

func (c *CtxIndex) List(opts ...*options.ListIndexesOptions) (*mongo.Cursor, error)

func (*CtxIndex) ListSpecifications

func (c *CtxIndex) ListSpecifications(opts ...*options.ListIndexesOptions) ([]*mongo.IndexSpecification, error)

type CtxMongoDatabase

type CtxMongoDatabase struct {
	// contains filtered or unexported fields
}

func Ctx

func NewCtxMongoDatabase

func NewCtxMongoDatabase(ctx context.Context, database *mongo.Database) *CtxMongoDatabase

func (*CtxMongoDatabase) Collection

func (c *CtxMongoDatabase) Collection(name string, opts ...*options.CollectionOptions) *CtxCollection

Jump to

Keyboard shortcuts

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