From 5354b57a87217c02d8d11ec0037f1a8ca246e397 Mon Sep 17 00:00:00 2001 From: tuuz Date: Mon, 13 Nov 2023 15:00:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Edb.Scan(struct)=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=9A=20-=20=E5=92=8CSelect=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=9A=84=E6=98=AF=EF=BC=8CScan=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=BB=85=E4=BB=85=E5=BD=B1=E5=93=8D=E8=BE=93=E5=87=BA?= =?UTF-8?q?=EF=BC=8C=E7=B1=BB=E4=BC=BCGoRedis=E7=9A=84Scan=E7=9A=84?= =?UTF-8?q?=E6=80=9D=E6=83=B3=EF=BC=8C=E4=BE=9D=E7=84=B6=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E6=8C=87=E5=AE=9Atable=EF=BC=8C=E5=8F=AA=E6=98=AF=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E7=9A=84Get=E6=88=96=E8=80=85Find=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=8D=A2=E6=88=90=E6=9C=AC=E6=96=B9=E6=B3=95=E5=8D=B3=E5=8F=AF?= =?UTF-8?q?=20-=20=E4=BC=A0=E5=85=A5struct{}=E5=8F=AF=E4=BB=A5=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=8D=95=E6=9D=A1=EF=BC=8C=E7=B1=BB=E4=BC=BCFind?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20-=20=E4=BC=A0=E5=85=A5[]struct{}=E5=B0=86?= =?UTF-8?q?=E4=BC=9A=E8=A7=A3=E6=9E=90=E6=88=90=E5=A4=9A=E6=9D=A1=EF=BC=8C?= =?UTF-8?q?=E7=B1=BB=E4=BC=BCGet=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 注意需要传入指针值,例如传入:&User{},而不是:User{} 避免(不是禁止的意思)使用这个方法传入Map[string]interface{} 如果你全程使用struct方法,建议你可以直接使用table().select()这样原版框架支持的模式来操作数据库,因为从代码思想和洁净度角度来看,保持业务代码风格统一也是很重要的 --- README.md | 31 ++++++++++++++++--------------- README_en.md | 17 ++++++++++------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index c9acec2..76614cc 100644 --- a/README.md +++ b/README.md @@ -79,27 +79,31 @@ ## 实例文档(Wiki) +说明:*为GorosePro独有功能 + - 增删改 - [增加Insert](../../wiki/Insert新增数据) - [删除Delete](../../wiki/Delete删除数据) - [更新Update](../../wiki/Update方法) - - [替换-Replace](../../wiki/Replace方法) + - *[替换-Replace](../../wiki/Replace方法) - 单条查询(对象)(Map[string]interface{}) - [Find/First返回对象](../../wiki/Find-First查询返回Obj对象方法) - 多条/联合查询([]Map[string]interface{} - [Get/Select返回数组](../../wiki/Get-Select方法) - [Join联合查询](../../wiki/Join-Select方法) - - [Paginator复杂的子查询分页构建](../../wiki/Paginator复杂的子查询分页构建) - - [PaginatorWG高性能分页](../../wiki/PaginatorWG多线程分页) + - *[Paginator复杂的子查询分页构建](../../wiki/Paginator复杂的子查询分页构建) + - *[PaginatorWG高性能分页](../../wiki/PaginatorWG多线程分页) - Query方法 - [Query方法使用原生语句查询](../../wiki/Query方法) - 嵌套事务 - - [支付环境下复杂的嵌套事务实例](../../wiki/支付环境下复杂的嵌套事务) + - *[支付环境下复杂的嵌套事务实例](../../wiki/支付环境下复杂的嵌套事务) - 子查询subQuery - - [SubSql防注入From子查询](../../wiki/SubQuery安全子查询) - - [SubWhere防注入where子查询](../../wiki/SubWhere安全子查询) + - *[SubSql防注入From子查询](../../wiki/SubQuery安全子查询) + - *[SubWhere防注入where子查询](../../wiki/SubWhere安全子查询) - 安全性能 - [Paginator-Performance-by-ChatGPT](../../wiki/Paginator分页查询的性能问题-ChatGPT ) +- 单条/多条查询(Struct) + - *[Scan方法](../../wiki/Scan将结果独立输出到struct) ## 简介 @@ -165,16 +169,13 @@ panic(err.Error()) ## TODO - 加入缓存层 - - 如果不使用Struct来接收返回,可能会导致Hash返回的Column类型从非string统一变成string(这是Redis的问题) - - 在开启缓存功能后避免使用断言是比较简单的解决方案,如果吧类型也存在Redis里面,固然能简单的解决但是也会增加Redis的链接负载 -- 可选泛型返回 - - 预计会对Select下手 - - 或者新增Scan方法 - - ScanGet\[T\]() - - ScanFind\[T\]() + - 如果不使用Struct来接收返回,可能会导致Hash返回的Column类型从非string统一变成string(这是Redis的问题) + - 在开启缓存功能后避免使用断言是比较简单的解决方案,如果吧类型也存在Redis里面,固然能简单的解决但是也会增加Redis的链接负载 +- 可选泛型返回...已完成 - ElasticSearch - - 数据自动上载 - - 从ES中读取数据 + - 数据自动上载 + - 从ES中读取数据 + ## Stargazers over time [![Stargazers over time](https://starchart.cc/tobycroft/gorose-pro.svg)](https://starchart.cc/tobycroft/gorose-pro) diff --git a/README_en.md b/README_en.md index e846b47..16f5ace 100644 --- a/README_en.md +++ b/README_en.md @@ -54,27 +54,31 @@ ## Docs and Demos(Wiki) +Notice:'*' means Only Support In GorosePro + - CUD functions - [Insert](../../wiki/Insert新增数据) - [Delete](../../wiki/Delete删除数据) - [Update](../../wiki/Update方法) - - [Replace](../../wiki/Replace方法) + - *[Replace](../../wiki/Replace方法) - Read the first line data and return in map[string]any - [Find/First](../../wiki/Find-First查询返回Obj对象方法) - Read multiple data in array by []map[string]any - [Get/Select](../../wiki/Get-Select方法) - [Join](../../wiki/Join-Select方法) - - [Paginator](../../wiki/Paginator复杂的子查询分页构建) - - [Paginator in HighPerformant](../../wiki/PaginatorWG多线程分页) + - *[Paginator](../../wiki/Paginator复杂的子查询分页构建) + - *[Paginator in HighPerformant](../../wiki/PaginatorWG多线程分页) - Raw SQL sentence mode - [Query](../../wiki/Query方法) - Nested Transaction(only support in GorosePro) - - [Demos](../../wiki/支付环境下复杂的嵌套事务) + - *[Demos](../../wiki/支付环境下复杂的嵌套事务) - subQuery - - [SubSql](../../wiki/SubQuery安全子查询) - - [SubWhere](../../wiki/SubWhere安全子查询) + - *[SubSql](../../wiki/SubQuery安全子查询) + - *[SubWhere](../../wiki/SubWhere安全子查询) - Security and Performance - [Paginator-Performance-by-ChatGPT](../../wiki/Paginator分页查询的性能问题-ChatGPT ) +- Single/Multiple data to struct(Struct) + - *[Scan方法](../../wiki/Scan将结果独立输出到struct) ## Introduction @@ -113,7 +117,6 @@ go get -u github.com/tobycroft/gorose-pro - [MySQL initializing](../../wiki/初始化方法MySQL) - [Oracle initializing](../../wiki/初始化方法Oracle) - For more configurations, you can configure the cluster, or even configure different databases at the same time. In a cluster, the database will randomly select the database of the cluster to complete the corresponding read-write operations. The master is the write database, and the slave is the read database. You need to do master-slave