| 8 | == Basic URL Syntax == |
| 9 | |
| 10 | - ''Parts in { } are optional, [ ] indicate alternatives'' |
| 11 | |
| 12 | The basic URL format is: /'''prefix'''/'''name'''{ /<'''arguments'''> }{ ?<'''query'''> } |
| 13 | |
| 14 | * '''prefix''' is the resource prefix (="module" name) |
| 15 | * '''name''' is the resource name (without prefix) |
| 16 | |
| 17 | * '''arguments''' is a list of: { /'''id''' }{ / [ '''method''' | '''component''' { /'''component_id''' } { /'''method''' } ] } |
| 18 | * '''id''' is a record ID in the main resource |
| 19 | * '''component''' is a component resource name (without prefix) |
| 20 | * '''component_id''' is a record ID in the component resource |
| 21 | * '''method''' is a URL method (only in GET/POST requests, e.g. "create", "update" or "delete") |
| 22 | |
| 23 | * '''query''' syntax see below |
| 24 | |
| 25 | == Basic Query Format == |
| 26 | |
| 27 | The basic query format is: '''resource'''.'''field'''{'''operator'''}='''value''' |
| 28 | |
| 29 | * '''resource''' is the name of the resource or component (without prefix) or the name of the context |
| 30 | * '''field''' is the name of the field to be tested |
| 31 | * '''operator''' is the operator |
| 32 | * '''value''' is the value or a comma-separated list of values to test against (a comma will be treated as OR) |
| 33 | |
| 34 | Supported operators: |
| 35 | |
| 36 | ||'''Operator'''||'''Method'''||'''Comments|| |
| 37 | ||!__eq||equal, ==||can be omitted|| |
| 38 | ||!__ne||not equal, !=|| || |
| 39 | ||!__lt||less than, <||numeric and date types only|| |
| 40 | ||!__le||less than or equal, <=||numeric and date types only|| |
| 41 | ||!__gt||greater than, >||numeric and date types only|| |
| 42 | ||!__ge||greater than or equal, >=||numeric and date types only|| |
| 43 | ||!__like||like, LIKE(%value%)||string/text types only|| |
| 44 | ||!__unlike||not like, NOT LIKE(%value%)||string/text types only|| |
| 45 | ||!__in||containment, contains(value)||list types only|| |
| 46 | ||!__ex||negative containment, not contains(value)||list types only|| |
| 47 | |
| 48 | == Field Queries == |
| 49 | |
| 50 | * Testing a field in the main resource |
| 51 | {{{ |
| 52 | /pr/person?person.first_name__like=Miriam |
| 53 | }}} |
| 54 | |
| 55 | == Component Field Queries == |
| 56 | |
| 57 | * Testing a field in a component resource |
| 58 | {{{ |
| 59 | /pr/person?address.city__like=Oslo |
| 60 | }}} |
| 61 | |
| 62 | == Context Queries == |
| 63 | |
| 64 | * Testing a field in a referenced resource |
| 65 | * Context must be specified like '''''context''.'''name'''={'''component'''.}'''field''' |
| 66 | * '''name''' is a name for the context (as reference for subsequent queries) |
| 67 | * '''component''' is the name of the component resource (without prefix) |
| 68 | * '''field''' is the field name of the foreign key field |
| 69 | |
| 70 | {{{ |
| 71 | /pr/person?context.location=address.location_id&location.lat__gt=0 |
| 72 | }}} |
| 73 | |