SingleQuery

class SingleQuery @InternalWowApi constructor(val filter: FilterExpression = MatchAllFilter, val projection: Projection = Projection.ALL, sort: List<Sort> = emptyList()) : Queryable<SingleQuery>

Data class representing a query for retrieving a single item with optional filtering, projection, and sorting.

It supports all standard query operations (Queryable) and expects at most one result, or none.

Parameters

sort

The order of the results; the query keeps a copy.

val query = SingleQuery(
filter = EqualFilter(QueryField("id"), value),
projection = Projection(include = listOf(QueryField("name"), QueryField("email"))),
sort = listOf(Sort(QueryField("createdDate"), Direction.DESC))
)

Constructors

Link copied to clipboard
constructor(filter: FilterExpression = MatchAllFilter, projection: Projection = Projection.ALL, sort: List<Sort> = emptyList())

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val filter: FilterExpression

The filter expression to apply to the query; MatchAllFilter, every record, by default.

Link copied to clipboard
open override val projection: Projection

The field projection to control which fields are included in the result.

Link copied to clipboard
open override val sort: List<Sort>

The sorting criteria to order results (useful when multiple matches exist); a copy, so a list its caller changes later changes neither this query nor its hash.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun withFilter(newFilter: FilterExpression): SingleQuery

Creates a new SingleQuery with the specified filter.

Link copied to clipboard
open override fun withProjection(newProjection: Projection): SingleQuery

Creates a new SingleQuery with the specified projection.