Skip to content

Commit

Permalink
Update database_to_structs.md, add example to show gen JSON (#743)
Browse files Browse the repository at this point in the history
* Update database_to_structs.md, add example to show gen JSON

* Update pages/gen/database_to_structs.md

Co-authored-by: jessetang <[email protected]>

---------

Co-authored-by: jessetang <[email protected]>
  • Loading branch information
code959437957 and demoManito authored Mar 9, 2024
1 parent c844bb4 commit 0c51c1c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pages/gen/database_to_structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func main() {
// Generate struct `User` based on table `users` and generating options
g.GenerateModel("users", gen.FieldIgnore("address"), gen.FieldType("id", "int64")),

// Generate struct `Customer` based on table `customer` and generating options
// customer table may have a tags column, it can be JSON type, gorm/gen tool can generate for your JSON data type
g.GenerateModel("customer", gen.FieldType("tags", "datatypes.JSON")),

)
g.ApplyBasic(
// Generate structs from all tables of current database
Expand Down

0 comments on commit 0c51c1c

Please sign in to comment.