orm

package
v0.0.0-...-66224dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

对 gorm 的拓展

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*gorm.DB
}

gorm.DB 的包装类, 拓展了一些方法

func NewDB

func NewDB(db *gorm.DB) *DB

创建一个 DB 实例

func (*DB) StartPage

func (o *DB) StartPage(pageParam *PageParam, list interface{}) *paging

开始分页

pageParam: 分页信息

list: 类型切片的引用, 示例: ` &[]model.User{} ` 必须满足此种格式.

type PageParam

type PageParam struct {
	// 当前页码
	Page int `json:"page" form:"page"`
	// 每页条数
	Size int `json:"size" form:"size"`
}

分页参数

func NewPageParam

func NewPageParam() *PageParam

创建一个 默认 size 为 10 的分页参数信息

type PageResult

type PageResult struct {
	Total int64       `json:"total"`
	List  interface{} `json:"list"`
}

分页结果

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL