API reference
API reference
Select your platform
No SDKs available
No versions available

CachedQueryBuilder Class

Modifiers: final
Builder for CachedQuery expressions.
This builder provides a restricted DSL that only supports has() operations with and/or combinators. Filters, sorting, and other Query operations are intentionally not available to ensure efficient incremental updates.
Example:
CachedQuery.create {
    where { has(Enemy.id) or has(Ally.id) }  // Use where as root (only one allowed)
}

Signature

class CachedQueryBuilder

Constructors

CachedQueryBuilder ()
Signature
constructor()

Functions

where ( initializer )
Creates a query using the where DSL block, matching the Query.Companion.where syntax.
This provides a consistent API with Query.Companion.where for familiarity. Only one where block is allowed per query - nested where calls are prevented at compile time.
The result of where has a filter method available, allowing filters to be applied only when where is used.
Example:
CachedQuery.create {
    where { has(Enemy.id, Health.id) }  // Same as: has(Enemy.id, Health.id)
}
CachedQuery.create {
    where { has(Enemy.id) }.filter { by(Enemy.statusData).isEqualTo(Status.ACTIVE) }
}

Signature
fun where(initializer: CachedQueryWhereBuilder.() -> CachedQueryNode): FilteredCachedQueryNode.Unfiltered
Parameters
initializer: Function1
  Query DSL block that returns a CachedQueryNode. Uses CachedQueryWhereBuilder which does not have a where method, preventing nesting.
Returns
FilteredCachedQueryNode.Unfiltered
  A FilteredCachedQueryNode.Unfiltered which has a filter method for adding filters.
Did you find this page helpful?