File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[package ]
22name = " chuchi-postgres"
33description = " A wrapper around tokio-postgres to simplify working with Postgres databases."
4- version = " 0.1.6 "
4+ version = " 0.1.7 "
55authors = [" Sören Meier <info@soerenmeier.ch>" ]
66homepage = " https://chuchi.dev/"
77repository = " https://github.com/chuchi-dev/chuchi-postgres"
Original file line number Diff line number Diff line change @@ -120,4 +120,26 @@ impl<'a> Trans<'a> {
120120 pg : self . pg . as_ref ( ) . map ( |pg| pg. connection ( ) ) ,
121121 }
122122 }
123+
124+ /// Commit the transaction.
125+ ///
126+ /// ## Note
127+ /// Does nothing if it contains a memory Conn
128+ pub async fn commit ( self ) -> Result < ( ) , Error > {
129+ match self . pg {
130+ Some ( pg) => pg. commit ( ) . await ,
131+ None => Ok ( ( ) ) ,
132+ }
133+ }
134+
135+ /// Rollback the transaction.
136+ ///
137+ /// ## Panics
138+ /// If the transaction is not set / this is a memory Conn
139+ pub async fn rollback ( self ) -> Result < ( ) , Error > {
140+ match self . pg {
141+ Some ( pg) => pg. commit ( ) . await ,
142+ None => panic ! ( "rollback not supported" ) ,
143+ }
144+ }
123145}
You can’t perform that action at this time.
0 commit comments