Created
July 4, 2019 06:57
-
-
Save juliuscanute/17b0133f1f2481dad1dd9c1ca82aff36 to your computer and use it in GitHub Desktop.
Search For Word in Dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val findSpec = SqlQuerySpec().apply { | |
queryText = "SELECT Dictionary.word AS word, Dictionary.meaning AS meaning FROM Dictionary WHERE Dictionary.partition = @tag AND contains(Dictionary.search, @query) OFFSET @offset LIMIT @records_per_page" | |
parameters = SqlParameterCollection().apply { | |
add(SqlParameter("@tag", query.first().toUpperCase().toString())) | |
add(SqlParameter("@query", query.toLowerCase())) | |
add(SqlParameter("@offset", offset)) | |
add(SqlParameter("@records_per_page", RECORDS_PER_PAGE)) | |
} | |
} | |
val countSpec = SqlQuerySpec().apply { | |
queryText = "SELECT COUNT(1) AS TotalRecords FROM Dictionary WHERE Dictionary.partition = @tag AND contains(Dictionary.search, @query)" | |
parameters = SqlParameterCollection().apply { | |
add(SqlParameter("@tag", query.first().toUpperCase().toString())) | |
add(SqlParameter("@query", query.toLowerCase())) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment