README ¶
MongoDB Adapter for Go
This module help to you some mongo command which add, get and del
Connect to Redis
mongoClient = ConnectMongo("mongodb://localhost:23176", , "dbname", "CollectionName")
Find
err := mongoClient.GetData(bson.D{{filters}}, interface{})
if err != nil {
log.Fatal(err.Error())
}
All Rows
err := mongoClient.GetAll(bson.D{{filters}}, interface{})
if err != nil {
log.Fatal(err.Error())
}
Insert
err := mongoClient.GetAll(bson.D{{filters}}, interface{})
if err != nil {
log.Fatal(err.Error())
}
Update
err := mongoClient.GetAll(bson.D{{filters}}, bson.D{{filters}})
if err != nil {
log.Fatal(err.Error())
}
Delete
err := mongoClient.DeleteData(bson.D{{filters}})
if err != nil {
log.Fatal(err.Error())
}
Documentation ¶
Index ¶
- type MongoClient
- func (c *MongoClient) AddData(insert interface{}) error
- func (c *MongoClient) DeleteData(filter bson.D) error
- func (c *MongoClient) GetAll(filter bson.D, returnData interface{}) error
- func (c *MongoClient) GetData(filter bson.D, returnData interface{}) error
- func (c *MongoClient) UpdateData(filter bson.D, update bson.D) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoClient ¶
type MongoClient struct { Client *mongo.Client Collection *mongo.Collection }
func ConnectMongo ¶
func ConnectMongo(mongoUrl string, dbName, collectionName string) *MongoClient
func (*MongoClient) AddData ¶
func (c *MongoClient) AddData(insert interface{}) error
func (*MongoClient) DeleteData ¶
func (c *MongoClient) DeleteData(filter bson.D) error
func (*MongoClient) GetAll ¶
func (c *MongoClient) GetAll(filter bson.D, returnData interface{}) error
func (*MongoClient) GetData ¶
func (c *MongoClient) GetData(filter bson.D, returnData interface{}) error
func (*MongoClient) UpdateData ¶
Click to show internal directories.
Click to hide internal directories.