I have a column in a view called all_devices of type json. Each row stores arrays of objects that have this structure:
[
{
"id": 1,
"device_type": 3,
"device_name": "AC",
"is_on": false
},
{
"id": 1,
"device_type": 0,
"device_name": "Light Bulb",
"is_on": false
},
{
"id": 1,
"device_type": 2,
"device_name": "TV",
"is_on": false
},
{
"id": 1,
"device_type": 1,
"device_name": "Carbon Dioxide Alarm",
"is_on": false
}
]
I use js supabase client and what I want to achieve is to filter array of objects to get devices with device_type that equal 0. I want to get this done for each row so I will get only devices with a certain type for each room.
I tried with something like this:
const { data } = await supabase.from(xyz).select(`id,label,all_devices`).eq('all_devices ->> device_type', 0);
```
but it just returns me an empty array.