Skip to content

Support for beginning a transaction inside boiler generated package #88

Closed
@eduacostam

Description

@eduacostam

This is only a proposal, maybe it needs some discussion.

The idea is that if we use boiler.SetDB(db) method in order to be able to use the G variants of the models, and avoid having to pass around a sql.DB instance, then there's no way to create a transaction inside a function of a struct that does not have the db instance in scope.

It might be nice to have a method in the models package func Begin() (*sql.Tx, errors) that uses the db instance passed into the SetDB method for creating a transaction and returning it, this way we can use transactions (for example when working with relationships) but still avoid having our structs have the need of the DB instance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions