watelineJS:单向协会

时间:2015-05-07 16:07:41

标签: node.js associations sails.js waterline sails-postgresql

我在SailsJS上使用Waterline ORM(PostgresQL适配器),我有两个型号:

  1. 建筑物:

    {
      tableName: 'buildings',
      attributes: {
      id: {
        type: 'integer',
        primaryKey: true
      },
      BuildingName: {type: 'string'},
      BuildingBodyId:{model:'buildingbodies'}
    }
    
  2. bodybuildings:

    {
      tableName: 'buildingbodies',
      id: {
        type: 'integer',
        primaryKey: true,
        required: true
      },
      RequiedBeInField: {type: 'integer'},
      BuildingViewState: {type: 'string'}
    };
    
  3. 我试图返回所有建筑物并使用下一个查询:

    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。谁能给我一个关于如何使用所有参数获得这两个表的提示?感谢。

0 个答案:

没有答案