#199 - Add documentation for Kotlin support.
This commit is contained in:
@@ -36,4 +36,8 @@ include::reference/r2dbc-repositories.adoc[leveloffset=+1]
|
||||
|
||||
include::reference/r2dbc-connections.adoc[leveloffset=+1]
|
||||
|
||||
include::reference/r2dbc-initialization.adoc[leveloffset=+1]
|
||||
|
||||
include::reference/mapping.adoc[leveloffset=+1]
|
||||
|
||||
include::reference/kotlin.adoc[leveloffset=+1]
|
||||
|
||||
28
src/main/asciidoc/reference/kotlin.adoc
Normal file
28
src/main/asciidoc/reference/kotlin.adoc
Normal file
@@ -0,0 +1,28 @@
|
||||
include::../{spring-data-commons-docs}/kotlin.adoc[]
|
||||
|
||||
include::../{spring-data-commons-docs}/kotlin-extensions.adoc[leveloffset=+1]
|
||||
|
||||
To retrieve a list of `SWCharacter` objects in Java, you would normally write the following:
|
||||
|
||||
[source,java]
|
||||
----
|
||||
Flux<SWCharacter> characters = client.select().from(SWCharacter.class).fetch().all();
|
||||
----
|
||||
|
||||
With Kotlin and the Spring Data extensions, you can instead write the following:
|
||||
|
||||
[source,kotlin]
|
||||
----
|
||||
val characters = client.select().from<SWCharacter>().fetch().all()
|
||||
// or (both are equivalent)
|
||||
val characters : Flux<SWCharacter> = client.select().from().fetch().all()
|
||||
----
|
||||
|
||||
As in Java, `characters` in Kotlin is strongly typed, but Kotlin's clever type inference allows for shorter syntax.
|
||||
|
||||
Spring Data R2DBC provides the following extensions:
|
||||
|
||||
* Reified generics support for `DatabaseClient` and `Criteria`.
|
||||
* <<kotlin.coroutines>> extensions for `DatabaseClient`.
|
||||
|
||||
include::../{spring-data-commons-docs}/kotlin-coroutines.adoc[leveloffset=+1]
|
||||
Reference in New Issue
Block a user