gorm增刪查改json gorm 關聯查詢請教

2021-10-13 08:41:38 字數 677 閱讀 4442

有如下兩張表

type activity_record struct ).select("activity_records.id,activity_records.activity_config_id").find(&list)

列印的 sql 語句:

[2020-07-06 09:54:57] [1.00ms] select activity_records.id,activity_records.activity_config_id from activity_records

[2020-07-06 09:54:57] [0.99ms] select id, type from activity_configs where (id in (35))

返回資料:

"id": 4,

"activity_config_id": 35,

"ac": {

"id": 35,

"type": 1

但是看起來它執行了兩次查詢,又沒有別的什麼方式讓生成如下的 sql 語句,並且返回資料結構如上面的結構:如

select ar.*, ac.* from activity_records ar inner join activity_configs ac on ac.id = ar.activity_config_id

剛開始看 golang,大佬些指點下

MongoDB增刪查改

mongodb沒有建立資料庫的命令,但是你可以先執行use db name來進行一些操作,如db.createcollection db table 這樣就可以建立乙個db name的資料庫了。以下語句其實都不用加引號 insert方法 insert obj db.test.insert write...

sed 增刪查改

對每行處理,文字替換 1.替換 s命令 sed s jcdd ganji g file 把檔案 file 中出現jcdd 的換出ganji.g標誌在整行範圍內把jcdd都替換為ganji。如果沒有g 標記,則只有每行第乙個匹配的jcdd被替換成ganji。g換出 ng代表 第n處開始出現的替換 se...

angular增刪查改

數量排序 ng model numsby 數量正序 數量倒序 ng click deleteall 批量刪除 ng click selectall 產品編號 產品名稱 購買數量 產品單價 產品總價 操作ng repeat x in product filter orderby numsby clas...