33use crate :: diesel:: * ;
44use crate :: data:: models:: table_a:: TableA ;
55use crate :: data:: schema:: * ;
6- use diesel:: QueryResult ;
76
8- pub type ConnectionType = diesel:: prelude :: PgConnection ;
7+ pub type ConnectionType = diesel:: r2d2 :: PooledConnection < diesel :: r2d2 :: ConnectionManager < diesel :: pg :: PgConnection > > ;
98
109/// Struct representing a row in table `tableB`
11- #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , Queryable , Selectable , QueryableByName , Associations , Identifiable ) ]
10+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , diesel :: Queryable , diesel :: Selectable , diesel :: QueryableByName , diesel :: Associations , diesel :: Identifiable ) ]
1211#[ diesel( table_name=tableB, primary_key( _id) , belongs_to( TableA , foreign_key=link) ) ]
1312pub struct TableB {
1413 /// Field representing column `_id`
@@ -18,7 +17,7 @@ pub struct TableB {
1817}
1918
2019/// Create Struct for a row in table `tableB` for [`TableB`]
21- #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , Insertable ) ]
20+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , diesel :: Insertable ) ]
2221#[ diesel( table_name=tableB) ]
2322pub struct CreateTableB {
2423 /// Field representing column `_id`
@@ -28,7 +27,7 @@ pub struct CreateTableB {
2827}
2928
3029/// Update Struct for a row in table `tableB` for [`TableB`]
31- #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , AsChangeset , PartialEq , Default ) ]
30+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , diesel :: AsChangeset , PartialEq , Default ) ]
3231#[ diesel( table_name=tableB) ]
3332pub struct UpdateTableB {
3433 /// Field representing column `link`
@@ -52,21 +51,21 @@ pub struct PaginationResult<T> {
5251
5352impl TableB {
5453 /// Insert a new row into `tableB` with a given [`CreateTableB`]
55- pub fn create ( db : & mut ConnectionType , item : & CreateTableB ) -> QueryResult < Self > {
54+ pub fn create ( db : & mut ConnectionType , item : & CreateTableB ) -> diesel :: QueryResult < Self > {
5655 use crate :: data:: schema:: tableB:: dsl:: * ;
5756
58- insert_into ( tableB) . values ( item) . get_result :: < Self > ( db)
57+ diesel :: insert_into ( tableB) . values ( item) . get_result :: < Self > ( db)
5958 }
6059
6160 /// Get a row from `tableB`, identified by the primary key
62- pub fn read ( db : & mut ConnectionType , param__id : i32 ) -> QueryResult < Self > {
61+ pub fn read ( db : & mut ConnectionType , param__id : i32 ) -> diesel :: QueryResult < Self > {
6362 use crate :: data:: schema:: tableB:: dsl:: * ;
6463
6564 tableB. filter ( _id. eq ( param__id) ) . first :: < Self > ( db)
6665 }
6766
6867 /// Paginates through the table where page is a 0-based index (i.e. page 0 is the first page)
69- pub fn paginate ( db : & mut ConnectionType , page : i64 , page_size : i64 ) -> QueryResult < PaginationResult < Self > > {
68+ pub fn paginate ( db : & mut ConnectionType , page : i64 , page_size : i64 ) -> diesel :: QueryResult < PaginationResult < Self > > {
7069 use crate :: data:: schema:: tableB:: dsl:: * ;
7170
7271 let page_size = if page_size < 1 { 1 } else { page_size } ;
@@ -84,14 +83,14 @@ impl TableB {
8483 }
8584
8685 /// Update a row in `tableB`, identified by the primary key with [`UpdateTableB`]
87- pub fn update ( db : & mut ConnectionType , param__id : i32 , item : & UpdateTableB ) -> QueryResult < Self > {
86+ pub fn update ( db : & mut ConnectionType , param__id : i32 , item : & UpdateTableB ) -> diesel :: QueryResult < Self > {
8887 use crate :: data:: schema:: tableB:: dsl:: * ;
8988
9089 diesel:: update ( tableB. filter ( _id. eq ( param__id) ) ) . set ( item) . get_result ( db)
9190 }
9291
9392 /// Delete a row in `tableB`, identified by the primary key
94- pub fn delete ( db : & mut ConnectionType , param__id : i32 ) -> QueryResult < usize > {
93+ pub fn delete ( db : & mut ConnectionType , param__id : i32 ) -> diesel :: QueryResult < usize > {
9594 use crate :: data:: schema:: tableB:: dsl:: * ;
9695
9796 diesel:: delete ( tableB. filter ( _id. eq ( param__id) ) ) . execute ( db)
0 commit comments