client

package
v0.0.0-...-befe94a Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToConvertToObjectID = errors.New("failed to convert to object id")
)

Functions

This section is empty.

Types

type DefaultMongoDBClient

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

func NewMongoDBClient

func NewMongoDBClient(ctx context.Context, conf *config.Config) (*DefaultMongoDBClient, func(), error)

func (*DefaultMongoDBClient) DeleteOne

func (c *DefaultMongoDBClient) DeleteOne(ctx context.Context, database string, collection string, filter interface{}) (*mongo.DeleteResult, error)

func (*DefaultMongoDBClient) FindMany

func (c *DefaultMongoDBClient) FindMany(
	ctx context.Context,
	database string,
	collection string,
	filter interface{},
	orderBy interface{},
	page int64,
	limit int64,
) (*mongo.Cursor, error)

func (*DefaultMongoDBClient) FindOne

func (c *DefaultMongoDBClient) FindOne(ctx context.Context, database string, collection string, filter interface{}) *mongo.SingleResult

func (*DefaultMongoDBClient) InsertOne

func (c *DefaultMongoDBClient) InsertOne(ctx context.Context, database string, collection string, data interface{}) (*primitive.ObjectID, error)

func (*DefaultMongoDBClient) UpdateOne

func (c *DefaultMongoDBClient) UpdateOne(ctx context.Context, database string, collection string, filter interface{}, update interface{}) (*mongo.UpdateResult, error)

type MongoDBClient

type MongoDBClient interface {
	InsertOne(ctx context.Context, database string, collection string, data interface{}) (*primitive.ObjectID, error)
	FindOne(ctx context.Context, database string, collection string, filter interface{}) *mongo.SingleResult
	FindMany(ctx context.Context, database string, collection string, filter interface{}, orderBy interface{}, page int64, limit int64) (*mongo.Cursor, error)
	UpdateOne(ctx context.Context, database string, collection string, filter interface{}, update interface{}) (*mongo.UpdateResult, error)
	DeleteOne(ctx context.Context, database string, collection string, filter interface{}) (*mongo.DeleteResult, error)
}

Jump to

Keyboard shortcuts

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