Node.js 用一个查询查询两个sails.js实例
我无法确定是否有可能,以及如何使用单个查询Model.find()在我的两个不同数据库、不同cloudSQL实例上查询两个SAIL模型。基本上也是从两个具有两个不同连接的不同模型中填充的 我在connections.js中设置了两个不同的连接:Node.js 用一个查询查询两个sails.js实例,node.js,sails.js,google-cloud-sql,Node.js,Sails.js,Google Cloud Sql,我无法确定是否有可能,以及如何使用单个查询Model.find()在我的两个不同数据库、不同cloudSQL实例上查询两个SAIL模型。基本上也是从两个具有两个不同连接的不同模型中填充的 我在connections.js中设置了两个不同的连接: MysqlServer: { adapter: 'sails-mysql', database: '..' ... }, MysqlServerStat: { adapter: 'sails-mysql', data
MysqlServer: {
adapter: 'sails-mysql',
database: '..'
...
},
MysqlServerStat: {
adapter: 'sails-mysql',
database: '..'
...
},
模型:具有关系,但使用两种不同的连接
(d-stat)
module.exports = {
connection: 'MysqlServerStat',
attributes: {
pro_id:{
connection: 'MysqlServer',
model:'pro'
}..
(pro)
module.exports = {
-default connection-
attributes: {
pro_d:{
connection: 'MysqlServerStat',
collection:'d_stat',
via: 'pro_id'
}..
在ProController中,我尝试同时从两个连接进行查询:
Pro.find()
.populate('d_stat')