Skip to content
aurora-criteria logo

Aurora Criteria

aurora-criteria

Aurora Criteria Pattern - Complete guide for QueryStatement usage in Aurora/NestJS. Trigger: When implementing queries, filters, searches, pagination, or complex data retrieval.

SKILL.md

Full skill instructions

When to Use

Use this skill when:

  • Implementing GET/​FIND queries in services or handlers
  • Building filters for REST or GraphQL endpoints
  • Adding pagination to data retrieval
  • Creating complex search functionality
  • Working with QueryStatement parameters

What is QueryStatement?

QueryStatement is Aurora's standardized interface for building complex database queries using the Criteria Pattern.

Core Structure

interface QueryStatement {
    where?: JSON;           // Filtering conditions
    attributes?: JSON;      // Field selection
    include?: string[];     // Relations to eager load
    order?: JSON;           // Sorting
    group?: JSON;           // Grouping
    limit?: number;         // Max results
    offset?: number;        // Skip results (pagination)
    distinct?: boolean;     // Unique results only
    col?: string;           // Column operations
}

Critical Patterns

⚠️ OPERATOR SYNTAX (CRITICAL!)

Operators MUST be quoted keys wrapped in square brackets:

// ✅ CORRECT
{ "where": { "age": { "[gte]": 18 } } }
{ "where": { "name": { "[startsWith]": "Carlos" } } }

// ❌ INCORRECT (will NOT work)
{ "where": { "age": { gte: 18 } } }

Usage in Services/​Queries

// In services
async main(queryStatement?: QueryStatement, constraint?: QueryStatement, cQMetadata?: CQMetadata) {
    return await this.repository.get({ queryStatement, constraint, cQMetadata });
}

// In queries
export class TeslaGetModelsQuery {
    constructor(
        public readonly queryStatement?: QueryStatement,
        public readonly constraint?: QueryStatement,
        public readonly cQMetadata?: CQMetadata,
    ) {}
}

Detailed References

Other QueryStatement Properties

Field Selection (attributes)

{ attributes: ['id', 'name', 'status'] }
{ attributes: { exclude: ['deletedAt', 'createdAt'] } }

Eager Loading (include)

{ include: [{ association: 'model' }, { association: 'units' }] }

Sorting (order)

{ order: [{ createdAt: 'desc' }, { name: 'asc' }] }

Pagination

{ offset: 0, limit: 25 }     // Page 1
{ offset: 25, limit: 25 }    // Page 2

Grouping & Distinct

{ group: ['status', 'year'] }
{ distinct: true }

Decision Tree

Need to filter data?
├─ Single condition → Use simple where: { field: value }
├─ Multiple AND conditions → Use implicit AND or "[and]"
├─ Multiple OR conditions → Use "[or]": [...]
├─ Range (min/​max) → Use "[gte]" and "[lte]"
├─ List of values → Use "[in]": [...]
└─ Pattern matching → Use "[like]", "[iLike]", or "[startsWith]"

Need to sort?
└─ Use order: [{ field: 'asc'|'desc' }]

Need pagination?
└─ Use offset + limit

Need specific fields?
└─ Use attributes: [...]

Need relations?
└─ Use include: [...]

Need to ensure security?
└─ Use constraint parameter (separate from queryStatement)

Best Practices

✅ DO

  • Always use quoted operators with brackets: "[gte]", "[startsWith]"
  • Use constraint for system-enforced filters (security, soft-deletes)
  • Use queryStatement for user-provided filters
  • Combine operators in same field: { year: { "[gte]": 2020, "[lte]": 2024 } }
  • Use [iLike] for case-insensitive searches
  • Always filter soft-deleted records: deletedAt: { "[is]": null }

❌ DON'T

  • Don't use unquoted operators: gte: ❌ Use "[gte]": ✅
  • Don't use operators without brackets: "gte" ❌ Use "[gte]" ✅
  • Don't trust user-provided constraint (always set server-side)
  • Don't forget pagination for large datasets
  • Don't use [like] with user input without validation

Resources

  • Aurora Core Types: @aurorajs.dev/​core exports QueryStatement
  • GraphQL Schema: See src/​@api/​graphql.ts for QueryStatement interface

Related Skills

  • aurora-project-structure - Understand where queries live
  • typescript - Type-safe QueryStatement construction
  • aurora-cli - Regenerate repositories after schema changes

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View