 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package query is a library of custom condition queries, support for complex conditional paging queries.
Index ¶
Constants ¶
const ( // Eq equal Eq = "eq" // Neq not equal Neq = "neq" // Gt greater than Gt = "gt" // Gte greater than or equal Gte = "gte" // Lt less than Lt = "lt" // Lte less than or equal Lte = "lte" // Like fuzzy lookup Like = "like" // In include In = "in" // NotIn exclude NotIn = "nin" // AND logic and AND string = "and" //nolint // OR logic or OR string = "or" //nolint )
Variables ¶
This section is empty.
Functions ¶
func SetMaxSize ¶
func SetMaxSize(max int)
SetMaxSize change the default maximum number of pages per page
Types ¶
type Column ¶
type Column struct {
	Name  string      `json:"name" form:"name"`   // column name
	Exp   string      `json:"exp" form:"exp"`     // expressions, default value is "=", support =, !=, >, >=, <, <=, like, in
	Value interface{} `json:"value" form:"value"` // column value
	Logic string      `json:"logic" form:"logic"` // logical type, defaults to and when the value is null, with &(and), ||(or)
}
    Column query info
type Conditions ¶
type Conditions struct {
	Columns []Column `json:"columns" form:"columns" binding:"min=1"` // columns info
}
    Conditions query conditions
func (*Conditions) ConvertToMongo ¶
func (c *Conditions) ConvertToMongo() (bson.M, error)
ConvertToMongo conversion to mongo-compliant parameters based on the Columns parameter ignore the logical type of the last column, whether it is a one-column or multi-column query
type Page ¶
type Page struct {
	// contains filtered or unexported fields
}
    Page info
func DefaultPage ¶
DefaultPage default page, number 20 per page, sorted by id backwards
func NewPage ¶
NewPage custom page, starting from page 0. the parameter columnNames indicates a sort field, if empty means id descending, if there are multiple column names, separated by a comma, a '-' sign in front of each column name indicates descending order, otherwise ascending order.
type Params ¶
type Params struct {
	Page  int    `json:"page" form:"page" binding:"gte=0"`
	Limit int    `json:"limit" form:"limit" binding:"gte=1"`
	Sort  string `json:"sort,omitempty" form:"sort" binding:""`
	Columns []Column `json:"columns,omitempty" form:"columns"` // not required
	// Deprecated: use Limit instead in sponge version v1.8.6, will remove in the future
	Size int `json:"size" form:"size"`
}
    Params query parameters
func (*Params) ConvertToMongoFilter ¶
ConvertToMongoFilter conversion to mongo-compliant parameters based on the Columns parameter ignore the logical type of the last column, whether it is a one-column or multi-column query