Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
TMP PROTOTYPE EMBED REFERENCE IN THE DOCUMENTATION WEBSITE
Browse files Browse the repository at this point in the history
  • Loading branch information
CLOVIS-AI committed Jul 12, 2024
1 parent 9f277f9 commit fcde245
Show file tree
Hide file tree
Showing 116 changed files with 2,666 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[dsl](../../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../../index.md)/[CompoundExpression](../index.md)/[Companion](index.md)

# Companion

[jvm]\
object [Companion](index.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[CompoundExpression](index.md)/[CompoundExpression](-compound-expression.md)

# CompoundExpression

[jvm]\
constructor(codec: CodecRegistry)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[CompoundExpression](index.md)/[accept](accept.md)

# accept

[jvm]\

@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)

fun [accept](accept.md)(expression: [Expression](../-expression/index.md))

Binds an arbitrary [expression](accept.md) as a sub-expression of the receiver.

### Security and correctness

This function makes no verification on the validity of the passed expression. It is added to this expression as-is.

This function is only publicly available to allow users to add missing operators themselves by implementing [Expression](../-expression/index.md) for their operator.

**An incorrectly written expression may allow arbitrary code execution on the database, data corruption, or data leaks. Only call this function on expressions you are sure are implemented correctly!**
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[CompoundExpression](index.md)

# CompoundExpression

abstract class [CompoundExpression](index.md)(codec: CodecRegistry) : [Expression](../-expression/index.md)

A compound node in the BSON AST. This class is an implementation detail of all operator DSLs.

This class adds the method [accept](accept.md) which allows binding a child expression into the current one. It manages the bound expressions internally, only giving the implementations access to them when simplify or write are called.

#### See also

| |
|---------------------------------------|
| [Expression](../-expression/index.md) |

#### Inheritors

| |
|-------------------------------------------------------------------------------------|
| [FilterExpression](../../fr.qsh.ktmongo.dsl.expr/-filter-expression/index.md) |
| [PredicateExpression](../../fr.qsh.ktmongo.dsl.expr/-predicate-expression/index.md) |

## Constructors

| | |
|-----------------------------------------------|--------------------------------------------|
| [CompoundExpression](-compound-expression.md) | [jvm]<br>constructor(codec: CodecRegistry) |

## Types

| Name | Summary |
|----------------------------------|--------------------------------------------------|
| [Companion](-companion/index.md) | [jvm]<br>object [Companion](-companion/index.md) |

## Functions

