gadelkareem / sails-dynamodb

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

'Must have one or two primary key attributes' when hash and range key defined #24

Open mlcloudsec opened 8 years ago

mlcloudsec commented 8 years ago

So let's say we have a model definition like this:

`{

identity: 'modelA',

connection: 'dynamoA',

tableName: 'tableA',

attributes: {

    fieldA: {
        type: 'integer',
        primaryKey: 'hash'
    },

    fieldB: {
        type: 'string',
        primaryKey: 'range'
    }
}

}`

The adapter throws 'Must have one or two primary key attributes' because the primaryKeys in the collection.definition is counting the hash and range primary keys and also an id field like so:

` id: { type: 'string', primaryKey: true, unique: true, defaultsTo: [Function] }

` This happens to be true even with autoPK:false. Suggestions?