Documentation ¶
Index ¶
- Variables
- type Index
- type IndexKey
- type MongoClient
- func (m *MongoClient) AbortTransaction(ctx context.Context) (interface{}, error)
- func (m *MongoClient) Aggregate(ctx context.Context, q interface{}) (*mongo.Cursor, error)
- func (m *MongoClient) Close() error
- func (m *MongoClient) CommitTransaction(ctx context.Context) (interface{}, error)
- func (m *MongoClient) Connect() error
- func (m *MongoClient) Create(ctx context.Context, t interface{}) error
- func (m *MongoClient) DropIndices() error
- func (m *MongoClient) EnsureIndices(indices []Index) error
- func (m *MongoClient) Get(ctx context.Context, q bson.M) (*mongo.SingleResult, error)
- func (m *MongoClient) List(ctx context.Context, q interface{}, skip, limit int) (*mongo.Cursor, error)
- func (m *MongoClient) Ping() error
- func (m *MongoClient) SetTTL() (interface{}, error)
- func (m *MongoClient) StartTransaction(ctx context.Context, id string) (context.Context, error)
- func (m *MongoClient) Update(ctx context.Context, q, val interface{}) error
- func (m *MongoClient) UpdatePartial(ctx context.Context, q, val interface{}) error
- type RedisClient
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotConnected = errors.New("redis: client not connected") ErrNotFound = errors.New("mongo: not found") )
list of infra errors.
Functions ¶
This section is empty.
Types ¶
type MongoClient ¶
MongoClient contains required field
func NewMongoClient ¶
func NewMongoClient(url string, ttl time.Duration) (*MongoClient, error)
NewMongoClient return a mongo client
func (*MongoClient) AbortTransaction ¶
func (m *MongoClient) AbortTransaction(ctx context.Context) (interface{}, error)
AbortTransaction aborts a transaction
func (*MongoClient) CommitTransaction ¶
func (m *MongoClient) CommitTransaction(ctx context.Context) (interface{}, error)
CommitTransaction finishes the transaction
func (*MongoClient) Connect ¶
func (m *MongoClient) Connect() error
Connect initiate a mongo connection
func (*MongoClient) Create ¶
func (m *MongoClient) Create(ctx context.Context, t interface{}) error
Create create a object
func (*MongoClient) DropIndices ¶
func (m *MongoClient) DropIndices() error
DropIndices drop previous mongo field
func (*MongoClient) EnsureIndices ¶
func (m *MongoClient) EnsureIndices(indices []Index) error
EnsureIndices ensure mongo index list
func (*MongoClient) Get ¶
func (m *MongoClient) Get(ctx context.Context, q bson.M) (*mongo.SingleResult, error)
Get return a single object based on query parameter
func (*MongoClient) List ¶
func (m *MongoClient) List(ctx context.Context, q interface{}, skip, limit int) (*mongo.Cursor, error)
List return a list of object based on query parameter
func (*MongoClient) Ping ¶
func (m *MongoClient) Ping() error
Ping check the mongo connection status
func (*MongoClient) SetTTL ¶
func (m *MongoClient) SetTTL() (interface{}, error)
SetTTL for mongo object
func (*MongoClient) StartTransaction ¶
StartTransaction starts the transaction
func (*MongoClient) Update ¶
func (m *MongoClient) Update(ctx context.Context, q, val interface{}) error
Update update a object
func (*MongoClient) UpdatePartial ¶
func (m *MongoClient) UpdatePartial(ctx context.Context, q, val interface{}) error
UpdatePartial update a object partially
type RedisClient ¶
RedisClient contain necessary field
func NewRedisClient ¶
func NewRedisClient(url string, ttl time.Duration) *RedisClient
NewRedisClient return a new RedisClient instance
func (*RedisClient) Create ¶
func (s *RedisClient) Create(key string, t []byte) error
Create create a new object