models

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

#NOTE Models in this directory are jsx models. We copy them here from jumpscale threebot just for easier regeneration. So, they need to be always in sync with the one in jumpscale threebot repo.

Documentation

Index

Constants

View Source
const (
	//Counters is the counters collection in mongo
	Counters = "counters"
)
View Source
const (
	// DefaultPageSize is default page size
	DefaultPageSize int64 = 100
)

Variables

View Source
var (
	//ErrFailedToGetID is base error for generation failure
	ErrFailedToGetID = errors.New("failed to generate new id")
)

Functions

func LastID

func LastID(ctx context.Context, db *mongo.Database, collection string) (schema.ID, error)

LastID get the last max value in the collection

func MustID

func MustID(ctx context.Context, db *mongo.Database, collection string) schema.ID

MustID must get next available ID, or panic with an error that has error.Is(err, ErrFailedToGetID) == true

func NextID

func NextID(ctx context.Context, db *mongo.Database, collection string) (schema.ID, error)

NextID for a collection

func NrPages

func NrPages(total, pageSize int64) int64

NrPages compute the number of page of a collection

func Pages

func Pages(p Pager, total int64) int64

Pages return number of pages based on the total number

func QueryInt

func QueryInt(r *http.Request, q string) (int64, error)

QueryInt get integer from query string

Types

type Pager

type Pager *options.FindOptions

Pager is the find options wrapper

func Page

func Page(p int64, size ...int64) Pager

Page creates a Pager

func PageFromRequest

func PageFromRequest(r *http.Request) Pager

PageFromRequest return page information from the page & size url params

Directories

Path Synopsis
generated

Jump to

Keyboard shortcuts

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