A sample program how to connect ent ORM
Execute command first
go run -mod=mod entgo.io/ent/cmd/ent new Book
go to ./ent/schema/book.go
and add fields(you want) to Book Schema
// Fields of the Book.
func (Book) Fields() []ent.Field {
return []ent.Field{
field.String("title").NotEmpty(),
field.String("author").NotEmpty(),
}
}
Execute command
go generate ./ent
Method | URL | Description |
---|---|---|
GET | /book | All Books Info |
GET | /book:id | One Book Info |
POST | /create | One Book Add |
PUT | /update/:id | One Book Update |
DELETE | /delete/:id | One Book Delete |