Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constraint pairs #133

Open
petermakeswebsites opened this issue Nov 9, 2021 · 1 comment
Open

Constraint pairs #133

petermakeswebsites opened this issue Nov 9, 2021 · 1 comment

Comments

@petermakeswebsites
Copy link

I would be delighted to have the ability to have a constraint made from two fields in a struct... Ie, constraint A and B. So that they don't have to be unique individually but have to be unique when as a combined pair.

It seems you guys don't have any kind of guidelines when it comes to contributing - happy to tinker with it myself if you're open to that.

@timshannon
Copy link
Owner

I welcome PRs. Feel free to tinker away.

If I were designing it, I think I'd treat any unique contraints that have matching tag fields as one unique value in the index:

type User struct {
  Name string `boltholdUnique:"UniqueID"`
  Email string `boltholdUnique:"UniqueID"` 
}

Unique value would be Name+Email. The only issue I see what with that is that struct field order isn't guaranteed, so we'd need to order alphabetically or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants