Documentation ¶
Index ¶
- func ConvertDateTime()
- func GetObjectID(ID bson.ObjectId) string
- func LoadJSONFile(filePath string) ([]byte, error)
- func New(host, db, user, pass string, port uint16)
- type MongoInfo
- func (mi *MongoInfo) Close()
- func (mi *MongoInfo) DelAllDocs(colName string) (err error)
- func (mi *MongoInfo) DropCol(colName string) (err error)
- func (mi *MongoInfo) DropDB(dbName string) error
- func (mi *MongoInfo) FindOne(bd bson.M, data interface{}) error
- func (mi *MongoInfo) GetCol(colName string) *mgo.Collection
- func (mi *MongoInfo) GetCount() int
- func (mi *MongoInfo) GetDB(dbName string) *mgo.Database
- func (mi *MongoInfo) SetExpireOnCollection(sessionExpire time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertDateTime ¶
func ConvertDateTime()
ConvertDateTime is to convert datetime GMT MongoDB stores times in UTC by default
func GetObjectID ¶
GetObjectID is to get ObjectId as string
func LoadJSONFile ¶
LoadJSONFile is to load JSON file
Types ¶
type MongoInfo ¶
type MongoInfo struct { Session *mgo.Session Db *mgo.Database C *mgo.Collection // contains filtered or unexported fields }
MongoInfo is for MongoDB instance
func GetMongo ¶
func GetMongo() *MongoInfo
GetMongo is to get instance. singleton architecture
This is for singleton design pattern
func NewInstance ¶
NewInstance makes a new instance
func (*MongoInfo) DelAllDocs ¶
DelAllDocs is to delete all documents record from collection. Version3.x
func (*MongoInfo) GetCol ¶
func (mi *MongoInfo) GetCol(colName string) *mgo.Collection
GetCol is to get and set collection
Click to show internal directories.
Click to hide internal directories.