Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoMatches = errors.New("no matches found for query")
ErrNoMatches indicates that no matches were found for a query
View Source
var ErrUnexpectedInsertResult = errors.New("unexpected insert result")
ErrUnexpectedInsertResult indicates that a result set is not a valid insert result
Functions ¶
This section is empty.
Types ¶
type FindOptions ¶
FindOptions represents Find function options
type ModelInterface ¶
type ModelInterface interface { Exists() bool GetID() interface{} SetID(interface{}) }
ModelInterface defines common mongo models
type MongoClient ¶
type MongoClient interface { Connect(context.Context) error Database(string, ...*options.DatabaseOptions) *mongo.Database }
MongoClient encapsulates the MongoDB Client struct
type MongoDB ¶
type MongoDB interface {
Collection(string, ...*options.CollectionOptions) *mongo.Collection
}
MongoDB encapsulates the MongoDB DB struct
type MongoHelper ¶
type MongoHelper interface { NewClient(uri string) (MongoClient, error) Find(ctx context.Context, coll string, filter interface{}, item interface{}, opts FindOptions) (pagination.Result, error) FindOne(ctx context.Context, coll string, filter interface{}, item interface{}) InsertOne(ctx context.Context, coll string, item interface{}) (primitive.ObjectID, error) GetIDFromInsertOneResult(*mongo.InsertOneResult) (primitive.ObjectID, error) UpdateOne(ctx context.Context, coll string, filter interface{}, item interface{}) error GetIndex(ctx context.Context, coll string, index string) (*bson.M, error) HasIndex(ctx context.Context, coll string, index string) (bool, error) AddIndexIfNotExists(ctx context.Context, coll string, name string, keys interface{}) error Aggregate(ctx context.Context, coll string, pipeline mongo.Pipeline) ([]bson.M, error) }
MongoHelper is used for helper functions
func NewHelper ¶
func NewHelper(db MongoDB) MongoHelper
NewHelper get an implementation of a MongoHelper
Click to show internal directories.
Click to hide internal directories.