// BeginTransaction begins a new transaction and returns a TransactionWrappingContext
// that is the transaction and the context with the new sqalx transaction node.
// The caller must use the returned context in subsequent function calls that are meant
// to happen within the transaction.
BeginTransaction begins a new transaction and returns a TransactionWrappingContext
that is the transaction and the context with the new sqalx transaction node.
The caller must use the returned context in subsequent function calls that are meant
to happen within the transaction.
// BeginTransaction begins a new transaction and returns a TransactionWrappingContext // that is the transaction and the context with the new sqalx transaction node . // The caller must use the returned context in subsequent function calls that are meant // to happen within the transaction .
func BeginTransaction(ctx context.Context) (*TransactionWrappingContext, error) {
	n, ok := ctx.Value("SqalxNode").(sqalx.Node)
	if !ok || n == nil {
		return nil, stacktrace.NewError("SqalxNode not present in context")
	}
	tx, err := n.Beginx()
	if err != nil {
		return nil, stacktrace.Propagate(err, "")
	}
	return &TransactionWrappingContext{
		Context: context.WithValue(ctx, "SqalxNode", tx),
		Node:    tx,
	}, nil
}
func BeginTransaction ( ctx context . Context ) ( * TransactionWrappingContext , error ) { n , ok := ctx . Value ( " " ) . ( sqalx . Node ) if ! ok || n == nil { return nil , stacktrace . NewError ( " " ) } tx , err := n . Beginx ( ) if err != nil { return nil , stacktrace . Propagate ( err , " " ) } return & TransactionWrappingContext { Context : context . WithValue ( ctx , " " , tx ) , Node : tx , } , nil }
BeginTransaction begins a new transaction and returns a TransactionWrappingContext
that is the transaction and the context with the new sqalx transaction node.
BeginTransaction begins a new transaction and returns a TransactionWrappingContext that is the transaction and the context with the new sqalx transaction node .