December 2017
Intermediate to advanced
316 pages
6h 58m
English
This ORM has the API for all operations that can be done in the database/sql package. We can install GORM using this command:
go get -u github.com/jinzhu/gorm
For full documentation about this ORM, visit, http://jinzhu.me/gorm/. Let us write a program that implements user and order type JSON models. A user can place an order. We will use the models that we defined in the previous chapter. We can create a new directory called jsonstore in $GOPATH/src/github.com/narenaryan and create a new directory for our model in it:
mkdir jsonstoremkdir jsonstore/modelstouch jsonstore/models/models.go
Now, edit the models.go file to this:
package models import ( "github.com/jinzhu/gorm" _ "github.com/lib/pq" ) type User struct ...
Read now
Unlock full access