实际上我尝试用Sailsjs作为DynamoDB数据库启动一个项目.
在互联网上搜索我发现这个包https://github.com/dohzoh/sails-dynamodb,我发现他们有完整的初始设置文档.
我将此软件包安装到我的项目中,然后按照以下步骤设置项目:
config/connections.js:
dynamoDb: {
adapter: "sails-dynamodb"
},
Run Code Online (Sandbox Code Playgroud)
和config/models.js:
connection: 'dynamoDb'
Run Code Online (Sandbox Code Playgroud)
我将我的amazon密钥放在node_modules/sails-dynamodb/credentials.json中
我创建了下一个模型:
module.exports = {
attributes: {
idFacebook : {
type : 'string',
unique: true
},
emailUser : {
type : 'string',
required : true
},
nameUser : {
type: 'string',
required : true
},
lastNameUser : {
type: 'string',
required : true
}
}
};
Run Code Online (Sandbox Code Playgroud)
当我航行升降时,抛出下一个错误:
/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:32
throw err;
^
Error: define no longer accepts schema callback, migrate to new api
at Object.vogels.define (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/node_modules/vogels/lib/index.js:126:11)
at …Run Code Online (Sandbox Code Playgroud) 我运行我的应用程序时出错.
应用程序错误.应用程序中发生错误,无法提供您的页面.请稍后重试.
如果您是应用程序所有者,请检查日志以获取详细信息.
Heroku日志:
May 05 08:17:00 game app/web.1: > node app.js
May 05 08:17:04 game app/web.1: error: Error: Failed to connect to MongoDB. Are you sure your configured Mongo instance is running?
May 05 08:17:04 game app/web.1: Error details:
May 05 08:17:04 game app/web.1: { [MongoError: connect ECONNREFUSED] name: 'MongoError', message: 'connect ECONNREFUSED' }
May 05 08:17:04 game app/web.1: at _createError (/app/node_modules/sails-mongo/lib/adapter.js:101:23)
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/lib/adapter.js:104:13
May 05 08:17:04 game app/web.1: at /app/node_modules/sails-mongo/lib/connection.js:25:20
May 05 08:17:04 …Run Code Online (Sandbox Code Playgroud)