Query Overview

Understanding the dcupl query structure, groups, and conditions for building complex queries.

QueryExecutionContext

QueryExecutionContext is the root container for executing queries. It holds:

  • modelKey - Target model to query
  • queries - Array of conditions and groups (the query tree)
  • groupType - How to combine queries: 'and' or 'or'
  • Item options - Pagination, projection, sorting

Think of it as the complete specification for a query operation.

QueryCondition

A QueryCondition is a single filter criterion:

  • attribute - Property to filter on
  • operator - How to compare (eq, find, gte, etc.)
  • value - Value to compare against
  • options - Optional: case sensitivity, mode

See Operators Reference for all available operators.

QueryConditionGroup

A QueryConditionGroup combines multiple conditions with boolean logic:

  • groupType - 'and' or 'or'
  • queries - Array of conditions (or nested groups)

AND Group

All conditions must match. Use for narrowing results.

OR Group

Any condition can match. Use for broadening results.

Nesting Groups

Groups can contain other groups, enabling complex boolean expressions:

(A AND B) OR (C AND D)

The recursive structure allows arbitrary nesting depth for any boolean logic you need.

Structure:

QueryExecutionContext
└── queries[]
    ├── QueryCondition
    └── QueryConditionGroup
        └── queries[]
            ├── QueryCondition
            └── QueryConditionGroup (recursive)

Item Options

QueryExecutionContext includes options from DcuplItemOptions:

Option Description
start Skip N items (pagination offset)
count Limit results to N items
projection Select specific properties to return
sort Order results by property

Building Queries

Real-world example: E-commerce product filter

Requirements:

  • Active products only
  • Category: Electronics OR Computers
  • Price between $100 and $1000
  • Sort by price, paginated

The context object fully describes this complex filter in a declarative, serializable format.

In Action

Build queries programmatically using the List Query API:

addCondition

Add a single condition. Multiple calls combine with AND.

addGroup

Add a group of conditions with custom boolean logic.

setCondition

Replace all existing conditions with a single condition.

setGroup

Replace all existing conditions with a group.

reset

Clear all conditions and start fresh.

What's Next?

  • Operators - Complete reference of all filter operators
  • Deep Queries - Query across model relationships
  • Lists - Create filtered views of your models