sails-dynamodb icon indicating copy to clipboard operation
sails-dynamodb copied to clipboard

Allow arbitrary table names

Open eleiva opened this issue 10 years ago • 4 comments

Cannot connect with dynamoDB Seems that is an error in my config ( related to the region ) but i double check and is all fine.

I tried with this in the model :

module.exports = {
  identity : "Sample",
  tableName: 'Sample',
  attributes: {
  }
};

And with "sample" table name in lowercase without luck. Error Log:

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

Thanks in advance.

eleiva avatar May 07 '15 17:05 eleiva

That typically means that it can't find the table that's being referenced. There is an odd default behavior of Vogels, which is what this adapter is based-upon, which requires that the table name be pluralized and lower-cased on amazon. I'll certainly accept a PR to fix this bug! See the Vogels docs: https://github.com/ryanfitz/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.

devinivy avatar May 08 '15 00:05 devinivy

Yes that is working now. I read "pluralize" as uppercase. So creating a table in DynamoDB all lowercase in a plural form (with an "s" at the end ) now works.

It looks like Vogel either is not receiving or doesn't care about the tableName attribute. I'll look into that. Thanks for the quick response!

micahschaefer avatar May 09 '15 15:05 micahschaefer

Are there any plans to update to the latest version of vogels?

It seems that the latest version of vogels would fix this issue and #20.

phillip-hall avatar Feb 12 '16 04:02 phillip-hall

@phillip-hall good to know! Would certainly take a PR.

devinivy avatar Feb 12 '16 05:02 devinivy