如何从adonisjs中的嵌套表关系中获取特定字段



这是我的代码查询

我只想从每个表中得到一些特定的字段:

const project = await Project.query()
.where("user_id", user_id)
.where('id', project_id)
.with('items.file.sheets.markup.comment.attachment').first()

但我得到了这样的回应有很多额外的字段

"status": true,
"message": "Here is detail of Your Project",
"data": {
"id": 1,
"name": "Spacey",
"description": "222 please change some points",
"created_at": "2021-03-24 17:18:56",
"updated_at": "2021-03-24 19:12:09",
"deleted_at": null,
"items": [
{
"id": 1,
"project_id": 1,
"assignee_id": 1,
"status": null,
"type": "markup",
"description": "my  ",
"version": 4,
"visibility": "1",
"due_date": "2019-12-31",
"priority": "high",
"resolved_on": null,
"created_by": 2,
"resolved_by": null,
"updated_by": null,
"created_at": "2021-03-24 17:19:02",
"updated_at": "2021-03-24 17:19:02",
"deleted_at": null,
"file": [
{
"id": 1,
"actual_name": "10Feb2021.pdf",
"original_ext": "pdf",
"random_name": "1616588342707_8063",
"original_local_path": "files/2/1/1/1616588342707_8063.pdf",
"image_url": "https://resolve-dev-backend.s3.us-east- "
"media_type": "profile",
"item_id": 1,
"user_id": 2,
"created_at": "2021-03-24 17:19:05",
"updated_at": "2021-03-24 17:19:05",
"created_by": 2,
"updated_by": null,
"deleted_at": null,
"sheets": [
{
"id": 1,
"actual_name": "convertpdftojpg.png",
"original_ext": "png",
"random_name": "1616588346705_117",
"original_local_path": "sheets/2/1/1/1616588346705_117.png",
"image_url": "https://resolve-dev-backend.s3.us-east-"
"type": "Sheet",
"item_id": 1,
"file_id": 1,
"user_id": 2,
"created_at": "2021-03-24 17:19:09",
"updated_at": "2021-03-24 17:19:09",
"created_by": 2,
"updated_by": null,
"deleted_at": null,
"markup": [
{
"id": 1,
"item_id": 1,
"sheet_id": 1,
"assignee_id": null,
"editor_details": "{"a": "b", "c": "d"}",
"visibility": "private",
"image_url": "{"a": "b", "c": "d"}",
"priority": "low",
"resolved_by": 2,
"resolved_on": "2021-03-",
"due_date": null,
"created_by": 2,
"created_at": "2021-03-24 18:30:21",
"updated_at": "2021-03-24 19:12:39",
"deleted_at": null,
"comment": []
}
]
}
]
}
],

但我不需要像每个表中的某个字段那样的project_id等对于
示例,我只需要文件表中的这些字段并希望从查询中的每个表中获取特定字段但我在我的邮差中得到了高于输出的响应

```
"id": 1,
"actual_name": "10 -Rehan Shakeel - Feb2021.pdf",
"image_url": "https://resolve-dev/file/2/1/1/1616588346705_117.pdf",
"media_type": "profile",
"created_at": "2021-03-24 17:19:05",
"updated_at": "2021-03-24 17:19:05",
"deleted_at": null,
```

尝试添加select语句,其中列位于数组中

const project = await Project.query()
.select(['tableyouwant.id', 'actual_name', 'image_url', 'media_type', ..........])
.where('id', project_id)
.with('items.file.sheets.markup.comment.attachment').first()

最新更新