Documentation ¶
Index ¶
- func DecodeCursor[T any](cursor *mongo.Cursor) ([]T, error)
- func EvaluateAndDecodeSingleResult(result *mongo.SingleResult, v interface{}) error
- type Account
- type Client
- func (client *Client) Disconnect()
- func (client *Client) GetCollection(databaseName, collection string) *mongo.Collection
- func (client *Client) GetDatabase(dbName string) *mongo.Database
- func (client *Client) Transaction(sessionOpt *options.SessionOptions, trxOpt *options.TransactionOptions, ...) error
- type Collection
- func (col *Collection[T]) Aggregate(logger Logger, pipeline interface{}, opts ...*options.AggregateOptions) ([]T, error)
- func (col *Collection[T]) AggregateWithTrx(logger Logger, pipeline interface{}, sessCtx *mongo.SessionContext, ...) ([]T, error)
- func (col *Collection[T]) BulkWrite(logger Logger, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
- func (col *Collection[T]) BulkWriteWithTrx(logger Logger, models []mongo.WriteModel, sessCtx *mongo.SessionContext, ...) (*mongo.BulkWriteResult, error)
- func (col *Collection[T]) CountDocuments(logger Logger, filter interface{}, opts ...*options.CountOptions) (int, error)
- func (col *Collection[T]) CountDocumentsWithTrx(logger Logger, filter interface{}, sessCtx *mongo.SessionContext, ...) (int, error)
- func (col *Collection[T]) DeleteMany(logger Logger, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (col *Collection[T]) DeleteManyWithTrx(logger Logger, filter interface{}, sessCtx *mongo.SessionContext, ...) (*mongo.DeleteResult, error)
- func (col *Collection[T]) DeleteOne(logger Logger, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (col *Collection[T]) DeleteOneWithTrx(logger Logger, filter interface{}, sessCtx *mongo.SessionContext, ...) (*mongo.DeleteResult, error)
- func (col *Collection[T]) EstimatedDocumentCount(logger Logger, opts ...*options.EstimatedDocumentCountOptions) (int, error)
- func (col *Collection[T]) EstimatedDocumentCountWithTrx(logger Logger, sessCtx *mongo.SessionContext, ...) (int, error)
- func (col *Collection[T]) FindAll(logger Logger, filter interface{}, opts ...*options.FindOptions) ([]T, error)
- func (col *Collection[T]) FindAllWithTrx(logger Logger, filter interface{}, sessCtx *mongo.SessionContext, ...) ([]T, error)
- func (col *Collection[T]) FindOne(logger Logger, data, filter interface{}, opts ...*options.FindOneOptions) error
- func (col *Collection[T]) FindOneAndDelete(logger Logger, data, filter interface{}, ...) error
- func (col *Collection[T]) FindOneAndDeleteWithTrx(logger Logger, data, filter interface{}, sessCtx *mongo.SessionContext, ...) error
- func (col *Collection[T]) FindOneAndModify(logger Logger, data, filter interface{}, update interface{}, ...) error
- func (col *Collection[T]) FindOneAndModifyWithTrx(logger Logger, data, filter interface{}, update interface{}, ...) error
- func (col *Collection[T]) FindOneAndReplace(logger Logger, data, filter interface{}, replacement interface{}, ...) error
- func (col *Collection[T]) FindOneAndReplaceWithTrx(logger Logger, data, filter interface{}, replacement interface{}, ...) error
- func (col *Collection[T]) FindOneWithTrx(logger Logger, data, filter interface{}, sessCtx *mongo.SessionContext, ...) error
- func (col *Collection[T]) InsertMany(logger Logger, documents []interface{}, opts ...*options.InsertManyOptions) (interface{}, error)
- func (col *Collection[T]) InsertManyWithTrx(logger Logger, documents []interface{}, sessCtx *mongo.SessionContext, ...) (interface{}, error)
- func (col *Collection[T]) InsertOne(logger Logger, document interface{}, opts ...*options.InsertOneOptions) (interface{}, error)
- func (col *Collection[T]) InsertOneWithTrx(logger Logger, document interface{}, sessCtx *mongo.SessionContext, ...) (interface{}, error)
- func (col *Collection[T]) ReplaceOne(logger Logger, filter interface{}, document interface{}, ...) (*mongo.UpdateResult, error)
- func (col *Collection[T]) ReplaceOneWithTrx(logger Logger, filter interface{}, document interface{}, ...) (*mongo.UpdateResult, error)
- func (col *Collection[T]) UpdateMany(logger Logger, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (col *Collection[T]) UpdateManyWithTrx(logger Logger, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (col *Collection[T]) UpdateOne(logger Logger, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (col *Collection[T]) UpdateOneWithTrx(logger Logger, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type Logger
- type MyLogger
- func (l *MyLogger) GetSlowQueryDurationOfAggregation() time.Duration
- func (l *MyLogger) GetSlowQueryDurationOfBulk() time.Duration
- func (l *MyLogger) GetSlowQueryDurationOfMany() time.Duration
- func (l *MyLogger) GetSlowQueryDurationOfOne() time.Duration
- func (l *MyLogger) GetTimeoutDuration() time.Duration
- func (l *MyLogger) SlowQuery(msg string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateAndDecodeSingleResult ¶
func EvaluateAndDecodeSingleResult(result *mongo.SingleResult, v interface{}) error
Types ¶
type Client ¶
var MongoClient *Client
func Connect ¶
func Connect(clientOpt *options.ClientOptions) *Client
func (*Client) Disconnect ¶
func (client *Client) Disconnect()
func (*Client) GetCollection ¶
func (client *Client) GetCollection(databaseName, collection string) *mongo.Collection
func (*Client) Transaction ¶
func (client *Client) Transaction(sessionOpt *options.SessionOptions, trxOpt *options.TransactionOptions, function func(sessCtx mongo.SessionContext) (interface{}, error)) error
type Collection ¶
type Collection[T any] struct { *mongo.Collection }
func NewCollection ¶
func NewCollection[T any](mongoClient *Client, databaseName, collectionName string) *Collection[T]
func (*Collection[T]) Aggregate ¶
func (col *Collection[T]) Aggregate(logger Logger, pipeline interface{}, opts ...*options.AggregateOptions) ([]T, error)
func (*Collection[T]) AggregateWithTrx ¶
func (col *Collection[T]) AggregateWithTrx(logger Logger, pipeline interface{}, sessCtx *mongo.SessionContext, opts ...*options.AggregateOptions) ([]T, error)
func (*Collection[T]) BulkWrite ¶
func (col *Collection[T]) BulkWrite(logger Logger, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
func (*Collection[T]) BulkWriteWithTrx ¶
func (col *Collection[T]) BulkWriteWithTrx(logger Logger, models []mongo.WriteModel, sessCtx *mongo.SessionContext, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
func (*Collection[T]) CountDocuments ¶
func (col *Collection[T]) CountDocuments(logger Logger, filter interface{}, opts ...*options.CountOptions) (int, error)
func (*Collection[T]) CountDocumentsWithTrx ¶
func (col *Collection[T]) CountDocumentsWithTrx(logger Logger, filter interface{}, sessCtx *mongo.SessionContext, opts ...*options.CountOptions) (int, error)
func (*Collection[T]) DeleteMany ¶
func (col *Collection[T]) DeleteMany(logger Logger, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Collection[T]) DeleteManyWithTrx ¶
func (col *Collection[T]) DeleteManyWithTrx(logger Logger, filter interface{}, sessCtx *mongo.SessionContext, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Collection[T]) DeleteOne ¶
func (col *Collection[T]) DeleteOne(logger Logger, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Collection[T]) DeleteOneWithTrx ¶
func (col *Collection[T]) DeleteOneWithTrx(logger Logger, filter interface{}, sessCtx *mongo.SessionContext, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
func (*Collection[T]) EstimatedDocumentCount ¶
func (col *Collection[T]) EstimatedDocumentCount(logger Logger, opts ...*options.EstimatedDocumentCountOptions) (int, error)
func (*Collection[T]) EstimatedDocumentCountWithTrx ¶
func (col *Collection[T]) EstimatedDocumentCountWithTrx(logger Logger, sessCtx *mongo.SessionContext, opts ...*options.EstimatedDocumentCountOptions) (int, error)
func (*Collection[T]) FindAll ¶
func (col *Collection[T]) FindAll(logger Logger, filter interface{}, opts ...*options.FindOptions) ([]T, error)
func (*Collection[T]) FindAllWithTrx ¶
func (col *Collection[T]) FindAllWithTrx(logger Logger, filter interface{}, sessCtx *mongo.SessionContext, opts ...*options.FindOptions) ([]T, error)
func (*Collection[T]) FindOne ¶
func (col *Collection[T]) FindOne(logger Logger, data, filter interface{}, opts ...*options.FindOneOptions) error
func (*Collection[T]) FindOneAndDelete ¶
func (col *Collection[T]) FindOneAndDelete(logger Logger, data, filter interface{}, opts ...*options.FindOneAndDeleteOptions) error
func (*Collection[T]) FindOneAndDeleteWithTrx ¶
func (col *Collection[T]) FindOneAndDeleteWithTrx(logger Logger, data, filter interface{}, sessCtx *mongo.SessionContext, opts ...*options.FindOneAndDeleteOptions) error
func (*Collection[T]) FindOneAndModify ¶
func (col *Collection[T]) FindOneAndModify(logger Logger, data, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) error
func (*Collection[T]) FindOneAndModifyWithTrx ¶
func (col *Collection[T]) FindOneAndModifyWithTrx(logger Logger, data, filter interface{}, update interface{}, sessCtx *mongo.SessionContext, opts ...*options.FindOneAndUpdateOptions) error
func (*Collection[T]) FindOneAndReplace ¶
func (col *Collection[T]) FindOneAndReplace(logger Logger, data, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) error
func (*Collection[T]) FindOneAndReplaceWithTrx ¶
func (col *Collection[T]) FindOneAndReplaceWithTrx(logger Logger, data, filter interface{}, replacement interface{}, sessCtx *mongo.SessionContext, opts ...*options.FindOneAndReplaceOptions) error
func (*Collection[T]) FindOneWithTrx ¶
func (col *Collection[T]) FindOneWithTrx(logger Logger, data, filter interface{}, sessCtx *mongo.SessionContext, opts ...*options.FindOneOptions) error
func (*Collection[T]) InsertMany ¶
func (col *Collection[T]) InsertMany(logger Logger, documents []interface{}, opts ...*options.InsertManyOptions) (interface{}, error)
func (*Collection[T]) InsertManyWithTrx ¶
func (col *Collection[T]) InsertManyWithTrx(logger Logger, documents []interface{}, sessCtx *mongo.SessionContext, opts ...*options.InsertManyOptions) (interface{}, error)
func (*Collection[T]) InsertOne ¶
func (col *Collection[T]) InsertOne(logger Logger, document interface{}, opts ...*options.InsertOneOptions) (interface{}, error)
func (*Collection[T]) InsertOneWithTrx ¶
func (col *Collection[T]) InsertOneWithTrx(logger Logger, document interface{}, sessCtx *mongo.SessionContext, opts ...*options.InsertOneOptions) (interface{}, error)
func (*Collection[T]) ReplaceOne ¶
func (col *Collection[T]) ReplaceOne(logger Logger, filter interface{}, document interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
func (*Collection[T]) ReplaceOneWithTrx ¶
func (col *Collection[T]) ReplaceOneWithTrx(logger Logger, filter interface{}, document interface{}, sessCtx *mongo.SessionContext, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
func (*Collection[T]) UpdateMany ¶
func (col *Collection[T]) UpdateMany(logger Logger, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*Collection[T]) UpdateManyWithTrx ¶
func (col *Collection[T]) UpdateManyWithTrx(logger Logger, filter interface{}, update interface{}, sessCtx *mongo.SessionContext, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*Collection[T]) UpdateOne ¶
func (col *Collection[T]) UpdateOne(logger Logger, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
func (*Collection[T]) UpdateOneWithTrx ¶
func (col *Collection[T]) UpdateOneWithTrx(logger Logger, filter interface{}, update interface{}, sessCtx *mongo.SessionContext, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
type Logger ¶
type Logger interface { SlowQuery(msg string) GetTimeoutDuration() time.Duration // context cancel timeout setting // slow query time settings GetSlowQueryDurationOfOne() time.Duration GetSlowQueryDurationOfMany() time.Duration GetSlowQueryDurationOfBulk() time.Duration GetSlowQueryDurationOfAggregation() time.Duration }
type MyLogger ¶
func (*MyLogger) GetSlowQueryDurationOfAggregation ¶
func (*MyLogger) GetSlowQueryDurationOfBulk ¶
func (*MyLogger) GetSlowQueryDurationOfMany ¶
func (*MyLogger) GetSlowQueryDurationOfOne ¶
func (*MyLogger) GetTimeoutDuration ¶
Click to show internal directories.
Click to hide internal directories.