Sailsjs控制关系属性

时间:2015-09-09 04:03:57

标签: sails.js

在我的sailsjs应用程序中,我有一个数据对象,它返回了它的子对象列表。现在那些孩子正在返回完整的属性,有没有办法让我限制孩子只返回一个属性(例如id)

目前我得到类似的东西

{
    "name": "parent",
    "children": [
        {
            "id": "id456",
            "name": "child",
            "createdAt": "2015-09-09T03:10:42.000Z",
            "dateAdded": "2014-10-10T04:00:00.000Z"
        }
    ],
    "id": "id123",
    "createdAt": "2015-09-09T03:10:42.000Z",
    "dateAdded": "2014-10-10T04:00:00.000Z"
}

我想回复一下:

{
    "name": "parent",
    "children": [
        "id456"
    ],
    "id": "id123",
    "createdAt": "2015-09-09T03:10:42.000Z",
    "dateAdded": "2014-10-10T04:00:00.000Z"
}

0 个答案:

没有答案