4

I have a question about SailsJS. As much research as I've done I have yet to find any substantial amount of examples or explanation to composite keys in SailsJS. From what I have done I have learned that you absolutely have to do some form of workaround in order to get composite keys to work in SailsJS however, I don't fully understand or follow the small examples that I have found online. If someone would take the time out of their day and explain them or explicitly give an example I'd be very appreciative.

varrick
  • 91
  • 1
  • 2
  • 6

1 Answers1

1

this is possibly already asked here: Sails.js composite unique field

And as the issue conversation on git - this is best something done in the actual DB and not live in the code...if that cannot be done for whatever your use case is that warrants the departure of the best practice, then code whatever works best for your needs...it's not a "wrong" answer to have needs that drive you to the edges sometimes :)

If you have a specific question feel free to edit your question with those and perhaps a better explanation of composite keys can be provided.

Community
  • 1
  • 1
JoeManFoo
  • 339
  • 3
  • 11
  • Well thank you, but for a slightly more specific question, you mention that it's not best practice. Which I agree. However if I wanted to avoid best practice how would I go about doing it? If you don't mind. Again, thank you for the confirmation just my curiosity. – varrick Jul 22 '15 at 15:42
  • Which adapter are you using? sails-mongo has this: https://www.npmjs.com/package/sails-hook-mongoat. If you're using something else, then the recommendations are to add them to your migration ups and downs. – JoeManFoo Jul 23 '15 at 18:14
  • Oh, well can you tell me what you mean by migration ups and downs? – varrick Jul 23 '15 at 18:19