Skip to content

Commit

Permalink
update README.md, fix response cache
Browse files Browse the repository at this point in the history
  • Loading branch information
morkid committed Mar 9, 2021
1 parent cd02c02 commit ac9a0aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gorm Pagination
# paginate - Gorm Pagination

[![Go Reference](https://pkg.go.dev/badge/github.com/morkid/paginate.svg)](https://pkg.go.dev/github.com/morkid/paginate)
[![CircleCI](https://circleci.com/gh/morkid/paginate.svg?style=svg)](https://circleci.com/gh/morkid/paginate)
Expand All @@ -7,7 +7,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/morkid/paginate)](https://goreportcard.com/report/github.com/morkid/paginate)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/morkid/paginate)](https://github.com/morkid/paginate/releases)

Simple way to paginate gorm result. [Gorm](https://github.com/go-gorm/gorm) Pagination is compatible for [net/http](https://golang.org/pkg/net/http/) or [fasthttp](https://github.com/valyala/fasthttp). This library also supports many frameworks are based on net/http or fasthttp.
Simple way to paginate [Gorm](https://github.com/go-gorm/gorm) result. **paginate** is compatible for [net/http](https://golang.org/pkg/net/http/) and [fasthttp](https://github.com/valyala/fasthttp). This library also supports many frameworks are based on net/http or fasthttp.

## Table Of Contents
- [Installation](#installation)
Expand Down Expand Up @@ -792,7 +792,7 @@ pg.ClearAllCache()
## Limitations
Gorm pagination doesn't support has many relationship. You can make API with separated endpoints for parent and child:
Paginate doesn't support has many relationship. You can make API with separated endpoints for parent and child:
```javascript
GET /users
Expand Down Expand Up @@ -842,7 +842,7 @@ GET /users/1/addresses
}
```

Gorm pagination doesn't support for customized json or table field name.
Paginate doesn't support for customized json or table field name.
Make sure your struct properties have same name with gorm column and json property before you expose them.
Example bad configuration:
Expand Down
1 change: 1 addition & 0 deletions paginate.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func (r resContext) Response(res interface{}) Page {
hasAdapter = true
if cKey != "" && adapter.IsValid(cKey) {
if cache, err := adapter.Get(cKey); nil == err {
page.Items = res
if err := json.Unmarshal([]byte(cache), &page); nil == err {
return page
}
Expand Down

0 comments on commit ac9a0aa

Please sign in to comment.