Documentation ¶
Index ¶
- func AddToSet(field string, value interface{}) bson.M
- func Compose(elements ...bson.DocElem) bson.M
- func FromID(id string) bson.M
- func Insert(ctx context.Context, col *mgo.Collection, entity interface{}) error
- func PipeList(ctx context.Context, col *mgo.Collection, pipeline []bson.M, ...) error
- func PipeOne(ctx context.Context, col *mgo.Collection, pipeline []bson.M, ...) error
- func QueryCount(ctx context.Context, col *mgo.Collection, criteria interface{}, ...) error
- func QueryList(ctx context.Context, col *mgo.Collection, criteria interface{}, ...) error
- func QueryOne(ctx context.Context, col *mgo.Collection, criteria interface{}, ...) error
- func Remove(ctx context.Context, col *mgo.Collection, criteria interface{}) error
- func RemoveFromSet(field string, value interface{}) bson.M
- func Set(field string, value interface{}) bson.M
- func Update(ctx context.Context, col *mgo.Collection, criteria interface{}, ...) error
- type ContextFactory
- type Operation
- type OperationContext
- type OperationExecutor
- type Option
- type Repository
- type RepositoryFactory
- type Session
- type SessionFactory
- type SessionProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PipeList ¶
func PipeList(ctx context.Context, col *mgo.Collection, pipeline []bson.M, entity interface{}, visit func(interface{}) error) error
PipeList function
func PipeOne ¶
func PipeOne(ctx context.Context, col *mgo.Collection, pipeline []bson.M, entity interface{}, visit func(interface{}) error) error
PipeOne function
func QueryCount ¶
func QueryCount(ctx context.Context, col *mgo.Collection, criteria interface{}, visit func(int) error) error
QueryCount function
func QueryList ¶
func QueryList(ctx context.Context, col *mgo.Collection, criteria interface{}, entity interface{}, visit func(interface{}) error) error
QueryList function
func QueryOne ¶
func QueryOne(ctx context.Context, col *mgo.Collection, criteria interface{}, entity interface{}, visit func(interface{}) error) error
QueryOne function
func RemoveFromSet ¶
Types ¶
type ContextFactory ¶
ContextFactory interface
func CreateContextFactory ¶
func CreateContextFactory(p SessionProvider, l logger.Logger) ContextFactory
CreateContextFactory instance
type Operation ¶
type Operation func(*mgo.Collection) error
Operation to be performed on mongo collection
type OperationContext ¶
OperationContext declares operation context
func CreateOperationContext ¶
func CreateOperationContext(ctx context.Context, db string, col string) *OperationContext
CreateOperationContext creates OperationContext
type OperationExecutor ¶
type OperationExecutor interface {
Execute(*OperationContext, Operation) error
}
OperationExecutor executes operation
func CreateExecutor ¶
func CreateExecutor(p SessionProvider, l logger.Logger) OperationExecutor
CreateExecutor instance
type Repository ¶
Repository type
func (*Repository) Create ¶
func (r *Repository) Create(ctx context.Context, entity interface{}) (string, error)
Create new document
type RepositoryFactory ¶
type RepositoryFactory struct { logger.Logger OperationExecutor // contains filtered or unexported fields }
RepositoryFactory type
func CreateRepositoryFactory ¶
func CreateRepositoryFactory(db string, e OperationExecutor, l logger.Logger) *RepositoryFactory
CreateRepositoryFactory creates repository factory
func (*RepositoryFactory) CreateRepository ¶
func (f *RepositoryFactory) CreateRepository(col string) *Repository
CreateRepository creates new repository
type Session ¶
type Session interface { Session() *mgo.Session Close(bool) }
func FromContext ¶
FromContext gets mongo session from context
func GetSession ¶
func GetSession(providers ...SessionProvider) Session
type SessionFactory ¶
type SessionFactory interface {
Session() (*mgo.Session, error)
}
SessionFactory interface
func CreateSessionFactory ¶
func CreateSessionFactory(opts ...Option) SessionFactory
CreateSessionFactory instance
type SessionProvider ¶
type SessionProvider interface {
Provide() Session
}
SessionProvider interface
func CreateContextSessionProvider ¶
func CreateContextSessionProvider(c context.Context, l logger.Logger) SessionProvider
CreateContextSessionProvider instance
func CreateCopySessionProvider ¶
func CreateCopySessionProvider(p SessionProvider, l logger.Logger) SessionProvider
CreateCopySessionProvider instance
func CreateSessionProvider ¶
func CreateSessionProvider(f SessionFactory, l logger.Logger) SessionProvider
CreateSessionProvider instance