在Sails js中集成DynamoDb

时间:2015-04-14 20:30:45

标签: request npm sails.js amazon-dynamodb waterline

实际上我尝试用Sailsjs作为DynamoDB数据库启动一个项目。

在互联网上搜索我发现这个包https://github.com/dohzoh/sails-dynamodb,我发现他们有完整的初始设置文档。

我将此软件包安装到我的项目中,然后按照以下步骤设置项目:

config / connections.js:

dynamoDb: {
    adapter: "sails-dynamodb"
  },

和config / models.js:

connection: 'dynamoDb'

我把我的亚马逊钥匙放在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
        }
    }
};

当我航行升降时,抛出下一个错误:

    /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 Object.module.exports.adapter._getModel (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/index.js:169:23)
    at Object.module.exports.adapter.define (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/index.js:289:33)
    at /usr/lib/node_modules/sails/node_modules/waterline/lib/waterline/adapter/ddl/index.js:60:15
    at bound (/usr/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:957:21)
    at applyInOriginalCtx (/usr/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:416:80)
    at wrappedCallback (/usr/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/normalize.js:315:18)
    at _normalizeCallback.callback.success (/usr/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/normalize.js:33:31)
    at _switch (/usr/lib/node_modules/sails/node_modules/waterline/node_modules/switchback/lib/factory.js:48:28)
    at Response.<anonymous> (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/index.js:340:21)
    at Request.<anonymous> (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:350:18)
    at Request.callListeners (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/sequential_executor.js:100:18)
    at Request.emit (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:604:14)
    at Request.transition (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:21:12)
    at AcceptorStateMachine.runTo (/home/uppersky01/proyectos/gameMouseCat/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/state_machine.js:14:12)

我正在寻找类似的错误,但是我没有找到这个问题的答案。我希望有人可以帮助我。

谢谢

1 个答案:

答案 0 :(得分:1)

我也遇到了同样的问题。 您可以尝试降级当前版本的“vogels”模块。 它不久前对我有用,但我不得不稍后升级,因为我不得不使用更新版本的“aws-sdk”。

也许vogels@0.12.0工作。我不记得它,但你可以尝试更多的版本。