advancedfilters

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package advancedfilters is a built-in plugin extending the generated filter/orderBy surface with two features default generation leaves out:

  • relation filters: filter a table by conditions on related rows — a forward FK exposes the parent's filter directly (posts: {author: {mood: {eq: HAPPY}}}), a reverse FK exposes a {some|none|every} wrapper over the child's filter (users: {postsByAuthorId: {some: {published: {eq: true}}}}). Both compile to EXISTS subqueries inside the single statement.
  • computed-column filtering and ordering: stable/immutable row-type functions without extra arguments become filter fields and orderBy enum values (postCount: {gt: "5"}, orderBy: [POST_COUNT_DESC]), compiled as function calls over the current row.

The plugin only adds schema surface plus catalog bindings; the compiler reads the bindings from schema.Built and stays inert when they are absent, so disabling the plugin (plugins.disabled: [advanced-filters]) removes the feature completely. The two halves toggle independently via plugins.settings.advanced-filters.{relations,computed}.

The surface is also tunable per object through smart comments (parsed directly from catalog comments, so this works even when the smart-comments plugin is disabled):

  • "@omit filter" on a foreign key skips its relation filter (both directions); "@omit filter" / "@omit order" on a computed function skips its filter field / orderBy values.
  • with plugins.settings.advanced-filters.relations_opt_in (or computed_opt_in) set, the default flips: only foreign keys / computed functions tagged "@filterable" (alias "@sortable") get filter surface.
  • "@fieldName" / "@foreignFieldName" renames apply automatically (they flow through the shared inflection pipeline).

Note: computed columns are not covered by indexes (unless a matching expression index exists), so computed filter/order fields bypass the filters.indexed_only policy by nature.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func New

func New(settings map[string]any) *Plugin

New builds the plugin from its `plugins.settings.advanced-filters` map.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Priority

func (p *Plugin) Priority() int

func (*Plugin) TransformSchema

func (p *Plugin) TransformSchema(_ context.Context, b *schema.Builder) error

Jump to

Keyboard shortcuts

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