我在 SailsJS 中使用 Waterline ORM(PostgreSQL 适配器),我有两个模型:
建筑物:
{ tableName: 'buildings', attributes: { id: { type: 'integer', primaryKey: true }, BuildingName: {type: 'string'}, BuildingBodyId:{model:'buildingbodies'} }
健美:
{ tableName: 'buildingbodies', id: { type: 'integer', primaryKey: true, required: true }, RequiedBeInField: {type: 'integer'}, BuildingViewState: {type: 'string'} };
我试图返回所有建筑物并使用下一个查询:
buildings.find({
select:['id','BuildingName','BuildingBodyId']})
.populate('BuildingBodyId')
返回结果:
{
"BuildingBodyId":{
"id":2,
"createdAt":"2015-05-07T12:46:55.501Z",
"updatedAt":"2015-05-07T12:46:55.501Z"},
"id":1,
"BuildingName":"YellowTeaField"
}
即 BuildingBodyId 返回没有 RequiedBeInField 和 BuildingViewState。谁能给我一个关于如何获得这两个表的所有参数的提示?谢谢。