From 1425603caf5f6f3e891ccf28200240225e191de3 Mon Sep 17 00:00:00 2001 From: Viktoriya Nikolova Date: Tue, 3 Dec 2024 12:05:12 +0100 Subject: [PATCH] Separate querying examples into functions --- .../snippets/exposed-dsl/src/main/kotlin/org/example/App.kt | 4 ++-- .../main/kotlin/org/example/examples/QueryingExamples.kt | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/documentation-website/Writerside/snippets/exposed-dsl/src/main/kotlin/org/example/App.kt b/documentation-website/Writerside/snippets/exposed-dsl/src/main/kotlin/org/example/App.kt index 5997eb34ed..dcb8d49f54 100644 --- a/documentation-website/Writerside/snippets/exposed-dsl/src/main/kotlin/org/example/App.kt +++ b/documentation-website/Writerside/snippets/exposed-dsl/src/main/kotlin/org/example/App.kt @@ -31,7 +31,7 @@ fun main() { runAliasExamples() runCustomSelectExamples() //runDeleteExamples() - //runQueryingExamples() + runQueryingExamples() } } @@ -79,7 +79,7 @@ fun runDeleteExamples() { fun runQueryingExamples() { val queryingExamples = QueryingExamples() - queryingExamples.printResults() + queryingExamples.aggregateAndSort() } fun runAliasExamples() { diff --git a/documentation-website/Writerside/snippets/exposed-dsl/src/main/kotlin/org/example/examples/QueryingExamples.kt b/documentation-website/Writerside/snippets/exposed-dsl/src/main/kotlin/org/example/examples/QueryingExamples.kt index d855b1a7b0..edc6751616 100644 --- a/documentation-website/Writerside/snippets/exposed-dsl/src/main/kotlin/org/example/examples/QueryingExamples.kt +++ b/documentation-website/Writerside/snippets/exposed-dsl/src/main/kotlin/org/example/examples/QueryingExamples.kt @@ -16,7 +16,7 @@ import org.jetbrains.exposed.sql.transactions.transaction */ class QueryingExamples { - fun printResults() { + fun useWhereConditions() { val allMoviesLike = StarWarsFilmsTable.selectAll() .where { StarWarsFilmsTable.name like "The %" } println(allMoviesLike.toList()) @@ -49,7 +49,9 @@ class QueryingExamples { StarWarsFilmsTable.sequelId eq anyFrom(arrayOf(6, 4)) } println(anyFromArray.toList()) + } + fun aggregateAndSort() { val count = StarWarsFilmsTable.selectAll() .where { StarWarsFilmsTable.sequelId eq 8 @@ -65,7 +67,9 @@ class QueryingExamples { .select(StarWarsFilmsTable.sequelId.count(), StarWarsFilmsTable.director) .groupBy(StarWarsFilmsTable.director) println("Grouped films: $groupedFilms") + } + fun limitResults() { // Take 2 films after the first one. val limitedFilms = StarWarsFilmsTable .selectAll()