当前位置:网站首页>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
边栏推荐
- 性能测试如何准备测试数据
- RK3399平台开发系列讲解(内核调试篇)2.50、嵌入式产品启动速度优化
- MongoDB permission verification is turned on and mongoose database configuration
- 【LeetCode】矩阵模拟相关题目汇总
- jenkins send mail system configuration
- 软件质量评估的通用模型
- SQL关联表更新
- Develop a SpaceX website based on the Appian low-code platform
- uniapp横向选项卡(水平滚动导航栏)效果demo(整理)
- 上课笔记(6)(2)——#742. 周末舞会
猜你喜欢
随机推荐
KT6368A Bluetooth certification problem_FCC and BQB_CE_KC certification or other instructions
矩阵数学原理
刘润直播预告 | 顶级高手,如何创造财富
如何写好测试用例
建模师经验分享:模型学习方法
数据类型及输入输出初探(C语言)
MongoDB权限验证开启与mongoose数据库配置
Some thoughts on writing
How to automatically push my new articles to my fans (very simple, can't learn to hit me)
上课笔记(6)(2)——#742. 周末舞会
Implementation principle of golang coroutine
Develop a SpaceX website based on the Appian low-code platform
【LeetCode】Summary of Two Pointer Problems
【LeetCode】双指针题解汇总
OpenCV:10特征检测
ARC129E Yet Another Minimization 题解 【网络流笔记】
《MySQL入门很轻松》第2章:MySQL管理工具介绍
没有这些「伪需求」,产品经理的 KPI 怎么完成?
对写作的一些感悟
中日颜色风格



![[CVA Valuation Training Camp] Financial Modeling Guide - Lecture 1](/img/8b/360df9a9094037dc358cb21c60cdc8.png)




