下面 SQL 语句中的第二列从 JSONB 列 (entity_json) 中检索 Platform__c 属性。
当我尝试使用语法 ["account_name", "entity_json ->> 'Platform__c'"]
作为列名时,它失败了。出现此错误:"column \"entity_json ->> 'Platform__c'\" does not exist"
在 Sequelize.js 中有没有办法使用文档中突出显示的一些语法来检索此列?
SELECT "account_name", entity_json ->> 'Platform__c' test
FROM "sfdc"."mt_account" AS "Account" WHERE "Account"."account_name" ILIKE
'somecustomer' LIMIT 10;
最佳答案
我现在在 Sequelize 4.44.0 上遇到了同样的问题,但是对我有用的是这样的:
Account.findAll({
where: {
name: {
[Op.iLike]: 'somecustomer',
},
attributes: [
'id',
[sequelize.json('entity_json.Platform__c'), 'Platform__c']
],
});
希望能帮助到你。
关于node.js - 有没有办法在 Sequelize.js 中包含包含在 JSONB 中的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36873019/