Skip to content

Commit 4e4c054

Browse files
author
cg33
committed
update to v1.2.13
1 parent e71ace9 commit 4e4c054

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

zh/admin/table/basic.md

+25
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,31 @@ info.AddField("Role Name", "role_name", db.Varchar).FieldJoin(types.Join{
214214
select ..., role.`role_name` from users left join role on users.`id` = role.`user_id` where ...
215215
```
216216

217+
多对多关系的连表,只需继续使用 FieldJoin :
218+
219+
```go
220+
221+
info.AddField("Role Name", "role_name", db.Varchar)FieldJoin(types.Join{
222+
Table: "role_users",
223+
JoinField: "user_id",
224+
Field: "id",
225+
}).
226+
FieldJoin(types.Join{
227+
Table: "roles",
228+
JoinField: "id",
229+
Field: "role_id",
230+
BaseTable: "role_users",
231+
})
232+
```
233+
234+
这将会生成类似这样的sql语句:
235+
236+
```sql
237+
select ..., roles.`role_name` from users left join role on users.`id` = role_users.`user_id` left join role_users.`role_id` = role.`id` where ...
238+
```
239+
240+
从而完成一次多对多关系的查询。
241+
217242
## 新增按钮
218243

219244
如果您需要新增一些功能按钮,可以调用:

0 commit comments

Comments
 (0)