Page sets the paging number for the model. The parameter `page` is started from 1 for paging. Note that, it differs that the Limit function starts from 0 for "LIMIT" statement. Note: Negative limit values are treated as zero.
(page, limit int)
| 675 | // Note that, it differs that the Limit function starts from 0 for "LIMIT" statement. |
| 676 | // Note: Negative limit values are treated as zero. |
| 677 | func (m *Model) Page(page, limit int) *Model { |
| 678 | model := m.getModel() |
| 679 | if page <= 0 { |
| 680 | page = 1 |
| 681 | } |
| 682 | if limit < 0 { |
| 683 | limit = 0 |
| 684 | } |
| 685 | model.start = (page - 1) * limit |
| 686 | model.limit = limit |
| 687 | return model |
| 688 | } |
| 689 | |
| 690 | // Having sets the having statement for the model. |
| 691 | // The parameters of this function usage are as the same as function Where. |