Documentation ¶
Index ¶
- Variables
- func IsExist() bool
- func Recover() error
- func Remove() error
- type Client
- func (c *Client) Aggregate(ctx context.Context, name string, groupStage mongo.Pipeline) ([]bson.M, error)
- func (c *Client) DeleteOne(ctx context.Context, name string, filter interface{}) error
- func (c *Client) Disconnect(ctx context.Context) error
- func (c *Client) Find(ctx context.Context, name string, filters ...interface{}) ([]bson.M, error)
- func (c *Client) FindOne(ctx context.Context, name string, filter interface{}) *mongo.SingleResult
- func (c *Client) InsertOne(ctx context.Context, name string, filter interface{}) (interface{}, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) UpdateOne(ctx context.Context, name string, filter, update interface{}) (*mongo.UpdateResult, error)
- type MongoDB
Constants ¶
This section is empty.
Variables ¶
View Source
var CONFIG = MongoDB{
DB: "mongo_test",
Timeout: 10,
Addr: "localhost:27017",
}
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func GetClient ¶
ctx, cancel := context.WithTimeout(context.Background(), CONFIG.Timeout*time.Second) GetClient
func (*Client) Aggregate ¶
func (c *Client) Aggregate(ctx context.Context, name string, groupStage mongo.Pipeline) ([]bson.M, error)
Aggregate
Click to show internal directories.
Click to hide internal directories.