Alex Muro
Alex Muro

Reputation: 125

Sailsjs Models with different schemas

I am working on a sails app where I want a certain model to be from a different schema. However no matter what I do, all of my models come from the same schema so one or the other is instantiated into a blank table that contains no data.

Here is my 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
  }

};

Here is my fist model api/models/Agency.js

module.exports = {

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

}

};

here is my second model api/models/Routes.js

module.exports = {

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

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

    }
};

I have tried using config:{} in the adapter as suggested in the documentation (http://sailsjs.org/#!documentation/models). This can change which of the schemas is used (I think whichever gets processed first) but always its one or the other.

Upvotes: 1

Views: 1780

Answers (1)

particlebanana
particlebanana

Reputation: 2416

Looks like a bug in the way adapters get built up in Sails. I reported the issue here and it should be fixed in 0.9.5: https://github.com/balderdashy/sails/issues/939

Upvotes: 2

Related Questions