Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate DynamoDb in Sails js

Actually I tried to start a project with Sailsjs as DynamoDB data base.

Searching the internet I found this package https://github.com/dohzoh/sails-dynamodb, I found that they have complete documentation for initial setup.

I installed this package to my project and I proceeded to set up the project as follows:

config/connections.js :

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

and config/models.js:

connection: 'dynamoDb'

I put my amazon keys in node_modules/sails-dynamodb/credentials.json

I create the next model:

module.exports = {
    attributes: {
        idFacebook : {
            type : 'string',
            unique: true
        }, 
        emailUser : {
            type : 'string',
            required : true
        }, 
        nameUser : {
            type: 'string',
            required : true
        },
        lastNameUser : {
            type: 'string',
            required : true
        }
    }
};

And when I sails lift, throw the next error:

    /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)

I'm looking for similar bugs, however I have not found an answer to this problem. I hope someone can help me.

Thank you

like image 816
Daniel Iturriza Avatar asked Nov 09 '22 16:11

Daniel Iturriza


1 Answers

I too faced the same problem. You can try downgrading your current version of "vogels" module. It worked for me some time ago but I had to upgrade it later because I had to use the newer version of "aws-sdk".

Maybe [email protected] work.I don't remember it exactly but you can try some more versions.

like image 51
Mudit Juneja Avatar answered Nov 15 '22 11:11

Mudit Juneja