使用GoFrame ORM查询数据时,由于字段值是一个泛型对象,返回的数据类型将会被自动识别映射到Go变量类型,作为泛型的具体值。

例如:

以下以mysql类型为例,介绍数据库类型与Go变量类型的自动识别映射关系: 

版本可能随时迭代更新,具体可查看源码 https://github.com/gogf/gf/blob/master/database/gdb/gdb_core_structure.go 


数据库类型Go变量类型
*charstring
*textstring
*binarybytes
*blobbytes
*intint
*moneyfloat64
bitint
big_intint64
floatfloat64
doublefloat64
decimalfloat64
boolbool
datetime.Time
datetimetime.Time
timestamptime.Time
其他string

这一特性对于需要将查询结果进行编码,并通过例如JSON方式直接返回给客户端来说将会非常友好。