Github : https://github.com/balderdashy/waterline
文档 : https://github.com/balderdashy/waterline-docs
Waterline 是通过Adapter关联不同的数据库, (不同的数据库由不同的 Adapter 来关联)
module.exports = {
identity: ‘user‘,
adapter: ‘default‘,
attributes: {
username: {
type: ‘string‘,
unique: true
},
email: {
type: ‘email‘,
unique: true
},
password: {
type: ‘string‘
},
toJSON: function() {
var obj = this.toObject();
delete obj.password;
return obj;
}
}
};
指定了adapter来关联不同的数据库//TODO 待实践
在Sails.js中 config/connections.js 下,修改
someMongodbServer: {
adapter: ‘sails-mongo‘,
host: ‘localhost‘,
port: 27017,
user: ‘‘,
password: ‘‘,
database: ‘riceServer‘
},
在config/models.js 下修改 connection: ‘someMongodbServer‘