gadelkareem / sails-dynamodb

Amazon DynamoDB adapter for Waterline / Sails.js
http://sailsjs.org
46 stars 22 forks source link

Not working #9

Closed micahschaefer closed 9 years ago

micahschaefer commented 9 years ago

Out of the box:

sails new sails-test && cd sails-test npm install sails-dynamodb --save sails generate api user

config/connections.js: dynamoDb: { adapter: 'sails-dynamodb', accessKeyId: 'mysecretkey', secretAccessKey: 'mysecretaccesskey', region: 'us-east-1' }

config/models.js: connection: 'dynamoDb' Then in DynamoDB, i have a "user" table and a "User" table:

When access server:port/user

error: Sending 500 ("Server Error") response: Error (E_UNKNOWN) :: Encountered an unexpected error ResourceNotFoundException: Requested resource not found at Request.extractError (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/protocol/json.js:43:27) at Request.callListeners (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/sequential_executor.js:100:18) at Request.emit (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:604:14) at Request.transition (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:21:12) at AcceptorStateMachine.runTo (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/state_machine.js:14:12) at /home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:22:9) at Request. (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:606:12) at Request.callListeners (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/sequential_executor.js:104:18) at Request.emit (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:604:14) at Request.transition (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:21:12) at AcceptorStateMachine.runTo (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/state_machine.js:14:12) at /home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request. (/home/ec2-user/devel/sails-test/node_modules/sails-dynamodb/node_modules/vogels/node_modules/aws-sdk/lib/request.js:22:9)

Details: ResourceNotFoundException: Requested resource not found

Can you provide a working sample code ? I would love to use this adapter.

I've tried using sails v0.10.0 and v.0.11.0,

I have created tables in DynamoDB with as User and user

I have added tableName with both User and user to the model

Thanks for any help!

devinivy commented 9 years ago

This is a fairly young adapter, but it does have some nice features, such as automatically picking the best index to use during a find. There's a lot of potential! That said, it currently needs a little work.

I think this issue here is caused by a limitation imposed upon us by Vogels, which is the underlying module used to make requests to dynamo. By default Vogels requires that table names be pluralized in DynamoDB! We need to fix this bug, and I'd love to see a PR! See the Vogels docs: https://www.npmjs.com/package/vogels

After you've defined your model you can configure the table name to use. By default, the table name used will be the lowercased and pluralized version of the name you provided when defining the model.

This is a dupe of issue #8, so let's move the conversation over there!