gadelkareem / sails-dynamodb

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

Unique not work #39

Open DiogoMachadoMarques opened 7 years ago

DiogoMachadoMarques commented 7 years ago

I created an attribute =

email: {
  type: "email",
  required: true,
  unique: true
}

And when you run Insert, it does not perform validation to single in the table.

ferrants commented 7 years ago

I'm not sure if unique will work at all with this adapter. If there is support, you would need to set a hash index on that attribute. I don't see another way that it would work with dynamo. Want to try setting a hash on that and trying?

ShubhankarS commented 7 years ago

Is Email also your primary key? If so, you can set the attributes as:

email: {
  type: "email",
  required: true,
  primaryKey: 'hash'
}           

However, as far as I've seen, adding a duplicate entry for the primaryKey through the adapter will overwrite the document that already exists with that particular primaryKey