i am having some trouble relating some search in the json type field in psql database , here is the case scenario
i have this sample data in the json type field
{"created_at": "2014-11-09 00:28:50", "id": 6, "operation": "UPDATE", "desc": "DB updation V3_19 "}
[{"created_at": "2014-11-16 18:21:22", "id": 6, "operation": "UPDATE", "desc": "DB updation V3_19 "}]
{"created_at": "2015-03-18 08:25:07", "id": 7, "operation": "INSERT", "desc": "DB INSERTION V3_24 "}
[{"created_at": {"$date": "2014-08-05T00:30:15.843+0500"}, "id": 5, "desc": "replaced from DB"}, {"created_at": "2014-11-17 00:08:42", "id": 6, "operation": "UPDATE", "desc": "DB updation V3_19 "}]
{"created_at": "2015-03-18 08:25:07", "id": 7, "operation": "INSERT", "desc": "DB INSERTION V3_24 "}
{"created_at": "2015-03-18 08:25:07", "id": 7, "operation": "INSERT", "desc": "DB INSERTION V3_24 "}
and i want to query only those records having operation = 'INSERT' and desc = 'DB INSERTION V3_24'
but when i am doing this simple query select count(*) from factual where info_flags->>'operation' = 'INSERT'
info_flags is the name of the json_type column,
it gives me the error as " ERROR: cannot extract field from a non-object "
can anyone guide me either it is data-inconsistency error or there is problem with query.
thanks
{}
and arrays[]
. can you give the result of aSELECT info_flags FROM factual
?{ object }
and the second contains[ { object } ]
they cannot be used in the same way. you have to verify your data consistency