Documentation ¶
Index ¶
- func ConnectMongoDB(ctx context.Context, name string, connection string) (*mongo.Database, error)
- type MongoRepository
- func (r *MongoRepository) Create(ctx context.Context, entity interface{}) (primitive.ObjectID, error)
- func (r *MongoRepository) Delete(ctx context.Context, ID string) error
- func (r *MongoRepository) Get(ctx context.Context, filter primitive.M, skip, limit *int) ([]interface{}, error)
- func (r *MongoRepository) GetByID(ctx context.Context, ID string) (interface{}, error)
- func (r *MongoRepository) Update(ctx context.Context, ID string, entity interface{}, upsert bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MongoRepository ¶
type MongoRepository struct {
// contains filtered or unexported fields
}
MongoRepository struct of a mongo repository
func NewMongoRepository ¶
func NewMongoRepository(collection *mongo.Collection, target interface{}) *MongoRepository
NewMongoRepository creates a mongodb repository
func (*MongoRepository) Create ¶
func (r *MongoRepository) Create(ctx context.Context, entity interface{}) (primitive.ObjectID, error)
Create creates an entity in the repository's collection
func (*MongoRepository) Delete ¶
func (r *MongoRepository) Delete(ctx context.Context, ID string) error
Delete deletes the document with the specified ID in the repository's collection
func (*MongoRepository) Get ¶
func (r *MongoRepository) Get(ctx context.Context, filter primitive.M, skip, limit *int) ([]interface{}, error)
Get gets the documents mathing the filter in the repository's collection
Click to show internal directories.
Click to hide internal directories.