You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`goqu` also supports scanning into multiple structs. In the example below we define a `Role` and `User` struct that could both be used individually to scan into. However, you can also create a new struct that adds both structs as fields that can be populated in a single query.
846
+
847
+
**NOTE** When calling `ScanStructs` without a select already defined it will automatically only `SELECT` the columns found in the struct
848
+
849
+
```go
850
+
typeRolestruct {
851
+
Iduint64`db:"id"`
852
+
UserIDuint64`db:"user_id"`
853
+
Namestring`db:"name"`
854
+
}
855
+
typeUserstruct {
856
+
Iduint64`db:"id"`
857
+
FirstNamestring`db:"first_name"`
858
+
LastNamestring`db:"last_name"`
859
+
}
860
+
typeUserAndRolestruct {
861
+
UserUser`db:"goqu_user"`// tag as the "goqu_user" table
862
+
RoleRole`db:"user_role"`// tag as "user_role" table
`goqu` also supports scanning into multiple structs. In the example below we define a `Role` and `User` struct that could both be used individually to scan into. However, you can also create a new struct that adds both structs as fields that can be populated in a single query.
945
+
946
+
**NOTE** When calling `ScanStruct` without a select already defined it will automatically only `SELECT` the columns found in the struct
947
+
948
+
```go
949
+
typeRolestruct {
950
+
UserIDuint64`db:"user_id"`
951
+
Namestring`db:"name"`
952
+
}
953
+
typeUserstruct {
954
+
IDuint64`db:"id"`
955
+
FirstNamestring`db:"first_name"`
956
+
LastNamestring`db:"last_name"`
957
+
}
958
+
typeUserAndRolestruct {
959
+
UserUser`db:"goqu_user"`// tag as the "goqu_user" table
960
+
RoleRole`db:"user_role"`// tag as "user_role" table
**NOTE** Using the `goqu.SetColumnRenameFunction` function, you can change the function that's used to rename struct fields when struct tags aren't defined
0 commit comments