Skip to content

Commit ea07e5e

Browse files
committed
Update README example - remove deprecated methods
1 parent b398748 commit ea07e5e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ For example, a typical search can be coded with a query like this (the following
2020
similar):
2121

2222
```kotlin
23-
fun search(id_: String?, firstName_: String?, lastName_: String?) =
23+
data class SearchParameters(val id: String?, val firstName: String?, val lastName: String?)
24+
25+
fun search(searchParameters: SearchParameters) =
2426
select(id, firstName, lastName) {
2527
from(Customer)
2628
where {
2729
active isEqualTo true
28-
and { id(isEqualToWhenPresent(id_).map { it?.padStart(5, '0') }) }
30+
and { id isEqualToWhenPresent searchParameters.id }
2931
and {
30-
firstName(isLikeCaseInsensitiveWhenPresent(firstName_)
32+
firstName(isLikeCaseInsensitiveWhenPresent(searchParameters.firstName)
3133
.map { "%" + it.trim() + "%" })
3234
}
3335
and {
34-
lastName(isLikeCaseInsensitiveWhenPresent(lastName_)
36+
lastName(isLikeCaseInsensitiveWhenPresent(searchParameters.lastName)
3537
.map { "%" + it.trim() + "%" })
3638
}
3739
}
@@ -44,9 +46,9 @@ This query does quite a lot...
4446

4547
1. It is a search with three search criteria - any combination of search criteria can be used
4648
2. Only records with an active status will be returned
47-
3. If `id_` is specified, it will be padded to length 5 with '0' at the beginning of the string
48-
4. If `firstName_` is specified, it will be used in a case-insensitive search and SQL wildcards will be appended
49-
5. If `lastName_` is specified, it will be used in a case-insensitive search and SQL wildcards will be appended
49+
3. If `id` is specified, it will be used as a filter
50+
4. If `firstName` is specified, it will be used in a case-insensitive search and SQL wildcards will be appended
51+
5. If `lastName` is specified, it will be used in a case-insensitive search and SQL wildcards will be appended
5052
6. The query results are limited to 500 rows
5153

5254
Using the dynamic SQL features of the library eliminates a lot of code that would be required for checking nulls,

0 commit comments

Comments
 (0)