| Name | Summary |
|-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [accept](accept.md) | [jvm]<br>@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>fun [accept](accept.md)(expression: [Expression](../-expression/index.md))<br>Binds an arbitrary [expression](accept.md) as a sub-expression of the receiver. |
| [acceptAll](../accept-all.md) | [jvm]<br>@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>fun [CompoundExpression](index.md).[acceptAll](../accept-all.md)(expressions: [Iterable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)&lt;[Expression](../-expression/index.md)&gt;)<br>Binds any arbitrary [expressions](../accept-all.md) as sub-expressions of the receiver. |
| [freeze](../-expression/freeze.md) | [jvm]<br>@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>fun [freeze](../-expression/freeze.md)()<br>Forbid further mutations to this expression. |
| [simplify](simplify.md) | [jvm]<br>@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>override fun [simplify](simplify.md)(): [Expression](../-expression/index.md)?<br>Allows the implementation to replace itself by another more appropriate representation. |
| [toString](../-expression/to-string.md) | [jvm]<br>override fun [toString](../-expression/to-string.md)(): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>Returns a JSON representation of this node, generated using [writeTo](../-expression/write-to.md).<br>[jvm]<br>fun [toString](../-expression/to-string.md)(simplified: [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>Returns a JSON representation of this node. |
| [writeTo](../-expression/write-to.md) | [jvm]<br>@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>fun [writeTo](../-expression/write-to.md)(writer: BsonWriter)<br>Writes this expression into a [writer](../-expression/write-to.md). |
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[CompoundExpression](index.md)/[simplify](simplify.md)

# simplify

[jvm]\

@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)

override fun [simplify](simplify.md)(): [Expression](../-expression/index.md)?

Allows the implementation to replace itself by another more appropriate representation.

For example, if the current node is an `$and` operator with a single child, it may use this function to replace itself by that child.

**Implementations must be pure.**
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[dsl](../../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../../index.md)/[Expression](../index.md)/[Companion](index.md)

# Companion

[jvm]\
object [Companion](index.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[Expression](index.md)/[Expression](-expression.md)

# Expression

[jvm]\
constructor(codec: CodecRegistry)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[Expression](index.md)/[freeze](freeze.md)

# freeze

[jvm]\

@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)

fun [freeze](freeze.md)()

Forbid further mutations to this expression.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[Expression](index.md)

# Expression

abstract class [Expression](index.md)(codec: CodecRegistry)

A node in the BSON AST.

Each node knows how to [writeTo](write-to.md) itself into the expression.

### Security

Implementing this interface allows to inject arbitrary BSON into a request. Be very careful not to allow request injections.

### Debugging notes

Use [toString](to-string.md) to generate the JSON of this expression.

#### Inheritors

| |
|--------------------------------------------------------|
| [CompoundExpression](../-compound-expression/index.md) |

## Constructors

| | |
|------------------------------|--------------------------------------------|
| [Expression](-expression.md) | [jvm]<br>constructor(codec: CodecRegistry) |

## Types

| Name | Summary |
|----------------------------------|--------------------------------------------------|
| [Companion](-companion/index.md) | [jvm]<br>object [Companion](-companion/index.md) |

## Functions

| Name | Summary |
|--------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [freeze](freeze.md) | [jvm]<br>@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>fun [freeze](freeze.md)()<br>Forbid further mutations to this expression. |
| [simplify](simplify.md) | [jvm]<br>@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>open fun [simplify](simplify.md)(): [Expression](index.md)?<br>Allows the implementation to replace itself by another more appropriate representation. |
| [toString](to-string.md) | [jvm]<br>override fun [toString](to-string.md)(): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>Returns a JSON representation of this node, generated using [writeTo](write-to.md).<br>[jvm]<br>fun [toString](to-string.md)(simplified: [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>Returns a JSON representation of this node. |
| [writeTo](write-to.md) | [jvm]<br>@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>fun [writeTo](write-to.md)(writer: BsonWriter)<br>Writes this expression into a [writer](write-to.md). |
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[Expression](index.md)/[simplify](simplify.md)

# simplify

[jvm]\

@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)

open fun [simplify](simplify.md)(): [Expression](index.md)?

Allows the implementation to replace itself by another more appropriate representation.

For example, if the current node is an `$and` operator with a single child, it may use this function to replace itself by that child.

**Implementations must be pure.**
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[Expression](index.md)/[toString](to-string.md)

# toString

[jvm]\
fun [toString](to-string.md)(simplified: [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)

Returns a JSON representation of this node.

If [simplified](to-string.md) is `true`, [simplifications](simplify.md) are executed before printing.

[jvm]\
override fun [toString](to-string.md)(): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)

Returns a JSON representation of this node, generated using [writeTo](write-to.md).
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](../index.md)/[Expression](index.md)/[writeTo](write-to.md)

# writeTo

[jvm]\

@[LowLevelApi](../../fr.qsh.ktmongo.dsl/-low-level-api/index.md)

fun [writeTo](write-to.md)(writer: BsonWriter)

Writes this expression into a [writer](write-to.md).

This function is guaranteed to be pure.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//[dsl](../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](index.md)/[acceptAll](accept-all.md)

# acceptAll

[jvm]\

@[LowLevelApi](../fr.qsh.ktmongo.dsl/-low-level-api/index.md)

fun [CompoundExpression](-compound-expression/index.md).[acceptAll](accept-all.md)(expressions: [Iterable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)&lt;[Expression](-expression/index.md)&gt;)

Binds any arbitrary [expressions](accept-all.md) as sub-expressions of the receiver.

To learn more about the security implications, see [CompoundExpression.accept](-compound-expression/accept.md).
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//[dsl](../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](index.md)

# Package-level declarations

## Types

| Name | Summary |
|-----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CompoundExpression](-compound-expression/index.md) | [jvm]<br>abstract class [CompoundExpression](-compound-expression/index.md)(codec: CodecRegistry) : [Expression](-expression/index.md)<br>A compound node in the BSON AST. This class is an implementation detail of all operator DSLs. |
| [Expression](-expression/index.md) | [jvm]<br>abstract class [Expression](-expression/index.md)(codec: CodecRegistry)<br>A node in the BSON AST. |

## Functions

| Name | Summary |
|---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [acceptAll](accept-all.md) | [jvm]<br>@[LowLevelApi](../fr.qsh.ktmongo.dsl/-low-level-api/index.md)<br>fun [CompoundExpression](-compound-expression/index.md).[acceptAll](accept-all.md)(expressions: [Iterable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-iterable/index.html)&lt;[Expression](-expression/index.md)&gt;)<br>Binds any arbitrary [expressions](accept-all.md) as sub-expressions of the receiver. |
| [withLoggedContext](with-logged-context.md) | [jvm]<br>fun BsonWriter.[withLoggedContext](with-logged-context.md)(storeLogs: [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) = true): BsonWriter |
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[dsl](../../index.md)/[fr.qsh.ktmongo.dsl.expr.common](index.md)/[withLoggedContext](with-logged-context.md)

# withLoggedContext

[jvm]\
fun BsonWriter.[withLoggedContext](with-logged-context.md)(storeLogs: [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) = true): BsonWriter
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr](../index.md)/[FilterExpression](index.md)/[FilterExpression](-filter-expression.md)

# FilterExpression

[jvm]\
constructor(codec: CodecRegistry)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//[dsl](../../../index.md)/[fr.qsh.ktmongo.dsl.expr](../index.md)/[FilterExpression](index.md)/[and](and.md)

# and

[jvm]\
fun [and](and.md)(block: [FilterExpression](index.md)&lt;[T](index.md)&gt;.() -&gt; [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html))

Performs a logical `AND` operation on one or more expressions, and selects the documents that satisfy *all* the expressions.

### Example

```kotlin
class User(
val name: String?,
val age: Int,
)

collection.findOne {
and {
User::name eq "foo"
User::age eq 18
}
}
```

### External resources

-
[Official documentation](https://www.mongodb.com/docs/manual/reference/operator/query/and/)

#### See also

| | |
|------------------------------|-------------------------|
| [FilterExpression.or](or.md) | Logical `OR` operation. |
Loading

0 comments on commit fcde245

Please sign in to comment.