package
0.0.0-20241122232756-5abfebf3a4ab
Repository: https://github.com/terrapi-solution/controller.git
Documentation: pkg.go.dev

# README

Supported filter operators

The following filter operators are supported:

  • : The equality operator filter=username:John matches only when the username is exactly John
  • \> The greater than operator filter=age>35 matches only when age is more than 35
  • \< The less than operator filter=salary<80000 matches only when salary is less than 80,000
  • \>= The greater than or equals to operator filter=items>=100 matches only when items is at least 100
  • \<= The less than or equals to operator filter=score<=100000 matches when score is 100,000 or lower
  • \!= The not equals to operator state!=FAIL matches when state has any value other than FAIL
  • \~ The like operator filter=lastName~illi matches when lastName contains the substring illi

Request example

curl -X GET http://localhost:8080/v1/modules?page=1&limit=10&order_by=username&order_direction=asc&filter="name:John"

Model definition

type UserModel struct {
    Username string `gorm:"uniqueIndex" filter:"param:login;searchable;filterable"`
    FullName string `filter:"searchable"`
    Role     string `filter:"filterable"`
}

The param tag defines a custom column name for the query parameter.

# Functions

FilterByQuery filters the response by query parameters.

# Constants

Filter response by column name values "filter={column_name}:{value}".
Order response by column name.
Paginate response with page and page_size.
Filter response with LIKE query "search={search_phrase}".
No description provided by the author