Documentation ¶
Index ¶
- func ConnectMongoDB(ctx context.Context, dsn string) (*mongo.Database, error)
- func ConnectPostgresDB(ctx context.Context, dsn string) (*sql.DB, error)
- func MigratePostgresDB(db *sql.DB, migrationsDir string) error
- type MongoRepository
- func (r *MongoRepository) Create(ctx context.Context, entity interface{}) (string, error)
- func (r *MongoRepository) Delete(ctx context.Context, ID string) error
- func (r *MongoRepository) Get(ctx context.Context, filter map[string]interface{}, skip, take *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{}) error
- type PostgresRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectMongoDB ¶
ConnectMongoDB opens a connection to the MongoDB and ensures that the db is reachable
func ConnectPostgresDB ¶
ConnectPostgresDB opens a connection to the PostgresDB and ensures that the db is reachable
Types ¶
type MongoRepository ¶
type MongoRepository struct { DB *mongo.Database Collection *mongo.Collection Target interface{} }
MongoRepository struct of a mongo repository Implements the Repository interface
func (*MongoRepository) Create ¶
func (r *MongoRepository) Create(ctx context.Context, entity interface{}) (string, 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 map[string]interface{}, skip, take *int) ([]interface{}, error)
Get gets the documents mathing the filter in the repository's collection
type PostgresRepository ¶
PostgresRepository struct of a mongo repository Needs a specific implementation of the Repository interface for every entity
Click to show internal directories.
Click to hide internal directories.