The collection.query( ) method returns all elements of a collection of objects that match the search conditions defined by queryString and (optionally) value and querySettings. If the original collection is a shared collection, the returned collection is also a shared collection.
Note: This method does not modify the original collection.
The queryString parameter uses the following syntax:
propertyPath comparator value {logicalOperator propertyPath comparator value}
For detailed information on how to build a query using queryString, value and querySettings parameters, please refer to the dataClass.query( ) method description.
This example returns persons whose name contains "in":
$col:=$c.query("name = :1";"@in@")
This example returns persons whose name does not begin with a string from a variable (entered by the user, for example):
$col:=$c.query("name # :1";$aString+"@")
This example returns persons whose age is not known (property set to null or undefined):
$col:=$c.query("age=null")
This example returns persons hired more than 90 days ago:
$col:=$c.query("dateHired < :1";(Current date-90))
Note: This last example requires that the "Use date type instead of ISO date format in objects" compatibility option is checked (see Compatibility page).
More examples of queries can be found in the dataClass.query( ) page.