Starting with Brain version 2.6, the "distinct" query parameter can be used to list the unique values of one property (or a combination of properties) that exist in a resource as an array of objects. For example, the following request returns all technologies of which at least one item exists in the items resource:
GET /api/items?distinct=technology
This query could return:
[
{
"technology": "rfid"
},
{
"technology": "bluetooth"
} ]
The distinct query parameter can be given multiple times to query unique combinations of properties. For example, the following request returns all unique technology/type combinations:
GET /api/items?distinct=technology&distinct=type
This query could return:
[ { "type": "tag", "technology": "rfid" }, { "type": "tag", "technology": "bluetooth" },
{
"type": "relay",
"technology": "bluetooth"
} ]
Please note that it is not possible to perform distinct queries on nested object paths (e.g. ?distinct=config.rfid_power_dbm
).
Comments
0 comments
Article is closed for comments.