Reputation: 1838
The second column in the SQL statement below retrieve Platform__c attribute from a JSONB column (entity_json).
When I try to use the syntax ["account_name", "entity_json ->> 'Platform__c'"]
as the column name, it fails. with this error: "column \"entity_json ->> 'Platform__c'\" does not exist"
Is there a way in Sequelize.js to retrieve this column using some syntax highlighted in the documentation?
SELECT "account_name", entity_json ->> 'Platform__c' test
FROM "sfdc"."mt_account" AS "Account" WHERE "Account"."account_name" ILIKE
'somecustomer' LIMIT 10;
Upvotes: 3
Views: 3681
Reputation: 81
I encountered the same problem now with Sequelize 4.44.0 however what works for me is something like this:
Account.findAll({
where: {
name: {
[Op.iLike]: 'somecustomer',
},
attributes: [
'id',
[sequelize.json('entity_json.Platform__c'), 'Platform__c']
],
});
Hope it helps.
Upvotes: 6
Reputation: 129
try the following syntax
SELECT "account_name", "entity_json"#>>'{Platform__c}' test
FROM "sfdc"."mt_account" AS "Account" WHERE "Account"."account_name" ILIKE 'somecustomer' LIMIT 10;
Upvotes: 0