Javascript 如何使用sails mongo适配器正确添加主机?
我已经通过npm进行了安装,并运行了一个基本的应用程序 但它不认识我的主人 MongoDB已启动并在默认端口27017上运行,但在生成模型后,尝试运行应用程序时出现以下错误: 这是我的adapter.js,我正在运行node v0.10.0和sails v0.8.895Javascript 如何使用sails mongo适配器正确添加主机?,javascript,mongodb,sails.js,Javascript,Mongodb,Sails.js,我已经通过npm进行了安装,并运行了一个基本的应用程序 但它不认识我的主人 MongoDB已启动并在默认端口27017上运行,但在生成模型后,尝试运行应用程序时出现以下错误: 这是我的adapter.js,我正在运行node v0.10.0和sails v0.8.895 // Configure installed adapters // If you define an attribute in your model definition, // it will override anyth
// Configure installed adapters
// If you define an attribute in your model definition,
// it will override anything from this global config.
module.exports.adapters = {
// If you leave the adapter config unspecified
// in a model definition, 'default' will be used.
'default': 'mongo',
// In-memory adapter for DEVELOPMENT ONLY
// (data is NOT preserved when the server shuts down)
memory: {
module: 'sails-dirty',
inMemory: true
},
// Persistent adapter for DEVELOPMENT ONLY
// (data IS preserved when the server shuts down)
// PLEASE NOTE: disk adapter not compatible with node v0.10.0 currently
// because of limitations in node-dirty
// See https://github.com/felixge/node-dirty/issues/34
// disk: {
// module: 'sails-dirty',
// filePath: './.tmp/dirty.db',
// inMemory: false
// },
mongo: {
module : 'sails-mongo',
url : 'mongodb://Chris:DBPASSWORD@localhost:27017/localHostTestDB'
}
};
我已经将用户添加到localHostTestDB,角色为admin
任何帮助都将不胜感激。谢谢 最终不得不将sails.js更新为0.9.3版,并使用sails-mongo适配器:
module.exports.adapters = {
// If you leave the adapter config unspecified
// in a model definition, 'default' will be used.
'default': 'mongo',
mongo: {
module : 'sails-mongo',
host : 'localhost',
user : 'Chris',
password : 'PASSWORD',
database : 'localHostTestDB'
},
// In-memory adapter for DEVELOPMENT ONLY
memory: {
module: 'sails-memory'
},
// Persistent adapter for DEVELOPMENT ONLY
// (data IS preserved when the server shuts down)
disk: {
module: 'sails-disk'
},
// // MySQL is the world's most popular relational database.
// // Learn more: http://en.wikipedia.org/wiki/MySQL
// mysql: {
// module: 'sails-mysql',
// host: 'YOUR_MYSQL_SERVER_HOSTNAME_OR_IP_ADDRESS',
// user: 'YOUR_MYSQL_USER',
// password: 'YOUR_MYSQL_PASSWORD',
// database: 'YOUR_MYSQL_DB'
// }
};
最终不得不将sails.js更新为0.9.3版,并使用sails mongo适配器:
module.exports.adapters = {
// If you leave the adapter config unspecified
// in a model definition, 'default' will be used.
'default': 'mongo',
mongo: {
module : 'sails-mongo',
host : 'localhost',
user : 'Chris',
password : 'PASSWORD',
database : 'localHostTestDB'
},
// In-memory adapter for DEVELOPMENT ONLY
memory: {
module: 'sails-memory'
},
// Persistent adapter for DEVELOPMENT ONLY
// (data IS preserved when the server shuts down)
disk: {
module: 'sails-disk'
},
// // MySQL is the world's most popular relational database.
// // Learn more: http://en.wikipedia.org/wiki/MySQL
// mysql: {
// module: 'sails-mysql',
// host: 'YOUR_MYSQL_SERVER_HOSTNAME_OR_IP_ADDRESS',
// user: 'YOUR_MYSQL_USER',
// password: 'YOUR_MYSQL_PASSWORD',
// database: 'YOUR_MYSQL_DB'
// }
};
从NPM安装。
将mongo配置添加到config/adapters.js文件中。
访问“从NPM安装”。
将mongo配置添加到config/adapters.js文件中。
visit我的问题最终与sails版本有关,尽管github上有一个问题说可以使用另一个适配器对象。谢谢你的帮助!我的问题最终与sails版本有关,尽管github上有一个问题说可以使用另一个适配器对象。谢谢你的帮助!您可能希望将db config移动到config/locals.js文件中。如果您使用的是Git,gitignore会忽略此文件,以避免您发布服务器配置。只需添加到module.exports obj:adapters:{'default':'mongo',mongo:{module:'sails mongo',host:'localhost',user:'Chris',password:'password',database:'localHostTestDB'}}您可能需要将数据库配置移到config/locals.js文件中。如果您使用的是Git,gitignore会忽略此文件,以避免您发布服务器配置。只需添加到module.exports obj:adapters:{'default':'mongo',mongo:{module:'sails mongo',host:'localhost',user:'Chris',password:'password',database:'localHostTestDB'}