Determining whether a query returned no results
Queries can return no results under certain conditions, such as queries that include predicates that users provide through the user interface. For example, users can search for people by name by using the user interface, such as finding people whose name is “John Smith.” The database could have several matches, or it could have none.
Your user interface displays a list of names when there is a match or the message “No-one found with that name” when
there is none. Use the Empty property on a result object to determine whether a query returned
any results, as the following Gosu code shows.
uses gw.api.database.Query
var query = Query.make(Person)
// Apply some subselect, join, and predicate methods here.
result = query.select()
if (result.Empty) {
...
}
Alternatively, you can test the Count property against zero or iterate a result object inside a
while loop with a counter and then test the counter for zero. Relational query performance
often improves if you use the Empty property.
