2014-07-10 46 views
1

我使用帆0.9。 這裏是adapters.js代碼:配置適配器在型號

module.exports.adapters = { 

mongo: { 
    module: 'sails-mongo', 
    host: 'localhost', 
    port: 27017, 
    user: '', 
    password: '', 
    database: 'tracker' 
}, 

mongo2: { 
    module: 'sails-mongo', 
    host: 'localhost', 
    port: 27017, 
    user: '', 
    password: '', 
} 
}; 

和型號:

module.exports = { 

adapter: 'mongo2', 

config: { 
    database: 'offer' 
}, 

attributes: { 

    name: { 
    type: 'string', 
    unique: true, 
    required: true 
    } 
} 
}; 

從文檔http://sailsjs.org/#!documentation/models我得到這個模型將被保存在一個名爲「要約」的數據庫,但它使用DB命名爲「帆」。看起來像它只是忽略模型的配置部分。 我的錯誤是什麼?

回答

0

你應該把數據庫適配器配置本身

mongo2: { 
    module: 'sails-mongo', 
    host: 'localhost', 
    port: 27017, 
    user: '', 
    password: '', 
    database: 'offer' 
}