我在SailsJS上使用Waterline ORM(PostgresQL适配器),我有两个型号:
建筑物:
{
tableName: 'buildings',
attributes: {
id: {
type: 'integer',
primaryKey: true
},
BuildingName: {type: 'string'},
BuildingBodyId:{model:'buildingbodies'}
}
bodybuildings:
{
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。谁能给我一个关于如何使用所有参数获得这两个表的提示?感谢。