在Sequelize中隐藏列名称

时间:2019-04-03 06:39:06

标签: node.js orm sequelize.js

我正在使用Sequelize,它有两个模型-Project和ProjectSolutions,其中Project有许多ProjectSolutions。查询以下项目的详细信息时,我渴望加载数据:

Project.findOne(
    { 
        include: [
            { model: ProjectSolution, as: 'solutions', attributes: { include:['solution'], exclude:['id', 'project_id', 'tblProjectProjectId'] } }
        ],
        where: { project_id: projectID, is_active: true }
    }
)

返回的结果如下:

{
    "project_id": "project_id_1",
    "name": "Mahendra's demo 1",
    "description": "demo descripition",
    "is_active": true,
    "created_by": "liya",
    "modified_by": null,
    "created_datetime": "2019-04-03T05:38:17.000Z",
    "modified_datetime": null,
    "solutions": [
        {
            "solution": "Document Cloud"
        },
        {
            "solution": "Experience Cloud"
        }
    ]
}

我想隐藏在solution数组中返回的列名solutions,如下所示:

{
    "project_id": "project_id_1",
    "name": "Mahendra's demo 1",
    "description": "demo descripition",
    "is_active": true,
    "created_by": "liya",
    "modified_by": null,
    "created_datetime": "2019-04-03T05:38:17.000Z",
    "modified_datetime": null,
    "solutions": [
        "Document Cloud",
        "Experience Cloud"
    ]
}

我介绍了文档,但找不到实现该目标的方法。有人知道如何实现这一目标吗?

0 个答案:

没有答案