1 Star 0 Fork 0

玟兵/go-util

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mysql_row.go 946 Bytes
一键复制 编辑 原始数据 按行查看 历史
玟兵 提交于 2024-06-24 20:08 +08:00 . 优化细节
package util
// MysqlRow 数据单元
type MysqlRow map[string]any
// ToStr 查询结果转字符串
func (row *MysqlRow) ToStr(key string) string {
return InterfaceToStr((*row)[key])
}
func (row *MysqlRow) ToStrings(key string) []string {
ret, _ := (*row)[key].([]string)
return ret
}
func (row *MysqlRow) ToMap(key string) map[string]any {
ret, _ := (*row)[key].(map[string]any)
return ret
}
// ToInt64 查询结果转整形
func (row *MysqlRow) ToInt64(key string) int64 {
return InterfaceToInt64((*row)[key])
}
// ToNum 查询结果转数字
func (row *MysqlRow) ToNum(key string) float64 {
return InterfaceToFloat64((*row)[key])
}
func (row *MysqlRow) Drop(keys ...string) {
for _, key := range keys {
delete(*row, key)
}
}
func (row *MysqlRow) DropAll() {
clear(*row)
}
func (row *MysqlRow) Set(key string, val any) {
(*row)[key] = val
}
func (row *MysqlRow) Has(key string) bool {
_, ok := (*row)[key]
return ok
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/binny_w/go-util.git
git@gitee.com:binny_w/go-util.git
binny_w
go-util
go-util
v0.0.49

搜索帮助