Closed SiBell closed 4 years ago
Could we adopt the same approach proposed for greater than/less than cases?
Something along the lines of inDeployment__isNull=true
or inDeployment[isNull]=true
?
Works for me.
I'd planned not to include any Null values in my API response, i.e. this:
{
"id": "sensor-1",
"name": "sensor 1"
}
Rather than this:
{
"id": "sensor-1",
"name": "sensor 1",
"inDeployment": null
}
Assuming it's fine to omit null properties, and doesn't break any rules of the standards we're sticking to, then perhaps inDeployment__isDefined=false
is better?
Happy to go with isDefined
as a the condition, I agree about not including nulls in these cases. Should we come up with a list of all the conditions we think we might need to use as query parameters, and the types they're applicable to, as in
isDefined
can be used for IRI referencesgte
, lte
, gt
, lt
for numeric valuescontains
, overlaps
, withinDistance
or similar for spatial conditionsYep good plan. Pop them in a table and whack it in the standards draft, e.g:
conditional | properties types applicable to | description | example |
---|---|---|---|
gte | numbers, date strings | Filter resources by property values greater than or equal to that specified | startdate__gte=2019-05-24 |
What me to make a first stab at this?
Closing this as discussion of the same matter has now moved to #18.
Example
Let's say I want to get a list of all my sensors:
GET /sensors
If I want to get all the sensors in a given deployment then I could use:
GET /sensors?inDeployment=public-weather-stations
Now what if I want to get all the sensors that are not in a deployment yet?
Possible solutions:
GET /sensors?inDeployment=false
Downside: You'll have to ban deployments called 'false'. The same would apply if you used
null
instead offalse
.GET /sensors?inDeployment=
Downside: This is ambiguous as to whether it means a) give me all sensors whatever the deployment, or b) gives me sensors not in a deployment.
GET /sensors?assignedToDeployment=false
Downside: You need to document another query string parameter. And probably forbid the presence of
inDeployment
whenassignedToDeployment=false
.