SQLAlchemy filtering JSON nested data in PostgreSQL JSONB

I store Nesting JSON as jsonb, but I have no idea how to select a nested json with an undefined value.

eg:.

{
    "facebook": {
        "openid": "123456789",
        "access_token": "6EFD26B0A868E3BB387E78851E42943F"
    }
}

I know the value is openid, but access_token is undefined.

I tried the following, but it causes an error.

cls.query.filter(User.auth["facebook"]["openid"].astext == openid).first()
+4
source share

All Articles