db_select with condition on json blob column in postgreSQL

28 Views Asked by At

I have a json blob column with data listed below in postgreSQL,column name is data, for building a chart in drupal10 website. i have to use db_select to get data based on a condtion in json key named chart_title

[ { "to": "Joint Programme", "nid": 20073, "from": "Funds Mobilized", "value": 272172483, "status": true, "weight": 5.8, "api_uri": "http://example.com", "to_color": "#b6ada7", "timestamp": 1708075222, "chart_type": "bar", "embed_code": "

google

", "from_color": "#f78f20", "line_color": "#f78f20", "sort_order": 0, "chart_group": "Resources 2022", "chart_title": "By Data", "chart_collection": "Investments" },

i have tried this

$connection = \Drupal::database();
$result = $connection->select('chart_data', 't')
    ->fields('t', ['data'])
    ->condition('t.data', 'By Data', '=')
    ->execute()
    ->fetchAll();

0

There are 0 best solutions below