From 024cbcc008f8f649ffa0195f1d091b594ec01546 Mon Sep 17 00:00:00 2001 From: kamranseifi Date: Sun, 25 Oct 2026 12:54:01 +0330 Subject: [PATCH] docs: improve figo search metadata and crawlable playground content --- README.md | 4 +- playground/index.html | 93 ++++++++++++++++++++++++++++++++++- playground/public/sitemap.xml | 6 +++ 3 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 playground/public/sitemap.xml diff --git a/README.md b/README.md index 30f4803..ecb132e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # figo — Go Dynamic Query Builder (v4) -figo turns a compact, database-agnostic filter DSL into concrete queries for **GORM**, **raw SQL** (MySQL / PostgreSQL / SQLite dialects), **MongoDB**, and **Elasticsearch**. You parse one filter string (typically straight from an HTTP query parameter) into an internal expression AST, then let an adapter render it for whichever backend you target. +figo is a **Go dynamic query builder and filter DSL** for **GORM**, **raw SQL** (MySQL / PostgreSQL / SQLite dialects), **MongoDB**, and **Elasticsearch**. Parse a filter string from an HTTP query parameter into an expression tree, then use an adapter to build a query for your backend. + +Use figo for dynamic API filtering, grouped conditions, sorting, pagination, and filtered relation loads. [Try the visual filter DSL playground](https://bi0dread.github.io/figo/), or jump to the [GORM filtering examples](#gorm-adapter) and [raw SQL query builder examples](#raw-sql-adapter). The core stays deliberately small — parse, build, render. Everything policy-shaped is an opt-in **plugin**: syntax validation & repair, field whitelisting, complexity limits, value validation, mandatory scopes (multi-tenant), caching, metrics, and audit logging. diff --git a/playground/index.html b/playground/index.html index 370758e..f704ac3 100644 --- a/playground/index.html +++ b/playground/index.html @@ -7,10 +7,99 @@ href="data:image/svg+xml,🧩" /> - figo playground + figo — Go Dynamic Query Builder & Filter DSL Playground + + + + + + + + + + + + -
+
+

figo — Go dynamic query builder and filter DSL

+

Build dynamic API filters for GORM, raw SQL, MongoDB, and Elasticsearch with one filter language. Try the visual playground below, then use the generated DSL in your Go application.

+ +
+
+
+
+

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. It does not run Go code or connect to your database. JavaScript is needed for the interactive builder; 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.

+ +
+
diff --git a/playground/public/sitemap.xml b/playground/public/sitemap.xml new file mode 100644 index 0000000..0aae764 --- /dev/null +++ b/playground/public/sitemap.xml @@ -0,0 +1,6 @@ + + + + https://bi0dread.github.io/figo/ + +