Sails version: 1.0.2
Node version: 10.8.0
NPM version: 6.2.0
DB adapter name: N/A
DB adapter version: N/A
Operating system: Windows 10
@Alirezamohammadi Thanks for posting, we'll take a look as soon as possible.
For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.
What database / adapter are you using? There may be options available to you depending on your environment :grin:
For example, sails-hook-mongoat looks like adds composite unique unique keys if you're using MongoDB. You may be able to modify it to work in your environment if you're daring enough.
That said, if you're not, set migrations to safe so Sails/Waterline doesn't destroy your schema, create the composite key at the database level and handle errors/exceptions as neccessary.
@texh Thanks, I am using PostgreSQL in my project, is there other way than creating composite keys at the DB level?
@Alirezamohammadi this is definitely on our radar, and @mikermcneil and I have been talking about how this could work, but I don't have a good idea of when it might make it's way into a future release.
As a workaround in the mean time, you might consider making some helpers to handle the logic for creating/updating any records that need special validation like that, and then calling those helpers rather than using .create() and .update() directly in those cases.
I would like to implement this. Any pointers on where to proceed?
@rachaelshaw Thanks for your consideration, I hope this feature will be added soon to the sails js.