adonisjs-query-builders

Build reusable AdonisJS Lucid query logic with model scopes and query objects.

2|1|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-query-builders
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adonisjs-query-builders
Source: https://github.com/omakei/adonisjs-architecture-skill/tree/main/adonisjs/skills/adonisjs-query-builder
Command: npx skills add https://github.com/omakei/adonisjs-architecture-skill --skill adonisjs-query-builders

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides patterns to compose reusable Lucid query logic in AdonisJS: using model scopes and standalone query objects to keep query logic centralized, readable, and testable.

Core Features & Use Cases

  • Model scopes offer reusable query fragments directly on models.
  • Standalone query objects support complex filtering endpoints with composable filters.
  • Preloading related data and supporting pagination and sorting for reliable results.

Quick Start

Define and apply reusable Lucid query patterns to filter orders by status, date, and total across endpoints.

Frequently Asked Questions about adonisjs-query-builders

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build reusable query filters in AdonisJS Lucid?

Build reusable Lucid queries by defining model scopes or standalone query objects to centralize filtering logic. This approach keeps complex query fragments readable, testable, and easily composable across multiple endpoints.

What is the best way to handle complex filtering across relationships in AdonisJS?

Handle complex filtering by applying composable filters within standalone query objects and explicitly preloading related data. This ensures predictable results when querying across status, dates, totals, and associated model data.

Can I use model scopes for pagination and sorting in Lucid?

Yes, model scopes can be combined with pagination and sorting parameters. Applying these constraints within reusable query fragments ensures reliable, paginated result sets across your filtering endpoints.

Does this query builder pattern require explicit validation for AdonisJS endpoints?

Yes, clear validation is required. Explicit validation ensures that composable filters for status, date, and totals process predictable inputs before the standalone query objects apply the Lucid scopes.

When should I use standalone query objects instead of model scopes in AdonisJS?

Use standalone query objects for complex filtering endpoints requiring composable filters, and model scopes for reusable fragments directly on models. Both keep query logic centralized, readable, and testable.

Why do my Lucid query filters return unpredictable results?

Unpredictable results often occur when explicit relationships preloading is missing. Define clear validation, preload related data, and apply pagination and sorting within your query objects to deliver predictable outcomes.