Javascript Sails.js:如何使用水线连接多个模型?

Javascript Sails.js:如何使用水线连接多个模型?,javascript,node.js,sails.js,waterline,Javascript,Node.js,Sails.js,Waterline,我有三个模型:大陆、国家和城市。我想加入这些模型以获得结果 Continental.js } Country.js city.js attributes: { city_Id:{ type:'string', primaryKey:true }, cityName:{ type:'string' }, description:{ type:'string' }, country:{ model:'country' } 现在我可以使用Model.q

我有三个模型:大陆、国家和城市。我想加入这些模型以获得结果

Continental.js }

Country.js city.js

attributes: {

city_Id:{

    type:'string',
    primaryKey:true
},

cityName:{

 type:'string'

},

description:{

 type:'string'

},

country:{

    model:'country'
}
现在我可以使用Model.query获得结果:

var query = 'select a.continent_Name,b.countryName,c.cityName from continent a inner join country b on a.continent_id = b.continent inner join city c on b.country_Id = c.country';

Continent.query(query,function(err,data){
     console.log(data);
});
结果是:

[{大陆名称:'亚洲', 国名:“印度”, 城市名称:“德里”}]

是否有任何方法可以通过使用类似“水线”的查询获得相同的结果

 Continent.find().populate().where({}).exec(function(err,data){
   console.log(data);
 });

因此,您已经创建了三个相互关联的模型,包括一个与其他两个模型都关联的模型(
Country
)。您是否真的对如何编写将所有结果链接在一起的吃水线查询感到困惑,或者您只是没有真正尝试过?我给你一个提示:你可以多次调用
populate
,用于不同的关联。snark是不必要的,但是@sgress454是正确的。RTFM并对每个型号使用“填充”或
populateAll()
感谢您的评论。是的,我知道我可以用populate()连接表。但我需要像这个国家一样的东西;有什么最新消息吗?提供了一些有关联接的文档,但不确定它们是否可用以及如何使用
var query = 'select a.continent_Name,b.countryName,c.cityName from continent a inner join country b on a.continent_id = b.continent inner join city c on b.country_Id = c.country';

Continent.query(query,function(err,data){
     console.log(data);
});
 Continent.find().populate().where({}).exec(function(err,data){
   console.log(data);
 });