Aurora Criteria Pattern - Complete guide for QueryStatement usage in Aurora/NestJS. Trigger: When implementing queries, filters, searches, pagination, or complex data retrieval.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
Aurora Criteria Pattern - Complete guide for QueryStatement usage in Aurora/NestJS. Trigger: When implementing queries, filters, searches, pagination, or complex data retrieval.
// Greater than
{ where: { year: { "[gt]": 2020 } } }
// Greater than or equal
{ where: { year: { "[gte]": 2020 } } }
// Less than
{ where: { year: { "[lt]": 2025 } } }
// Less than or equal
{ where: { year: { "[lte]": 2024 } } }
// Combined range
{
where: {
year: {
"[gte]": 2020,
"[lte]": 2024
}
}
}
Range Operators
// BETWEEN (inclusive)
{ where: { year: { "[between]": [2020, 2024] } } }
// NOT BETWEEN
{ where: { year: { "[notBetween]": [2000, 2010] } } }
Set Operators
// IN - Value in list
{
where: {
status: {
"[in]": ["PRODUCTION", "PREPRODUCTION"]
}
}
}
// NOT IN - Value not in list
{
where: {
status: {
"[notIn]": ["DISCLAIMER", "CONCEPTION"]
}
}
}
// User query + System constraintconstqueryStatement: QueryStatement = {
where: {
name: { "[startsWith]": "Model" }
}
};
constconstraint: QueryStatement = {
where: {
isActive: true, // Force only active recordsdeletedAt: { "[is]": null } // Force soft-delete check
}
};
awaitthis.repository.get({
queryStatement,
constraint // System applies this regardless of user input
});
Example 5: GraphQL/REST Usage
# GraphQL Queryquery GetModels($query: QueryStatement){
teslaGetModels(query:$query) {
id
name
year
status
}}# Variables{"query":{"where":{"year":{"[gte]":2020}},
"order":[{"year":"desc"}],
"limit":10}}
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 } }