Documentation ¶
Index ¶
- func Init(uri, db string, maxPool uint64) (*mongo.Database, error)
- type BaseRepository
- func (b *BaseRepository) Aggregate(ctx context.Context, sortFields []string, sortValue []int, page int64, ...) ([]interface{}, int64, error)
- func (b *BaseRepository) Collection() *mongo.Collection
- func (b *BaseRepository) Create(ctx context.Context, model interface{}) (primitive.ObjectID, error)
- func (b *BaseRepository) CreateCompoundIndex(ctx context.Context, compoundIndex []string, unique bool) error
- func (b *BaseRepository) CreateMany(ctx context.Context, models []interface{}) ([]primitive.ObjectID, error)
- func (b *BaseRepository) Database() *mongo.Database
- func (b *BaseRepository) Delete(ctx context.Context, ids []primitive.ObjectID) error
- func (b *BaseRepository) Filter(ctx context.Context, filters map[string]interface{}, sortFields []string, ...) (int64, error)
- func (b *BaseRepository) FindById(ctx context.Context, id primitive.ObjectID, value interface{}) error
- func (b *BaseRepository) FindOne(ctx context.Context, filters map[string]interface{}, value interface{}) error
- func (b *BaseRepository) Update(ctx context.Context, model interface{}, id primitive.ObjectID, ...) error
- func (b *BaseRepository) WithTransaction(ctx context.Context, ...) (interface{}, error)
- type Repository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseRepository ¶
func (*BaseRepository) Collection ¶
func (b *BaseRepository) Collection() *mongo.Collection
func (*BaseRepository) CreateCompoundIndex ¶
func (*BaseRepository) CreateMany ¶
func (*BaseRepository) Database ¶
func (b *BaseRepository) Database() *mongo.Database
func (*BaseRepository) FindOne ¶
func (b *BaseRepository) FindOne(ctx context.Context, filters map[string]interface{}, value interface{}) error
func (*BaseRepository) WithTransaction ¶
func (b *BaseRepository) WithTransaction(ctx context.Context, callback func(sessCtx mongo.SessionContext) (interface{}, error), opts ...*options.TransactionOptions) (interface{}, error)
type Repository ¶
type Repository interface { Database() *mongo.Database Collection() *mongo.Collection FindById(ctx context.Context, id primitive.ObjectID, value interface{}) error Create(ctx context.Context, model interface{}) (primitive.ObjectID, error) CreateMany(ctx context.Context, models []interface{}) ([]primitive.ObjectID, error) Update(ctx context.Context, model interface{}, id primitive.ObjectID, dateModified int64) error Delete(ctx context.Context, id []primitive.ObjectID) error Filter(ctx context.Context, filters map[string]interface{}, sortFields []string, sortValues []int, page int64, limit int64, result interface{}) (int64, error) CreateCompoundIndex(ctx context.Context, compoundIndex []string, unique bool) error FindOne(ctx context.Context, filters map[string]interface{}, value interface{}) error Aggregate(ctx context.Context, sortFields []string, sortValues []int, page int64, limit int64, agg ...interface{}) ([]interface{}, int64, error) WithTransaction(ctx context.Context, fn func(sessCtx mongo.SessionContext) (interface{}, error), opts ...*options.TransactionOptions) (interface{}, error) }
Click to show internal directories.
Click to hide internal directories.