Documentation ¶
Index ¶
- func Deadlock(err error) bool
- func NotFound(err error) bool
- func UniqueViolation(err error) bool
- type Backend
- func (b *Backend) Begin() *Backend
- func (b *Backend) Close() error
- func (b *Backend) Connect(migrations ...*gormigrate.Migration) error
- func (b *Backend) Context() context.Context
- func (b *Backend) End(rErr error) error
- func (b *Backend) WithContext(ctx context.Context) *Backend
- func (b *Backend) WithLogger(printer Printer) *Backend
- type Pagination
- type Paginator
- type Printer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UniqueViolation ¶
UniqueViolation is true when database unique index is violated
Types ¶
type Backend ¶
type Backend struct { DB *gorm.DB Driver gorm.Dialector Config *gorm.Config Debug bool UseLogMixin bool Migrate bool MaxIdleConns int MaxOpenConns int ConnMaxLifetime time.Duration InitSchema func(*gorm.DB) error }
Backend implements generic database backend
func (*Backend) Connect ¶
func (b *Backend) Connect(migrations ...*gormigrate.Migration) error
Connect sets up the backend and applies migrations if Migrate flag is set to true. InitSchema func if set, is used to create initial schema.
func (*Backend) WithContext ¶
WithContext creates Backend clone with new context and logger
func (*Backend) WithLogger ¶
WithLogger injects log printer func into Backend
type Pagination ¶
type Pagination struct { PageSize int `json:"page_size"` NextPageToken string `json:"next_page_token"` ThisPageToken string `json:"this_page_token"` PrevPageToken string `json:"prev_page_token"` }
Pagination contains pagination fields
func (*Pagination) GetPageSize ¶
func (p *Pagination) GetPageSize() int
GetPageSize returns pagination size
type Paginator ¶
Paginator provides cursor-based paginator
func (*Paginator) Paginate ¶
func (p *Paginator) Paginate(src interface{}, pgn *Pagination) (interface{}, *Pagination)
Paginate query result according to parameter
Click to show internal directories.
Click to hide internal directories.