A restful API example using Gorm (ORM) and postgreSQL. The purpose for which I made this API was just for practice
GET /api/v1/category/
GET /api/v1/category/:id
POST /api/v1/category/
PATCH /api/v1/items/:id
DELETE /api/v1/items/:id
GET /api/v1/customer/
GET /api/v1/customer/:id
POST /api/v1/customer/
POST /api/v1/customer/:id
PATCH /api/v1/customer/:id
DELETE /api/v1/customer/:id
GET /api/v1/product/
GET /api/v1/product/:id
POST /api/v1/product/
PATCH /api/v1/product/:id
DELETE /api/v1/product/:id
Create a .env file, inside export URL connection where "market" is the database name.
export DATABASE_URI_DEV="postgres://postgres:root@localhost:5432/market?sslmode=disable"
before run migrations, make you sure to create the database on your database engine.
Inside server.go, uncomment the method "StartMigrations()"
//initial migrations
connection.StartMigrations()
Run it once
go run ./server.go
if you do the above settings correctly, everything should be fine, now if you look the database engine you'll see the migrated tables (Comment again "StartMigrations()" method).