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

Unique not work

Open DiogoMachadoMarques opened this issue 7 years ago • 2 comments

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.

DiogoMachadoMarques avatar Mar 20 '17 20:03 DiogoMachadoMarques

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?

ferrants avatar Mar 21 '17 03:03 ferrants

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

ShubhankarS avatar Jul 21 '17 11:07 ShubhankarS