Sailsjs具有不同模式的模型

时间:2013-10-01 21:00:49

标签: node.js postgresql sails.js

我正在开发一个sails应用程序,我希望某个模型来自不同的模式。但无论我做什么,我的所有模型都来自相同的模式,因此将一个或另一个模型实例化为一个不包含数据的空白表。

这是我的config / adapters.js:

module.exports.adapters = {

 // If you leave the adapter config unspecified 
 // in a model definition, 'default' will be used.
 'default': 'agency',
  disk: {
     module: 'sails-disk'
   },
   agency:{
     module: 'sails-postgresql',
     host: 'localhost',
     user: 'postgres',
     password: '*****',
     database: 'transit_analyst',
     port: 5432,
     pool: true
   },
   routes:{
    module: 'sails-postgresql',
    host: 'localhost',
    user: 'postgres',
    password: '******',
    database: 'testdb',
    port: 5432,
    pool: true
  }

};

这是我的拳头模型api / models / Agency.js

module.exports = {

adapter: 'agency',  
schema:true,
attributes: {
      date_last_updated: {type:'INTEGER'},
    feed_baseurl: {type:'STRING'},
    ...

}

};

这是我的第二个模型api / models / Routes.js

module.exports = {

adapter: 'routes',
autoPK:false,
attributes: {

    route_id: {type:"STRING"},
    agency_id:{type:"STRING"},
            ...
            ...

    }
};

我已尝试在文档(http://sailsjs.org/#!documentation/models)中建议的适配器中使用config:{}。这可以改变使用哪个模式(我认为先处理哪个模式)但总是使用其中一个模式。

1 个答案:

答案 0 :(得分:2)

看起来像是在Sails中构建适配器的方式中的错误。我在此处报告了此问题,应该在0.9.5https://github.com/balderdashy/sails/issues/939

中修复
相关问题