246 | | == Hierarchical Query Operator __typeof == |
247 | | |
248 | | The {{{__typeof}}} query operator can be used to filter by a type and all its sub-types in a hierarchical taxonomy. |
249 | | |
250 | | ''(Description to follow)'' |
| 246 | == Hierarchical Query Operator typeof == |
| 247 | |
| 248 | The {{{typeof}}} query operator can be used to filter by a type and all its sub-types in a hierarchical taxonomy. |
| 249 | |
| 250 | It can be used with a reference (or list:reference) to a hierarchical table: |
| 251 | {{{#!python |
| 252 | query = FS("site_facility_type.facility_type_id").typeof(4L) |
| 253 | }}} |
| 254 | |
| 255 | or with a field within the hierarchical table: |
| 256 | {{{#!python |
| 257 | query = FS("site_facility_type.facility_type_id.name").typeof("Hospital") |
| 258 | }}} |
| 259 | |
| 260 | For string fields within the hierarchical table, "*" can be used as wildcard: |
| 261 | {{{#!python |
| 262 | # Matches e.g. "Fuel Depot", "Goods Depot" etc, and all their subtypes |
| 263 | query = FS("site_facility_type.facility_type_id.name").typeof("*Depot") |
| 264 | }}} |
| 265 | |
| 266 | Multiple options can be specified as list: |
| 267 | {{{#!python |
| 268 | # Matches "Hospital", "*Depot" and all their subtypes |
| 269 | query = FS("site_facility_type.facility_type_id.name").typeof(["Hospital", "*Depot"]) |
| 270 | }}} |
| 271 | |
| 272 | In URLs, the operator is specified as !__typeof like: |
| 273 | {{{ |
| 274 | eden/org/facility?site_facility_type.facility_type_id.name__typeof=Hospital,*Depot |
| 275 | }}} |
| 276 | |
| 277 | Where {{{typeof}}} is used with a virtual field, or no hierarchy is configured for the target table, it falls back to {{{belongs}}} (or {{{contains}}} for list-types, respectively). |