ConditionDsl
A DSL for building complex conditions in a fluent and readable manner. This class extends NestedFieldDsl to support nested field operations and provides a wide range of methods to construct various types of conditions.
Example usage:
val condition = ConditionDsl().apply {
"name" eq "John"
"age" gt 30
and {
"status" eq "active"
"role" isIn listOf("admin", "user")
}
or {
"email" contains "@example.com"
"phone" isNull()
}
}Methods:
condition(condition: Condition): Adds a condition to the list of conditions.String.nested(block: ConditionDsl.() -> Unit): Creates a nested condition block for the given field.KCallable<*>.nested(block: ConditionDsl.() -> Unit): Creates a nested condition block for the property represented by the KCallable.and(block: ConditionDsl.() -> Unit): Combines multiple conditions with a logical AND.or(block: ConditionDsl.() -> Unit): Combines multiple conditions with a logical OR.nor(block: ConditionDsl.() -> Unit): Combines multiple conditions with a logical NOR.all(): Adds a condition that matches all documents.id(value: String): Adds a condition to match a specific ID.ids(value: List<String>)andids(vararg value: String): Adds a condition to match multiple IDs.aggregateId(value: String),aggregateIds(value: List<String>), andaggregateIds(vararg value: String): Adds a condition to match aggregate IDs.tenantId(value: String): Adds a condition to match a specific tenant ID.ownerId(value: String): Adds a condition to match a specific owner ID.deleted(value: DeletionState): Adds a condition to match based on the deletion state.String.eq(value: Any)andKCallable<*>.eq(value: Any): Adds an equality condition.String.ne(value: Any)andKCallable<*>.ne(value: Any): Adds a not-equal condition.String.gt(value: Any)andKCallable<*>.gt(value: Any): Adds a greater-than condition.String.lt(value: Any)andKCallable<*>.lt(value: Any): Adds a less-than condition.String.gte(value: Any)andKCallable<*>.gte(value: Any): Adds a greater-than-or-equal condition.String.lte(value: Any)andKCallable<*>.lte(value: Any): Adds a less-than-or-equal condition.String.contains(value: String, ignoreCase: Boolean = false)andKCallable<*>.contains(value: String): Adds a condition to check if the field contains the specified value.String.isIn(value: List<Any>)andKCallable<*>.isIn(value: List<Any>): Adds a condition to check if the field is in the specified list.String.notIn(value: List<Any>)andKCallable<*>.notIn(value: List<Any>): Adds a condition to check if the field is not in the specified list.String.between(value: Pair<V, V>)andKCallable<*>.between(start: V): Adds a condition to check if the field is between two values.BetweenStart<V>.to(end: V): Completes the between condition with the end value.String.all(value: List<Any>)andKCallable<*>.all(value: List<Any>): Adds a condition to check if the field contains all the specified values.String.startsWith(value: String, ignoreCase: Boolean = false)andKCallable<*>.startsWith(value: String): Adds a condition to check if the field starts with the specified value.String.endsWith(value: String, ignoreCase: Boolean = false)andKCallable<*>.endsWith(value: String): Adds a condition to check if the field ends with the specified value.String.elemMatch(block: ConditionDsl.() -> Unit)andKCallable<*>.elemMatch(block: ConditionDsl.() -> Unit): Adds a condition to match elements in an array.String.isNull()andKCallable<*>.isNull(): Adds a condition to check if the field is null.String.notNull()andKCallable<*>.notNull(): Adds a condition to check if the field is not null.String.isTrue()andKCallable<*>.isTrue(): Adds a condition to check if the field is true.String.isFalse()andKCallable<*>.isFalse(): Adds a condition to check if the field is false.String.exists(exists: Boolean = true)andKCallable<*>.exists(exists: Boolean = true): Adds a condition to check if the field exists.String.today(datePattern: Any? = null)andKCallable<*>.today(datePattern: Any? = null): Adds a condition to check if the field is today.String.beforeToday(time: Any): Adds a condition to check if the field is before today at the specified time.String.tomorrow(datePattern: Any? = null): Adds a condition to check if the field is tomorrow.