我已经通过npm安装了sails-mongo并运行了一个基本的sails.js应用程序 但它没有认出我的主人。
MongoDB已启动并在默认端口27017上运行但在生成模型后,我在尝试运行应用程序时遇到此错误:
这是我的adapter.js,我正在运行节点v0.10.0并且运行v0.8.895
// 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。
任何帮助都会受到赞赏。谢谢!
答案 0 :(得分:1)
结束必须将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'
// }
};
答案 1 :(得分:0)
从NPM安装。 将mongo配置添加到config / adapters.js文件中。 访问http://sailsjs.org