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

Set constraints on tables #15

Open
aybabtme opened this issue Apr 25, 2014 · 0 comments
Open

Set constraints on tables #15

aybabtme opened this issue Apr 25, 2014 · 0 comments

Comments

@aybabtme
Copy link

It would be great if we could set contraints on tables. For instance, something like this:

type Program struct {
    ID          string    `db:"program_id"`
    // ... stuff
}

type Exec struct {
    ID     string `db:"exec_id"`
    ProgramID string `db:"program_id"`
}

func (r Exec) registerTable(dbMap *modl.DbMap) {
    execTbl:= dbMap.AddTable(r, "exec").SetKeys(false, "exec_id")
    execTbl.SetForeignKey("program_id", Program{}.ID). // what i'd like
        OnDelete(modl.Cascade).  // going the extra mile
        OnUpdate(modl.Restrict)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant