Changes between Version 24 and Version 25 of S3/S3ResourceFilter
- Timestamp:
- 06/13/14 12:17:48 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
S3/S3ResourceFilter
v24 v25 121 121 S3FieldSelector instances can also be generated at the back-end, simply by: 122 122 123 {{{ 123 {{{#!python 124 124 selector = S3FieldSelector(<field selector>) 125 125 }}} … … 127 127 Such selectors can then be used to create filter queries, using a syntax very similar to web2py queries: 128 128 129 {{{ 129 {{{#!python 130 130 afilter = S3FieldSelector("person.first_name") == "Dominic" 131 131 bfilter = ~(S3FieldSelector("person.first_name").like("Dominic")) # negation by ~ operator … … 149 149 These filter queries can also be joined together by {{{&}}} and {{{|}}} operators: 150 150 151 {{{ 151 {{{#!python 152 152 cfilter = (S3FieldSelector("person.first_name") == "Dominic") & (S3FieldSelector("contact.value") == "dominic@nursix.org") 153 153 }}} … … 157 157 To add a filter to a resource is as simple as: 158 158 159 {{{ 159 {{{#!python 160 160 myfilter = S3FieldSelector("person.first_name") == "Dominic" 161 161 resource.add_filter(myfilter) … … 166 166 You can though also specify a standard web2py Query for add_filter, in which case you would have to specify the respective join manually. If you specify a component alias as "c" parameter, the join for this component would be added automatically. 167 167 168 {{{ 168 {{{#!python 169 169 myfilter = db.pr_contact.value == "dominic@nursix.org" 170 170 resource.add_filter(myfilter, c="contact")