繁体   English   中英

有没有办法在Sequelize.js中包含JSONB中包含的属性?

[英]Is there a way include an attribute contained in JSONB with Sequelize.js?

下面的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;

尝试以下语法

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']
  ],
});

希望能帮助到你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM