mongo_client

package
v0.0.0-...-1968fcb Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BsonDeserialize

func BsonDeserialize(ex interface{}) gotask.Middleware

BsonDeserialize deserializes bson cmd into a struct cmd

func BsonSerialize

func BsonSerialize() gotask.Middleware

BsonSerialize serializes any result into a bson encoded result

func ConsAwsClient

func ConsAwsClient() (map[string]interface{}, error)

初始化aws

func ErrorFilter

func ErrorFilter() gotask.Middleware

Types

type AggregateCmd

type AggregateCmd struct {
	Database   string
	Collection string
	Pipeline   mongo.Pipeline
	Opts       *options.AggregateOptions
}

type BulkWriteCmd

type BulkWriteCmd struct {
	Database   string
	Collection string
	Operations []map[string][]bson.Raw
	Opts       *options.BulkWriteOptions
}

type Cmd

type Cmd struct {
	Database string
	Command  bson.D
	Opts     *options.RunCmdOptions
}

type Config

type Config struct {
	Uri              string
	ConnectTimeout   time.Duration
	ReadWriteTimeout time.Duration
}

func LoadConfig

func LoadConfig() Config

LoadConfig loads Configurations from environmental variables or config file in PHP. Environmental variables takes priority.

type CountDocumentsCmd

type CountDocumentsCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Opts       *options.CountOptions
}

type CreateIndexCmd

type CreateIndexCmd struct {
	Database   string
	Collection string
	IndexKeys  bson.Raw
	Opts       *options.IndexOptions
	CreateOpts *options.CreateIndexesOptions
}

type CreateIndexesCmd

type CreateIndexesCmd struct {
	Database   string
	Collection string
	Models     []mongo.IndexModel
	Opts       *options.IndexOptions
	CreateOpts *options.CreateIndexesOptions
}

type DeleteManyCmd

type DeleteManyCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Opts       *options.DeleteOptions
}

type DeleteOneCmd

type DeleteOneCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Opts       *options.DeleteOptions
}

type DistinctCmd

type DistinctCmd struct {
	Database   string
	Collection string
	FieldName  string
	Filter     bson.Raw
	Opts       *options.DistinctOptions
}

type DropCmd

type DropCmd struct {
	Database   string
	Collection string
}

type DropIndexCmd

type DropIndexCmd struct {
	Database   string
	Collection string
	Name       string
	Opts       *options.DropIndexesOptions
}

type DropIndexesCmd

type DropIndexesCmd struct {
	Database   string
	Collection string
	Opts       *options.DropIndexesOptions
}

type FindCmd

type FindCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Opts       *options.FindOptions
}

type FindOneAndDeleteCmd

type FindOneAndDeleteCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Opts       *options.FindOneAndDeleteOptions
}

type FindOneAndReplaceCmd

type FindOneAndReplaceCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Replace    bson.Raw
	Opts       *options.FindOneAndReplaceOptions
}

type FindOneAndUpdateCmd

type FindOneAndUpdateCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Update     bson.Raw
	Opts       *options.FindOneAndUpdateOptions
}

type FindOneCmd

type FindOneCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Opts       *options.FindOneOptions
}

type InsertManyCmd

type InsertManyCmd struct {
	Database   string
	Collection string
	Records    []interface{}
	Opts       *options.InsertManyOptions
}

type InsertOneCmd

type InsertOneCmd struct {
	Database   string
	Collection string
	Record     bson.Raw
	Opts       *options.InsertOneOptions
}

type ListIndexesCmd

type ListIndexesCmd struct {
	Database   string
	Collection string
	Opts       *options.ListIndexesOptions
}

type MongoProxy

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

func NewMongoProxy

func NewMongoProxy(client *mongo.Client) *MongoProxy

NewMongoProxy creates a new Mongo Proxy

func NewMongoProxyWithTimeout

func NewMongoProxyWithTimeout(client *mongo.Client, timeout time.Duration) *MongoProxy

NewMongoProxyWithTimeout creates a new Mongo Proxy, with a read write timeout.

func (*MongoProxy) Aggregate

func (m *MongoProxy) Aggregate(payload []byte, result *[]byte) error

Aggregate executes an aggregate command against the collection and returns all the resulting documents.

func (*MongoProxy) AwsSendSystemEmail

func (m *MongoProxy) AwsSendSystemEmail(payload string, result *interface{}) error

发送AWS 系统邮件

func (*MongoProxy) BulkWrite

func (m *MongoProxy) BulkWrite(payload []byte, result *[]byte) error

func (*MongoProxy) CountDocuments

