2022年5月26日 星期四

[Golang] GORM: Get started

   Golang   GORM    ORM 




Introduction


GORM is the ORM library for Golang. Here are my notes to get started.

I used PostgreSQL as the database, you can create a PostgreSQL container in Docker by following the steps.


Basic

Learn how to CRUD(Insert, Update, Delete and Query) one row or many rows.


Relations

We can establish foreign key, one-to-one (Has one), one-to-many (Has many) or many-to-many relations on or between Tables in GORM  by defining Field tags on struct.


Gin + GORM

I wrote the sample code to integrate Gin and GORM, and it also supports API document by gin-swagger.

For how to use gin-swagger, see the article: Gin + Swagger.




沒有留言:

張貼留言