当前位置:网站首页>gorm的Raw与scan
gorm的Raw与scan
2022-08-05 00:11:00 【景行三千】
gorm的Raw与scan
Raw
- 中文:原生的
作用:在写gorm语句时候用来写Raw sql语句(原生sql语句)
gorm官方介绍Scan:
https://gorm.io/zh_CN/docs/query.html#Scan
Scanning results into a struct works similarly to the way we use Find
百度翻译:将结果扫描到结构中的工作方式与“Find”类似`
type Result struct {
Name string
Age int
}
var result Result
db.Table("users").Select("name", "age").Where("name = ?", "Antonio").Scan(&result)
// Raw SQL
db.Raw("SELECT name, age FROM users WHERE name = ?", "Antonio").Scan(&result
总结:不看源码的话,不必纠结,可以理解为find和scan一样,
注意点:一般写联表查询的时候,会用scan
边栏推荐
- VMware NSX 4.0 -- 网络安全虚拟化平台
- 如何写好测试用例
- 【LeetCode】矩阵模拟相关题目汇总
- Bidding Announcement | Operation and Maintenance Project of Haina Baichuang Official Account
- 2 用D435i运行VINS-fusion
- 网站最终产品页使用单一入口还是多入口?
- KT148A voice chip ic working principle and internal architecture description of the chip
- 怎样进行在不改变主线程执行的时候,进行日志的记录
- Develop a SpaceX website based on the Appian low-code platform
- 子连接中的参数传递
猜你喜欢
随机推荐
SQL association table update
【数据挖掘概论】数据挖掘的简单描述
leetcode经典例题——单词拆分
KT148A语音芯片怎么烧录语音进入芯片里面通过串口和电脑端的工具
The applicable scenarios and common product types of the KT148A electronic voice chip ic solution
2 用D435i运行VINS-fusion
4 - "PyTorch Deep Learning Practice" - Backpropagation
Security software Avast and Symantec NortonLifeLock merge with UK approval, market value soars 43%
子连接中的参数传递
Mysql_13 事务
游戏3D建模入门,有哪些建模软件可以选择?
2022年华数杯数学建模
Develop a SpaceX website based on the Appian low-code platform
MAUI Blazor 权限经验分享 (定位,使用相机)
【云原生--Kubernetes】调度约束
Cloud native - Kubernetes 】 【 scheduling constraints
IDEA 文件编码修改
The role of the annotation @ EnableAutoConfiguration and how to use
.net(C#)获取两个日期间隔的年月日
How to burn the KT148A voice chip into the chip through the serial port and the tools on the computer