Try the visual filter builder
Add a Condition block, choose a field and operator, and connect it to the Query node. Combine conditions with AND, OR, and NOT blocks. Sort, Page, and Load blocks add sorting, pagination, and relation filters. Copy the generated DSL into your application.
The playground generates filter text in your browser. The live data preview applies that DSL to sample accounts and orders, so you can see matching rows, sorting, and pagination immediately. It does not run Go code or connect to your database. JavaScript is needed for the interactive builder and preview; the examples and documentation below are available without it.
Build database queries from API filters in Go
figo parses a filter string into an expression tree. An adapter translates that tree into a query for your backend. For example, an API can accept a filter for active users aged 18 or older, ordered by creation date:
status="active" and age>=18 sort=created_at:desc page=skip:0,take:20
Install the Go package:
go get github.com/bi0dread/figo/v4
Build a parameterized SQL WHERE clause with the raw SQL adapter:
package example
import (
"github.com/bi0dread/figo/v4"
"github.com/bi0dread/figo/v4/adapters"
)
func ActiveUsersFilter() (string, []any, error) {
f := figo.New()
f.AddFiltersFromString(`status="active" and age>=18`)
if err := f.BuildE(adapters.RawAdapter{}); err != nil {
return "", nil, err
}
return adapters.BuildRawWhere(f)
}
// Pass the returned WHERE clause and arguments to your database driver.
For user-supplied filters, reject parse errors and configure the field, value, scope, and complexity policies your API needs. See the complete Go quick start and plugin documentation.
Dynamic filtering with GORM
Use the GORM adapter when your application already uses GORM. The same DSL can describe comparisons, grouped conditions, sorting, pagination, and filtered preloads. figo builds the filter; your application executes the query through GORM.
Read the GORM adapter examples to apply a built filter to a GORM query.
SQL, MongoDB, and Elasticsearch adapters
The raw SQL adapter supports MySQL, PostgreSQL, and SQLite dialects. The MongoDB adapter produces BSON filters and find options. The Elasticsearch adapter produces query JSON. Backend behavior can differ for NULL values and other operations; check the adapter documentation for details.