func (m *MongoProxy) CountDocuments(payload []byte, result *[]byte) error

CountDocuments returns the number of documents in the collection.

func (*MongoProxy) CreateIndex

func (m *MongoProxy) CreateIndex(payload []byte, result *[]byte) error

func (*MongoProxy) CreateIndexes

func (m *MongoProxy) CreateIndexes(payload []byte, result *[]byte) error

func (*MongoProxy) DeleteMany

func (m *MongoProxy) DeleteMany(payload []byte, result *[]byte) error

DeleteMany executes a delete command to delete documents from the collection.

func (*MongoProxy) DeleteOne

func (m *MongoProxy) DeleteOne(payload []byte, result *[]byte) error

DeleteOne executes a delete command to delete at most one document from the collection.

func (*MongoProxy) Distinct

func (m *MongoProxy) Distinct(payload []byte, result *[]byte) error

Distinct executes a distinct command to find the unique values for a specified field in the collection.

func (*MongoProxy) Drop

func (m *MongoProxy) Drop(payload []byte, result *[]byte) error

Drop drops the collection on the server. This method ignores "namespace not found" errors so it is safe to drop a collection that does not exist on the server.

func (*MongoProxy) DropIndex

func (m *MongoProxy) DropIndex(payload []byte, result *[]byte) error

func (*MongoProxy) DropIndexes

func (m *MongoProxy) DropIndexes(payload []byte, result *[]byte) error

func (*MongoProxy) Find

func (m *MongoProxy) Find(payload []byte, result *[]byte) error

Find executes a find command and returns all the matching documents in the collection.

func (*MongoProxy) FindOne

func (m *MongoProxy) FindOne(payload []byte, result *[]byte) error

FindOne executes a find command and returns one document in the collection.

func (*MongoProxy) FindOneAndDelete

func (m *MongoProxy) FindOneAndDelete(payload []byte, result *[]byte) error

FindOneAndDelete executes a findAndModify command to delete at most one document in the collection. and returns the document as it appeared before deletion.

func (*MongoProxy) FindOneAndReplace

func (m *MongoProxy) FindOneAndReplace(payload []byte, result *[]byte) error

FindOneAndReplace executes a findAndModify command to replace at most one document in the collection and returns the document as it appeared before replacement.

func (*MongoProxy) FindOneAndUpdate

func (m *MongoProxy) FindOneAndUpdate(payload []byte, result *[]byte) error

FindOneAndUpdate executes a findAndModify command to update at most one document in the collection and returns the document as it appeared before updating.

func (*MongoProxy) InsertMany

func (m *MongoProxy) InsertMany(payload []byte, result *[]byte) (err error)

InsertMany executes an insert command to insert multiple documents into the collection. If write errors occur during the operation (e.g. duplicate key error), this method returns a BulkWriteException error.

func (*MongoProxy) InsertOne

func (m *MongoProxy) InsertOne(payload []byte, result *[]byte) (err error)

InsertOne executes an insert command to insert a single document into the collection.

func (*MongoProxy) ListIndexes

func (m *MongoProxy) ListIndexes(payload []byte, result *[]byte) error

func (*MongoProxy) ReplaceOne

func (m *MongoProxy) ReplaceOne(payload []byte, result *[]byte) error

ReplaceOne executes an update command to replace at most one document in the collection.

func (*MongoProxy) RunCommand

func (m *MongoProxy) RunCommand(payload []byte, result *[]byte) error

RunCommand executes the given command against the database.

func (*MongoProxy) RunCommandCursor

func (m *MongoProxy) RunCommandCursor(payload []byte, result *[]byte) error

RunCommandCursor executes the given command against the database and parses the response as a slice. If the command being executed does not return a slice, the command will be executed on the server and an error will be returned because the server response cannot be parsed as a slice.

func (*MongoProxy) UpdateMany

func (m *MongoProxy) UpdateMany(payload []byte, result *[]byte) error

UpdateMany executes an update command to update documents in the collection.

func (*MongoProxy) UpdateOne

func (m *MongoProxy) UpdateOne(payload []byte, result *[]byte) error

UpdateOne executes an update command to update at most one document in the collection.

type ReplaceOneCmd

type ReplaceOneCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Replace    bson.Raw
	Opts       *options.ReplaceOptions
}

type UpdateManyCmd

type UpdateManyCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Update     bson.Raw
	Opts       *options.UpdateOptions
}

type UpdateOneCmd

type UpdateOneCmd struct {
	Database   string
	Collection string
	Filter     bson.Raw
	Update     bson.Raw
	Opts       *options.UpdateOptions
}

Jump to

Keyboard shortcuts

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