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>) and ids(vararg value: String): Adds a condition to match multiple IDs.

  • aggregateId(value: String), aggregateIds(value: List<String>), and aggregateIds(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) and KCallable<*>.eq(value: Any): Adds an equality condition.

  • String.ne(value: Any) and KCallable<*>.ne(value: Any): Adds a not-equal condition.

  • String.gt(value: Any) and KCallable<*>.gt(value: Any): Adds a greater-than condition.

  • String.lt(value: Any) and KCallable<*>.lt(value: Any): Adds a less-than condition.

  • String.gte(value: Any) and KCallable<*>.gte(value: Any): Adds a greater-than-or-equal condition.

  • String.lte(value: Any) and KCallable<*>.lte(value: Any): Adds a less-than-or-equal condition.

  • String.contains(value: String, ignoreCase: Boolean = false) and KCallable<*>.contains(value: String): Adds a condition to check if the field contains the specified value.

  • String.isIn(value: List<Any>) and KCallable<*>.isIn(value: List<Any>): Adds a condition to check if the field is in the specified list.

  • String.notIn(value: List<Any>) and KCallable<*>.notIn(value: List<Any>): Adds a condition to check if the field is not in the specified list.

  • String.between(value: Pair<V, V>) and KCallable<*>.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>) and KCallable<*>.all(value: List<Any>): Adds a condition to check if the field contains all the specified values.

  • String.startsWith(value: String, ignoreCase: Boolean = false) and KCallable<*>.startsWith(value: String): Adds a condition to check if the field starts with the specified value.

  • String.endsWith(value: String, ignoreCase: Boolean = false) and KCallable<*>.endsWith(value: String): Adds a condition to check if the field ends with the specified value.

  • String.elemMatch(block: ConditionDsl.() -> Unit) and KCallable<*>.elemMatch(block: ConditionDsl.() -> Unit): Adds a condition to match elements in an array.

  • String.isNull() and KCallable<*>.isNull(): Adds a condition to check if the field is null.

  • String.notNull() and KCallable<*>.notNull(): Adds a condition to check if the field is not null.

  • String.isTrue() and KCallable<*>.isTrue(): Adds a condition to check if the field is true.

  • String.isFalse() and KCallable<*>.isFalse(): Adds a condition to check if the field is false.

  • String.exists(exists: Boolean = true) and KCallable<*>.exists(exists: Boolean = true): Adds a condition to check if the field exists.

  • String.today(datePattern: Any? = null) and KCallable<*>.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.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun aggregateId(value: String)
Link copied to clipboard
fun aggregateIds(vararg value: String)
fun aggregateIds(value: List<String>)
Link copied to clipboard
fun all()
infix fun String.all(value: List<Any>)
infix fun KCallable<*>.all(value: List<Any>)
Link copied to clipboard
fun and(block: ConditionDsl.() -> Unit)
Link copied to clipboard
infix fun String.beforeToday(time: Any)
Link copied to clipboard
infix fun <V> String.between(start: V): BetweenStart<V>
infix fun <V> String.between(value: Pair<V, V>)
infix fun <V> KCallable<*>.between(start: V): BetweenStart<V>
Link copied to clipboard
Link copied to clipboard
fun condition(condition: Condition)
Link copied to clipboard
infix fun String.contains(value: String)
infix fun KCallable<*>.contains(value: String)
fun String.contains(value: String, ignoreCase: Boolean = false)
Link copied to clipboard
fun deleted(value: Boolean)
Link copied to clipboard
fun String.earlierDays(days: Int, datePattern: Any? = null)
Link copied to clipboard
infix fun String.elemMatch(block: ConditionDsl.() -> Unit)
infix fun KCallable<*>.elemMatch(block: ConditionDsl.() -> Unit)
Link copied to clipboard
infix fun String.endsWith(value: String)
infix fun KCallable<*>.endsWith(value: String)
fun String.endsWith(value: String, ignoreCase: Boolean = false)
Link copied to clipboard
infix fun String.eq(value: Any)
infix fun KCallable<*>.eq(value: Any)
Link copied to clipboard
fun String.exists(exists: Boolean = true)
fun KCallable<*>.exists(exists: Boolean = true)
Link copied to clipboard
infix fun String.gt(value: Any)
infix fun KCallable<*>.gt(value: Any)
Link copied to clipboard
infix fun String.gte(value: Any)
infix fun KCallable<*>.gte(value: Any)
Link copied to clipboard
fun id(value: String)
Link copied to clipboard
fun ids(vararg value: String)
fun ids(value: List<String>)
Link copied to clipboard
Link copied to clipboard
infix fun String.isIn(value: List<Any>)
infix fun KCallable<*>.isIn(value: List<Any>)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun String.lastMonth(datePattern: Any? = null)
fun KCallable<*>.lastMonth(datePattern: Any? = null)
Link copied to clipboard
fun String.lastWeek(datePattern: Any? = null)
fun KCallable<*>.lastWeek(datePattern: Any? = null)
Link copied to clipboard
infix fun String.lt(value: Any)
infix fun KCallable<*>.lt(value: Any)
Link copied to clipboard
infix fun String.lte(value: Any)
infix fun KCallable<*>.lte(value: Any)
Link copied to clipboard
infix fun String.ne(value: Any)
infix fun KCallable<*>.ne(value: Any)
Link copied to clipboard
infix fun String.nested(block: ConditionDsl.() -> Unit)
infix fun KCallable<*>.nested(block: ConditionDsl.() -> Unit)
fun nested(nestedField: String)
Link copied to clipboard
Link copied to clipboard
fun String.nextWeek(datePattern: Any? = null)
fun KCallable<*>.nextWeek(datePattern: Any? = null)
Link copied to clipboard
fun nor(block: ConditionDsl.() -> Unit)
Link copied to clipboard
infix fun String.notIn(value: List<Any>)
infix fun KCallable<*>.notIn(value: List<Any>)
Link copied to clipboard
Link copied to clipboard
fun or(block: ConditionDsl.() -> Unit)
Link copied to clipboard
fun ownerId(value: String)
Link copied to clipboard
fun raw(value: Any)
Link copied to clipboard
infix fun String.recentDays(days: Int)
infix fun KCallable<*>.recentDays(days: Int)
fun String.recentDays(days: Int, datePattern: Any? = null)
Link copied to clipboard
infix fun String.startsWith(value: String)
infix fun KCallable<*>.startsWith(value: String)
fun String.startsWith(value: String, ignoreCase: Boolean = false)
Link copied to clipboard
fun tenantId(value: String)
Link copied to clipboard
fun String.thisMonth(datePattern: Any? = null)
fun KCallable<*>.thisMonth(datePattern: Any? = null)
Link copied to clipboard
fun String.thisWeek(datePattern: Any? = null)
fun KCallable<*>.thisWeek(datePattern: Any? = null)
Link copied to clipboard
infix fun <V> BetweenStart<V>.to(end: V)
Link copied to clipboard
fun String.today(datePattern: Any? = null)
fun KCallable<*>.today(datePattern: Any? = null)
Link copied to clipboard
fun String.tomorrow(datePattern: Any? = null)
fun KCallable<*>.tomorrow(datePattern: Any? = null)
Link copied to clipboard