【问题标题】:Sailsjs Models with different schemas具有不同模式的 Sailsjs 模型
【发布时间】:2013-10-08 04:24:44
【问题描述】:

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

这是我的配置/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:{}。这可以改变使用哪个模式(我认为先处理哪个模式),但始终是一个或另一个。

【问题讨论】:

    标签: node.js postgresql sails.js


    【解决方案1】:

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

    【讨论】:

    • 感谢您这么快回来,感谢您在sails-postgres 上所做的工作,是否有计划添加postgis 支持?
    • 这似乎已在sails 0.9.8中修复,所以我将接受。
    猜你喜欢
    • 1970-01-01
    • 2015-12-24
    • 2023-01-31
    • 2020-03-25
    • 1970-01-01
    • 1970-01-01
    • 2017-03-29
    • 2011-06-11
    • 2017-01-17
    相关资源
    最近更新 更多