Documentation ¶
Index ¶
- func GetMongoClient() (*mongo.Client, error)
- func IsDuplicateKey(key string, err error) bool
- func IsKeyDuplicated(err error) bool
- func IsNotFound(err error) bool
- type Map
- type Repo
- func (db *Repo) Aggregate(ctx context.Context, results interface{}, col string, pipeline interface{}, ...) error
- func (db *Repo) BulkWrite(ctx context.Context, operations []mongo.WriteModel, ...) error
- func (db *Repo) CountBy(ctx context.Context, query Map) (int64, error)
- func (db *Repo) CountManyByOwner(ctx context.Context, ownerID string, query Map) (int64, error)
- func (db *Repo) DeleteFile(ctx context.Context, filename string) error
- func (db *Repo) DeleteMany(ctx context.Context, query Map) error
- func (db *Repo) DeleteOne(ctx context.Context, data helpermodels.Datable) error
- func (db *Repo) Find(ctx context.Context, query Map, data interface{}, opts ...*options.FindOptions) error
- func (db *Repo) FindBy(ctx context.Context, by, key string, p Map, result helpermodels.Datable) error
- func (db *Repo) FindByID(ctx context.Context, id string, p Map, result helpermodels.Datable) error
- func (db *Repo) FindOne(ctx context.Context, query Map, data interface{}, ...) error
- func (db *Repo) GetFile(ctx context.Context, id string) ([]byte, int64, error)
- func (db *Repo) Insert(ctx context.Context, data helpermodels.Datable) error
- func (db *Repo) SaveFile(ctx context.Context, filename, fileType string, file []byte) error
- func (db *Repo) SoftDeleteMany(ctx context.Context, q Map) error
- func (db *Repo) UpdateMany(ctx context.Context, query Map, updateWith Map, opts ...*options.UpdateOptions) error
- func (db *Repo) UpdateOne(ctx context.Context, data helpermodels.Datable, upsert bool) error
- type Repoable
- type Storage
- type StorageMongo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMongoClient ¶
GetMongoClient : To Get Mongo Client Object
func IsDuplicateKey ¶
IsDuplicateKey test if a key already exist on storage
func IsKeyDuplicated ¶
IsKeyDuplicated test if a key already exist on storage
Types ¶
type Map ¶
type Map map[string]interface{}
func MergeDefaultProjection ¶
MergeDefaultProjection merge projection with required values
type Repo ¶
type Repo struct { Storage Storage Collection *mongo.Collection }
Repo all table DB instances
func (*Repo) BulkWrite ¶
func (db *Repo) BulkWrite(ctx context.Context, operations []mongo.WriteModel, op *options.BulkWriteOptions) error
func (*Repo) CountManyByOwner ¶
func (*Repo) UpdateMany ¶
type Repoable ¶
type Repoable interface { DeleteFile(ctx context.Context, filename string) error SaveFile(ctx context.Context, filename, fileType string, file []byte) error GetFile(ctx context.Context, id string) ([]byte, int64, error) FindBy(ctx context.Context, by, key string, p Map, result helpermodels.Datable) error Find(ctx context.Context, query Map, data interface{}, opts ...*options.FindOptions) error FindOne(ctx context.Context, query Map, data interface{}, opts ...*options.FindOneOptions) error FindByID(ctx context.Context, id string, p Map, result helpermodels.Datable) error Insert(ctx context.Context, data helpermodels.Datable) error UpdateOne(ctx context.Context, data helpermodels.Datable, upsert bool) error UpdateMany(ctx context.Context, query Map, updateWith Map, opts ...*options.UpdateOptions) error CountManyByOwner(ctx context.Context, ownerID string, query Map) (int64, error) CountBy(ctx context.Context, query Map) (int64, error) BulkWrite(ctx context.Context, operations []mongo.WriteModel, op *options.BulkWriteOptions) error SoftDeleteMany(ctx context.Context, q Map) error DeleteOne(ctx context.Context, data helpermodels.Datable) error DeleteMany(ctx context.Context, query Map) error Aggregate(ctx context.Context, r interface{}, c string, p interface{}, o *options.AggregateOptions) error }
type Storage ¶
type Storage interface { GetDatabase() *mongo.Database GetCollection(name string) *mongo.Collection }
type StorageMongo ¶
type StorageMongo struct { Database string CollectionPrefix string // contains filtered or unexported fields }
StorageMongo define all storage action and methods
func (*StorageMongo) GetCollection ¶
func (s *StorageMongo) GetCollection(name string) *mongo.Collection
func (*StorageMongo) GetDatabase ¶
func (s *StorageMongo) GetDatabase() *mongo.Database
Click to show internal directories.
Click to hide internal directories.