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

Export DbMap within Transaction #35

Open
tonyhb opened this issue Mar 23, 2015 · 1 comment
Open

Export DbMap within Transaction #35

tonyhb opened this issue Mar 23, 2015 · 1 comment

Comments

@tonyhb
Copy link

tonyhb commented Mar 23, 2015

I'd love to be able to mix basic CRUD queries with Modl with more advanced, raw sqlx queries.

The one thing holding this back is assimilating a *sqlx.Tx within Modl like this:

func ORMTx(tx *sql.Tx) *modl.Transaction {
    // where dbMap is a previously initialised *model.DbMap
    return &modl.Transaction{dbMap, tx}
}

Doing this would let you chain sqlx.Tx raw queries alongside Modl queries:

tx := sqlx.MustBegin()
SomethingWithSQL(tx)
SomethingWithORM(tx)
tx.Commit()

Or is mixing the two crazy?

@tonyhb
Copy link
Author

tonyhb commented Mar 23, 2015

Uh, maybe instead of exporting DbMap we could create a method within Modl to assimilate a tx?

func (m *DbMap) AssimilateTx(tx *sqlx.Tx) *Transaction {
    return &Transaction{m, tx}
}

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