Documentation ¶
Index ¶
- type ChDocu
- type DBConf
- type DbType
- type IMongoDao
- type IMysqlDao
- type Machine
- type MongoDao
- func (m *MongoDao) ConnectMongo(dt DbType) (err error)
- func (m *MongoDao) DeleteData(host Machine, dbname, collection string, u int64) error
- func (m *MongoDao) DisconnectMongo(dt DbType)
- func (m *MongoDao) GetCollectionData(host Machine, db string, coll string, value []int64) (result []bson.M, err error)
- func (m *MongoDao) GetDataByUniqueKey(host Machine, db string, coll string, key string, value string) (result []bson.M, err error)
- func (m *MongoDao) GetHostConf(dt DbType, host Machine) *DBConf
- func (m *MongoDao) GetHostDatabseInfo(dt DbType, host Machine) (databases []string, u string, p string, err error)
- func (m *MongoDao) GetHostTable(dt DbType, host Machine, key string) (tables map[string]interface{}, err error)
- func (m *MongoDao) GetHosts(dt DbType) (hosts []Machine)
- func (m *MongoDao) ImportByJsfile(host Machine, jsfile *os.File, dbname string) error
- func (m *MongoDao) InsertData(host Machine, c string, dbname string, doc interface{}) error
- func (m *MongoDao) UpdateData(host Machine, dbname string, collection string, srcUid int64, destUid int64) error
- func (m *MongoDao) UseDatabase(host Machine, dbname string) (db *mongo.Database, err error)
- type MysqlDao
- func (m *MysqlDao) ConnectMySql(dt DbType) (err error)
- func (m *MysqlDao) DeleteConstraint(host Machine, dbname string, uid []int64) (err error)
- func (m *MysqlDao) DeleteData(host Machine, table string, uid int64) error
- func (m *MysqlDao) DisForeignKey(host Machine) error
- func (m *MysqlDao) DisconnectMysql(dt DbType)
- func (m *MysqlDao) GetConstraint(host Machine, dbname string, value []int64, path string) (err error)
- func (m *MysqlDao) GetDataByUniqueKey(host Machine, table string, key string, value string) (tableData []map[string]interface{}, err error)
- func (m *MysqlDao) GetHostConf(dt DbType, host Machine) *DBConf
- func (m *MysqlDao) GetHostDatabseInfo(dt DbType, host Machine) (databases []string, u string, p string, err error)
- func (m *MysqlDao) GetHostTable(dt DbType, host Machine, key string) (tables map[string]interface{}, err error)
- func (m *MysqlDao) GetHosts(dt DbType) (hosts []Machine)
- func (m *MysqlDao) GetMysqlTableData(host Machine, table string, value []int64) (tableData []map[string]interface{}, err error)
- func (m *MysqlDao) ImportByShell(host Machine, dbname string, path string) error
- func (m *MysqlDao) ModifyData(host Machine, table string, field int64, uid int64) (err error)
- func (m *MysqlDao) SwitchDB(host Machine, dbName string)
- type SqlType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DBConf ¶
type DBConf struct { Client Machine // User 用户名 User string // Password 密码 Password string Databases []string FromHost []string Keys []string Tables map[string]interface{} Dbtype DbType Sql SqlType }
func GetAllSqlInfo ¶
type IMongoDao ¶
type IMongoDao interface { ConnectMongo(dt DbType) (err error) DisconnectMongo(dt DbType) GetHosts(dt DbType) (hosts []Machine) GetHostConf(dt DbType, host Machine) *DBConf UseDatabase(host Machine, dbname string) (db *mongo.Database, err error) GetCollectionData(host Machine, db string, coll string, value []int64) (result []bson.M, err error) GetDataByUniqueKey(host Machine, db string, coll string, key string, value string) (result []bson.M, err error) UpdateData(host Machine, dbname string, collection string, srcUid int64, dstUid int64) error InsertData(host Machine, c string, dbname string, doc interface{}) error DeleteData(host Machine, dbname, collection string, u int64) error ImportByJsfile(host Machine, jsfile *os.File, dbname string) error GetHostTable(dt DbType, host Machine, key string) (tables map[string]interface{}, err error) GetHostDatabseInfo(dt DbType, host Machine) (databases []string, u string, p string, err error) }
type IMysqlDao ¶
type IMysqlDao interface { ConnectMySql(dt DbType) (err error) DisconnectMysql(dt DbType) GetHosts(dt DbType) (hosts []Machine) SwitchDB(host Machine, dbName string) DisForeignKey(host Machine) error GetMysqlTableData(host Machine, table string, value []int64) (res []map[string]interface{}, err error) GetDataByUniqueKey(host Machine, table string, key string, value string) (res []map[string]interface{}, err error) ModifyData(host Machine, table string, field int64, uid int64) error ImportByShell(host Machine, dbname string, path string) error DeleteData(host Machine, table string, u int64) error GetConstraint(host Machine, dbname string, value []int64, path string) (err error) DeleteConstraint(host Machine, dbname string, uid []int64) (err error) GetHostConf(dt DbType, host Machine) *DBConf GetHostTable(dt DbType, host Machine, key string) (tables map[string]interface{}, err error) GetHostDatabseInfo(dt DbType, host Machine) (databases []string, u string, p string, err error) }
实现这四个函数,用于封装服务
type MongoDao ¶
type MongoDao struct {
Conf []*DBConf
}
func (*MongoDao) ConnectMongo ¶
ConnectMongo 连接所有的mongo server
func (*MongoDao) DeleteData ¶
func (*MongoDao) DisconnectMongo ¶
func (*MongoDao) GetCollectionData ¶
func (m *MongoDao) GetCollectionData(host Machine, db string, coll string, value []int64) (result []bson.M, err error)
GetCollectionData 获取collection中的数据
func (*MongoDao) GetDataByUniqueKey ¶
func (*MongoDao) GetHostDatabseInfo ¶
func (*MongoDao) GetHostTable ¶
func (*MongoDao) ImportByJsfile ¶
func (*MongoDao) InsertData ¶
func (*MongoDao) UpdateData ¶
type MysqlDao ¶
type MysqlDao struct { //DB *sqlx.DB Conf []*DBConf }
func (*MysqlDao) ConnectMySql ¶
ConnectMysql 创建mysql的连接
func (*MysqlDao) DeleteConstraint ¶
func (*MysqlDao) DeleteData ¶
func (*MysqlDao) DisForeignKey ¶
DisForeignKey 禁用外键约束
func (*MysqlDao) DisconnectMysql ¶
func (*MysqlDao) GetConstraint ¶
func (m *MysqlDao) GetConstraint(host Machine, dbname string, value []int64, path string) (err error)
GetConstraint 导出外键关联的数据
func (*MysqlDao) GetDataByUniqueKey ¶
func (*MysqlDao) GetHostDatabseInfo ¶
func (*MysqlDao) GetHostTable ¶
func (*MysqlDao) GetMysqlTableData ¶
func (m *MysqlDao) GetMysqlTableData(host Machine, table string, value []int64) (tableData []map[string]interface{}, err error)
GetMysqlTableData 获取table中符合要求的数据
func (*MysqlDao) ImportByShell ¶
func (*MysqlDao) ModifyData ¶
Click to show internal directories.
Click to hide internal directories.